Vize

a11y/no-redundant-roles

要素本来の意味と重複する ARIA role を検出します。

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

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

悪い例

button は元から button の役割を持つため、同じ role を重複して指定しています。

<template>
  <button role="button">Save</button>
</template>

良い例

重複する role を取り除き、HTML の標準の役割を使います。

<template>
  <button>Save</button>
</template>

設定(Vite+)

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

export default defineConfig({}).withVue({
  linter: {
    "preset": "incremental",
    "rules": {
      "a11y/no-redundant-roles": "warn"
    }
  },
});

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

関連ページ