eslint-plugin-img-alt
v1.0.7
Published
An ESLint plugin to enforce adding the `alt` attribute to `img` tags in JSX. If an `img` tag doesn't have an `alt` attribute, the rule will automatically fix it by adding `alt="no data"`.
Downloads
10
Maintainers
Readme
eslint-plugin-img-alt
An ESLint plugin to enforce adding the alt
attribute to img
tags in JSX. If an img
tag doesn't have an alt
attribute, the rule will automatically fix it by adding alt="no data"
.
Installation
You'll first need to install ESLint:
npm install eslint --save-dev
Next, install eslint-plugin-img-alt
:
npm install eslint-plugin-img-alt --save-dev
Note: If you installed ESLint globally (using the -g
flag) then you must also install eslint-plugin-img-alt
globally.
Usage
Add img-alt
to the plugins section of your .eslintrc
configuration file. Then, configure the rule under the rules section:
{
"plugins": ["img-alt"],
"rules": {
"img-alt/require-alt-attribute": "error"
}
}
Supported Rules
require-alt-attribute
: Enforces the presence of the alt attribute on img tags. If the attribute is missing, ESLint will automatically fix it by adding alt="no data".