Vize

a11y/heading-levels

禁止跳过标题层级。

默认严重程度 预设 自动修复 选项
warning nuxt, opinionated 不支持 无

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

错误示例

标题序列从 h1 直接跳到 h3,跳过二级。

<template>
  <h1>Account</h1>
  <h3>Billing</h3>
</template>

正确示例

将账单标题改为 h2,保持连续的标题层级。

<template>
  <h1>Account</h1>
  <h2>Billing</h2>
</template>

配置(Vite+)

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

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

然后运行 vp run lint。

相关页面