css/no-important
Discourage use of !important in CSS.
| Default severity | Presets | Automatic fix | Options |
|---|---|---|---|
warning |
opinionated, nuxt |
No | None |
Applies to: CSS, SCSS, Sass, Less and Stylus style blocks, as written (not preprocessed).
Bad
The color declaration overrides normal cascade priority with !important.
<style scoped>
.button {
color: red !important;
}
</style>
Good
The color comes from a custom property without an important declaration.
<style scoped>
.button {
color: var(--button-color);
}
</style>
Configuration (Vite+)
import { defineConfig } from "@vizejs/vite-plugin/vite-plus";
export default defineConfig({}).withVue({
linter: {
"preset": "incremental",
"rules": {
"css/no-important": "warn"
}
},
});
Then run vp run lint.