vue/html-button-has-type
button に有効な type を明示します。
既定の重大度: warning
プリセット: nuxt, opinionated
自動修正: なし。修正内容を確認してください
適用範囲: Vue SFC のテンプレート・ブロック。必要な script の文脈も例に含めています。
オプション: ルール固有のオプションはありません。重大度とプリセットは設定できます。
設定(Vite+)
import { defineConfig } from "@vizejs/vite-plugin/vite-plus";
export default defineConfig({
lint: {
vize: {
"preset": "incremental",
"rules": {
"vue/html-button-has-type": "warn"
}
},
},
});
vp run lint
悪い
一つは 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>
良い例は上記の設定でこのルールの検出を避ける例です。他のルールでは検出される場合があります。