Vize

a11y/aria-role

具有 ARIA 角色的元素必须使用有效的非抽象 ARIA 角色。

默认严重程度 预设 自动修复 选项
error happy-path, nuxt, ecosystem, opinionated 不支持 无

适用范围:Vue SFC 模板和代码块,包括规则所需的脚本上下文。

错误示例

datepicker 不是此 section 上可识别的 ARIA 角色。

<template>
  <section role="datepicker">...</section>
</template>

正确示例

section 使用可识别的 dialog 角色,以及描述日期选择的标签。

<template>
  <section role="dialog" aria-label="Choose a date">...</section>
</template>

配置(Vite+)

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

export default defineConfig({}).withVue({
  linter: {
    "preset": "incremental",
    "rules": {
      "a11y/aria-role": "error"
    }
  },
});

然后运行 vp run lint。

相关页面