Vize

vue/no-boolean-attr-value

HTML の真偽属性に不要な値を指定した箇所を検出します。

既定の重大度 プリセット 自動修正 オプション
warning nuxt, opinionated あり なし

適用範囲:Vue SFC のテンプレートと各ブロック。ルールに必要な script の文脈も例に含めています。

悪い例

真偽属性の disabled と checked に、不要な文字列の値を指定しています。

<template>
  <input disabled="disabled" />
  <input checked="checked" />
  <button disabled="true">Save</button>
</template>

良い例

値を付けず、真偽属性があることだけで同じ状態を表します。

<template>
  <input disabled />
  <input checked />
  <button disabled>Save</button>
</template>

設定(Vite+)

import { defineConfig } from "@vizejs/vite-plugin/vite-plus";

export default defineConfig({}).withVue({
  linter: {
    "preset": "incremental",
    "rules": {
      "vue/no-boolean-attr-value": "warn"
    }
  },
});

設定したら vp run lint を実行します。

関連ページ