a11y/media-has-caption
Require media elements to have captions
Default severity: warning
Presets: happy-path, nuxt, ecosystem, opinionated
Automatic fix: None; review the suggested change
Applies to: Vue SFC templates and blocks, with script context where the rule requires it
Options: No rule-specific options. Severity and preset selection are configurable.
Configuration (Vite+)
import { defineConfig } from "@vizejs/vite-plugin/vite-plus";
export default defineConfig({
lint: {
vize: {
"preset": "incremental",
"rules": {
"a11y/media-has-caption": "warn"
}
},
},
});
vp run lint
Bad
The video has playback controls but no caption track.
<template>
<video src="/demo.mp4" controls />
</template>
Good
A track with kind="captions" supplies the English captions for the same video.
<template>
<video src="/demo.mp4" controls>
<track kind="captions" src="/demo.en.vtt" srclang="en" label="English" />
</video>
</template>
Good avoids this rule's finding under the configuration above; other rules may still report diagnostics.