vapor/prefer-static-class
文字列リテラルの :class を静的 class に置き換えます。
| 既定の重大度 | プリセット | 自動修正 | オプション |
|---|---|---|---|
warning |
nuxt, opinionated |
あり | なし |
適用範囲:Vue SFC のテンプレートと各ブロック。ルールに必要な script の文脈も例に含めています。
悪い例
変化しないクラスの文字列をバインディングで評価しています。
<template>
<section :class="'panel panel-primary'">Profile</section>
</template>
良い例
同じ panel のクラスを静的な class 属性に指定します。
<template>
<section class="panel panel-primary">Profile</section>
</template>
設定(Vite+)
import { defineConfig } from "@vizejs/vite-plugin/vite-plus";
export default defineConfig({}).withVue({
linter: {
"preset": "incremental",
"rules": {
"vapor/prefer-static-class": "warn"
}
},
});
設定したら vp run lint を実行します。