source: frontend/node_modules/eslint-plugin-jsx-a11y/lib/rules/tabindex-no-positive.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.6 KB
Line 
1"use strict";
2
3Object.defineProperty(exports, "__esModule", {
4 value: true
5});
6exports["default"] = void 0;
7var _jsxAstUtils = require("jsx-ast-utils");
8var _schemas = require("../util/schemas");
9/**
10 * @fileoverview Enforce tabIndex value is not greater than zero.
11 * @author Ethan Cohen
12 */
13
14// ----------------------------------------------------------------------------
15// Rule Definition
16// ----------------------------------------------------------------------------
17
18var errorMessage = 'Avoid positive integer values for tabIndex.';
19var schema = (0, _schemas.generateObjSchema)();
20var _default = exports["default"] = {
21 meta: {
22 docs: {
23 url: 'https://github.com/jsx-eslint/eslint-plugin-jsx-a11y/tree/HEAD/docs/rules/tabindex-no-positive.md',
24 description: 'Enforce `tabIndex` value is not greater than zero.'
25 },
26 schema: [schema]
27 },
28 create: function create(context) {
29 return {
30 JSXAttribute: function JSXAttribute(attribute) {
31 var name = (0, _jsxAstUtils.propName)(attribute).toUpperCase();
32
33 // Check if tabIndex is the attribute
34 if (name !== 'TABINDEX') {
35 return;
36 }
37
38 // Only check literals because we can't infer values from certain expressions.
39 var value = Number((0, _jsxAstUtils.getLiteralPropValue)(attribute));
40
41 // eslint-disable-next-line no-restricted-globals
42 if (isNaN(value) || value <= 0) {
43 return;
44 }
45 context.report({
46 node: attribute,
47 message: errorMessage
48 });
49 }
50 };
51 }
52};
53module.exports = exports.default;
Note: See TracBrowser for help on using the repository browser.