source: frontend/node_modules/eslint-plugin-jsx-a11y/lib/rules/aria-unsupported-elements.js

Last change on this file was 9af201e, checked in by MBK <marija.karapandzova@…>, 2 weeks ago

Fix frontend appearance

  • Property mode set to 100644
File size: 2.3 KB
Line 
1"use strict";
2
3Object.defineProperty(exports, "__esModule", {
4 value: true
5});
6exports["default"] = void 0;
7var _ariaQuery = require("aria-query");
8var _jsxAstUtils = require("jsx-ast-utils");
9var _schemas = require("../util/schemas");
10var _getElementType = _interopRequireDefault(require("../util/getElementType"));
11function _interopRequireDefault(e) { return e && e.__esModule ? e : { "default": e }; }
12/**
13 * @fileoverview Enforce that elements that do not support ARIA roles,
14 * states and properties do not have those attributes.
15 * @author Ethan Cohen
16 */
17
18// ----------------------------------------------------------------------------
19// Rule Definition
20// ----------------------------------------------------------------------------
21
22var errorMessage = function errorMessage(invalidProp) {
23 return "This element does not support ARIA roles, states and properties. Try removing the prop '".concat(invalidProp, "'.");
24};
25var invalidAttributes = new Set(_ariaQuery.aria.keys().concat('role'));
26var schema = (0, _schemas.generateObjSchema)();
27var _default = exports["default"] = {
28 meta: {
29 docs: {
30 url: 'https://github.com/jsx-eslint/eslint-plugin-jsx-a11y/tree/HEAD/docs/rules/aria-unsupported-elements.md',
31 description: 'Enforce that elements that do not support ARIA roles, states, and properties do not have those attributes.'
32 },
33 schema: [schema]
34 },
35 create: function create(context) {
36 var elementType = (0, _getElementType["default"])(context);
37 return {
38 JSXOpeningElement: function JSXOpeningElement(node) {
39 var nodeType = elementType(node);
40 var nodeAttrs = _ariaQuery.dom.get(nodeType) || {};
41 var _nodeAttrs$reserved = nodeAttrs.reserved,
42 isReservedNodeType = _nodeAttrs$reserved === void 0 ? false : _nodeAttrs$reserved;
43
44 // If it's not reserved, then it can have aria-* roles, states, and properties
45 if (isReservedNodeType === false) {
46 return;
47 }
48 node.attributes.forEach(function (prop) {
49 if (prop.type === 'JSXSpreadAttribute') {
50 return;
51 }
52 var name = (0, _jsxAstUtils.propName)(prop).toLowerCase();
53 if (invalidAttributes.has(name)) {
54 context.report({
55 node,
56 message: errorMessage(name)
57 });
58 }
59 });
60 }
61 };
62 }
63};
64module.exports = exports.default;
Note: See TracBrowser for help on using the repository browser.