/
home
/
techb158
/
balavpn.abdallabala.com
/
node_modules
/
eslint-plugin-jsx-a11y
/
lib
/
rules
/
/home/techb158/balavpn.abdallabala.com/node_modules/eslint-plugin-jsx-a11y/lib/rules
mkdir
upload
Name
Size
Mode
Actions
accessible-emoji.js
2817
0666
edit
dl
rm
alt-text.js
8661
0666
edit
dl
rm
anchor-ambiguous-text.js
2386
0666
edit
dl
rm
anchor-has-content.js
2090
0666
edit
dl
rm
anchor-is-valid.js
5646
0666
edit
dl
rm
aria-activedescendant-has-tabindex.js
2516
0666
edit
dl
rm
aria-props.js
1907
0666
edit
dl
rm
aria-proptypes.js
4249
0666
edit
dl
rm
aria-role.js
2908
0666
edit
dl
rm
aria-unsupported-elements.js
2406
0666
edit
dl
rm
autocomplete-valid.js
2579
0666
edit
dl
rm
click-events-have-key-events.js
2682
0666
edit
dl
rm
control-has-associated-label.js
4521
0666
edit
dl
rm
heading-has-content.js
2216
0666
edit
dl
rm
html-has-lang.js
1573
0666
edit
dl
rm
iframe-has-title.js
1640
0666
edit
dl
rm
img-redundant-alt.js
3681
0666
edit
dl
rm
interactive-supports-focus.js
4428
0666
edit
dl
rm
label-has-associated-control.js
4752
0666
edit
dl
rm
label-has-for.js
5467
0666
edit
dl
rm
lang.js
2044
0666
edit
dl
rm
media-has-caption.js
3441
0666
edit
dl
rm
mouse-events-have-key-events.js
5448
0666
edit
dl
rm
no-access-key.js
1526
0666
edit
dl
rm
no-aria-hidden-on-focusable.js
1720
0666
edit
dl
rm
no-autofocus.js
2027
0666
edit
dl
rm
no-distracting-elements.js
1858
0666
edit
dl
rm
no-interactive-element-to-noninteractive-role.js
3223
0666
edit
dl
rm
no-noninteractive-element-interactions.js
4796
0666
edit
dl
rm
no-noninteractive-element-to-interactive-role.js
3037
0666
edit
dl
rm
no-noninteractive-tabindex.js
5627
0666
edit
dl
rm
no-onchange.js
1899
0666
edit
dl
rm
no-redundant-roles.js
3142
0666
edit
dl
rm
no-static-element-interactions.js
5140
0666
edit
dl
rm
prefer-tag-over-role.js
4040
0666
edit
dl
rm
role-has-required-aria-props.js
3479
0666
edit
dl
rm
role-supports-aria-props.js
3401
0666
edit
dl
rm
scope.js
1866
0666
edit
dl
rm
tabindex-no-positive.js
1599
0666
edit
dl
rm
Edit:
/home/techb158/balavpn.abdallabala.com/node_modules/eslint-plugin-jsx-a11y/lib/rules/alt-text.js
(8661B)
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports["default"] = void 0; var _jsxAstUtils = require("jsx-ast-utils"); var _arrayPrototype = _interopRequireDefault(require("array.prototype.flatmap")); var _schemas = require("../util/schemas"); var _getElementType = _interopRequireDefault(require("../util/getElementType")); var _hasAccessibleChild = _interopRequireDefault(require("../util/hasAccessibleChild")); var _isPresentationRole = _interopRequireDefault(require("../util/isPresentationRole")); function _interopRequireDefault(e) { return e && e.__esModule ? e : { "default": e }; } /** * @fileoverview Enforce all elements that require alternative text have it. * @author Ethan Cohen */ // ---------------------------------------------------------------------------- // Rule Definition // ---------------------------------------------------------------------------- var DEFAULT_ELEMENTS = ['img', 'object', 'area', 'input[type="image"]']; var schema = (0, _schemas.generateObjSchema)({ elements: _schemas.arraySchema, img: _schemas.arraySchema, object: _schemas.arraySchema, area: _schemas.arraySchema, 'input[type="image"]': _schemas.arraySchema }); var ariaLabelHasValue = function ariaLabelHasValue(prop) { var value = (0, _jsxAstUtils.getPropValue)(prop); if (value === undefined) { return false; } if (typeof value === 'string' && value.length === 0) { return false; } return true; }; var ruleByElement = { img(context, node, nodeType) { var altProp = (0, _jsxAstUtils.getProp)(node.attributes, 'alt'); // Missing alt prop error. if (altProp === undefined) { if ((0, _isPresentationRole["default"])(nodeType, node.attributes)) { context.report({ node, message: 'Prefer alt="" over a presentational role. First rule of aria is to not use aria if it can be achieved via native HTML.' }); return; } // Check for `aria-label` to provide text alternative // Don't create an error if the attribute is used correctly. But if it // isn't, suggest that the developer use `alt` instead. var ariaLabelProp = (0, _jsxAstUtils.getProp)(node.attributes, 'aria-label'); if (ariaLabelProp !== undefined) { if (!ariaLabelHasValue(ariaLabelProp)) { context.report({ node, message: 'The aria-label attribute must have a value. The alt attribute is preferred over aria-label for images.' }); } return; } // Check for `aria-labelledby` to provide text alternative // Don't create an error if the attribute is used correctly. But if it // isn't, suggest that the developer use `alt` instead. var ariaLabelledbyProp = (0, _jsxAstUtils.getProp)(node.attributes, 'aria-labelledby'); if (ariaLabelledbyProp !== undefined) { if (!ariaLabelHasValue(ariaLabelledbyProp)) { context.report({ node, message: 'The aria-labelledby attribute must have a value. The alt attribute is preferred over aria-labelledby for images.' }); } return; } context.report({ node, message: "".concat(nodeType, " elements must have an alt prop, either with meaningful text, or an empty string for decorative images.") }); return; } // Check if alt prop is undefined. var altValue = (0, _jsxAstUtils.getPropValue)(altProp); var isNullValued = altProp.value === null; // <img alt /> if (altValue && !isNullValued || altValue === '') { return; } // Undefined alt prop error. context.report({ node, message: "Invalid alt value for ".concat(nodeType, ". Use alt=\"\" for presentational images.") }); }, object(context, node, unusedNodeType, elementType) { var ariaLabelProp = (0, _jsxAstUtils.getProp)(node.attributes, 'aria-label'); var arialLabelledByProp = (0, _jsxAstUtils.getProp)(node.attributes, 'aria-labelledby'); var hasLabel = ariaLabelHasValue(ariaLabelProp) || ariaLabelHasValue(arialLabelledByProp); var titleProp = (0, _jsxAstUtils.getLiteralPropValue)((0, _jsxAstUtils.getProp)(node.attributes, 'title')); var hasTitleAttr = !!titleProp; if (hasLabel || hasTitleAttr || (0, _hasAccessibleChild["default"])(node.parent, elementType)) { return; } context.report({ node, message: 'Embedded <object> elements must have alternative text by providing inner text, aria-label or aria-labelledby props.' }); }, area(context, node) { var ariaLabelProp = (0, _jsxAstUtils.getProp)(node.attributes, 'aria-label'); var arialLabelledByProp = (0, _jsxAstUtils.getProp)(node.attributes, 'aria-labelledby'); var hasLabel = ariaLabelHasValue(ariaLabelProp) || ariaLabelHasValue(arialLabelledByProp); if (hasLabel) { return; } var altProp = (0, _jsxAstUtils.getProp)(node.attributes, 'alt'); if (altProp === undefined) { context.report({ node, message: 'Each area of an image map must have a text alternative through the `alt`, `aria-label`, or `aria-labelledby` prop.' }); return; } var altValue = (0, _jsxAstUtils.getPropValue)(altProp); var isNullValued = altProp.value === null; // <area alt /> if (altValue && !isNullValued || altValue === '') { return; } context.report({ node, message: 'Each area of an image map must have a text alternative through the `alt`, `aria-label`, or `aria-labelledby` prop.' }); }, 'input[type="image"]': function inputImage(context, node, nodeType) { // Only test input[type="image"] if (nodeType === 'input') { var typePropValue = (0, _jsxAstUtils.getPropValue)((0, _jsxAstUtils.getProp)(node.attributes, 'type')); if (typePropValue !== 'image') { return; } } var ariaLabelProp = (0, _jsxAstUtils.getProp)(node.attributes, 'aria-label'); var arialLabelledByProp = (0, _jsxAstUtils.getProp)(node.attributes, 'aria-labelledby'); var hasLabel = ariaLabelHasValue(ariaLabelProp) || ariaLabelHasValue(arialLabelledByProp); if (hasLabel) { return; } var altProp = (0, _jsxAstUtils.getProp)(node.attributes, 'alt'); if (altProp === undefined) { context.report({ node, message: '<input> elements with type="image" must have a text alternative through the `alt`, `aria-label`, or `aria-labelledby` prop.' }); return; } var altValue = (0, _jsxAstUtils.getPropValue)(altProp); var isNullValued = altProp.value === null; // <area alt /> if (altValue && !isNullValued || altValue === '') { return; } context.report({ node, message: '<input> elements with type="image" must have a text alternative through the `alt`, `aria-label`, or `aria-labelledby` prop.' }); } }; var _default = exports["default"] = { meta: { docs: { url: 'https://github.com/jsx-eslint/eslint-plugin-jsx-a11y/tree/HEAD/docs/rules/alt-text.md', description: 'Enforce all elements that require alternative text have meaningful information to relay back to end user.' }, schema: [schema] }, create: function create(context) { var options = context.options[0] || {}; // Elements to validate for alt text. var elementOptions = options.elements || DEFAULT_ELEMENTS; // Get custom components for just the elements that will be tested. var customComponents = (0, _arrayPrototype["default"])(elementOptions, function (element) { return options[element]; }); var typesToValidate = new Set([].concat(customComponents, elementOptions).map(function (type) { return type === 'input[type="image"]' ? 'input' : type; })); var elementType = (0, _getElementType["default"])(context); return { JSXOpeningElement(node) { var nodeType = elementType(node); if (!typesToValidate.has(nodeType)) { return; } var DOMElement = nodeType; if (DOMElement === 'input') { DOMElement = 'input[type="image"]'; } // Map nodeType to the DOM element if we are running this on a custom component. if (elementOptions.indexOf(DOMElement) === -1) { DOMElement = elementOptions.find(function (element) { var customComponentsForElement = options[element] || []; return customComponentsForElement.indexOf(nodeType) > -1; }); } ruleByElement[DOMElement](context, node, nodeType, elementType); } }; } }; module.exports = exports.default;
Save
cmd:
run