css/no-hardcoded-values
Suggest using CSS variables instead of hardcoded values
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-hardcoded-values": "warn"
}
},
},
});
vp run lint
Bad
The button embeds spacing numbers and a hexadecimal color directly in the declarations.
<style scoped>
.button {
padding: 12px 16px;
color: #174ea6;
}
</style>
Good
The declarations refer to named spacing and color custom properties, so these values can be maintained as tokens.
<style scoped>
.button {
padding: var(--space-3) var(--space-4);
color: var(--color-action-text);
}
</style>
Good avoids this rule's finding under the configuration above; other rules may still report diagnostics.