css/no-display-none
Suggest using v-show instead of display: none.
| Default severity | Presets | Automatic fix | Options |
|---|---|---|---|
warning |
opinionated, nuxt |
No | None |
Applies to: Plain CSS style blocks (scss, sass, less and stylus blocks are skipped).
Bad
The .message declaration hides the local paragraph through CSS rather than a template visibility condition.
<template>
<p class="message">Saved</p>
</template>
<style scoped>
.message {
display: none;
}
</style>
Good
v-show="isSaved" makes the visibility condition explicit on the local paragraph and removes display: none.
<template>
<p v-show="isSaved" class="message">Saved</p>
</template>
Configuration (Vite+)
import { defineConfig } from "@vizejs/vite-plugin/vite-plus";
export default defineConfig({}).withVue({
linter: {
"preset": "incremental",
"rules": {
"css/no-display-none": "warn"
}
},
});
Then run vp run lint.