@@ -25,9 +25,10 @@ const parserOptions = {
25
25
const ruleTester = new RuleTester ( ) ;
26
26
27
27
const expectedError = {
28
- message : 'Interactive elements with onClick handlers must be focusable. ' +
29
- 'Either set the tabIndex property to a valid value (usually 0), ' +
30
- 'or use an element type which is inherently focusable such as `button`.' ,
28
+ message : 'An non-interactive element with an onClick handler and an ' +
29
+ 'interactive role must be focusable. Either set the tabIndex property to ' +
30
+ 'a valid value (usually 0) or use an element type which is inherently ' +
31
+ 'focusable such as `button`.' ,
31
32
type : 'JSXOpeningElement' ,
32
33
} ;
33
34
@@ -54,6 +55,7 @@ ruleTester.run('onclick-has-focus', rule, {
54
55
{ code : '<input type="hidden" onClick={() => void 0} tabIndex="-1" />' , parserOptions } ,
55
56
{ code : '<input type="hidden" onClick={() => void 0} tabIndex={-1} />' , parserOptions } ,
56
57
{ code : '<input onClick={() => void 0} />' , parserOptions } ,
58
+ { code : '<input onClick={() => void 0} role="combobox" />' , parserOptions } ,
57
59
{ code : '<button onClick={() => void 0} className="foo" />' , parserOptions } ,
58
60
{ code : '<option onClick={() => void 0} className="foo" />' , parserOptions } ,
59
61
{ code : '<select onClick={() => void 0} className="foo" />' , parserOptions } ,
@@ -71,6 +73,7 @@ ruleTester.run('onclick-has-focus', rule, {
71
73
{ code : '<a onClick={() => void 0} href="http://x.y.z" />' , parserOptions } ,
72
74
{ code : '<a onClick={() => void 0} href="http://x.y.z" tabIndex="0" />' , parserOptions } ,
73
75
{ code : '<a onClick={() => void 0} href="http://x.y.z" tabIndex={0} />' , parserOptions } ,
76
+ { code : '<a onClick={() => void 0} href="http://x.y.z" role="button" />' , parserOptions } ,
74
77
{ code : '<TestComponent onClick={doFoo} />' , parserOptions } ,
75
78
{ code : '<input onClick={() => void 0} type="hidden" />;' , parserOptions } ,
76
79
{ code : '<span onClick="submitForm();">Submit</span>' , errors : [ expectedError ] , parserOptions } ,
0 commit comments