Socket
Socket
Sign inDemoInstall

eslint-plugin-jsx-a11y

Package Overview
Dependencies
Maintainers
2
Versions
82
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

eslint-plugin-jsx-a11y - npm Package Compare versions

Comparing version 1.3.0 to 1.4.0

7

CHANGELOG.md

@@ -0,1 +1,8 @@

1.4.0 / 2016-06-10
==================
- [dependency] Integrate `jsx-ast-utils` (extracted JSX core module)
1. [jsx-ast-utils](https://github.com/evcohen/jsx-ast-utils)
- [fix] Better error reporting for aria-unsupported-elements indicating which prop to remove.
1.3.0 / 2016-06-05

@@ -2,0 +9,0 @@ ==================

4

lib/rules/aria-proptypes.js

@@ -15,3 +15,3 @@ /**

var _getAttributeValue = require('../util/getAttributeValue');
var _jsxAstUtils = require('jsx-ast-utils');

@@ -71,3 +71,3 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }

var value = (0, _getAttributeValue.getLiteralAttributeValue)(attribute);
var value = (0, _jsxAstUtils.getLiteralPropValue)(attribute);

@@ -74,0 +74,0 @@ // We only want to check literal prop values, so just pass if it's null.

@@ -15,3 +15,3 @@ /**

var _getAttributeValue = require('../util/getAttributeValue');
var _jsxAstUtils = require('jsx-ast-utils');

@@ -30,3 +30,3 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }

var value = (0, _getAttributeValue.getLiteralAttributeValue)(attribute);
var value = (0, _jsxAstUtils.getLiteralPropValue)(attribute);

@@ -33,0 +33,0 @@ // If value is undefined, then the role attribute will be dropped in the DOM.

@@ -19,20 +19,14 @@ /**

var _getAttribute = require('../util/getAttribute');
var _jsxAstUtils = require('jsx-ast-utils');
var _getAttribute2 = _interopRequireDefault(_getAttribute);
var _getNodeType = require('../util/getNodeType');
var _getNodeType2 = _interopRequireDefault(_getNodeType);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } else { return Array.from(arr); } }
var errorMessage = function errorMessage(invalidProp) {
return 'This element does not support ARIA roles, states and properties. Try removing the prop \'' + invalidProp + '\'.';
};
var errorMessage = 'This element does not support ARIA roles, states and properties.';
module.exports = function (context) {
return {
JSXOpeningElement: function JSXOpeningElement(node) {
var nodeType = (0, _getNodeType2.default)(node);
var nodeType = (0, _jsxAstUtils.elementType)(node);
var nodeAttrs = _DOM2.default[nodeType];

@@ -47,10 +41,11 @@ var isReservedNodeType = nodeAttrs && nodeAttrs.reserved || false;

var invalidAttributes = Object.keys(_ARIA2.default).concat('ROLE');
var hasInvalidAttribute = _getAttribute2.default.apply(undefined, [node.attributes].concat(_toConsumableArray(invalidAttributes))) !== undefined;
if (hasInvalidAttribute) {
context.report({
node: node,
message: errorMessage
});
}
node.attributes.forEach(function (prop) {
if (invalidAttributes.indexOf(prop.name.name.toUpperCase()) > -1) {
context.report({
node: node,
message: errorMessage(prop.name.name)
});
}
});
}

@@ -57,0 +52,0 @@ };

@@ -11,16 +11,4 @@ /**

var _getAttribute = require('../util/getAttribute');
var _jsxAstUtils = require('jsx-ast-utils');
var _getAttribute2 = _interopRequireDefault(_getAttribute);
var _getAttributeValue = require('../util/getAttributeValue');
var _getAttributeValue2 = _interopRequireDefault(_getAttributeValue);
var _getNodeType = require('../util/getNodeType');
var _getNodeType2 = _interopRequireDefault(_getNodeType);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
var errorMessage = 'Links must not point to "#". Use a more descriptive href or use a button instead.';

@@ -32,3 +20,3 @@

var typeCheck = ['a'].concat(context.options[0]);
var nodeType = (0, _getNodeType2.default)(node);
var nodeType = (0, _jsxAstUtils.elementType)(node);

@@ -40,4 +28,4 @@ // Only check 'a' elements and custom types.

var href = (0, _getAttribute2.default)(node.attributes, 'href');
var value = (0, _getAttributeValue2.default)(href);
var href = (0, _jsxAstUtils.getProp)(node.attributes, 'href');
var value = (0, _jsxAstUtils.getPropValue)(href);

@@ -44,0 +32,0 @@ if (href && value === '#') {

@@ -11,16 +11,4 @@ /**

var _getAttribute = require('../util/getAttribute');
var _jsxAstUtils = require('jsx-ast-utils');
var _getAttribute2 = _interopRequireDefault(_getAttribute);
var _getAttributeValue = require('../util/getAttributeValue');
var _getAttributeValue2 = _interopRequireDefault(_getAttributeValue);
var _getNodeType = require('../util/getNodeType');
var _getNodeType2 = _interopRequireDefault(_getNodeType);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
module.exports = function (context) {

@@ -30,3 +18,3 @@ return {

var typeCheck = ['img'].concat(context.options[0]);
var nodeType = (0, _getNodeType2.default)(node);
var nodeType = (0, _jsxAstUtils.elementType)(node);

@@ -38,4 +26,4 @@ // Only check 'img' elements and custom types.

var roleProp = (0, _getAttribute2.default)(node.attributes, 'role');
var roleValue = (0, _getAttributeValue2.default)(roleProp);
var roleProp = (0, _jsxAstUtils.getProp)(node.attributes, 'role');
var roleValue = (0, _jsxAstUtils.getPropValue)(roleProp);
var isPresentation = roleProp && typeof roleValue === 'string' && roleValue.toLowerCase() === 'presentation';

@@ -47,3 +35,3 @@

var altProp = (0, _getAttribute2.default)(node.attributes, 'alt');
var altProp = (0, _jsxAstUtils.getProp)(node.attributes, 'alt');

@@ -60,3 +48,3 @@ // Missing alt prop error.

// Check if alt prop is undefined.
var altValue = (0, _getAttributeValue2.default)(altProp);
var altValue = (0, _jsxAstUtils.getPropValue)(altProp);
var isNullValued = altProp.value === null; // <img alt />

@@ -63,0 +51,0 @@

@@ -11,10 +11,4 @@ /**

var _getAttribute = require('../util/getAttribute');
var _jsxAstUtils = require('jsx-ast-utils');
var _getAttribute2 = _interopRequireDefault(_getAttribute);
var _getAttributeValue = require('../util/getAttributeValue');
var _getAttributeValue2 = _interopRequireDefault(_getAttributeValue);
var _isHiddenFromScreenReader = require('../util/isHiddenFromScreenReader');

@@ -24,6 +18,2 @@

var _getNodeType = require('../util/getNodeType');
var _getNodeType2 = _interopRequireDefault(_getNodeType);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }

@@ -40,3 +30,3 @@

JSXOpeningElement: function JSXOpeningElement(node) {
var type = (0, _getNodeType2.default)(node);
var type = (0, _jsxAstUtils.elementType)(node);
if (type !== 'img') {

@@ -46,3 +36,3 @@ return;

var altProp = (0, _getAttribute2.default)(node.attributes, 'alt');
var altProp = (0, _jsxAstUtils.getProp)(node.attributes, 'alt');
// Return if alt prop is not present.

@@ -60,3 +50,3 @@ if (altProp === undefined) {

var value = (0, _getAttributeValue2.default)(altProp);
var value = (0, _jsxAstUtils.getPropValue)(altProp);
var isVisible = (0, _isHiddenFromScreenReader2.default)(type, node.attributes) === false;

@@ -63,0 +53,0 @@

@@ -11,16 +11,4 @@ /**

var _getAttribute = require('../util/getAttribute');
var _jsxAstUtils = require('jsx-ast-utils');
var _getAttribute2 = _interopRequireDefault(_getAttribute);
var _getAttributeValue = require('../util/getAttributeValue');
var _getAttributeValue2 = _interopRequireDefault(_getAttributeValue);
var _getNodeType = require('../util/getNodeType');
var _getNodeType2 = _interopRequireDefault(_getNodeType);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
var errorMessage = 'Form controls using a label to identify them must be ' + 'programmatically associated with the control using htmlFor';

@@ -32,3 +20,3 @@

var typeCheck = ['label'].concat(context.options[0]);
var nodeType = (0, _getNodeType2.default)(node);
var nodeType = (0, _jsxAstUtils.elementType)(node);

@@ -40,4 +28,4 @@ // Only check 'label' elements and custom types.

var htmlForAttr = (0, _getAttribute2.default)(node.attributes, 'htmlFor');
var htmlForValue = (0, _getAttributeValue2.default)(htmlForAttr);
var htmlForAttr = (0, _jsxAstUtils.getProp)(node.attributes, 'htmlFor');
var htmlForValue = (0, _jsxAstUtils.getPropValue)(htmlForAttr);
var isInvalid = htmlForAttr === false || !htmlForValue;

@@ -44,0 +32,0 @@

@@ -12,12 +12,4 @@ /**

var _getAttribute = require('../util/getAttribute');
var _jsxAstUtils = require('jsx-ast-utils');
var _getAttribute2 = _interopRequireDefault(_getAttribute);
var _getAttributeValue = require('../util/getAttributeValue');
var _getAttributeValue2 = _interopRequireDefault(_getAttributeValue);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
var mouseOverErrorMessage = 'onMouseOver must be accompanied by onFocus for accessibility.';

@@ -32,8 +24,8 @@ var mouseOutErrorMessage = 'onMouseOut must be accompanied by onBlur for accessibility.';

// Check onmouseover / onfocus pairing.
var onMouseOver = (0, _getAttribute2.default)(attributes, 'onMouseOver');
var onMouseOverValue = (0, _getAttributeValue2.default)(onMouseOver);
var onMouseOver = (0, _jsxAstUtils.getProp)(attributes, 'onMouseOver');
var onMouseOverValue = (0, _jsxAstUtils.getPropValue)(onMouseOver);
if (onMouseOver && (onMouseOverValue !== null || onMouseOverValue !== undefined)) {
var hasOnFocus = (0, _getAttribute2.default)(attributes, 'onFocus');
var onFocusValue = (0, _getAttributeValue2.default)(hasOnFocus);
var hasOnFocus = (0, _jsxAstUtils.getProp)(attributes, 'onFocus');
var onFocusValue = (0, _jsxAstUtils.getPropValue)(hasOnFocus);

@@ -49,7 +41,7 @@ if (hasOnFocus === false || onFocusValue === null || onFocusValue === undefined) {

// Checkout onmouseout / onblur pairing
var onMouseOut = (0, _getAttribute2.default)(attributes, 'onMouseOut');
var onMouseOutValue = (0, _getAttributeValue2.default)(onMouseOut);
var onMouseOut = (0, _jsxAstUtils.getProp)(attributes, 'onMouseOut');
var onMouseOutValue = (0, _jsxAstUtils.getPropValue)(onMouseOut);
if (onMouseOut && (onMouseOutValue !== null || onMouseOutValue !== undefined)) {
var hasOnBlur = (0, _getAttribute2.default)(attributes, 'onBlur');
var onBlurValue = (0, _getAttributeValue2.default)(hasOnBlur);
var hasOnBlur = (0, _jsxAstUtils.getProp)(attributes, 'onBlur');
var onBlurValue = (0, _jsxAstUtils.getPropValue)(hasOnBlur);

@@ -56,0 +48,0 @@ if (hasOnBlur === false || onBlurValue === null || onBlurValue === undefined) {

@@ -11,12 +11,4 @@ /**

var _getAttribute = require('../util/getAttribute');
var _jsxAstUtils = require('jsx-ast-utils');
var _getAttribute2 = _interopRequireDefault(_getAttribute);
var _getAttributeValue = require('../util/getAttributeValue');
var _getAttributeValue2 = _interopRequireDefault(_getAttributeValue);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
var errorMessage = 'No access key attribute allowed. Inconsistencies ' + 'between keyboard shortcuts and keyboard comments used by screenreader ' + 'and keyboard only users create a11y complications.';

@@ -27,4 +19,4 @@

JSXOpeningElement: function JSXOpeningElement(node) {
var accessKey = (0, _getAttribute2.default)(node.attributes, 'accesskey');
var accessKeyValue = (0, _getAttributeValue2.default)(accessKey);
var accessKey = (0, _jsxAstUtils.getProp)(node.attributes, 'accesskey');
var accessKeyValue = (0, _jsxAstUtils.getPropValue)(accessKey);

@@ -31,0 +23,0 @@ if (accessKey && accessKeyValue) {

@@ -11,8 +11,4 @@ /**

var _getAttribute = require('../util/getAttribute');
var _jsxAstUtils = require('jsx-ast-utils');
var _getAttribute2 = _interopRequireDefault(_getAttribute);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
var errorMessage = 'onBlur must be used instead of onchange, ' + 'unless absolutely necessary and it causes no negative consequences ' + 'for keyboard only or screen reader users.';

@@ -23,4 +19,4 @@

JSXOpeningElement: function JSXOpeningElement(node) {
var onChange = (0, _getAttribute2.default)(node.attributes, 'onChange');
var hasOnBlur = (0, _getAttribute2.default)(node.attributes, 'onBlur') !== undefined;
var onChange = (0, _jsxAstUtils.getProp)(node.attributes, 'onChange');
var hasOnBlur = (0, _jsxAstUtils.getProp)(node.attributes, 'onBlur') !== undefined;

@@ -27,0 +23,0 @@ if (onChange && !hasOnBlur) {

@@ -15,10 +15,4 @@ /**

var _getAttribute = require('../util/getAttribute');
var _jsxAstUtils = require('jsx-ast-utils');
var _getAttribute2 = _interopRequireDefault(_getAttribute);
var _getNodeType = require('../util/getNodeType');
var _getNodeType2 = _interopRequireDefault(_getNodeType);
var _getTabIndex = require('../util/getTabIndex');

@@ -41,7 +35,7 @@

if ((0, _getAttribute2.default)(attributes, 'onClick') === undefined) {
if ((0, _jsxAstUtils.getProp)(attributes, 'onClick') === undefined) {
return;
}
var type = (0, _getNodeType2.default)(node);
var type = (0, _jsxAstUtils.elementType)(node);

@@ -52,3 +46,3 @@ if ((0, _isHiddenFromScreenReader2.default)(type, attributes)) {

return;
} else if ((0, _getTabIndex2.default)((0, _getAttribute2.default)(attributes, 'tabIndex')) !== undefined) {
} else if ((0, _getTabIndex2.default)((0, _jsxAstUtils.getProp)(attributes, 'tabIndex')) !== undefined) {
return;

@@ -55,0 +49,0 @@ }

@@ -16,14 +16,4 @@ /**

var _getAttribute = require('../util/getAttribute');
var _jsxAstUtils = require('jsx-ast-utils');
var _getAttribute2 = _interopRequireDefault(_getAttribute);
var _getAttributeValue = require('../util/getAttributeValue');
var _getAttributeValue2 = _interopRequireDefault(_getAttributeValue);
var _getNodeType = require('../util/getNodeType');
var _getNodeType2 = _interopRequireDefault(_getNodeType);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }

@@ -41,7 +31,7 @@

var attributes = node.attributes;
if ((0, _getAttribute2.default)(attributes, 'onclick') === undefined) {
if ((0, _jsxAstUtils.getProp)(attributes, 'onclick') === undefined) {
return;
}
var type = (0, _getNodeType2.default)(node);
var type = (0, _jsxAstUtils.elementType)(node);

@@ -52,3 +42,3 @@ if ((0, _isHiddenFromScreenReader2.default)(type, attributes)) {

return;
} else if ((0, _getAttributeValue2.default)((0, _getAttribute2.default)(attributes, 'role'))) {
} else if ((0, _jsxAstUtils.getPropValue)((0, _jsxAstUtils.getProp)(attributes, 'role'))) {
return;

@@ -55,0 +45,0 @@ }

@@ -15,8 +15,4 @@ /**

var _getAttributeValue = require('../util/getAttributeValue');
var _jsxAstUtils = require('jsx-ast-utils');
var _getAttribute = require('../util/getAttribute');
var _getAttribute2 = _interopRequireDefault(_getAttribute);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }

@@ -36,3 +32,3 @@

var value = (0, _getAttributeValue.getLiteralAttributeValue)(attribute);
var value = (0, _jsxAstUtils.getLiteralPropValue)(attribute);

@@ -56,3 +52,3 @@ // If value is undefined, then the role attribute will be dropped in the DOM.

var hasRequiredProps = requiredProps.every(function (prop) {
return (0, _getAttribute2.default)(attribute.parent.attributes, prop);
return (0, _jsxAstUtils.getProp)(attribute.parent.attributes, prop);
});

@@ -59,0 +55,0 @@

@@ -12,12 +12,2 @@ /**

var _getAttribute = require('../util/getAttribute');
var _getAttribute2 = _interopRequireDefault(_getAttribute);
var _getAttributeValue = require('../util/getAttributeValue');
var _getNodeType = require('../util/getNodeType');
var _getNodeType2 = _interopRequireDefault(_getNodeType);
var _role = require('../util/attributes/role');

@@ -35,6 +25,6 @@

var _jsxAstUtils = require('jsx-ast-utils');
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } else { return Array.from(arr); } }
var errorMessage = function errorMessage(attr, role, tag, isImplicit) {

@@ -52,5 +42,5 @@ if (isImplicit) {

// If role is not explicitly defined, then try and get its implicit role.
var type = (0, _getNodeType2.default)(node);
var role = (0, _getAttribute2.default)(node.attributes, 'role');
var roleValue = role ? (0, _getAttributeValue.getLiteralAttributeValue)(role) : (0, _getImplicitRole2.default)(type, node.attributes);
var type = (0, _jsxAstUtils.elementType)(node);
var role = (0, _jsxAstUtils.getProp)(node.attributes, 'role');
var roleValue = role ? (0, _jsxAstUtils.getLiteralPropValue)(role) : (0, _getImplicitRole2.default)(type, node.attributes);
var isImplicit = roleValue && role === undefined;

@@ -70,11 +60,10 @@

});
var invalidAttr = _getAttribute2.default.apply(undefined, [node.attributes].concat(_toConsumableArray(invalidAriaPropsForRole)));
if (invalidAttr === undefined) {
return;
}
context.report({
node: node,
message: errorMessage(invalidAttr.name.name, roleValue, type, isImplicit)
node.attributes.forEach(function (prop) {
if (invalidAriaPropsForRole.indexOf(prop.name.name.toUpperCase()) > -1) {
context.report({
node: node,
message: errorMessage(prop.name.name, roleValue, type, isImplicit)
});
}
});

@@ -81,0 +70,0 @@ }

@@ -11,3 +11,3 @@ /**

var _getAttributeValue = require('../util/getAttributeValue');
var _jsxAstUtils = require('jsx-ast-utils');

@@ -28,3 +28,3 @@ var errorMessage = 'Avoid positive integer values for tabIndex.';

// Only check literals because we can't infer values from certain expressions.
var value = Number((0, _getAttributeValue.getLiteralAttributeValue)(attribute));
var value = Number((0, _jsxAstUtils.getLiteralPropValue)(attribute));

@@ -31,0 +31,0 @@ if (isNaN(value) || value <= 0) {

@@ -8,8 +8,4 @@ 'use strict';

var _getAttributeValue = require('./getAttributeValue');
var _jsxAstUtils = require('jsx-ast-utils');
var _getAttributeValue2 = _interopRequireDefault(_getAttributeValue);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
/**

@@ -22,3 +18,3 @@ * Returns the tabIndex value.

// one exists as an expression.
var literalTabIndex = (0, _getAttributeValue.getLiteralAttributeValue)(tabIndex);
var literalTabIndex = (0, _jsxAstUtils.getLiteralPropValue)(tabIndex);
if (literalTabIndex !== undefined || literalTabIndex !== null) {

@@ -28,3 +24,3 @@ return isNaN(Number(literalTabIndex)) ? undefined : literalTabIndex;

return (0, _getAttributeValue2.default)(tabIndex);
return (0, _jsxAstUtils.getPropValue)(tabIndex);
}

@@ -8,8 +8,4 @@ 'use strict';

var _getAttribute = require('../getAttribute');
var _jsxAstUtils = require('jsx-ast-utils');
var _getAttribute2 = _interopRequireDefault(_getAttribute);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
/**

@@ -19,3 +15,3 @@ * Returns the implicit role for an anchor tag.

function getImplicitRoleForAnchor(attributes) {
if ((0, _getAttribute2.default)(attributes, 'href')) {
if ((0, _jsxAstUtils.getProp)(attributes, 'href')) {
return 'link';

@@ -22,0 +18,0 @@ }

@@ -8,8 +8,4 @@ 'use strict';

var _getAttribute = require('../getAttribute');
var _jsxAstUtils = require('jsx-ast-utils');
var _getAttribute2 = _interopRequireDefault(_getAttribute);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
/**

@@ -19,3 +15,3 @@ * Returns the implicit role for an area tag.

function getImplicitRoleForArea(attributes) {
if ((0, _getAttribute2.default)(attributes, 'href')) {
if ((0, _jsxAstUtils.getProp)(attributes, 'href')) {
return 'link';

@@ -22,0 +18,0 @@ }

@@ -8,10 +8,4 @@ 'use strict';

var _getAttribute = require('../getAttribute');
var _jsxAstUtils = require('jsx-ast-utils');
var _getAttribute2 = _interopRequireDefault(_getAttribute);
var _getAttributeValue = require('../getAttributeValue');
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
/**

@@ -21,5 +15,5 @@ * Returns the implicit role for an img tag.

function getImplicitRoleForImg(attributes) {
var alt = (0, _getAttribute2.default)(attributes, 'alt');
var alt = (0, _jsxAstUtils.getProp)(attributes, 'alt');
if (alt && (0, _getAttributeValue.getLiteralAttributeValue)(alt) === '') {
if (alt && (0, _jsxAstUtils.getLiteralPropValue)(alt) === '') {
return 'presentation';

@@ -26,0 +20,0 @@ }

@@ -8,10 +8,4 @@ 'use strict';

var _getAttribute = require('../getAttribute');
var _jsxAstUtils = require('jsx-ast-utils');
var _getAttribute2 = _interopRequireDefault(_getAttribute);
var _getAttributeValue = require('../getAttributeValue');
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
/**

@@ -21,6 +15,6 @@ * Returns the implicit role for an input tag.

function getImplicitRoleForInput(attributes) {
var type = (0, _getAttribute2.default)(attributes, 'type');
var type = (0, _jsxAstUtils.getProp)(attributes, 'type');
if (type) {
var value = (0, _getAttributeValue.getLiteralAttributeValue)(type) || '';
var value = (0, _jsxAstUtils.getLiteralPropValue)(type) || '';

@@ -27,0 +21,0 @@ switch (value.toUpperCase()) {

@@ -8,8 +8,4 @@ 'use strict';

var _getAttribute = require('../getAttribute');
var _jsxAstUtils = require('jsx-ast-utils');
var _getAttribute2 = _interopRequireDefault(_getAttribute);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
/**

@@ -19,3 +15,3 @@ * Returns the implicit role for a link tag.

function getImplicitRoleForLink(attributes) {
if ((0, _getAttribute2.default)(attributes, 'href')) {
if ((0, _jsxAstUtils.getProp)(attributes, 'href')) {
return 'link';

@@ -22,0 +18,0 @@ }

@@ -8,10 +8,4 @@ 'use strict';

var _getAttribute = require('../getAttribute');
var _jsxAstUtils = require('jsx-ast-utils');
var _getAttribute2 = _interopRequireDefault(_getAttribute);
var _getAttributeValue = require('../getAttributeValue');
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
/**

@@ -21,6 +15,6 @@ * Returns the implicit role for a menu tag.

function getImplicitRoleForMenu(attributes) {
var type = (0, _getAttribute2.default)(attributes, 'type');
var type = (0, _jsxAstUtils.getProp)(attributes, 'type');
if (type) {
var value = (0, _getAttributeValue.getLiteralAttributeValue)(type);
var value = (0, _jsxAstUtils.getLiteralPropValue)(type);

@@ -27,0 +21,0 @@ return value && value.toUpperCase() === 'TOOLBAR' ? 'toolbar' : '';

@@ -8,10 +8,4 @@ 'use strict';

var _getAttribute = require('../getAttribute');
var _jsxAstUtils = require('jsx-ast-utils');
var _getAttribute2 = _interopRequireDefault(_getAttribute);
var _getAttributeValue = require('../getAttributeValue');
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
/**

@@ -21,6 +15,6 @@ * Returns the implicit role for a menuitem tag.

function getImplicitRoleForMenuitem(attributes) {
var type = (0, _getAttribute2.default)(attributes, 'type');
var type = (0, _jsxAstUtils.getProp)(attributes, 'type');
if (type) {
var value = (0, _getAttributeValue.getLiteralAttributeValue)(type) || '';
var value = (0, _jsxAstUtils.getLiteralPropValue)(type) || '';

@@ -27,0 +21,0 @@ switch (value.toUpperCase()) {

@@ -7,12 +7,4 @@ 'use strict';

var _getAttribute = require('./getAttribute');
var _jsxAstUtils = require('jsx-ast-utils');
var _getAttribute2 = _interopRequireDefault(_getAttribute);
var _getAttributeValue = require('./getAttributeValue');
var _getAttributeValue2 = _interopRequireDefault(_getAttributeValue);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
/**

@@ -27,3 +19,3 @@ * Returns boolean indicating that the aria-hidden prop

if (type.toUpperCase() === 'INPUT') {
var hidden = (0, _getAttributeValue.getLiteralAttributeValue)((0, _getAttribute2.default)(attributes, 'type'));
var hidden = (0, _jsxAstUtils.getLiteralPropValue)((0, _jsxAstUtils.getProp)(attributes, 'type'));

@@ -35,3 +27,3 @@ if (hidden && hidden.toUpperCase() == 'HIDDEN') {

var ariaHidden = (0, _getAttributeValue2.default)((0, _getAttribute2.default)(attributes, 'aria-hidden'));
var ariaHidden = (0, _jsxAstUtils.getPropValue)((0, _jsxAstUtils.getProp)(attributes, 'aria-hidden'));
return ariaHidden === true;

@@ -38,0 +30,0 @@ };

@@ -7,10 +7,4 @@ 'use strict';

var _getAttribute = require('./getAttribute');
var _jsxAstUtils = require('jsx-ast-utils');
var _getAttribute2 = _interopRequireDefault(_getAttribute);
var _getAttributeValue = require('./getAttributeValue');
var _getAttributeValue2 = _interopRequireDefault(_getAttributeValue);
var _getTabIndex = require('./getTabIndex');

@@ -29,4 +23,4 @@

a: function a(attributes) {
var href = (0, _getAttributeValue2.default)((0, _getAttribute2.default)(attributes, 'href'));
var tabIndex = (0, _getTabIndex2.default)((0, _getAttribute2.default)(attributes, 'tabIndex'));
var href = (0, _jsxAstUtils.getPropValue)((0, _jsxAstUtils.getProp)(attributes, 'href'));
var tabIndex = (0, _getTabIndex2.default)((0, _jsxAstUtils.getProp)(attributes, 'tabIndex'));
return href !== undefined || tabIndex !== undefined;

@@ -42,3 +36,3 @@ },

input: function input(attributes) {
var typeAttr = (0, _getAttributeValue.getLiteralAttributeValue)((0, _getAttribute2.default)(attributes, 'type'));
var typeAttr = (0, _jsxAstUtils.getLiteralPropValue)((0, _jsxAstUtils.getProp)(attributes, 'type'));
return typeAttr ? typeAttr.toUpperCase() !== 'HIDDEN' : true;

@@ -45,0 +39,0 @@ },

{
"name": "eslint-plugin-jsx-a11y",
"version": "1.3.0",
"version": "1.4.0",
"description": "A static analysis linter of jsx and their accessibility with screen readers.",

@@ -44,4 +44,5 @@ "keywords": [

"damerau-levenshtein": "^1.0.0",
"jsx-ast-utils": "^1.0.0",
"object-assign": "^4.0.1"
}
}

@@ -12,3 +12,3 @@ /**

import ariaAttributes from '../util/attributes/ARIA';
import { getLiteralAttributeValue } from '../util/getAttributeValue';
import { getLiteralPropValue } from 'jsx-ast-utils';

@@ -63,3 +63,3 @@ const errorMessage = (name, type, permittedValues) => {

const value = getLiteralAttributeValue(attribute);
const value = getLiteralPropValue(attribute);

@@ -66,0 +66,0 @@ // We only want to check literal prop values, so just pass if it's null.

@@ -12,3 +12,3 @@ /**

import roles from '../util/attributes/role';
import { getLiteralAttributeValue } from '../util/getAttributeValue';
import { getLiteralPropValue } from 'jsx-ast-utils';

@@ -24,3 +24,3 @@ const errorMessage = 'Elements with ARIA roles must use a valid, non-abstract ARIA role.';

const value = getLiteralAttributeValue(attribute);
const value = getLiteralPropValue(attribute);

@@ -27,0 +27,0 @@ // If value is undefined, then the role attribute will be dropped in the DOM.

@@ -13,10 +13,10 @@ /**

import ARIA from '../util/attributes/ARIA';
import getAttribute from '../util/getAttribute';
import getNodeType from '../util/getNodeType';
import { elementType } from 'jsx-ast-utils';
const errorMessage = 'This element does not support ARIA roles, states and properties.';
const errorMessage = invalidProp =>
`This element does not support ARIA roles, states and properties. Try removing the prop '${invalidProp}'.`;
module.exports = context => ({
JSXOpeningElement: node => {
const nodeType = getNodeType(node);
const nodeType = elementType(node);
const nodeAttrs = DOM[nodeType];

@@ -31,10 +31,11 @@ const isReservedNodeType = nodeAttrs && nodeAttrs.reserved || false;

const invalidAttributes = Object.keys(ARIA).concat('ROLE');
const hasInvalidAttribute = getAttribute(node.attributes, ...invalidAttributes) !== undefined;
if (hasInvalidAttribute) {
context.report({
node,
message: errorMessage
});
}
node.attributes.forEach(prop => {
if (invalidAttributes.indexOf(prop.name.name.toUpperCase()) > -1) {
context.report({
node,
message: errorMessage(prop.name.name)
});
}
});
}

@@ -41,0 +42,0 @@ });

@@ -11,5 +11,3 @@ /**

import getAttribute from '../util/getAttribute';
import getAttributeValue from '../util/getAttributeValue';
import getNodeType from '../util/getNodeType';
import { getProp, getPropValue, elementType } from 'jsx-ast-utils';

@@ -21,3 +19,3 @@ const errorMessage = 'Links must not point to "#". Use a more descriptive href or use a button instead.';

const typeCheck = [ 'a' ].concat(context.options[0]);
const nodeType = getNodeType(node);
const nodeType = elementType(node);

@@ -29,4 +27,4 @@ // Only check 'a' elements and custom types.

const href = getAttribute(node.attributes, 'href');
const value = getAttributeValue(href);
const href = getProp(node.attributes, 'href');
const value = getPropValue(href);

@@ -33,0 +31,0 @@ if (href && value === '#') {

@@ -11,5 +11,3 @@ /**

import getAttribute from '../util/getAttribute';
import getAttributeValue from '../util/getAttributeValue';
import getNodeType from '../util/getNodeType';
import { getProp, getPropValue, elementType } from 'jsx-ast-utils';

@@ -19,3 +17,3 @@ module.exports = context => ({

const typeCheck = [ 'img' ].concat(context.options[0]);
const nodeType = getNodeType(node);
const nodeType = elementType(node);

@@ -27,4 +25,4 @@ // Only check 'img' elements and custom types.

const roleProp = getAttribute(node.attributes, 'role');
const roleValue = getAttributeValue(roleProp);
const roleProp = getProp(node.attributes, 'role');
const roleValue = getPropValue(roleProp);
const isPresentation = roleProp && typeof roleValue === 'string' && roleValue.toLowerCase() === 'presentation';

@@ -36,3 +34,3 @@

const altProp = getAttribute(node.attributes, 'alt');
const altProp = getProp(node.attributes, 'alt');

@@ -49,3 +47,3 @@ // Missing alt prop error.

// Check if alt prop is undefined.
const altValue = getAttributeValue(altProp);
const altValue = getPropValue(altProp);
const isNullValued = altProp.value === null; // <img alt />

@@ -52,0 +50,0 @@

@@ -11,6 +11,4 @@ /**

import getAttribute from '../util/getAttribute';
import getAttributeValue from '../util/getAttributeValue';
import { getProp, getPropValue, elementType } from 'jsx-ast-utils';
import isHiddenFromScreenReader from '../util/isHiddenFromScreenReader';
import getNodeType from '../util/getNodeType';

@@ -33,3 +31,3 @@ const REDUNDANT_WORDS = [

JSXOpeningElement: node => {
const type = getNodeType(node);
const type = elementType(node);
if (type !== 'img') {

@@ -39,3 +37,3 @@ return;

const altProp = getAttribute(node.attributes, 'alt');
const altProp = getProp(node.attributes, 'alt');
// Return if alt prop is not present.

@@ -55,3 +53,3 @@ if (altProp === undefined) {

const value = getAttributeValue(altProp);
const value = getPropValue(altProp);
const isVisible = isHiddenFromScreenReader(type, node.attributes) === false;

@@ -58,0 +56,0 @@

@@ -11,5 +11,3 @@ /**

import getAttribute from '../util/getAttribute';
import getAttributeValue from '../util/getAttributeValue';
import getNodeType from '../util/getNodeType';
import { getProp, getPropValue, elementType } from 'jsx-ast-utils';

@@ -22,3 +20,3 @@ const errorMessage = 'Form controls using a label to identify them must be ' +

const typeCheck = [ 'label' ].concat(context.options[0]);
const nodeType = getNodeType(node);
const nodeType = elementType(node);

@@ -30,4 +28,4 @@ // Only check 'label' elements and custom types.

const htmlForAttr = getAttribute(node.attributes, 'htmlFor');
const htmlForValue = getAttributeValue(htmlForAttr);
const htmlForAttr = getProp(node.attributes, 'htmlFor');
const htmlForValue = getPropValue(htmlForAttr);
const isInvalid = htmlForAttr === false || !htmlForValue;

@@ -34,0 +32,0 @@

@@ -12,5 +12,5 @@ /**

import getAttribute from '../util/getAttribute';
import getAttributeValue from '../util/getAttributeValue';
import { getProp, getPropValue } from 'jsx-ast-utils';
const mouseOverErrorMessage = 'onMouseOver must be accompanied by onFocus for accessibility.';

@@ -24,8 +24,8 @@ const mouseOutErrorMessage = 'onMouseOut must be accompanied by onBlur for accessibility.';

// Check onmouseover / onfocus pairing.
const onMouseOver = getAttribute(attributes, 'onMouseOver');
const onMouseOverValue = getAttributeValue(onMouseOver);
const onMouseOver = getProp(attributes, 'onMouseOver');
const onMouseOverValue = getPropValue(onMouseOver);
if (onMouseOver && (onMouseOverValue !== null || onMouseOverValue !== undefined)) {
const hasOnFocus = getAttribute(attributes, 'onFocus');
const onFocusValue = getAttributeValue(hasOnFocus);
const hasOnFocus = getProp(attributes, 'onFocus');
const onFocusValue = getPropValue(hasOnFocus);

@@ -41,7 +41,7 @@ if (hasOnFocus === false || onFocusValue === null || onFocusValue === undefined) {

// Checkout onmouseout / onblur pairing
const onMouseOut = getAttribute(attributes, 'onMouseOut');
const onMouseOutValue = getAttributeValue(onMouseOut);
const onMouseOut = getProp(attributes, 'onMouseOut');
const onMouseOutValue = getPropValue(onMouseOut);
if (onMouseOut && (onMouseOutValue !== null || onMouseOutValue !== undefined)) {
const hasOnBlur = getAttribute(attributes, 'onBlur');
const onBlurValue = getAttributeValue(hasOnBlur);
const hasOnBlur = getProp(attributes, 'onBlur');
const onBlurValue = getPropValue(hasOnBlur);

@@ -48,0 +48,0 @@ if (hasOnBlur === false || onBlurValue === null || onBlurValue === undefined) {

@@ -11,4 +11,3 @@ /**

import getAttribute from '../util/getAttribute';
import getAttributeValue from '../util/getAttributeValue';
import { getProp, getPropValue } from 'jsx-ast-utils';

@@ -21,4 +20,4 @@ const errorMessage = 'No access key attribute allowed. Inconsistencies ' +

JSXOpeningElement: node => {
const accessKey = getAttribute(node.attributes, 'accesskey');
const accessKeyValue = getAttributeValue(accessKey);
const accessKey = getProp(node.attributes, 'accesskey');
const accessKeyValue = getPropValue(accessKey);

@@ -25,0 +24,0 @@ if (accessKey && accessKeyValue) {

@@ -11,3 +11,3 @@ /**

import getAttribute from '../util/getAttribute';
import { getProp } from 'jsx-ast-utils';

@@ -20,4 +20,4 @@ const errorMessage = 'onBlur must be used instead of onchange, ' +

JSXOpeningElement: node => {
const onChange = getAttribute(node.attributes, 'onChange');
const hasOnBlur = getAttribute(node.attributes, 'onBlur') !== undefined;
const onChange = getProp(node.attributes, 'onChange');
const hasOnBlur = getProp(node.attributes, 'onBlur') !== undefined;

@@ -24,0 +24,0 @@ if (onChange && !hasOnBlur) {

@@ -9,4 +9,3 @@ /**

import isInteractiveElement from '../util/isInteractiveElement';
import getAttribute from '../util/getAttribute';
import getNodeType from '../util/getNodeType';
import { getProp, elementType } from 'jsx-ast-utils';
import getTabIndex from '../util/getTabIndex';

@@ -25,7 +24,7 @@

const { attributes } = node;
if (getAttribute(attributes, 'onClick') === undefined) {
if (getProp(attributes, 'onClick') === undefined) {
return;
}
const type = getNodeType(node);
const type = elementType(node);

@@ -36,3 +35,3 @@ if (isHiddenFromScreenReader(type, attributes)) {

return;
} else if (getTabIndex(getAttribute(attributes, 'tabIndex')) !== undefined) {
} else if (getTabIndex(getProp(attributes, 'tabIndex')) !== undefined) {
return;

@@ -39,0 +38,0 @@ }

@@ -10,5 +10,3 @@ /**

import isInteractiveElement from '../util/isInteractiveElement';
import getAttribute from '../util/getAttribute';
import getAttributeValue from '../util/getAttributeValue';
import getNodeType from '../util/getNodeType';
import { getProp, getPropValue, elementType } from 'jsx-ast-utils';

@@ -25,7 +23,7 @@ // ----------------------------------------------------------------------------

const attributes = node.attributes;
if (getAttribute(attributes, 'onclick') === undefined) {
if (getProp(attributes, 'onclick') === undefined) {
return;
}
const type = getNodeType(node);
const type = elementType(node);

@@ -36,3 +34,3 @@ if (isHiddenFromScreenReader(type, attributes)) {

return;
} else if (getAttributeValue(getAttribute(attributes, 'role'))) {
} else if (getPropValue(getProp(attributes, 'role'))) {
return;

@@ -39,0 +37,0 @@ }

@@ -12,5 +12,5 @@ /**

import validRoleTypes from '../util/attributes/role';
import { getLiteralAttributeValue } from '../util/getAttributeValue';
import getAttribute from '../util/getAttribute';
import { getProp, getLiteralPropValue } from 'jsx-ast-utils';
const errorMessage = (role, requiredProps) =>

@@ -27,3 +27,3 @@ `Elements with the ARIA role "${role}" must have the following ` +

const value = getLiteralAttributeValue(attribute);
const value = getLiteralPropValue(attribute);

@@ -43,3 +43,3 @@ // If value is undefined, then the role attribute will be dropped in the DOM.

if (requiredProps.length > 0) {
const hasRequiredProps = requiredProps.every(prop => getAttribute(attribute.parent.attributes, prop));
const hasRequiredProps = requiredProps.every(prop => getProp(attribute.parent.attributes, prop));

@@ -46,0 +46,0 @@ if (hasRequiredProps === false) {

@@ -12,8 +12,6 @@ /**

import getAttribute from '../util/getAttribute';
import { getLiteralAttributeValue } from '../util/getAttributeValue';
import getNodeType from '../util/getNodeType';
import ROLES from '../util/attributes/role';
import ARIA from '../util/attributes/ARIA';
import getImplicitRole from '../util/getImplicitRole';
import { getProp, getLiteralPropValue, elementType } from 'jsx-ast-utils';

@@ -31,5 +29,5 @@ const errorMessage = (attr, role, tag, isImplicit) => {

// If role is not explicitly defined, then try and get its implicit role.
const type = getNodeType(node);
const role = getAttribute(node.attributes, 'role');
const roleValue = role ? getLiteralAttributeValue(role) : getImplicitRole(type, node.attributes);
const type = elementType(node);
const role = getProp(node.attributes, 'role');
const roleValue = role ? getLiteralPropValue(role) : getImplicitRole(type, node.attributes);
const isImplicit = roleValue && role === undefined;

@@ -47,13 +45,11 @@

const invalidAriaPropsForRole = Object.keys(ARIA).filter(attribute => propertySet.indexOf(attribute) === -1);
const invalidAttr = getAttribute(node.attributes, ...invalidAriaPropsForRole);
if (invalidAttr === undefined) {
return;
}
context.report({
node,
message: errorMessage(invalidAttr.name.name, roleValue, type, isImplicit)
node.attributes.forEach(prop => {
if (invalidAriaPropsForRole.indexOf(prop.name.name.toUpperCase()) > -1) {
context.report({
node,
message: errorMessage(prop.name.name, roleValue, type, isImplicit)
});
}
});
}

@@ -60,0 +56,0 @@ });

@@ -11,3 +11,3 @@ /**

import { getLiteralAttributeValue } from '../util/getAttributeValue';
import { getLiteralPropValue } from 'jsx-ast-utils';

@@ -27,3 +27,3 @@ const errorMessage = 'Avoid positive integer values for tabIndex.';

// Only check literals because we can't infer values from certain expressions.
const value = Number(getLiteralAttributeValue(attribute));
const value = Number(getLiteralPropValue(attribute));

@@ -30,0 +30,0 @@ if (isNaN(value) || value <= 0) {

'use strict';
import getAttributeValue, { getLiteralAttributeValue } from './getAttributeValue';
import { getPropValue, getLiteralPropValue } from 'jsx-ast-utils';
/**

@@ -14,3 +12,3 @@ * Returns the tabIndex value.

// one exists as an expression.
const literalTabIndex = getLiteralAttributeValue(tabIndex);
const literalTabIndex = getLiteralPropValue(tabIndex);
if (literalTabIndex !== undefined || literalTabIndex !== null) {

@@ -20,3 +18,3 @@ return isNaN(Number(literalTabIndex)) ? undefined : literalTabIndex;

return getAttributeValue(tabIndex);
return getPropValue(tabIndex);
}

@@ -1,2 +0,2 @@

import getAttribute from '../getAttribute';
import { getProp } from 'jsx-ast-utils';

@@ -7,3 +7,3 @@ /**

export default function getImplicitRoleForAnchor(attributes) {
if (getAttribute(attributes, 'href')) {
if (getProp(attributes, 'href')) {
return 'link';

@@ -10,0 +10,0 @@ }

@@ -1,2 +0,2 @@

import getAttribute from '../getAttribute';
import { getProp } from 'jsx-ast-utils';

@@ -7,3 +7,3 @@ /**

export default function getImplicitRoleForArea(attributes) {
if (getAttribute(attributes, 'href')) {
if (getProp(attributes, 'href')) {
return 'link';

@@ -10,0 +10,0 @@ }

@@ -1,3 +0,2 @@

import getAttribute from '../getAttribute';
import { getLiteralAttributeValue } from '../getAttributeValue';
import { getProp, getLiteralPropValue } from 'jsx-ast-utils';

@@ -8,5 +7,5 @@ /**

export default function getImplicitRoleForImg(attributes) {
const alt = getAttribute(attributes, 'alt');
const alt = getProp(attributes, 'alt');
if (alt && getLiteralAttributeValue(alt) === '') {
if (alt && getLiteralPropValue(alt) === '') {
return 'presentation';

@@ -13,0 +12,0 @@ }

@@ -1,6 +0,3 @@

import getAttribute from '../getAttribute';
import { getLiteralAttributeValue } from '../getAttributeValue';
import { getProp, getLiteralPropValue } from 'jsx-ast-utils';
/**

@@ -10,6 +7,6 @@ * Returns the implicit role for an input tag.

export default function getImplicitRoleForInput(attributes) {
const type = getAttribute(attributes, 'type');
const type = getProp(attributes, 'type');
if (type) {
const value = getLiteralAttributeValue(type) || '';
const value = getLiteralPropValue(type) || '';

@@ -16,0 +13,0 @@ switch (value.toUpperCase()) {

@@ -1,2 +0,2 @@

import getAttribute from '../getAttribute';
import { getProp } from 'jsx-ast-utils';

@@ -7,3 +7,3 @@ /**

export default function getImplicitRoleForLink(attributes) {
if (getAttribute(attributes, 'href')) {
if (getProp(attributes, 'href')) {
return 'link';

@@ -10,0 +10,0 @@ }

@@ -1,3 +0,2 @@

import getAttribute from '../getAttribute';
import { getLiteralAttributeValue } from '../getAttributeValue';
import { getProp, getLiteralPropValue } from 'jsx-ast-utils';

@@ -8,6 +7,6 @@ /**

export default function getImplicitRoleForMenu(attributes) {
const type = getAttribute(attributes, 'type');
const type = getProp(attributes, 'type');
if (type) {
const value = getLiteralAttributeValue(type);
const value = getLiteralPropValue(type);

@@ -14,0 +13,0 @@ return (value && value.toUpperCase() === 'TOOLBAR') ? 'toolbar' : '';

@@ -1,3 +0,2 @@

import getAttribute from '../getAttribute';
import { getLiteralAttributeValue } from '../getAttributeValue';
import { getProp, getLiteralPropValue } from 'jsx-ast-utils';

@@ -8,6 +7,6 @@ /**

export default function getImplicitRoleForMenuitem(attributes) {
const type = getAttribute(attributes, 'type');
const type = getProp(attributes, 'type');
if (type) {
const value = getLiteralAttributeValue(type) || '';
const value = getLiteralPropValue(type) || '';

@@ -14,0 +13,0 @@ switch (value.toUpperCase()) {

'use strict';
import getAttribute from './getAttribute';
import getAttributeValue, { getLiteralAttributeValue } from './getAttributeValue';
import { getProp, getPropValue, getLiteralPropValue } from 'jsx-ast-utils';
/**

@@ -17,3 +14,3 @@ * Returns boolean indicating that the aria-hidden prop

if (type.toUpperCase() === 'INPUT') {
const hidden = getLiteralAttributeValue(getAttribute(attributes, 'type'));
const hidden = getLiteralPropValue(getProp(attributes, 'type'));

@@ -25,3 +22,3 @@ if (hidden && hidden.toUpperCase() == 'HIDDEN') {

const ariaHidden = getAttributeValue(getAttribute(attributes, 'aria-hidden'));
const ariaHidden = getPropValue(getProp(attributes, 'aria-hidden'));
return ariaHidden === true;

@@ -28,0 +25,0 @@ };

'use strict';
import getAttribute from './getAttribute';
import getAttributeValue, { getLiteralAttributeValue } from './getAttributeValue';
import { getProp, getPropValue, getLiteralPropValue } from 'jsx-ast-utils';
import getTabIndex from './getTabIndex';
import DOMElements from './attributes/DOM';
// Map of tagNames to functions that return whether that element is interactive or not.
const interactiveMap = {
a: attributes => {
const href = getAttributeValue(getAttribute(attributes, 'href'));
const tabIndex = getTabIndex(getAttribute(attributes, 'tabIndex'));
const href = getPropValue(getProp(attributes, 'href'));
const tabIndex = getTabIndex(getProp(attributes, 'tabIndex'));
return href !== undefined || tabIndex !== undefined;

@@ -21,3 +18,3 @@ },

input: attributes => {
const typeAttr = getLiteralAttributeValue(getAttribute(attributes, 'type'));
const typeAttr = getLiteralPropValue(getProp(attributes, 'type'));
return typeAttr ? typeAttr.toUpperCase() !== 'HIDDEN' : true;

@@ -24,0 +21,0 @@ },

@@ -30,6 +30,6 @@ /**

const errorMessage = {
message: 'This element does not support ARIA roles, states and properties.',
const errorMessage = invalidProp => ({
message: `This element does not support ARIA roles, states and properties. Try removing the prop '${invalidProp}'.`,
type: 'JSXOpeningElement'
};
});

@@ -62,3 +62,3 @@ // Generate valid test cases

code: `<${reservedElem} role />`,
errors: [ errorMessage ],
errors: [ errorMessage('role') ],
parserOptions

@@ -71,3 +71,3 @@ }));

code: `<${reservedElem} aria-hidden />`,
errors: [ errorMessage ],
errors: [ errorMessage('aria-hidden') ],
parserOptions

@@ -74,0 +74,0 @@ }));

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc