Package Exports
- eslint-plugin-react-a11y
- eslint-plugin-react-a11y/types
Readme
Accessibility (a11y) rules for React applications, enforcing WCAG standards.
Description
This plugin ensures your React applications are accessible to all users by strictly enforcing WCAG standards. It automatically detects common accessibility issues in your JSX, such as missing alt text or improper aria labels, and guides you toward compliant solutions. Implementing these rules helps you build inclusive web experiences that meet modern accessibility requirements.
Philosophy
Interlace fosters strength through integration. We interlace accessibility directly into your workflow, creating inclusive applications by design. Tools should guide rather than gatekeep, providing educational feedback that strengthens developers.
Why an independent ecosystem? ๐ Ship fast without upstream bureaucracy โข ๐ค AI-optimized messages (WCAG, severity, fixes) โข โก Unified codebase for performance โข ๐๏ธ Consistent patterns across all plugins โข ๐ Educational "why" explanations
All rules are clean-room implementations following eslint-plugin-jsx-a11y naming conventions โ familiar API, better engineering.
Getting Started
- To check out the guide, visit eslint.interlace.tools. ๐
- ่ฆๆฅ็ไธญๆ ๆๅ, ่ฏท่ฎฟ้ฎ eslint.interlace.tools. ๐
- ๊ฐ์ด๋ ๋ฌธ์๋ eslint.interlace.tools์์ ํ์ธํ์ค ์ ์์ต๋๋ค. ๐
- ใฌใคใใฏ eslint.interlace.toolsใงใ็ขบ่ชใใ ใใใ ๐
- Para ver la guรญa, visita eslint.interlace.tools. ๐
- ููุงุทูุงุน ุนูู ุงูุฏูููุ ูู ุจุฒูุงุฑุฉ eslint.interlace.tools. ๐
npm install eslint-plugin-react-a11y --save-devQuick Start
// eslint.config.js
import reactA11y from 'eslint-plugin-react-a11y';
export default [reactA11y.configs.recommended];โ๏ธ 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/img-requires-alt': '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/img-requires-alt': [
'error',
{
allowAriaLabel: true,
allowAriaLabelledby: true,
},
],
'react-a11y/anchor-ambiguous-text': [
'warn',
{
words: ['click here', 'here', 'more', 'read more', 'learn more'],
},
],
},
},
];Rules
Legend
| Icon | Description |
|---|---|
| ๐ผ | Recommended: Included in the recommended preset. |
| โ ๏ธ | Warns: Set towarn in recommended preset. |
| ๐ง | Auto-fixable: Automatically fixable by the --fix CLI option. |
| ๐ก | Suggestions: Providing code suggestions in IDE. |
| ๐ซ | Deprecated: This rule is deprecated. |
| Rule | WCAG Criterion | Description | ๐ผ | โ ๏ธ | ๐ง | ๐ก | ๐ซ |
|---|---|---|---|---|---|---|---|
alt-text |
1.1.1 | Image missing alt text | ๐ผ | ||||
html-has-lang |
3.1.1 | html element missing lang attribute | ๐ผ | ||||
iframe-has-title |
2.4.1 | iframe element missing title | ๐ผ | ||||
mouse-events-have-key-events |
2.1.1 | onMouseOver must be accompanied by onFocus | ๐ผ | ||||
no-access-key |
2.1.1 | No access key attribute allowed | ๐ผ | ||||
no-autofocus |
2.4.3 | No autofocus attribute allowed | ๐ผ | ||||
no-distracting-elements |
2.2.2 | Distracting elements (marquee, blink) are not allowed | ๐ผ | ||||
aria-props |
4.1.2 | Invalid ARIA attribute | ๐ผ | ||||
aria-role |
4.1.2 | Invalid ARIA role | ๐ผ | ||||
role-has-required-aria-props |
4.1.2 | Role missing required aria props | ๐ผ | ||||
aria-unsupported-elements |
4.1.2 | Element does not support ARIA roles/props | ๐ผ | ||||
click-events-have-key-events |
2.1.1 | onClick must be accompanied by onKeyUp/KeyDown | ๐ผ | ||||
heading-has-content |
1.3.1 | Headings must have content | ๐ผ | ||||
label-has-associated-control |
3.3.2 | Form label must be associated with a control | ๐ผ | ||||
tabindex-no-positive |
2.4.3 | Avoid positive tabIndex | ๐ผ |
AI-Optimized Messages
This plugin is optimized for ESLint's Model Context Protocol (MCP), enabling AI assistants like Cursor, GitHub Copilot, and Claude to:
- Understand the exact vulnerability type via CWE references
- Apply the correct fix using structured guidance
- Provide educational context to developers
src/components/Button.tsx
12:5 error ๐ CWE-20 WCAG:4.1.2 CVSS:5.3 | Interactive element missing accessible name | CRITICAL [WCAG 2.1 A]
Fix: Add aria-label="Submit Order" or inner text | https://eslint.interlace.tools/...// .cursor/mcp.json
{
"mcpServers": {
"eslint": {
"command": "npx",
"args": ["@eslint/mcp@latest"]
}
}
}By providing this structured context (CWE, OWASP, Fix), we enable AI tools to reason about the security flaw rather than hallucinating. This allows Copilot/Cursor to suggest the exact correct fix immediately.
๐ Related ESLint Plugins
Part of the Interlace ESLint Ecosystem โ AI-native security plugins with LLM-optimized error messages:
| Plugin | Downloads | Description |
|---|---|---|
eslint-plugin-secure-coding |
General security rules & OWASP guidelines. | |
eslint-plugin-pg |
PostgreSQL security & best practices. | |
eslint-plugin-crypto |
NodeJS Cryptography security rules. | |
eslint-plugin-jwt |
JWT security & best practices. | |
eslint-plugin-browser-security |
Browser-specific security & XSS prevention. | |
eslint-plugin-express-security |
Express.js security hardening rules. | |
eslint-plugin-lambda-security |
AWS Lambda security best practices. | |
eslint-plugin-nestjs-security |
NestJS security rules & patterns. | |
eslint-plugin-import-next |
Next-gen import sorting & architecture. |
๐ License
MIT ยฉ Ofri Peretz
