vapor/prefer-static-class
Prefer static class over dynamic class binding for string literals.
| Default severity | Presets | Automatic fix | Options |
|---|---|---|---|
warning |
nuxt, opinionated |
Yes | None |
Applies to: Vue SFC templates and blocks, with script context where the rule requires it.
Bad
The class binding evaluates a constant string even though the class does not change.
<template>
<section :class="'panel panel-primary'">Profile</section>
</template>
Good
A static class attribute expresses the same panel classes without a binding.
<template>
<section class="panel panel-primary">Profile</section>
</template>
Configuration (Vite+)
import { defineConfig } from "@vizejs/vite-plugin/vite-plus";
export default defineConfig({}).withVue({
linter: {
"preset": "incremental",
"rules": {
"vapor/prefer-static-class": "warn"
}
},
});
Then run vp run lint.