source: frontend/node_modules/eslint-plugin-jsx-a11y/lib/rules/scope.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: 1.8 KB
RevLine 
[9af201e]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 scope prop is only used on <th> elements.
14 * @author Ethan Cohen
15 */
16
17// ----------------------------------------------------------------------------
18// Rule Definition
19// ----------------------------------------------------------------------------
20
21var errorMessage = 'The scope prop can only be used on <th> elements.';
22var schema = (0, _schemas.generateObjSchema)();
23var _default = exports["default"] = {
24 meta: {
25 docs: {
26 url: 'https://github.com/jsx-eslint/eslint-plugin-jsx-a11y/tree/HEAD/docs/rules/scope.md',
27 description: 'Enforce `scope` prop is only used on `<th>` elements.'
28 },
29 schema: [schema]
30 },
31 create: function create(context) {
32 var elementType = (0, _getElementType["default"])(context);
33 return {
34 JSXAttribute: function JSXAttribute(node) {
35 var name = (0, _jsxAstUtils.propName)(node);
36 if (name && name.toUpperCase() !== 'SCOPE') {
37 return;
38 }
39 var parent = node.parent;
40 var tagName = elementType(parent);
41
42 // Do not test higher level JSX components, as we do not know what
43 // low-level DOM element this maps to.
44 if (!_ariaQuery.dom.has(tagName)) {
45 return;
46 }
47 if (tagName && tagName.toUpperCase() === 'TH') {
48 return;
49 }
50 context.report({
51 node,
52 message: errorMessage
53 });
54 }
55 };
56 }
57};
58module.exports = exports.default;
Note: See TracBrowser for help on using the repository browser.