css/no-display-none
Suggest using v-show instead of display: none
Default severity: warning
Presets: opinionated, nuxt
Automatic fix: None; review the suggested change
Applies to: CSS inside SFC style blocks
Options: No rule-specific options. Severity and preset selection are configurable.
Configuration (Vite+)
import { defineConfig } from "@vizejs/vite-plugin/vite-plus";
export default defineConfig({
lint: {
vize: {
"preset": "incremental",
"rules": {
"css/no-display-none": "warn"
}
},
},
});
vp run lint
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>
Good avoids this rule's finding under the configuration above; other rules may still report diagnostics.