source: frontend/node_modules/eslint-plugin-jsx-a11y/lib/rules/anchor-has-content.js

Last change on this file was 9af201e, checked in by MBK <marija.karapandzova@…>, 13 days 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 _getElementType = _interopRequireDefault(require("../util/getElementType"));
9var _schemas = require("../util/schemas");
10var _hasAccessibleChild = _interopRequireDefault(require("../util/hasAccessibleChild"));
11function _interopRequireDefault(e) { return e && e.__esModule ? e : { "default": e }; }
12/**
13 * @fileoverview Enforce anchor elements to contain accessible content.
14 * @author Lisa Ring & Niklas Holmberg
15 */
16
17// ----------------------------------------------------------------------------
18// Rule Definition
19// ----------------------------------------------------------------------------
20
21var errorMessage = 'Anchors must have content and the content must be accessible by a screen reader.';
22var schema = (0, _schemas.generateObjSchema)({
23 components: _schemas.arraySchema
24});
25var _default = exports["default"] = {
26 meta: {
27 docs: {
28 url: 'https://github.com/jsx-eslint/eslint-plugin-jsx-a11y/tree/HEAD/docs/rules/anchor-has-content.md',
29 description: 'Enforce all anchors to contain accessible content.'
30 },
31 schema: [schema]
32 },
33 create: function create(context) {
34 var elementType = (0, _getElementType["default"])(context);
35 return {
36 JSXOpeningElement: function JSXOpeningElement(node) {
37 var options = context.options[0] || {};
38 var componentOptions = options.components || [];
39 var typeCheck = ['a'].concat(componentOptions);
40 var nodeType = elementType(node);
41
42 // Only check anchor elements and custom types.
43 if (typeCheck.indexOf(nodeType) === -1) {
44 return;
45 }
46 if ((0, _hasAccessibleChild["default"])(node.parent, elementType)) {
47 return;
48 }
49 if ((0, _jsxAstUtils.hasAnyProp)(node.attributes, ['title', 'aria-label'])) {
50 return;
51 }
52 context.report({
53 node,
54 message: errorMessage
55 });
56 }
57 };
58 }
59};
60module.exports = exports.default;
Note: See TracBrowser for help on using the repository browser.