Getting Started
npm install --save-dev eslint eslint-plugin-react-a11y
// eslint.config.mjs
import { configs } from 'eslint-plugin-react-a11y';
export default [configs.recommended];
recommended is the preset to start with. The others are listed under Configuration Presets below.
Using oxlint or Vite+? Install oxlint-plugin-react-a11y: the same rules under the same react-a11y/<rule> IDs, without ESLint. Its page has the setup.
Description
This plugin provides ESLint rules for React accessibility: ARIA, alt text, keyboard interaction and focus management, from WCAG 2.1.
- Why — a linter nobody reads protects nothing. We would rather miss a finding
than spend your attention on one that was never real.
- How — evidence, not names. A rule fires on what the code does, resolved
through the AST and ESLint's own scope analysis.
- What — every finding carries its fix, in prose for a human and as structured
JSON for an agent. Security rules add a CWE mapping and, where assigned, a CVSS score.
That trade costs recall, and we measure it:
methodology
· results
· a false positive is a bug.
⚙️ Configuration Presets
| Preset |
Description |
recommended |
Enables critical accessibility rules (WCAG Level A as errors, AA as warnings) |
strict |
Enforces all rules as errors for maximum WCAG compliance |
wcag-a |
Only rules required for WCAG 2.1 Level A compliance |
wcag-aa |
Includes Level A + additional rules for Level AA compliance |
Configuration Examples
Basic Usage
// eslint.config.js
import reactA11y from 'eslint-plugin-react-a11y';
export default [reactA11y.configs.recommended];
With TypeScript
import reactA11y from 'eslint-plugin-react-a11y';
import tseslint from 'typescript-eslint';
export default [
...tseslint.configs.recommended,
reactA11y.configs.recommended,
{
files: ['**/*.{ts,tsx}'],
rules: {
'react-a11y/alt-text': 'error',
},
},
];
Strict WCAG Compliance
import reactA11y from 'eslint-plugin-react-a11y';
export default [
reactA11y.configs['wcag-aa'],
{
// Additional customizations
},
];
Custom Configuration
import reactA11y from 'eslint-plugin-react-a11y';
export default [
{
plugins: {
'react-a11y': reactA11y,
},
rules: {
'react-a11y/alt-text': [
'error',
{
allowAriaLabel: true,
allowAriaLabelledby: true,
},
],
'react-a11y/anchor-ambiguous-text': [
'warn',
{
words: ['click here', 'here', 'more', 'read more', 'learn more'],
},
],
},
},
];
Migrating from eslint-plugin-jsx-a11y
Facts, as measured against eslint-plugin-jsx-a11y 6.10.2.
-
Keep your rule IDs and disable comments. Register the plugin under the jsx-a11y key and every
shared rule resolves under jsx-a11y/<rule>. 35 rule names are the same in both plugins; none is renamed.
import reactA11y from 'eslint-plugin-react-a11y';
export default [
{
plugins: { 'jsx-a11y': reactA11y },
rules: { 'jsx-a11y/alt-text': 'error' },
},
];
// eslint-disable-next-line jsx-a11y/alt-text keeps working unchanged.
-
Rules that do not exist here: aria-proptypes (a live upstream rule, enabled in both upstream presets).
A config that enables it throws on load. The deprecated upstream rules accessible-emoji, label-has-for and
no-onchange are registered as no-ops (meta.deprecated: true), so a config that names them loads; they report
nothing and no preset enables them. label-has-for is replacedBy label-has-associated-control.
-
Options load. The option objects in upstream's recommended and strict presets load without error
(includeRoles, allowExpressionValues, element-keyed handler lists, elements, hoverInHandlers). Which are
read is listed on each rule's page; includeRoles is accepted and read by nothing, as upstream.
-
settings['jsx-a11y'] is not read yet. components, polymorphicPropName, polymorphicAllowList and
attributes are ignored by every rule. Use the per-rule options (components, controlComponents, ...) instead.
-
The presets use the react-a11y/ prefix and are not aliased to jsx-a11y/. configs.recommended and
flatConfigs.recommended (also strict) are the same object, keyed react-a11y; spreading one next to a plugin
registered as jsx-a11y enables the rules under both prefixes. Each preset sets
languageOptions.parserOptions.ecmaFeatures.jsx.
-
Severities differ. recommended here is error for WCAG Level A rules and warn for the rest;
upstream's is error for nearly every rule, with per-rule options that these presets do not carry.
📦 Compatibility
| Package |
Version |
| ESLint |
^8.40.0 \|\| ^9.0.0 \|\| ^10.0.0 |
| Node.js |
>=22.13.0 |
See the ESLint Version Support Policy — current ecosystem share data, the 20% gate, and the forward-looking exception that covers v10.
Rules
Legend
| Icon |
Description |
| 💼 |
Recommended: Included in the recommended preset. |
| ⚠️ |
Warns: Set to warn in recommended preset. |
| 🔧 |
Auto-fixable: Automatically fixable by the --fix CLI option. |
| 💡 |
Suggestions: Providing code suggestions in IDE. |
| 🚫 |
Deprecated: This rule is deprecated. |
| 🟢 |
Type-unaware: AST-only, runs in oxlint JS-plugin tier. |
| 🟡 |
Type-aware (refining): pure-AST primary path; types refine precision. |
| 🟠 |
Type-aware (graceful): requires TS program; silent without it. |