eslint-plugin-jsx-a11y
Advanced tools
Comparing version 1.2.1 to 1.2.2
@@ -0,1 +1,6 @@ | ||
1.2.2 / 2016-05-20 | ||
================== | ||
- [fix] Fix checks involving the tabIndex attribute that do not account for integer literals | ||
1.2.1 / 2016-05-19 | ||
@@ -2,0 +7,0 @@ ================== |
@@ -33,3 +33,3 @@ /** | ||
var errorMessage = 'Elements with onClick handlers must be focusable. ' + 'Either set the tabIndex property (usually 0), or use an element type which ' + 'is inherently focusable such as `button`.'; | ||
var errorMessage = 'Elements with onClick handlers must be focusable. ' + 'Either set the tabIndex property to a valid value (usually 0), or use ' + 'an element type which is inherently focusable such as `button`.'; | ||
@@ -51,3 +51,3 @@ module.exports = function (context) { | ||
return; | ||
} else if ((0, _getAttributeValue2.default)((0, _getAttribute2.default)(attributes, 'tabIndex'))) { | ||
} else if (!isNaN(Number((0, _getAttributeValue2.default)((0, _getAttribute2.default)(attributes, 'tabIndex'))))) { | ||
return; | ||
@@ -54,0 +54,0 @@ } |
@@ -13,2 +13,4 @@ 'use strict'; | ||
var _getAttributeValue2 = _interopRequireDefault(_getAttributeValue); | ||
var _DOM = require('./attributes/DOM'); | ||
@@ -23,5 +25,5 @@ | ||
a: function a(attributes) { | ||
var href = (0, _getAttribute2.default)(attributes, 'href'); | ||
var tabIndex = (0, _getAttribute2.default)(attributes, 'tabIndex'); | ||
return Boolean(href) || !href && Boolean(tabIndex); | ||
var href = (0, _getAttributeValue2.default)((0, _getAttribute2.default)(attributes, 'href')); | ||
var tabIndex = (0, _getAttributeValue2.default)((0, _getAttribute2.default)(attributes, 'tabIndex')); | ||
return Boolean(href) || !isNaN(Number(tabIndex)); | ||
}, | ||
@@ -28,0 +30,0 @@ // This is same as `a` interactivity function |
{ | ||
"name": "eslint-plugin-jsx-a11y", | ||
"version": "1.2.1", | ||
"version": "1.2.2", | ||
"description": "A static analysis linter of jsx and their accessibility with screen readers.", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
@@ -18,4 +18,4 @@ /** | ||
const errorMessage = 'Elements with onClick handlers must be focusable. ' + | ||
'Either set the tabIndex property (usually 0), or use an element type which ' + | ||
'is inherently focusable such as `button`.'; | ||
'Either set the tabIndex property to a valid value (usually 0), or use ' + | ||
'an element type which is inherently focusable such as `button`.'; | ||
@@ -35,3 +35,3 @@ module.exports = context => ({ | ||
return; | ||
} else if (getAttributeValue(getAttribute(attributes, 'tabIndex'))) { | ||
} else if (!isNaN(Number(getAttributeValue(getAttribute(attributes, 'tabIndex'))))) { | ||
return; | ||
@@ -38,0 +38,0 @@ } |
'use strict'; | ||
import getAttribute from './getAttribute'; | ||
import { getLiteralAttributeValue } from './getAttributeValue'; | ||
import getAttributeValue, { getLiteralAttributeValue } from './getAttributeValue'; | ||
import DOMElements from './attributes/DOM'; | ||
@@ -12,5 +12,5 @@ | ||
a: attributes => { | ||
const href = getAttribute(attributes, 'href'); | ||
const tabIndex = getAttribute(attributes, 'tabIndex'); | ||
return (Boolean(href) || (!href && Boolean(tabIndex))); | ||
const href = getAttributeValue(getAttribute(attributes, 'href')); | ||
const tabIndex = getAttributeValue(getAttribute(attributes, 'tabIndex')); | ||
return Boolean(href) || !isNaN(Number(tabIndex)); | ||
}, | ||
@@ -17,0 +17,0 @@ // This is same as `a` interactivity function |
@@ -30,4 +30,4 @@ /** | ||
message: 'Elements with onClick handlers must be focusable. ' + | ||
'Either set the tabIndex property (usually 0), or use an element type which ' + | ||
'is inherently focusable such as `button`.', | ||
'Either set the tabIndex property to a valid value (usually 0), ' + | ||
'or use an element type which is inherently focusable such as `button`.', | ||
type: 'JSXOpeningElement' | ||
@@ -50,2 +50,3 @@ }; | ||
{ code: '<input type="hidden" onClick={() => void 0} tabIndex="-1" />', parserOptions }, | ||
{ code: '<input type="hidden" onClick={() => void 0} tabIndex={-1} />', parserOptions }, | ||
{ code: '<input onClick={() => void 0} />', parserOptions }, | ||
@@ -58,9 +59,11 @@ { code: '<button onClick={() => void 0} className="foo" />', parserOptions }, | ||
{ code: '<a tabIndex="0" onClick={() => void 0} />', parserOptions }, | ||
{ code: '<a tabIndex={0} onClick={() => void 0} />', parserOptions }, | ||
{ code: '<a role="button" href="#" onClick={() => void 0} />', parserOptions }, | ||
{ code: '<a onClick={() => void 0} href="http://x.y.z" />', parserOptions }, | ||
{ code: '<a onClick={() => void 0} href="http://x.y.z" tabIndex="0" />', parserOptions }, | ||
{ code: '<a onClick={() => void 0} href="http://x.y.z" tabIndex={0} />', parserOptions }, | ||
{ code: '<TestComponent onClick={doFoo} />', parserOptions }, | ||
{ code: '<input onClick={() => void 0} type="hidden" />;', parserOptions }, | ||
{ code: '<span onClick="doSomething();" tabIndex="0">Click me!</span>', parserOptions }, | ||
{ code: '<span onClick="doSomething();" tabIndex="0">Click me!</span>', parserOptions }, | ||
{ code: '<span onClick="doSomething();" tabIndex={0}>Click me!</span>', parserOptions }, | ||
{ code: '<span onClick="doSomething();" tabIndex="-1">Click me too!</span>', parserOptions }, | ||
@@ -75,6 +78,13 @@ { code: '<a href="javascript:void(0);" onClick="doSomething();">Click ALL the things!</a>', parserOptions }, | ||
{ code: '<span onClick="submitForm();" tabIndex={undefined}>Submit</span>', errors: [ expectedError ], parserOptions }, | ||
{ code: '<span onClick="submitForm();" tabIndex="bad">Submit</span>', errors: [ expectedError ], parserOptions }, | ||
{ code: '<a onClick="showNextPage();">Next page</a>', errors: [ expectedError ], parserOptions }, | ||
{ code: '<a onClick="showNextPage();" tabIndex={undefined}>Next page</a>', errors: [ expectedError ], parserOptions }, | ||
{ code: '<a onClick="showNextPage();" tabIndex="bad">Next page</a>', errors: [ expectedError ], parserOptions }, | ||
{ code: '<a onClick={() => void 0} />', errors: [ expectedError ], parserOptions }, | ||
{ code: '<area onClick={() => void 0} className="foo" />', errors: [ expectedError ], parserOptions }, | ||
{ code: '<div onClick={() => void 0} />;', errors: [ expectedError ], parserOptions }, | ||
{ code: '<div onClick={() => void 0} tabIndex={undefined} />;', errors: [ expectedError ], parserOptions }, | ||
{ code: '<div onClick={() => void 0} tabIndex="bad" />;', errors: [ expectedError ], parserOptions }, | ||
{ code: '<div onClick={() => void 0} role={undefined} />;', errors: [ expectedError ], parserOptions }, | ||
{ code: '<div onClick={() => void 0} aria-hidden={false} />;', errors: [ expectedError ], parserOptions }, | ||
{ code: '<div onClick={() => void 0} {...props} />;', errors: [ expectedError ], parserOptions }, | ||
@@ -85,6 +95,4 @@ { code: '<section onClick={() => void 0} />;', errors: [ expectedError ], parserOptions }, | ||
{ code: '<header onClick={() => void 0} />;', errors: [ expectedError ], parserOptions }, | ||
{ code: '<footer onClick={() => void 0} />;', errors: [ expectedError ], parserOptions }, | ||
{ code: '<div onClick={() => void 0} aria-hidden={false} />;', errors: [ expectedError ], parserOptions }, | ||
{ code: '<a onClick={() => void 0} />', errors: [ expectedError ], parserOptions } | ||
{ code: '<footer onClick={() => void 0} />;', errors: [ expectedError ], parserOptions } | ||
] | ||
}); |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
371706
11508