source: frontend/node_modules/eslint-plugin-jsx-a11y/lib/rules/no-autofocus.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.0 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 _ariaQuery = require("aria-query");
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 autoFocus prop is not used.
14 * @author Ethan Cohen <@evcohen>
15 */
16
17// ----------------------------------------------------------------------------
18// Rule Definition
19// ----------------------------------------------------------------------------
20
21var errorMessage = 'The autoFocus prop should not be used, as it can reduce usability and accessibility for users.';
22var schema = (0, _schemas.generateObjSchema)({
23 ignoreNonDOM: {
24 type: 'boolean',
25 "default": false
26 }
27});
28var _default = exports["default"] = {
29 meta: {
30 docs: {
31 url: 'https://github.com/jsx-eslint/eslint-plugin-jsx-a11y/tree/HEAD/docs/rules/no-autofocus.md',
32 description: 'Enforce autoFocus prop is not used.'
33 },
34 schema: [schema]
35 },
36 create: function create(context) {
37 var elementType = (0, _getElementType["default"])(context);
38 return {
39 JSXAttribute: function JSXAttribute(attribute) {
40 // Determine if ignoreNonDOM is set to true
41 // If true, then do not run rule.
42 var options = context.options[0] || {};
43 var ignoreNonDOM = !!options.ignoreNonDOM;
44 if (ignoreNonDOM) {
45 var type = elementType(attribute.parent);
46 if (!_ariaQuery.dom.get(type)) {
47 return;
48 }
49 }
50
51 // Don't normalize, since React only recognizes autoFocus on low-level DOM elements.
52 if ((0, _jsxAstUtils.propName)(attribute) === 'autoFocus') {
53 context.report({
54 node: attribute,
55 message: errorMessage
56 });
57 }
58 }
59 };
60 }
61};
62module.exports = exports.default;
Note: See TracBrowser for help on using the repository browser.