Vize

a11y/label-has-for

Require labels to have associated form controls.

Default severity Presets Automatic fix Options
warning happy-path, nuxt, ecosystem, opinionated No Rule options

Applies to: Vue SFC templates and blocks, with script context where the rule requires it.

List component names that render a native form control and therefore satisfy label nesting. PascalCase and kebab-case spellings are equivalent. Options do not enable the rule; later config layers replace the complete list, and [] clears inherited names.

Bad

The separate label is neither associated through for nor wrapped around the input.

<template>
<label>Name</label>
</template>

Good

The nested native input is implicitly associated with its wrapping label.

<template>
<label>Name <input v-model="name" /></label>
</template>

Configuration (Vite+)

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

export default defineConfig({}).withVue({
  linter: {
    "preset": "incremental",
    "rules": {
      "a11y/label-has-for": "warn"
    },
    "ruleOptions": {
      "a11y/label-has-for": {
        "controlComponents": [
          "CInputField"
        ]
      }
    }
  },
});

Then run vp run lint.