a11y/img-alt
Require alt attribute on images for accessibility.
| Default severity | Presets | Automatic fix | Options |
|---|---|---|---|
warning |
None | No | None |
Applies to: Vue SFC templates and blocks, with script context where the rule requires it.
Bad
The avatar image is missing its alt attribute.
<template>
<img src="/avatar.png" />
</template>
Good
alt="User avatar" supplies a text alternative for the avatar.
<template>
<img src="/avatar.png" alt="User avatar" />
</template>
Configuration (Vite+)
import { defineConfig } from "@vizejs/vite-plugin/vite-plus";
export default defineConfig({}).withVue({
linter: {
"preset": "incremental",
"rules": {
"a11y/img-alt": "warn"
}
},
});
Then run vp run lint.