Vize

vue/html-button-has-type

button に有効な type を明示します。

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

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

悪い例

一つは type を省略し、もう一つは対応しない foo を指定しています。

<template>
<button>Click</button>
<button type="foo">Click</button>
</template>

良い例

button、submit、reset を明示します。バインドする type は動的な値として扱います。

<template>
<button type="button">Click</button>
<button type="submit">Save</button>
<button type="reset">Reset</button>
<button :type="dynamicType">Click</button>
</template>

設定(Vite+)

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

export default defineConfig({}).withVue({
  linter: {
    "preset": "incremental",
    "rules": {
      "vue/html-button-has-type": "warn"
    }
  },
});

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

関連ページ