Registry / testing / tslint-react-a11y

tslint-react-a11y

JSON →
library1.1.0jsnpmunverified

JSX accessibility lint rules for TSLint, extracted from tslint-microsoft-contrib. Version 1.1.0 (latest) adds 6 new rules including react-a11y-accessible-headings and react-a11y-iframes. Provides a focused set of WCAG-compliant React rules for automated a11y checks. Unlike eslint-plugin-jsx-a11y, this integrates directly with TSLint for TypeScript projects. The package is now in long-term maintenance as TSLint is deprecated in favor of ESLint. No additional releases expected.

npm install tslint-react-a11y
INSTALL
IMPORT
SIG · TSLINT-REACT-A11Y
T
tslint-react-a11y
testingjavascriptv1.1.0
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

tslint-react-a11y
In tslint.json: { "extends": ["tslint-react-a11y"] }
Trying to import package via require/import statement
This is a TSLint config package, not a programmatic library. Use config extension not code imports.
react-a11y-accessible-headings
In tslint.json rules section: { "react-a11y-accessible-headings": true }
Using require('tslint-react-a11y').rules or similar
Rules are enabled via tslint.json rules object, not by importing the package.
RulesDirectory
In tslint.json: { "rulesDirectory": ["node_modules/tslint-react-a11y/lib"] }
Forgetting to specify rulesDirectory when not using extends
When using 'extends', rulesDirectory may be automatically set. Check tslint docs.

Complete tslint.json configuration enabling all accessibility rules with example option object.

// tslint.json { "extends": ["tslint:latest", "tslint-react", "tslint-react-a11y"], "rules": { "react-a11y-anchors": [true, { "ignore-case": false, "ignore-whitespace": "trim" }], "react-a11y-aria-unsupported-elements": true, "react-a11y-event-has-role": true, "react-a11y-image-button-has-alt": true, "react-a11y-img-has-alt": true, "react-a11y-lang": true, "react-a11y-meta": true, "react-a11y-props": true, "react-a11y-proptypes": true, "react-a11y-role": true, "react-a11y-role-supports-aria-props": true, "react-a11y-tabindex-no-positive": true, "react-a11y-titles": true, // v1.1.0 new rules "react-a11y-accessible-headings": true, "react-a11y-iframes": true, "react-a11y-input-elements": true, "react-a11y-mouse-event-has-key-event": true, "react-a11y-no-onchange": true, "react-a11y-required": true } }
Debug
Known issues
deprecatedTSLint is deprecated; consider migrating to ESLint with eslint-plugin-jsx-a11y.
fix
Use eslint-plugin-jsx-a11y with @typescript-eslint/parser for TypeScript.
affects: >=0.0.0
breakingRule options changed between v1.0.0 and v1.1.0; react-a11y-anchors now accepts an object rather than boolean.
fix
Update rule configuration to { "react-a11y-anchors": [true, { "ignore-case": false, "ignore-whitespace": "trim" }] }
affects: >=1.1.0
gotchaMissing tslint and typescript peer dependencies cause runtime errors.
fix
Install tslint and typescript as devDependencies.
affects: >=1.0.0
gotchaRules from tslint-react-a11y can conflict with tslint:latest or tslint-react rules if not properly ordered.
fix
Place tslint-react-a11y last in the extends array.
affects: >=1.0.0
Errors
Common errors & fixes
Cannot find module 'tslint'
Missing tslint peer dependency
fix
npm install --save-dev tslint
Unknown rule: react-a11y-accessible-headings
Using v1.0.0 which does not include this rule
fix
Update to v1.1.0: npm install tslint-react-a11y@1.1.0
TypeError: Cannot read property 'apply' of undefined
Incorrect rulesDirectory path in tslint.json
fix
Add "rulesDirectory": ["node_modules/tslint-react-a11y/lib"]
Upgrade
Version history
1.1.0latest on npm
Audit
Dependencies
tslint-microsoft-contribrequiredBundles the a11y rules extracted from this dependency
tslintrequiredPeer dependency required by the tslint plugin system
typescriptrequiredRequired for TSLint runtime and type checking
Agent activity
4 hits · last 30 days
node
4
Resources
tslint-react-a11y — npm install tslint-react-a11y · libregistry