css/no-important
Déconseiller !important en CSS.
| Gravité par défaut | Préréglages | Correction automatique | Options |
|---|---|---|---|
warning |
opinionated, nuxt |
Non | Aucune |
Champ d’application : Blocs style CSS, SCSS, Sass, Less et Stylus, tels qu’écrits (sans préprocesseur).
Mauvais
La déclaration de couleur remplace la priorité normale de la cascade avec !important.
<style scoped>
.button {
color: red !important;
}
</style>
Bon
La couleur provient d’une propriété personnalisée sans déclaration important.
<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"
}
},
});
Lancez ensuite vp run lint.