vue/prefer-true-attribute-shorthand
true を指定するバインディングを boolean 属性の省略形にします。
既定の重大度: warning
プリセット: nuxt, opinionated
自動修正: なし。修正内容を確認してください
適用範囲: Vue SFC のテンプレート・ブロック。必要な script の文脈も例に含めています。
オプション: ルール固有のオプションはありません。重大度とプリセットは設定できます。
設定(Vite+)
import { defineConfig } from "@vizejs/vite-plugin/vite-plus";
export default defineConfig({
lint: {
vize: {
"preset": "incremental",
"rules": {
"vue/prefer-true-attribute-shorthand": "warn"
}
},
},
});
vp run lint
悪い
標準の boolean 属性 disabled に、固定の true をバインドしています。
<template>
<input :disabled="true" />
</template>
良い
標準の boolean 属性は省略形にします。false のバインディングやコンポーネントの prop は値を残します。
<template>
<input disabled />
<input :disabled="false" />
<MyComponent :visible="true" />
<MyComponent :visible="isVisible" />
</template>
良い例は上記の設定でこのルールの検出を避ける例です。他のルールでは検出される場合があります。