8000 Add note and rule about not using accessKey · evozonjs/javascript@f697a15 · GitHub
[go: up one dir, main page]

Skip to content

Commit f697a15

Browse files
committed
Add note and rule about not using accessKey
Inconsistencies between keyboard shortcuts and keyboard commands used by people using screenreaders and keyboards complicate accessibility.
1 parent 0c3b13f commit f697a15

File tree

2 files changed

+19
-3
lines changed

2 files changed

+19
-3
lines changed

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,10 @@ module.exports = {
99
// View link below for react rules documentation
1010
// https://github.com/yannickcr/eslint-plugin-react#list-of-supported-rules
1111
'rules': {
12+
// Prevent use of `accessKey`
13+
// https://github.com/evcohen/eslint-plugin-jsx-a11y/blob/master/docs/rules/no-access-key.md
14+
'jsx-a11y/no-access-key': 2,
15+
1216
// Require <img> to have a non-empty `alt` prop, or role="presentation"
1317
// https://github.com/evcohen/eslint-plugin-jsx-a11y/blob/master/docs/rules/img-uses-alt.md
1418
'jsx-a11y/img-uses-alt': 2,

react/README.md

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -249,15 +249,27 @@
249249

250250
```javascript
251251
// bad - not an ARIA role
252-
<div role="datepicker"></div>
252+
<div role="datepicker" />
253253
254254
// bad - abstract ARIA role
255-
<div role="range"></div>
255+
<div role="range" />
256256
257257
// good
258-
<div role="button"></div>
258+
<div role="button" />
259259
```
260260

261+
- Do not use `accessKey` on elements. eslint: [`jsx-a11y/no-access-key`](https://github.com/evcohen/eslint-plugin-jsx-a11y/blob/master/docs/rules/no-access-key.md)
262+
263+
> Why? Inconsistencies between keyboard shortcuts and keyboard commands used by people using screenreaders and keyboards complicate accessibility.
264+
265+
```javascript
266+
// bad
267+
<div accessKey="h" />
268+
269+
// good
270+
<div />
271+
```
272+
261273
## Parentheses
262274

263275
- 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