8000 Add note and rule about valid, non-abstract ARIA roles · evozonjs/javascript@0c3b13f · GitHub
[go: up one dir, main page]

Skip to content

Commit 0c3b13f

Browse files
committed
Add note and rule about valid, non-abstract ARIA roles
This rule will help people use only valid roles, which might save people from simple, accessibility-busting mistakes.
1 parent f2aca29 commit 0c3b13f

File tree

2 files changed

+17
-0
lines changed

2 files changed

+17
-0
lines changed

packages/eslint-config-airbnb/rules/react.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,10 @@ module.exports = {
1717
// https://github.com/evcohen/eslint-plugin-jsx-a11y/blob/master/docs/rules/redundant-alt.md
1818
'jsx-a11y/redundant-alt': 2,
1919

20+
// Require ARIA roles to be valid and non-abstract
21+
// https://github.com/evcohen/eslint-plugin-jsx-a11y/blob/master/docs/rules/valid-aria-role.md
22+
'jsx-a11y/valid-aria-role': 2,
23+
2024
// Prevent missing displayName in a React component definition
2125
// https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/display-name.md
2226
'react/display-name': [0, { 'ignoreTranspilerName': false }],

react/README.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -245,6 +245,19 @@
245245
<img src="hello.jpg" alt="Me waving hello" />
246246
```
247247

248+
- Use only valid, non-abstract [ARIA roles](https://www.w3.org/TR/wai-aria/roles#role_definitions). eslint: [`jsx-a11y/valid-aria-role`](https://github.com/evcohen/eslint-plugin-jsx-a11y/blob/master/docs/rules/valid-aria-role.md)
249+
250+
```javascript
251+
// bad - not an ARIA role
252+
<div role="datepicker"></div>
253+
254+
// bad - abstract ARIA role
255+
<div role="range"></div>
256+
257+
// good
258+
<div role="button"></div>
259+
```
260+
248261
## Parentheses
249262

250263
- Wrap JSX tags in parentheses when they span more than one line. eslint: [`react/wrap-multilines`](https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/wrap-multilines.md)

0 commit comments

Comments
 (0)
0