css/no-utility-classes
Warn against implementing utility classes in component styles.
| 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 authored selectors use utility-shaped names such as .flex, .mt-4, and .text-center.
<style scoped>
.flex { display: flex; }
.mt-4 { margin-top: 1rem; }
.text-center { text-align: center; }
</style>
Good
A component-specific .my-component selector groups the component styling under one semantic name.
<style scoped>
.my-component { display: flex; margin-top: 1rem; }
</style>
Configuration (Vite+)
import { defineConfig } from "@vizejs/vite-plugin/vite-plus";
export default defineConfig({}).withVue({
linter: {
"preset": "incremental",
"rules": {
"css/no-utility-classes": "warn"
}
},
});
Then run vp run lint.