JSPM

eslint-plugin-react-a11y

2.1.0
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 60
  • Score
    100M100P100Q79392F
  • License MIT

React accessibility ESLint plugin with 37 LLM-optimized rules for WCAG 2.1 compliance. Provides structured error messages for AI assistants and auto-fix capabilities.

Package Exports

  • eslint-plugin-react-a11y
  • eslint-plugin-react-a11y/types

Readme

ESLint Interlace Logo

Accessibility (a11y) rules for React applications, enforcing WCAG standards.

NPM Version NPM Downloads Package License Codecov Since Dec 2025

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

npm install eslint-plugin-react-a11y --save-dev

Quick 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.

Part of the Interlace ESLint Ecosystem โ€” AI-native security plugins with LLM-optimized error messages:

Plugin Downloads Description
eslint-plugin-secure-coding downloads General security rules & OWASP guidelines.
eslint-plugin-pg downloads PostgreSQL security & best practices.
eslint-plugin-crypto downloads NodeJS Cryptography security rules.
eslint-plugin-jwt downloads JWT security & best practices.
eslint-plugin-browser-security downloads Browser-specific security & XSS prevention.
eslint-plugin-express-security downloads Express.js security hardening rules.
eslint-plugin-lambda-security downloads AWS Lambda security best practices.
eslint-plugin-nestjs-security downloads NestJS security rules & patterns.
eslint-plugin-import-next downloads Next-gen import sorting & architecture.

๐Ÿ“„ License

MIT ยฉ Ofri Peretz

ESLint Interlace Plugin