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

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

Fix frontend appearance

  • Property mode set to 100644
File size: 1.9 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 _getSuggestion = _interopRequireDefault(require("../util/getSuggestion"));
11function _interopRequireDefault(e) { return e && e.__esModule ? e : { "default": e }; }
12/**
13 * @fileoverview Enforce all aria-* properties are valid.
14 * @author Ethan Cohen
15 */
16
17// ----------------------------------------------------------------------------
18// Rule Definition
19// ----------------------------------------------------------------------------
20
21var ariaAttributes = _ariaQuery.aria.keys();
22var errorMessage = function errorMessage(name) {
23 var suggestions = (0, _getSuggestion["default"])(name, ariaAttributes);
24 var message = "".concat(name, ": This attribute is an invalid ARIA attribute.");
25 if (suggestions.length > 0) {
26 return "".concat(message, " Did you mean to use ").concat(suggestions, "?");
27 }
28 return message;
29};
30var schema = (0, _schemas.generateObjSchema)();
31var _default = exports["default"] = {
32 meta: {
33 docs: {
34 url: 'https://github.com/jsx-eslint/eslint-plugin-jsx-a11y/tree/HEAD/docs/rules/aria-props.md',
35 description: 'Enforce all `aria-*` props are valid.'
36 },
37 schema: [schema]
38 },
39 create: function create(context) {
40 return {
41 JSXAttribute: function JSXAttribute(attribute) {
42 var name = (0, _jsxAstUtils.propName)(attribute);
43
44 // `aria` needs to be prefix of property.
45 if (name.indexOf('aria-') !== 0) {
46 return;
47 }
48 var isValid = _ariaQuery.aria.has(name);
49 if (isValid === false) {
50 context.report({
51 node: attribute,
52 message: errorMessage(name)
53 });
54 }
55 }
56 };
57 }
58};
59module.exports = exports.default;
Note: See TracBrowser for help on using the repository browser.