build status npm version license Coverage Status Total npm downloads

# eslint-plugin-jsx-a11y Static AST checker for accessibility rules on JSX elements. ## Why? Ryan Florence built out this awesome runtime-analysis tool called [react-a11y](https://github.com/reactjs/react-a11y). It is super useful. However, since you're probably already using linting in your project, this plugin comes for free and closer to the actual development process. Pairing this plugin with an editor lint plugin, you can bake accessibility standards into your application in real-time. **Note**: This project does not *replace* react-a11y, but can and should be used in conjunction with it. Static analysis tools cannot determine values of variables that are being placed in props before runtime, so linting will not fail if that value is undefined and/or does not pass the lint rule. ## Installation **If you are installing this plugin via `eslint-config-airbnb`, please follow [these instructions](https://github.com/airbnb/javascript/tree/master/packages/eslint-config-airbnb#eslint-config-airbnb-1).** You'll first need to install [ESLint](http://eslint.org): ```sh # npm npm install eslint --save-dev # yarn yarn add eslint --dev ``` Next, install `eslint-plugin-jsx-a11y`: ```sh # npm npm install eslint-plugin-jsx-a11y --save-dev # yarn yarn add eslint-plugin-jsx-a11y --dev ``` **Note:** If you installed ESLint globally (using the `-g` flag in npm, or the `global` prefix in yarn) then you must also install `eslint-plugin-jsx-a11y` globally. ## Usage Add `jsx-a11y` to the plugins section of your `.eslintrc` configuration file. You can omit the `eslint-plugin-` prefix: ```json { "plugins": [ "jsx-a11y" ] } ``` Then configure the rules you want to use under the rules section. ```json { "rules": { "jsx-a11y/rule-name": 2 } } ``` You can also enable all the recommended or strict rules at once. Add `plugin:jsx-a11y/recommended` or `plugin:jsx-a11y/strict` in `extends`: ```json { "extends": [ "plugin:jsx-a11y/recommended" ] } ``` ## Supported Rules - [accessible-emoji](docs/rules/accessible-emoji.md): Enforce emojis are wrapped in and provide screenreader access. - [alt-text](docs/rules/alt-text.md): Enforce all elements that require alternative text have meaningful information to relay back to end user. - [anchor-has-content](docs/rules/anchor-has-content.md): Enforce all anchors to contain accessible content. - [anchor-is-valid](docs/rules/anchor-is-valid.md): Enforce all anchors are valid, navigable elements. - [aria-activedescendant-has-tabindex](docs/rules/aria-activedescendant-has-tabindex.md): Enforce elements with aria-activedescendant are tabbable. - [aria-props](docs/rules/aria-props.md): Enforce all `aria-*` props are valid. - [aria-proptypes](docs/rules/aria-proptypes.md): Enforce ARIA state and property values are valid. - [aria-role](docs/rules/aria-role.md): Enforce that elements with ARIA roles must use a valid, non-abstract ARIA role. - [aria-unsupported-elements](docs/rules/aria-unsupported-elements.md): Enforce that elements that do not support ARIA roles, states, and properties do not have those attributes. - [click-events-have-key-events](docs/rules/click-events-have-key-events.md): Enforce a clickable non-interactive element has at least one keyboard event listener. - [heading-has-content](docs/rules/heading-has-content.md): Enforce heading (`h1`, `h2`, etc) elements contain accessible content. - [html-has-lang](docs/rules/html-has-lang.md): Enforce `` element has `lang` prop. - [iframe-has-title](docs/rules/iframe-has-title.md): Enforce iframe elements have a title attribute. - [img-redundant-alt](docs/rules/img-redundant-alt.md): Enforce `` alt prop does not contain the word "image", "picture", or "photo". - [interactive-supports-focus](docs/rules/interactive-supports-focus.md): Enforce that elements with interactive handlers like `onClick` must be focusable. - [label-has-associated-control](docs/rules/label-has-associated-control.md): Enforce that a `label` tag has a text label and an associated control. - [lang](docs/rules/lang.md): Enforce lang attribute has a valid value. - [media-has-caption](docs/rules/media-has-caption.md): Enforces that `