vue/no-inline-style
Discourage use of inline style attributes.
| Default severity | Presets | Automatic fix | Options |
|---|---|---|---|
warning |
nuxt, opinionated |
No | None |
Applies to: Vue SFC templates and blocks, with script context where the rule requires it.
Bad
The static style attribute embeds the color declaration in the element.
<template>
<div style="color: red">Text</div>
</template>
Good
Classes express the fixed color; the ratio-dependent width remains a dynamic style binding, outside the static-attribute check.
<template>
<div class="text-red">Text</div>
<span :class="{ 'text-red': isRed }">Text</span>
<div :style="{ width: `${ratio}%` }">Text</div>
</template>
Configuration (Vite+)
import { defineConfig } from "@vizejs/vite-plugin/vite-plus";
export default defineConfig({}).withVue({
linter: {
"preset": "incremental",
"rules": {
"vue/no-inline-style": "warn"
}
},
});
Then run vp run lint.