Security News
NVD Backlog Tops 20,000 CVEs Awaiting Analysis as NIST Prepares System Updates
NVD’s backlog surpasses 20,000 CVEs as analysis slows and NIST announces new system updates to address ongoing delays.
eslint-plugin-jsx-a11y
Advanced tools
A static analysis linter of jsx and their accessibility with screen readers.
The eslint-plugin-jsx-a11y npm package is a collection of accessibility-related rules for ESLint that enforce best practices for accessibility in JSX (most commonly used with React). It helps developers write code that is accessible to users with disabilities by checking for common accessibility errors and suggesting improvements.
Accessible elements
Ensures interactive elements are accessible. For example, this rule checks that buttons have an accessible name and can be interacted with via keyboard.
<button onClick={this.handleClick}>Click me</button>
Aria roles
Enforces the use of valid ARIA roles and that elements with ARIA roles have the required attributes for that role.
<div role="button" onClick={this.handleRoleClick}>Role Button</div>
Media captions
Ensures media elements such as audio and video have captions or descriptions to aid users who cannot see or hear the content.
<video><track kind="captions" /></video>
No redundant alt text
Prevents the use of redundant alt text in images, which can be frustrating for screen reader users.
<img src="image.jpg" alt="" />
Keyboard accessibility
Ensures that custom interactive elements are focusable and have keyboard event handlers to mimic native interactive elements.
<div tabIndex="0" onKeyDown={this.handleKeyDown}>Focusable Div</div>
Similar to eslint-plugin-jsx-a11y, but specifically tailored for Vue.js applications. It provides a set of accessibility rules for Vue.js templates.
While not exclusively focused on accessibility, eslint-plugin-react includes some rules related to accessibility. It is a broader linting tool for React-specific code practices.
Although not an ESLint plugin, axe-core is a library for accessibility testing that can be integrated into testing frameworks. It provides comprehensive accessibility checks that can be run on rendered HTML, complementing the static analysis provided by eslint-plugin-jsx-a11y.
Static AST checker for accessibility rules on JSX elements.
Ryan Florence built out this awesome runtime-analysis tool called 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.
You'll first need to install ESLint:
$ npm i eslint --save-dev
Next, install eslint-plugin-jsx-a11y
:
$ npm install eslint-plugin-jsx-a11y --save-dev
Note: If you installed ESLint globally (using the -g
flag) then you must also install eslint-plugin-jsx-a11y
globally.
Add jsx-a11y
to the plugins section of your .eslintrc
configuration file. You can omit the eslint-plugin-
prefix:
{
"plugins": [
"jsx-a11y"
]
}
Then configure the rules you want to use under the rules section.
{
"rules": {
"jsx-a11y/rule-name": 2
}
}
Feel free to contribute! I am currently using Google Chrome's Audit Rules to map out as rules for this plugin.
eslint-plugin-jsx-a11y is licensed under the MIT License.
FAQs
Static AST checker for accessibility rules on JSX elements.
The npm package eslint-plugin-jsx-a11y receives a total of 13,647,957 weekly downloads. As such, eslint-plugin-jsx-a11y popularity was classified as popular.
We found that eslint-plugin-jsx-a11y demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
NVD’s backlog surpasses 20,000 CVEs as analysis slows and NIST announces new system updates to address ongoing delays.
Security News
Research
A malicious npm package disguised as a WhatsApp client is exploiting authentication flows with a remote kill switch to exfiltrate data and destroy files.
Security News
PyPI now supports digital attestations, enhancing security and trust by allowing package maintainers to verify the authenticity of Python packages.