vue/attribute-hyphenation
コンポーネントの prop 属性名を設定した形式に揃えます。
| 既定の重大度 | プリセット | 自動修正 | オプション |
|---|---|---|---|
warning |
happy-path, nuxt, ecosystem, opinionated |
あり | ルールのオプション |
適用範囲:Vue SFC のテンプレートと各ブロック。ルールに必要な script の文脈も例に含めています。
悪い例
コンポーネントの属性名を camelCase の firstName にしています。
<template>
<UserCard firstName="Ada" />
</template>
良い例
first-name に変更し、設定されたハイフン区切りの属性名の方針に合わせます。
<template>
<UserCard first-name="Ada" />
</template>
設定(Vite+)
import { defineConfig } from "@vizejs/vite-plugin/vite-plus";
export default defineConfig({}).withVue({
linter: {
"preset": "incremental",
"rules": {
"vue/attribute-hyphenation": "warn"
}
},
});
設定したら vp run lint を実行します。