-
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Enable some
eslint-plugin-jsx-a11y
rules
- `jsx-a11y/click-events-have-key-events` as a warning - `jsx-a11y/mouse-events-have-key-events` as a warning - `jsx-a11y/no-onchange` as an error - `jsx-a11y/onclick-has-focus` as an error - `jsx-a11y/onclick-has-role` as an error
- Loading branch information
Showing
2 changed files
with
31 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import { rules } from '../react-a11y' | ||
|
||
describe('react-a11y rules', () => { | ||
it('contains only react-a11y rules', () => { | ||
const keys = Object.keys(rules) | ||
const expected = Array.from( | ||
keys, () => expect.stringMatching(/^jsx-a11y\/.+$/), | ||
) | ||
|
||
expect(keys).toEqual(expected) | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
module.exports = { | ||
rules: { | ||
// require onClick be accompanied by onKeyUp/onKeyDown/onKeyPress | ||
// https://github.com/evcohen/eslint-plugin-jsx-a11y/blob/master/docs/rules/click-events-have-key-events.md | ||
'jsx-a11y/click-events-have-key-events': 'warn', | ||
// require that mouseover/out come with focus/blur, for keyboard-only users | ||
// https://github.com/evcohen/eslint-plugin-jsx-a11y/blob/master/docs/rules/mouse-events-have-key-events.md | ||
'jsx-a11y/mouse-events-have-key-events': 'warn', | ||
// require onBlur instead of onChange | ||
// https://github.com/evcohen/eslint-plugin-jsx-a11y/blob/master/docs/rules/no-onchange.md | ||
'jsx-a11y/no-onchange': 'error', | ||
// Enforce that elements with onClick handlers must be focusable. | ||
// https://github.com/evcohen/eslint-plugin-jsx-a11y/blob/master/docs/rules/onclick-has-focus.md | ||
'jsx-a11y/onclick-has-focus': 'error', | ||
// require things with onClick to have an aria role | ||
// https://github.com/evcohen/eslint-plugin-jsx-a11y/blob/master/docs/rules/onclick-has-role.md | ||
'jsx-a11y/onclick-has-role': 'error', | ||
}, | ||
} |