@elastic/eslint-plugin-eui 2.8.0 → 2.9.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"icon_accessibility_rules.d.ts","sourceRoot":"","sources":["../../../../src/rules/a11y/icon_accessibility_rules.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAY,MAAM,0BAA0B,CAAC;
|
|
1
|
+
{"version":3,"file":"icon_accessibility_rules.d.ts","sourceRoot":"","sources":["../../../../src/rules/a11y/icon_accessibility_rules.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAY,MAAM,0BAA0B,CAAC;AAMjE,eAAO,MAAM,yBAAyB,sHAiFpC,CAAC"}
|
|
@@ -6,6 +6,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
exports.EuiIconAccessibilityRules = void 0;
|
|
7
7
|
var _utils = require("@typescript-eslint/utils");
|
|
8
8
|
var _remove_attr = require("../../utils/remove_attr");
|
|
9
|
+
var _has_spread = require("../../utils/has_spread");
|
|
9
10
|
const COMPONENT = 'EuiIcon';
|
|
10
11
|
const EuiIconAccessibilityRules = exports.EuiIconAccessibilityRules = _utils.ESLintUtils.RuleCreator.withoutDocs({
|
|
11
12
|
create(context) {
|
|
@@ -17,6 +18,12 @@ const EuiIconAccessibilityRules = exports.EuiIconAccessibilityRules = _utils.ESL
|
|
|
17
18
|
if (openingElement.name.type !== 'JSXIdentifier' || openingElement.name.name !== COMPONENT) {
|
|
18
19
|
return;
|
|
19
20
|
}
|
|
21
|
+
|
|
22
|
+
// Skip fixing when spread props are present (e.g., <EuiIcon {...props} />)
|
|
23
|
+
// because we cannot safely determine or modify aria-related attributes.
|
|
24
|
+
if ((0, _has_spread.hasSpread)(openingElement.attributes)) {
|
|
25
|
+
return;
|
|
26
|
+
}
|
|
20
27
|
let ariaHiddenAttr;
|
|
21
28
|
let tabIndexAttr;
|
|
22
29
|
let isIconNamed = false;
|
|
@@ -29,14 +36,9 @@ const EuiIconAccessibilityRules = exports.EuiIconAccessibilityRules = _utils.ESL
|
|
|
29
36
|
isIconNamed = true;
|
|
30
37
|
}
|
|
31
38
|
}
|
|
32
|
-
const hasAriaHiddenTrue = !!ariaHiddenAttr && ariaHiddenAttr.value && (
|
|
33
|
-
// aria-hidden={true}
|
|
34
|
-
ariaHiddenAttr.value.type === 'JSXExpressionContainer' && ariaHiddenAttr.value.expression.type === 'Literal' && ariaHiddenAttr.value.expression.value === true ||
|
|
35
|
-
// aria-hidden='true'
|
|
36
|
-
ariaHiddenAttr.value.type === 'Literal' && ariaHiddenAttr.value.value === 'true');
|
|
37
39
|
|
|
38
40
|
// Case: `tabIndex` and `aria-hidden` cannot be used together
|
|
39
|
-
if (tabIndexAttr &&
|
|
41
|
+
if (tabIndexAttr && ariaHiddenAttr) {
|
|
40
42
|
context.report({
|
|
41
43
|
node: openingElement,
|
|
42
44
|
messageId: 'tabIndexWithAriaHidden',
|
|
@@ -49,8 +51,8 @@ const EuiIconAccessibilityRules = exports.EuiIconAccessibilityRules = _utils.ESL
|
|
|
49
51
|
return;
|
|
50
52
|
}
|
|
51
53
|
|
|
52
|
-
// Require accessible name or `aria-hidden
|
|
53
|
-
if (!isIconNamed && !
|
|
54
|
+
// Require accessible name or `aria-hidden`; if `aria-hidden` exists, do not insert a value
|
|
55
|
+
if (!isIconNamed && !ariaHiddenAttr) {
|
|
54
56
|
context.report({
|
|
55
57
|
node: openingElement,
|
|
56
58
|
messageId: 'missingTitleOrAriaHidden',
|
|
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.EuiIconAccessibilityRules = void 0;
|
|
4
4
|
const utils_1 = require("@typescript-eslint/utils");
|
|
5
5
|
const remove_attr_1 = require("../../utils/remove_attr");
|
|
6
|
+
const has_spread_1 = require("../../utils/has_spread");
|
|
6
7
|
const COMPONENT = 'EuiIcon';
|
|
7
8
|
exports.EuiIconAccessibilityRules = utils_1.ESLintUtils.RuleCreator.withoutDocs({
|
|
8
9
|
create(context) {
|
|
@@ -13,6 +14,11 @@ exports.EuiIconAccessibilityRules = utils_1.ESLintUtils.RuleCreator.withoutDocs(
|
|
|
13
14
|
openingElement.name.name !== COMPONENT) {
|
|
14
15
|
return;
|
|
15
16
|
}
|
|
17
|
+
// Skip fixing when spread props are present (e.g., <EuiIcon {...props} />)
|
|
18
|
+
// because we cannot safely determine or modify aria-related attributes.
|
|
19
|
+
if ((0, has_spread_1.hasSpread)(openingElement.attributes)) {
|
|
20
|
+
return;
|
|
21
|
+
}
|
|
16
22
|
let ariaHiddenAttr;
|
|
17
23
|
let tabIndexAttr;
|
|
18
24
|
let isIconNamed = false;
|
|
@@ -28,18 +34,8 @@ exports.EuiIconAccessibilityRules = utils_1.ESLintUtils.RuleCreator.withoutDocs(
|
|
|
28
34
|
isIconNamed = true;
|
|
29
35
|
}
|
|
30
36
|
}
|
|
31
|
-
const hasAriaHiddenTrue = !!ariaHiddenAttr &&
|
|
32
|
-
ariaHiddenAttr.value &&
|
|
33
|
-
(
|
|
34
|
-
// aria-hidden={true}
|
|
35
|
-
(ariaHiddenAttr.value.type === 'JSXExpressionContainer' &&
|
|
36
|
-
ariaHiddenAttr.value.expression.type === 'Literal' &&
|
|
37
|
-
ariaHiddenAttr.value.expression.value === true) ||
|
|
38
|
-
// aria-hidden='true'
|
|
39
|
-
(ariaHiddenAttr.value.type === 'Literal' &&
|
|
40
|
-
ariaHiddenAttr.value.value === 'true'));
|
|
41
37
|
// Case: `tabIndex` and `aria-hidden` cannot be used together
|
|
42
|
-
if (tabIndexAttr &&
|
|
38
|
+
if (tabIndexAttr && ariaHiddenAttr) {
|
|
43
39
|
context.report({
|
|
44
40
|
node: openingElement,
|
|
45
41
|
messageId: 'tabIndexWithAriaHidden',
|
|
@@ -52,8 +48,8 @@ exports.EuiIconAccessibilityRules = utils_1.ESLintUtils.RuleCreator.withoutDocs(
|
|
|
52
48
|
});
|
|
53
49
|
return;
|
|
54
50
|
}
|
|
55
|
-
// Require accessible name or `aria-hidden
|
|
56
|
-
if (!isIconNamed && !
|
|
51
|
+
// Require accessible name or `aria-hidden`; if `aria-hidden` exists, do not insert a value
|
|
52
|
+
if (!isIconNamed && !ariaHiddenAttr) {
|
|
57
53
|
context.report({
|
|
58
54
|
node: openingElement,
|
|
59
55
|
messageId: 'missingTitleOrAriaHidden',
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"icon_accessibility_rules.js","sourceRoot":"","sources":["../../../../src/rules/a11y/icon_accessibility_rules.ts"],"names":[],"mappings":";;;AAAA,oDAAiE;AACjE,yDAA0D;
|
|
1
|
+
{"version":3,"file":"icon_accessibility_rules.js","sourceRoot":"","sources":["../../../../src/rules/a11y/icon_accessibility_rules.ts"],"names":[],"mappings":";;;AAAA,oDAAiE;AACjE,yDAA0D;AAC1D,uDAAmD;AAEnD,MAAM,SAAS,GAAG,SAAS,CAAC;AAEf,QAAA,yBAAyB,GAAG,mBAAW,CAAC,WAAW,CAAC,WAAW,CAAC;IAC3E,MAAM,CAAC,OAAO;QAEZ,OAAO;YACL,UAAU,CAAC,IAAyB;gBAClC,MAAM,EAAE,cAAc,EAAE,GAAG,IAAI,CAAC;gBAChC,IACE,cAAc,CAAC,IAAI,CAAC,IAAI,KAAK,eAAe;oBAC5C,cAAc,CAAC,IAAI,CAAC,IAAI,KAAK,SAAS,EACtC,CAAC;oBACD,OAAO;gBACT,CAAC;gBAED,2EAA2E;gBAC3E,wEAAwE;gBACxE,IAAI,IAAA,sBAAS,EAAC,cAAc,CAAC,UAAU,CAAC,EAAE,CAAC;oBACzC,OAAO;gBACT,CAAC;gBAED,IAAI,cAAiD,CAAC;gBACtD,IAAI,YAA+C,CAAC;gBACpD,IAAI,WAAW,GAAG,KAAK,CAAC;gBAExB,KAAK,MAAM,IAAI,IAAI,cAAc,CAAC,UAAU,EAAE,CAAC;oBAC7C,IAAI,IAA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