-
Notifications
You must be signed in to change notification settings - Fork 127
Expand file tree
/
Copy pathno-access-key.js
More file actions
39 lines (34 loc) · 1.16 KB
/
no-access-key.js
File metadata and controls
39 lines (34 loc) · 1.16 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
import {
devices,
hasProp
} from '../util';
export default [{
msg: 'No `accessKey` attribute allowed. Inconsistencies '
+ 'between keyboard shortcuts and keyboard comments used by screenreader '
+ 'and keyboard only users create a11y complications.',
url: 'http://webaim.org/techniques/keyboard/accesskey#spec',
affects: [
devices.screenReader,
devices.keyboardOnly
],
test(tagName, props) {
const accessKey = hasProp(props, 'accessKey');
return !accessKey;
}
}];
export const fail = [{
when: 'there is an `accessKey` prop',
// eslint-disable-next-line jsx-a11y/no-access-key
render: React => <div accessKey="a" />
}];
export const pass = [{
when: 'there is an no `accessKey` prop',
render: React => <div />
}];
export const description = `
Enforce no accessKey prop on element. Access keys are HTML elements that allow
web developers to assign keyboard shortcuts to elements. Inconsistencies between
keyboard shortcuts and keyboard commands used by screenreader and keyboard only
users create accessibility complications so to avoid complications, access keys
should not be used.
`;