a11y/alt-text
Require alternative text for media elements.
| Default severity | Presets | Automatic fix | Options |
|---|---|---|---|
warning |
happy-path, nuxt, ecosystem, opinionated |
No | None |
Applies to: Vue SFC templates and blocks, with script context where the rule requires it.
Bad
The image submit control supplies only its image URL; it has no alt text describing the action.
<template>
<input type="image" src="/submit.png" />
</template>
Good
alt="Submit search" gives the image control an accessible name that describes submitting the search.
<template>
<input type="image" src="/submit.png" alt="Submit search" />
</template>
Configuration (Vite+)
import { defineConfig } from "@vizejs/vite-plugin/vite-plus";
export default defineConfig({}).withVue({
linter: {
"preset": "incremental",
"rules": {
"a11y/alt-text": "warn"
}
},
});
Then run vp run lint.