@@ -32,9 +32,15 @@ module.exports = {
3232 // https://github.com/evcohen/eslint-plugin-jsx-a11y/blob/master/docs/rules/href-no-hash.md
3333 'jsx-a11y/href-no-hash' : [ 'error' , { components : [ 'a' ] } ] ,
3434
35- // Require <img> to have a non-empty `alt` prop, or role="presentation"
36- // https://github.com/evcohen/eslint-plugin-jsx-a11y/blob/master/docs/rules/img-has-alt.md
37- 'jsx-a11y/img-has-alt' : 'error' ,
35+ // Enforce that all elements that require alternative text have meaningful information
36+ // https://github.com/evcohen/eslint-plugin-jsx-a11y/blob/master/docs/rules/alt-text.md
37+ 'jsx-a11y/alt-text' : [ 'error' , {
38+ elements : [ 'img' , 'object' , 'area' , 'input[type="image"]' ] ,
39+ img : [ ] ,
40+ object : [ ] ,
41+ area : [ ] ,
42+ 'input[type="image"]' : [ ] ,
43+ } ] ,
3844
3945 // Prevent img alt text from containing redundant words like "image", "picture", or "photo"
4046 // https://github.com/evcohen/eslint-plugin-jsx-a11y/blob/master/docs/rules/img-redundant-alt.md
@@ -57,14 +63,9 @@ module.exports = {
5763 // https://github.com/evcohen/eslint-plugin-jsx-a11y/blob/master/docs/rules/no-onchange.md
5864 'jsx-a11y/no-onchange' : 'off' ,
5965
60- // Enforce that elements with onClick handlers must be focusable.
61- // TODO: evaluate
62- // https://github.com/evcohen/eslint-plugin-jsx-a11y/blob/master/docs/rules/onclick-has-focus.md
63- 'jsx-a11y/onclick-has-focus' : 'off' ,
64-
65- // require things with onClick to have an aria role
66- // https://github.com/evcohen/eslint-plugin-jsx-a11y/blob/master/docs/rules/onclick-has-role.md
67- 'jsx-a11y/onclick-has-role' : 'off' ,
66+ // Elements with an interactive role and interaction handlers must be focusable
67+ // https://github.com/evcohen/eslint-plugin-jsx-a11y/blob/master/docs/rules/interactive-supports-focus.md
68+ 'jsx-a11y/interactive-supports-focus' : 'error' ,
6869
6970 // Enforce that elements with ARIA roles must have all required attributes
7071 // for that role.
@@ -109,7 +110,29 @@ module.exports = {
109110
110111 // Enforce that DOM elements without semantic behavior not have interaction handlers
111112 // https://github.com/evcohen/eslint-plugin-jsx-a11y/blob/master/docs/rules/no-static-element-interactions.md
112- 'jsx-a11y/no-static-element-interactions' : 'error' ,
113+ 'jsx-a11y/no-static-element-interactions' : [ 'error' , {
114+ handlers : [
115+ 'onClick' ,
116+ 'onMouseDown' ,
117+ 'onMouseUp' ,
118+ 'onKeyPress' ,
119+ 'onKeyDown' ,
120+ 'onKeyUp' ,
121+ ]
122+ } ] ,
123+
124+ // A non-interactive element does not support event handlers (mouse and key handlers)
125+ // https://github.com/evcohen/eslint-plugin-jsx-a11y/blob/master/docs/rules/no-noninteractive-element-interactions.md
126+ 'jsx-a11y/no-noninteractive-element-interactions' : [ 'error' , {
127+ handlers : [
128+ 'onClick' ,
129+ 'onMouseDown' ,
130+ 'onMouseUp' ,
131+ 'onKeyPress' ,
132+ 'onKeyDown' ,
133+ 'onKeyUp' ,
134+ ]
135+ } ] ,
113136
114137 // ensure emoji are accessible
115138 // https://github.com/evcohen/eslint-plugin-jsx-a11y/blob/master/docs/rules/accessible-emoji.md
@@ -125,10 +148,41 @@ module.exports = {
125148
126149 // prohibit autoFocus prop
127150 // https://github.com/evcohen/eslint-plugin-jsx-a11y/blob/master/docs/rules/no-autofocus.md
128- 'jsx-a11y/no-autofocus' : 'error' ,
151+ 'jsx-a11y/no-autofocus' : [ 'error' , { ignoreNonDOM : true } ] ,
129152
130153 // ensure HTML elements do not specify redundant ARIA roles
131154 // https://github.com/evcohen/eslint-plugin-jsx-a11y/blob/master/docs/rules/no-redundant-roles.md
132155 'jsx-a11y/no-redundant-roles' : 'error' ,
156+
157+ // media elements must have captions
158+ // https://github.com/evcohen/eslint-plugin-jsx-a11y/blob/master/docs/rules/media-has-caption.md
159+ 'jsx-a11y/media-has-caption' : [ 'error' , {
160+ audio : [ ] ,
161+ video : [ ] ,
162+ track : [ ] ,
163+ } ] ,
164+
165+ // WAI-ARIA roles should not be used to convert an interactive element to non-interactive
166+ // https://github.com/evcohen/eslint-plugin-jsx-a11y/blob/master/docs/rules/no-interactive-element-to-noninteractive-role.md
167+ 'jsx-a11y/no-interactive-element-to-noninteractive-role' : [ 'error' , {
168+ tr : [ 'none' , 'presentation' ] ,
169+ } ] ,
170+
171+ // WAI-ARIA roles should not be used to convert a non-interactive element to interactive
172+ // https://github.com/evcohen/eslint-plugin-jsx-a11y/blob/master/docs/rules/no-noninteractive-element-to-interactive-role.md
173+ 'jsx-a11y/no-noninteractive-element-to-interactive-role' : [ 'error' , {
174+ ul : [ 'listbox' , 'menu' , 'menubar' , 'radiogroup' , 'tablist' , 'tree' , 'treegrid' ] ,
175+ ol : [ 'listbox' , 'menu' , 'menubar' , 'radiogroup' , 'tablist' , 'tree' , 'treegrid' ] ,
176+ li : [ 'menuitem' , 'option' , 'row' , 'tab' , 'treeitem' ] ,
177+ table : [ 'grid' ] ,
178+ td : [ 'gridcell' ] ,
179+ } ] ,
180+
181+ // Tab key navigation should be limited to elements on the page that can be interacted with.
182+ // https://github.com/evcohen/eslint-plugin-jsx-a11y/blob/master/docs/rules/no-noninteractive-tabindex.md
183+ 'jsx-a11y/no-noninteractive-tabindex' : [ 'error' , {
184+ tags : [ ] ,
185+ roles : [ 'tabpanel' ] ,
186+ } ] ,
133187 } ,
134188} ;
0 commit comments