@elastic/eslint-plugin-eui 2.2.1 → 2.4.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.
- package/README.md +13 -1
- package/lib/cjs/index.js +11 -2
- package/lib/cjs/rules/a11y/callout_announce_on_mount.d.ts +3 -0
- package/lib/cjs/rules/a11y/callout_announce_on_mount.d.ts.map +1 -0
- package/lib/cjs/rules/a11y/callout_announce_on_mount.js +67 -0
- package/lib/cjs/rules/a11y/consistent_is_invalid_props.d.ts.map +1 -1
- package/lib/cjs/rules/a11y/consistent_is_invalid_props.js +2 -1
- package/lib/cjs/rules/a11y/no_unnamed_interactive_element.d.ts +3 -0
- package/lib/cjs/rules/a11y/no_unnamed_interactive_element.d.ts.map +1 -0
- package/lib/cjs/rules/a11y/no_unnamed_interactive_element.js +89 -0
- package/lib/cjs/rules/a11y/no_unnamed_radio_group.d.ts +3 -0
- package/lib/cjs/rules/a11y/no_unnamed_radio_group.d.ts.map +1 -0
- package/lib/cjs/rules/a11y/no_unnamed_radio_group.js +58 -0
- package/lib/cjs/rules/a11y/require_aria_label_for_modals.js +1 -1
- package/lib/cjs/rules/a11y/sr_output_disabled_tooltip.d.ts.map +1 -1
- package/lib/cjs/rules/a11y/sr_output_disabled_tooltip.js +2 -2
- package/lib/cjs/utils/are_attrs_equal.d.ts +2 -0
- package/lib/cjs/utils/are_attrs_equal.d.ts.map +1 -0
- package/lib/cjs/utils/are_attrs_equal.js +31 -0
- package/lib/cjs/utils/get_allowed_a11y_prop_names_for_component.d.ts +24 -0
- package/lib/cjs/utils/get_allowed_a11y_prop_names_for_component.d.ts.map +1 -0
- package/lib/cjs/utils/get_allowed_a11y_prop_names_for_component.js +50 -0
- package/lib/cjs/utils/has_a11y_prop_for_component.d.ts +20 -0
- package/lib/cjs/utils/has_a11y_prop_for_component.d.ts.map +1 -0
- package/lib/cjs/utils/has_a11y_prop_for_component.js +47 -0
- package/lib/cjs/utils/has_spread.d.ts +12 -0
- package/lib/cjs/utils/has_spread.d.ts.map +1 -0
- package/lib/cjs/utils/has_spread.js +38 -0
- package/lib/cjs/utils/is_in_conditional_rendering.d.ts +3 -0
- package/lib/cjs/utils/is_in_conditional_rendering.d.ts.map +1 -0
- package/lib/cjs/utils/is_in_conditional_rendering.js +35 -0
- package/lib/esm/index.js +9 -0
- package/lib/esm/index.js.map +1 -1
- package/lib/esm/rules/a11y/callout_announce_on_mount.d.ts +2 -0
- package/lib/esm/rules/a11y/callout_announce_on_mount.js +76 -0
- package/lib/esm/rules/a11y/callout_announce_on_mount.js.map +1 -0
- package/lib/esm/rules/a11y/consistent_is_invalid_props.js +2 -1
- package/lib/esm/rules/a11y/consistent_is_invalid_props.js.map +1 -1
- package/lib/esm/rules/a11y/no_unnamed_interactive_element.d.ts +2 -0
- package/lib/esm/rules/a11y/no_unnamed_interactive_element.js +106 -0
- package/lib/esm/rules/a11y/no_unnamed_interactive_element.js.map +1 -0
- package/lib/esm/rules/a11y/no_unnamed_radio_group.d.ts +2 -0
- package/lib/esm/rules/a11y/no_unnamed_radio_group.js +56 -0
- package/lib/esm/rules/a11y/no_unnamed_radio_group.js.map +1 -0
- package/lib/esm/rules/a11y/require_aria_label_for_modals.js +1 -1
- package/lib/esm/rules/a11y/require_aria_label_for_modals.js.map +1 -1
- package/lib/esm/rules/a11y/sr_output_disabled_tooltip.js +2 -2
- package/lib/esm/rules/a11y/sr_output_disabled_tooltip.js.map +1 -1
- package/lib/esm/utils/are_attrs_equal.d.ts +1 -0
- package/lib/esm/utils/are_attrs_equal.js +28 -0
- package/lib/esm/utils/are_attrs_equal.js.map +1 -0
- package/lib/esm/utils/get_allowed_a11y_prop_names_for_component.d.ts +23 -0
- package/lib/esm/utils/get_allowed_a11y_prop_names_for_component.js +45 -0
- package/lib/esm/utils/get_allowed_a11y_prop_names_for_component.js.map +1 -0
- package/lib/esm/utils/has_a11y_prop_for_component.d.ts +19 -0
- package/lib/esm/utils/has_a11y_prop_for_component.js +45 -0
- package/lib/esm/utils/has_a11y_prop_for_component.js.map +1 -0
- package/lib/esm/utils/has_spread.d.ts +11 -0
- package/lib/esm/utils/has_spread.js +34 -0
- package/lib/esm/utils/has_spread.js.map +1 -0
- package/lib/esm/utils/is_in_conditional_rendering.d.ts +2 -0
- package/lib/esm/utils/is_in_conditional_rendering.js +34 -0
- package/lib/esm/utils/is_in_conditional_rendering.js.map +1 -0
- package/package.json +1 -1
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.isInConditionalRendering = isInConditionalRendering;
|
|
7
|
+
/*
|
|
8
|
+
* Licensed to Elasticsearch B.V. under one or more contributor
|
|
9
|
+
* license agreements. See the NOTICE file distributed with
|
|
10
|
+
* this work for additional information regarding copyright
|
|
11
|
+
* ownership. Elasticsearch B.V. licenses this file to you under
|
|
12
|
+
* the Apache License, Version 2.0 (the "License"); you may
|
|
13
|
+
* not use this file except in compliance with the License.
|
|
14
|
+
* You may obtain a copy of the License at
|
|
15
|
+
*
|
|
16
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
17
|
+
*
|
|
18
|
+
* Unless required by applicable law or agreed to in writing,
|
|
19
|
+
* software distributed under the License is distributed on an
|
|
20
|
+
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
|
21
|
+
* KIND, either express or implied. See the License for the
|
|
22
|
+
* specific language governing permissions and limitations
|
|
23
|
+
* under the License.
|
|
24
|
+
*/
|
|
25
|
+
|
|
26
|
+
function isInConditionalRendering(node) {
|
|
27
|
+
let parent = node.parent;
|
|
28
|
+
while (parent) {
|
|
29
|
+
if (parent.type === 'ConditionalExpression' || parent.type === 'IfStatement' || parent.type === 'LogicalExpression' && parent.operator === '&&') {
|
|
30
|
+
return true;
|
|
31
|
+
}
|
|
32
|
+
parent = parent.parent;
|
|
33
|
+
}
|
|
34
|
+
return false;
|
|
35
|
+
}
|
package/lib/esm/index.js
CHANGED
|
@@ -18,6 +18,7 @@
|
|
|
18
18
|
* under the License.
|
|
19
19
|
*/
|
|
20
20
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
21
|
+
const callout_announce_on_mount_1 = require("./rules/a11y/callout_announce_on_mount");
|
|
21
22
|
const href_or_on_click_1 = require("./rules/href_or_on_click");
|
|
22
23
|
const no_restricted_eui_imports_1 = require("./rules/no_restricted_eui_imports");
|
|
23
24
|
const no_css_color_1 = require("./rules/no_css_color");
|
|
@@ -25,6 +26,8 @@ const require_aria_label_for_modals_1 = require("./rules/a11y/require_aria_label
|
|
|
25
26
|
const consistent_is_invalid_props_1 = require("./rules/a11y/consistent_is_invalid_props");
|
|
26
27
|
const sr_output_disabled_tooltip_1 = require("./rules/a11y/sr_output_disabled_tooltip");
|
|
27
28
|
const prefer_eui_icon_tip_1 = require("./rules/a11y/prefer_eui_icon_tip");
|
|
29
|
+
const no_unnamed_radio_group_1 = require("./rules/a11y/no_unnamed_radio_group");
|
|
30
|
+
const no_unnamed_interactive_element_1 = require("./rules/a11y/no_unnamed_interactive_element");
|
|
28
31
|
const config = {
|
|
29
32
|
rules: {
|
|
30
33
|
'href-or-on-click': href_or_on_click_1.HrefOnClick,
|
|
@@ -34,6 +37,9 @@ const config = {
|
|
|
34
37
|
'consistent-is-invalid-props': consistent_is_invalid_props_1.ConsistentIsInvalidProps,
|
|
35
38
|
'sr-output-disabled-tooltip': sr_output_disabled_tooltip_1.ScreenReaderOutputDisabledTooltip,
|
|
36
39
|
'prefer-eui-icon-tip': prefer_eui_icon_tip_1.PreferEuiIconTip,
|
|
40
|
+
'no-unnamed-radio-group': no_unnamed_radio_group_1.NoUnnamedRadioGroup,
|
|
41
|
+
'callout-announce-on-mount': callout_announce_on_mount_1.CallOutAnnounceOnMount,
|
|
42
|
+
'no-unnamed-interactive-element': no_unnamed_interactive_element_1.NoUnnamedInteractiveElement,
|
|
37
43
|
},
|
|
38
44
|
configs: {
|
|
39
45
|
recommended: {
|
|
@@ -46,6 +52,9 @@ const config = {
|
|
|
46
52
|
'@elastic/eui/consistent-is-invalid-props': 'warn',
|
|
47
53
|
'@elastic/eui/sr-output-disabled-tooltip': 'warn',
|
|
48
54
|
'@elastic/eui/prefer-eui-icon-tip': 'warn',
|
|
55
|
+
'@elastic/eui/no-unnamed-radio-group': 'warn',
|
|
56
|
+
'@elastic/eui/callout-announce-on-mount': 'warn',
|
|
57
|
+
'@elastic/eui/no-unnamed-interactive-element': 'warn',
|
|
49
58
|
},
|
|
50
59
|
},
|
|
51
60
|
},
|
package/lib/esm/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;GAiBG;;AAEH,+DAAuD;AACvD,iFAA2E;AAC3E,uDAAkD;AAElD,8FAAuF;AACvF,0FAAoF;AACpF,wFAA4F;AAC5F,0EAAoE;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;GAiBG;;AAEH,sFAAgF;AAChF,+DAAuD;AACvD,iFAA2E;AAC3E,uDAAkD;AAElD,8FAAuF;AACvF,0FAAoF;AACpF,wFAA4F;AAC5F,0EAAoE;AACpE,gFAA0E;AAC1E,gGAA0F;AAG1F,MAAM,MAAM,GAAG;IACb,KAAK,EAAE;QACL,kBAAkB,EAAE,8BAAW;QAC/B,2BAA2B,EAAE,kDAAsB;QACnD,cAAc,EAAE,yBAAU;QAC1B,+BAA+B,EAAE,yDAAyB;QAC1D,6BAA6B,EAAE,sDAAwB;QACvD,4BAA4B,EAAE,8DAAiC;QAC/D,qBAAqB,EAAE,sCAAgB;QACvC,wBAAwB,EAAG,4CAAmB;QAC9C,2BAA2B,EAAE,kDAAsB;QACnD,gCAAgC,EAAE,4DAA2B;KAC9D;IACD,OAAO,EAAE;QACP,WAAW,EAAE;YACX,OAAO,EAAE,CAAC,4BAA4B,CAAC;YACvC,KAAK,EAAE;gBACL,+BAA+B,EAAE,MAAM;gBACvC,wCAAwC,EAAE,MAAM;gBAChD,2BAA2B,EAAE,MAAM;gBACnC,4CAA4C,EAAE,MAAM;gBACpD,0CAA0C,EAAE,MAAM;gBAClD,yCAAyC,EAAE,MAAM;gBACjD,kCAAkC,EAAE,MAAM;gBAC1C,qCAAqC,EAAE,MAAM;gBAC7C,wCAAwC,EAAE,MAAM;gBAChD,6CAA6C,EAAE,MAAM;aACtD;SACF;KACF;CACF,CAAC;AAEF,MAAM,CAAC,OAAO,GAAG,MAAM,CAAC"}
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/*
|
|
3
|
+
* Licensed to Elasticsearch B.V. under one or more contributor
|
|
4
|
+
* license agreements. See the NOTICE file distributed with
|
|
5
|
+
* this work for additional information regarding copyright
|
|
6
|
+
* ownership. Elasticsearch B.V. licenses this file to you under
|
|
7
|
+
* the Apache License, Version 2.0 (the "License"); you may
|
|
8
|
+
* not use this file except in compliance with the License.
|
|
9
|
+
* You may obtain a copy of the License at
|
|
10
|
+
*
|
|
11
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
12
|
+
*
|
|
13
|
+
* Unless required by applicable law or agreed to in writing,
|
|
14
|
+
* software distributed under the License is distributed on an
|
|
15
|
+
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
|
16
|
+
* KIND, either express or implied. See the License for the
|
|
17
|
+
* specific language governing permissions and limitations
|
|
18
|
+
* under the License.
|
|
19
|
+
*/
|
|
20
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
21
|
+
exports.CallOutAnnounceOnMount = void 0;
|
|
22
|
+
const utils_1 = require("@typescript-eslint/utils");
|
|
23
|
+
const is_in_conditional_rendering_1 = require("../../utils/is_in_conditional_rendering");
|
|
24
|
+
const has_spread_1 = require("../../utils/has_spread");
|
|
25
|
+
const CALLOUT_COMPONENT = 'EuiCallOut';
|
|
26
|
+
exports.CallOutAnnounceOnMount = utils_1.ESLintUtils.RuleCreator.withoutDocs({
|
|
27
|
+
create(context) {
|
|
28
|
+
return {
|
|
29
|
+
JSXElement(node) {
|
|
30
|
+
const { openingElement } = node;
|
|
31
|
+
if (openingElement.name.type !== 'JSXIdentifier' ||
|
|
32
|
+
openingElement.name.name !== CALLOUT_COMPONENT) {
|
|
33
|
+
return;
|
|
34
|
+
}
|
|
35
|
+
if (openingElement.attributes.some(attr => attr.type === 'JSXAttribute' &&
|
|
36
|
+
attr.name.type === 'JSXIdentifier' &&
|
|
37
|
+
attr.name.name === 'announceOnMount')) {
|
|
38
|
+
return;
|
|
39
|
+
}
|
|
40
|
+
if ((0, is_in_conditional_rendering_1.isInConditionalRendering)(node)) {
|
|
41
|
+
context.report({
|
|
42
|
+
node: openingElement,
|
|
43
|
+
messageId: 'missingAnnounceOnMount',
|
|
44
|
+
fix: (0, has_spread_1.hasSpread)(openingElement.attributes) ? undefined : (fixer) => {
|
|
45
|
+
return fixer.insertTextAfterRange([openingElement.name.range[1], openingElement.name.range[1]], ' announceOnMount');
|
|
46
|
+
},
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
},
|
|
50
|
+
};
|
|
51
|
+
},
|
|
52
|
+
meta: {
|
|
53
|
+
type: 'problem',
|
|
54
|
+
docs: {
|
|
55
|
+
description: `Ensure ${CALLOUT_COMPONENT} components that are conditionally rendered have announceOnMount prop for better accessibility`
|
|
56
|
+
},
|
|
57
|
+
fixable: 'code',
|
|
58
|
+
schema: [],
|
|
59
|
+
messages: {
|
|
60
|
+
missingAnnounceOnMount: [
|
|
61
|
+
`${CALLOUT_COMPONENT} should have \`announceOnMount\` prop when conditionally rendered for better accessibility.`,
|
|
62
|
+
'\n',
|
|
63
|
+
`When ${CALLOUT_COMPONENT} appears dynamically (e.g., after user interaction, form validation, etc.),`,
|
|
64
|
+
'screen readers may not announce its content. Adding `announceOnMount` ensures the callout',
|
|
65
|
+
'is properly announced to users with assistive technologies.',
|
|
66
|
+
'\n',
|
|
67
|
+
'Example:',
|
|
68
|
+
` <${CALLOUT_COMPONENT} announceOnMount title="Error" color="danger">`,
|
|
69
|
+
' This message will be announced when it appears',
|
|
70
|
+
` </${CALLOUT_COMPONENT}>`,
|
|
71
|
+
].join('\n'),
|
|
72
|
+
},
|
|
73
|
+
},
|
|
74
|
+
defaultOptions: [],
|
|
75
|
+
});
|
|
76
|
+
//# sourceMappingURL=callout_announce_on_mount.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"callout_announce_on_mount.js","sourceRoot":"","sources":["../../../../src/rules/a11y/callout_announce_on_mount.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;GAiBG;;;AAEH,oDAAwD;AACxD,yFAAmF;AACnF,uDAAmD;AAEnD,MAAM,iBAAiB,GAAG,YAAY,CAAC;AAE1B,QAAA,sBAAsB,GAAG,mBAAW,CAAC,WAAW,CAAC,WAAW,CAAC;IACxE,MAAM,CAAC,OAAO;QACZ,OAAO;YACL,UAAU,CAAC,IAAI;gBACb,MAAM,EAAE,cAAc,EAAE,GAAG,IAAI,CAAC;gBAChC,IAAI,cAAc,CAAC,IAAI,CAAC,IAAI,KAAK,eAAe;oBAC5C,cAAc,CAAC,IAAI,CAAC,IAAI,KAAK,iBAAiB,EAAE,CAAC;oBACnD,OAAO;gBACT,CAAC;gBACD,IAAI,cAAc,CAAC,UAAU,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CACxC,IAAI,CAAC,IAAI,KAAK,cAAc;oBAC5B,IAAI,CAAC,IAAI,CAAC,IAAI,KAAK,eAAe;oBAClC,IAAI,CAAC,IAAI,CAAC,IAAI,KAAK,iBAAiB,CACrC,EAAE,CAAC;oBACF,OAAO;gBACT,CAAC;gBACD,IAAI,IAAA,sDAAwB,EAAC,IAAI,CAAC,EAAE,CAAC;oBACnC,OAAO,CAAC,MAAM,CAAC;wBACb,IAAI,EAAE,cAAc;wBACpB,SAAS,EAAE,wBAAwB;wBACnC,GAAG,EAAE,IAAA,sBAAS,EAAC,cAAc,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,KAAK,EAAE,EAAE;4BAChE,OAAO,KAAK,CAAC,oBAAoB,CAC/B,CAAC,cAAc,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,cAAc,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,EAC5D,kBAAkB,CACnB,CAAC;wBACJ,CAAC;qBACF,CAAC,CAAC;gBACL,CAAC;YACH,CAAC;SACF,CAAC;IACJ,CAAC;IACD,IAAI,EAAE;QACJ,IAAI,EAAE,SAAS;QACf,IAAI,EAAE;YACJ,WAAW,EAAE,UAAU,iBAAiB,gGAAgG;SACzI;QACD,OAAO,EAAE,MAAM;QACf,MAAM,EAAE,EAAE;QACV,QAAQ,EAAE;YACR,sBAAsB,EAAE;gBACtB,GAAG,iBAAiB,6FAA6F;gBACjH,IAAI;gBACJ,QAAQ,iBAAiB,6EAA6E;gBACtG,2FAA2F;gBAC3F,6DAA6D;gBAC7D,IAAI;gBACJ,UAAU;gBACV,MAAM,iBAAiB,gDAAgD;gBACvE,oDAAoD;gBACpD,OAAO,iBAAiB,GAAG;aAC5B,CAAC,IAAI,CAAC,IAAI,CAAC;SACb;KACF;IACD,cAAc,EAAE,EAAE;CACnB,CAAC,CAAC"}
|
|
@@ -21,6 +21,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
21
21
|
exports.ConsistentIsInvalidProps = void 0;
|
|
22
22
|
const utils_1 = require("@typescript-eslint/utils");
|
|
23
23
|
const get_attr_value_1 = require("../../utils/get_attr_value");
|
|
24
|
+
const are_attrs_equal_1 = require("../../utils/are_attrs_equal");
|
|
24
25
|
const formControlComponent = 'EuiFormRow';
|
|
25
26
|
const formControlChildComponents = [
|
|
26
27
|
'EuiFieldNumber',
|
|
@@ -53,7 +54,7 @@ exports.ConsistentIsInvalidProps = utils_1.ESLintUtils.RuleCreator.withoutDocs({
|
|
|
53
54
|
return;
|
|
54
55
|
}
|
|
55
56
|
const childIsInvalid = (0, get_attr_value_1.getAttrValue)(context, childElement.openingElement.attributes, 'isInvalid');
|
|
56
|
-
if (childIsInvalid
|
|
57
|
+
if (!(0, are_attrs_equal_1.areAttrsEqual)(childIsInvalid, formRowIsInvalid)) {
|
|
57
58
|
const componentName = childElement.openingElement.name.name;
|
|
58
59
|
context.report({
|
|
59
60
|
node: childElement,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"consistent_is_invalid_props.js","sourceRoot":"","sources":["../../../../src/rules/a11y/consistent_is_invalid_props.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;GAiBG;;;AAEH,oDAAsE;AACtE,+DAA0D;AAC1D,MAAM,oBAAoB,GAAG,YAAY,CAAC;AAE1C,MAAM,0BAA0B,GAAG;IACjC,gBAAgB;IAChB,eAAe;IACf,cAAc;IACd,aAAa;IACb,aAAa;IACb,+BAA+B;IAC/B,mBAAmB;IACnB,WAAW;CACZ,CAAC;AAEW,QAAA,wBAAwB,GAAG,mBAAW,CAAC,WAAW,CAAC,WAAW,CAAC;IAC1E,MAAM,CAAC,OAAO;QACZ,OAAO;YACL,UAAU,CAAC,IAAI;gBACb,MAAM,cAAc,GAAG,IAAI,CAAC,cAAc,CAAC;gBAE3C,IACE,cAAc,EAAE,IAAI,CAAC,IAAI,KAAK,eAAe;oBAC7C,cAAc,CAAC,IAAI,CAAC,IAAI,KAAK,oBAAoB;oBACjD,cAAc,CAAC,UAAU,CAAC,MAAM,KAAK,CAAC,EACtC,CAAC;oBACD,OAAO;gBACT,CAAC;gBAED,MAAM,gBAAgB,GAAG,IAAA,6BAAY,EACnC,OAAO,EACP,cAAc,CAAC,UAAU,EACzB,WAAW,CACZ,CAAC;gBAEF,IAAI,gBAAgB,KAAK,SAAS,EAAE,CAAC;oBACnC,OAAO;gBACT,CAAC;gBAED,MAAM,YAAY,GAAG,IAAI,CAAC,QAAQ,CAAC,IAAI,CACrC,CAAC,KAAK,EAAgC,EAAE,CACtC,KAAK,CAAC,IAAI,KAAK,YAAY;oBAC3B,KAAK,CAAC,cAAc,EAAE,IAAI,CAAC,IAAI,KAAK,eAAe;oBACnD,0BAA0B,CAAC,QAAQ,CAAC,KAAK,CAAC,cAAc,CAAC,IAAI,CAAC,IAAI,CAAC,CACtE,CAAC;gBAEF,IAAI,CAAC,YAAY,EAAE,CAAC;oBAClB,OAAO;gBACT,CAAC;gBAED,MAAM,cAAc,GAAG,IAAA,6BAAY,EACjC,OAAO,EACP,YAAY,CAAC,cAAc,CAAC,UAAU,EACtC,WAAW,CACZ,CAAC;gBAEF,IAAI,cAAc,
|
|
1
|
+
{"version":3,"file":"consistent_is_invalid_props.js","sourceRoot":"","sources":["../../../../src/rules/a11y/consistent_is_invalid_props.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;GAiBG;;;AAEH,oDAAsE;AACtE,+DAA0D;AAC1D,iEAA4D;AAE5D,MAAM,oBAAoB,GAAG,YAAY,CAAC;AAE1C,MAAM,0BAA0B,GAAG;IACjC,gBAAgB;IAChB,eAAe;IACf,cAAc;IACd,aAAa;IACb,aAAa;IACb,+BAA+B;IAC/B,mBAAmB;IACnB,WAAW;CACZ,CAAC;AAEW,QAAA,wBAAwB,GAAG,mBAAW,CAAC,WAAW,CAAC,WAAW,CAAC;IAC1E,MAAM,CAAC,OAAO;QACZ,OAAO;YACL,UAAU,CAAC,IAAI;gBACb,MAAM,cAAc,GAAG,IAAI,CAAC,cAAc,CAAC;gBAE3C,IACE,cAAc,EAAE,IAAI,CAAC,IAAI,KAAK,eAAe;oBAC7C,cAAc,CAAC,IAAI,CAAC,IAAI,KAAK,oBAAoB;oBACjD,cAAc,CAAC,UAAU,CAAC,MAAM,KAAK,CAAC,EACtC,CAAC;oBAC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,CACtB,kBAAkB,EAClB,cAAc,gBAAgB,GAAG,CAClC,CAAC;4BACJ,CAAC;4BAED,MAAM,cAAc,GAAG,YAAY,CAAC,cAAc,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;4BAEjE,OAAO,KAAK,CAAC,oBAAoB,CAC/B,CAAC,cAAc,EAAE,cAAc,CAAC,EAChC,eAAe,gBAAgB,GAAG,CACnC,CAAC;wBACJ,CAAC;wBACD,IAAI,EAAE;4BACJ,oBAAoB,EAAE,oBAAoB;4BAC1C,SAAS,EAAE,aAAa;yBACzB;qBACF,CAAC,CAAC;gBACL,CAAC;YACH,CAAC;SACF,CAAC;IACJ,CAAC;IACD,IAAI,EAAE;QACJ,IAAI,EAAE,SAAS;QACf,IAAI,EAAE;YACJ,WAAW,EAAE,oFAAoF;SAClG;QACD,OAAO,EAAE,MAAM;QACf,MAAM,EAAE,EAAE;QACV,QAAQ,EAAE;YACR,qBAAqB,EAAE,mGAAmG;SAC3H;KACF;IACD,cAAc,EAAE,EAAE;CACnB,CAAC,CAAC"}
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/*
|
|
3
|
+
* Licensed to Elasticsearch B.V. under one or more contributor
|
|
4
|
+
* license agreements. See the NOTICE file distributed with
|
|
5
|
+
* this work for additional information regarding copyright
|
|
6
|
+
* ownership. Elasticsearch B.V. licenses this file to you under
|
|
7
|
+
* the Apache License, Version 2.0 (the "License"); you may
|
|
8
|
+
* not use this file except in compliance with the License.
|
|
9
|
+
* You may obtain a copy of the License at
|
|
10
|
+
*
|
|
11
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
12
|
+
*
|
|
13
|
+
* Unless required by applicable law or agreed to in writing,
|
|
14
|
+
* software distributed under the License is distributed on an
|
|
15
|
+
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
|
16
|
+
* KIND, either express or implied. See the License for the
|
|
17
|
+
* specific language governing permissions and limitations
|
|
18
|
+
* under the License.
|
|
19
|
+
*/
|
|
20
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
21
|
+
exports.NoUnnamedInteractiveElement = void 0;
|
|
22
|
+
const utils_1 = require("@typescript-eslint/utils");
|
|
23
|
+
const has_spread_1 = require("../../utils/has_spread");
|
|
24
|
+
const get_allowed_a11y_prop_names_for_component_1 = require("../../utils/get_allowed_a11y_prop_names_for_component");
|
|
25
|
+
const has_a11y_prop_for_component_1 = require("../../utils/has_a11y_prop_for_component");
|
|
26
|
+
const interactiveComponents = [
|
|
27
|
+
'EuiBetaBadge',
|
|
28
|
+
'EuiButtonEmpty',
|
|
29
|
+
'EuiButtonIcon',
|
|
30
|
+
'EuiComboBox',
|
|
31
|
+
'EuiSelect',
|
|
32
|
+
'EuiSelectWithWidth',
|
|
33
|
+
'EuiSuperSelect',
|
|
34
|
+
'EuiPagination',
|
|
35
|
+
'EuiTreeView',
|
|
36
|
+
'EuiBreadcrumbs',
|
|
37
|
+
];
|
|
38
|
+
const wrappingComponents = ['EuiFormRow'];
|
|
39
|
+
const interactiveComponentsWithLabel = ['EuiBetaBadge'];
|
|
40
|
+
const baseA11yProps = ['aria-label', 'aria-labelledby'];
|
|
41
|
+
// Single source of truth for the utils (keeps them reusable)
|
|
42
|
+
const a11yConfig = {
|
|
43
|
+
interactiveComponentsWithLabel: [...interactiveComponentsWithLabel],
|
|
44
|
+
wrappingComponents: [...wrappingComponents],
|
|
45
|
+
baseA11yProps: [...baseA11yProps],
|
|
46
|
+
};
|
|
47
|
+
exports.NoUnnamedInteractiveElement = utils_1.ESLintUtils.RuleCreator.withoutDocs({
|
|
48
|
+
meta: {
|
|
49
|
+
type: 'problem',
|
|
50
|
+
hasSuggestions: false,
|
|
51
|
+
schema: [],
|
|
52
|
+
messages: {
|
|
53
|
+
missingA11y: '{{component}} must include an accessible label. Use one of: {{a11yProps}}',
|
|
54
|
+
},
|
|
55
|
+
},
|
|
56
|
+
defaultOptions: [],
|
|
57
|
+
create(context) {
|
|
58
|
+
const sourceCode = context.sourceCode;
|
|
59
|
+
function report(opening) {
|
|
60
|
+
if (opening.name.type !== 'JSXIdentifier')
|
|
61
|
+
return;
|
|
62
|
+
const component = opening.name.name;
|
|
63
|
+
const allowed = (0, get_allowed_a11y_prop_names_for_component_1.getAllowedA11yPropNamesForComponent)(component, a11yConfig).join(', ');
|
|
64
|
+
context.report({
|
|
65
|
+
node: opening,
|
|
66
|
+
messageId: 'missingA11y',
|
|
67
|
+
data: {
|
|
68
|
+
component,
|
|
69
|
+
a11yProps: allowed,
|
|
70
|
+
},
|
|
71
|
+
});
|
|
72
|
+
}
|
|
73
|
+
return {
|
|
74
|
+
JSXOpeningElement(node) {
|
|
75
|
+
if (node.name.type !== 'JSXIdentifier')
|
|
76
|
+
return;
|
|
77
|
+
const componentName = node.name.name;
|
|
78
|
+
const isInteractive = interactiveComponents.includes(componentName);
|
|
79
|
+
if (!isInteractive)
|
|
80
|
+
return;
|
|
81
|
+
if ((0, has_spread_1.hasSpread)(node.attributes) ||
|
|
82
|
+
(0, has_a11y_prop_for_component_1.hasA11yPropForComponent)(componentName, node.attributes, a11yConfig)) {
|
|
83
|
+
return;
|
|
84
|
+
}
|
|
85
|
+
const ancestors = sourceCode.getAncestors(node);
|
|
86
|
+
const wrapper = [...ancestors]
|
|
87
|
+
.reverse()
|
|
88
|
+
.find((a) => a.type === 'JSXElement' &&
|
|
89
|
+
a.openingElement.name.type === 'JSXIdentifier' &&
|
|
90
|
+
wrappingComponents.includes(a.openingElement.name.name));
|
|
91
|
+
if (wrapper) {
|
|
92
|
+
const open = wrapper.openingElement;
|
|
93
|
+
const wrapperName = open.name.type === 'JSXIdentifier' ? open.name.name : '';
|
|
94
|
+
if (!(0, has_spread_1.hasSpread)(open.attributes) &&
|
|
95
|
+
!(0, has_a11y_prop_for_component_1.hasA11yPropForComponent)(wrapperName, open.attributes, a11yConfig)) {
|
|
96
|
+
report(open);
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
else {
|
|
100
|
+
report(node);
|
|
101
|
+
}
|
|
102
|
+
},
|
|
103
|
+
};
|
|
104
|
+
},
|
|
105
|
+
});
|
|
106
|
+
//# sourceMappingURL=no_unnamed_interactive_element.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"no_unnamed_interactive_element.js","sourceRoot":"","sources":["../../../../src/rules/a11y/no_unnamed_interactive_element.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;GAiBG;;;AAEH,oDAAsE;AACtE,uDAAmD;AACnD,qHAG+D;AAC/D,yFAAkF;AAElF,MAAM,qBAAqB,GAAG;IAC5B,cAAc;IACd,gBAAgB;IAChB,eAAe;IACf,aAAa;IACb,WAAW;IACX,oBAAoB;IACpB,gBAAgB;IAChB,eAAe;IACf,aAAa;IACb,gBAAgB;CACR,CAAC;AAEX,MAAM,kBAAkB,GAAG,CAAC,YAAY,CAAU,CAAC;AACnD,MAAM,8BAA8B,GAAG,CAAC,cAAc,CAAU,CAAC;AACjE,MAAM,aAAa,GAAG,CAAC,YAAY,EAAE,iBAAiB,CAAU,CAAC;AAEjE,6DAA6D;AAC7D,MAAM,UAAU,GAAe;IAC7B,8BAA8B,EAAE,CAAC,GAAG,8BAA8B,CAAC;IACnE,kBAAkB,EAAE,CAAC,GAAG,kBAAkB,CAAC;IAC3C,aAAa,EAAE,CAAC,GAAG,aAAa,CAAC;CAClC,CAAC;AAEW,QAAA,2BAA2B,GAAG,mBAAW,CAAC,WAAW,CAAC,WAAW,CAAC;IAC7E,IAAI,EAAE;QACJ,IAAI,EAAE,SAAS;QACf,cAAc,EAAE,KAAK;QACrB,MAAM,EAAE,EAAE;QACV,QAAQ,EAAE;YACR,WAAW,EACT,2EAA2E;SAC9E;KACF;IACD,cAAc,EAAE,EAAE;IAClB,MAAM,CAAC,OAAO;QACZ,MAAM,UAAU,GAAG,OAAO,CAAC,UAAU,CAAC;QAEtC,SAAS,MAAM,CAAC,OAAmC;YACjD,I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O,EAAE,CAAC;oBACZ,MAAM,IAAI,GAAG,OAAO,CAAC,cAAc,CAAC;oBACpC,MAAM,WAAW,GACf,IAAI,CAAC,IAAI,CAAC,IAAI,KAAK,eAAe,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC;oBAC3D,IACE,CAAC,IAAA,sBAAS,EAAC,IAAI,CAAC,UAAU,CAAC;wBAC3B,CAAC,IAAA,qDAAuB,EAAC,WAAW,EAAE,IAAI,CAAC,UAAU,EAAE,UAAU,CAAC,EAClE,CAAC;wBACD,MAAM,CAAC,IAAI,CAAC,CAAC;oBACf,CAAC;gBACH,CAAC;qBAAM,CAAC;oBACN,MAAM,CAAC,IAAI,CAAC,CAAC;gBACf,CAAC;YACH,CAAC;SACF,CAAC;IACJ,CAAC;CACF,CAAC,CAAC"}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/*
|
|
3
|
+
* Licensed to Elasticsearch B.V. under one or more contributor
|
|
4
|
+
* license agreements. See the NOTICE file distributed with
|
|
5
|
+
* this work for additional information regarding copyright
|
|
6
|
+
* ownership. Elasticsearch B.V. licenses this file to you under
|
|
7
|
+
* the Apache License, Version 2.0 (the "License"); you may
|
|
8
|
+
* not use this file except in compliance with the License.
|
|
9
|
+
* You may obtain a copy of the License at
|
|
10
|
+
*
|
|
11
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
12
|
+
*
|
|
13
|
+
* Unless required by applicable law or agreed to in writing,
|
|
14
|
+
* software distributed under the License is distributed on an
|
|
15
|
+
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
|
16
|
+
* KIND, either express or implied. See the License for the
|
|
17
|
+
* specific language governing permissions and limitations
|
|
18
|
+
* under the License.
|
|
19
|
+
*/
|
|
20
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
21
|
+
exports.NoUnnamedRadioGroup = void 0;
|
|
22
|
+
const utils_1 = require("@typescript-eslint/utils");
|
|
23
|
+
const radioComponents = ['EuiRadio', 'EuiRadioGroup'];
|
|
24
|
+
exports.NoUnnamedRadioGroup = utils_1.ESLintUtils.RuleCreator.withoutDocs({
|
|
25
|
+
create(context) {
|
|
26
|
+
return {
|
|
27
|
+
JSXOpeningElement(node) {
|
|
28
|
+
if (node.name.type === 'JSXIdentifier' &&
|
|
29
|
+
radioComponents.includes(node.name.name)) {
|
|
30
|
+
const hasNameAttr = node.attributes.some((attr) => attr.type === 'JSXAttribute' &&
|
|
31
|
+
attr.name.type === 'JSXIdentifier' &&
|
|
32
|
+
attr.name.name === 'name');
|
|
33
|
+
if (!hasNameAttr) {
|
|
34
|
+
context.report({
|
|
35
|
+
node,
|
|
36
|
+
messageId: 'missingRadioName',
|
|
37
|
+
data: { component: node.name.name },
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
},
|
|
42
|
+
};
|
|
43
|
+
},
|
|
44
|
+
meta: {
|
|
45
|
+
type: 'problem',
|
|
46
|
+
docs: {
|
|
47
|
+
description: 'Ensure that all radio input components have a `name` attribute. The `name` attribute is required for radio inputs to be grouped correctly, allowing users to select only one option from a set. Without a `name`, radios may not behave as expected and can cause accessibility issues for assistive technologies.',
|
|
48
|
+
},
|
|
49
|
+
schema: [],
|
|
50
|
+
messages: {
|
|
51
|
+
missingRadioName: '{{ component }} must have a `name` attribute. The `name` attribute is required for radio inputs to be grouped correctly, ensuring only one option can be selected and improving accessibility for all users.',
|
|
52
|
+
},
|
|
53
|
+
},
|
|
54
|
+
defaultOptions: [],
|
|
55
|
+
});
|
|
56
|
+
//# sourceMappingURL=no_unnamed_radio_group.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"no_unnamed_radio_group.js","sourceRoot":"","sources":["../../../../src/rules/a11y/no_unnamed_radio_group.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;GAiBG;;;AAEH,oDAAuD;AAEvD,MAAM,eAAe,GAAG,CAAC,UAAU,EAAE,eAAe,CAAC,CAAC;AAEzC,QAAA,mBAAmB,GAAG,mBAAW,CAAC,WAAW,CAAC,WAAW,CAAC;IACrE,MAAM,CAAC,OAAO;QACZ,OAAO;YACL,iBAAiB,CAAC,IAAI;gBACpB,IACE,IAAI,CAAC,IAAI,CAAC,IAAI,KAAK,eAAe;oBAClC,eAAe,CAAC,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,EACxC,CAAC;oBACD,MAAM,WAAW,GAAG,IAAI,CAAC,UAAU,CAAC,IAAI,CACtC,CAAC,IAAI,EAAE,EAAE,CACP,IAAI,CAAC,IAAI,KAAK,cAAc;wBAC5B,IAAI,CAAC,IAAI,CAAC,IAAI,KAAK,eAAe;wBAClC,IAAI,CAAC,IAAI,CAAC,IAAI,KAAK,MAAM,CAC5B,CAAC;oBAEF,IAAI,CAAC,WAAW,EAAE,CAAC;wBACjB,OAAO,CAAC,MAAM,CAAC;4BACb,IAAI;4BACJ,SAAS,EAAE,kBAAkB;4BAC7B,IAAI,EAAE,EAAE,SAAS,EAAE,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE;yBACpC,CAAC,CAAC;oBACL,CAAC;gBACH,CAAC;YACH,CAAC;SACF,CAAC;IACJ,CAAC;IACD,IAAI,EAAE;QACJ,IAAI,EAAE,SAAS;QACf,IAAI,EAAE;YACJ,WAAW,EACT,oTAAoT;SACvT;QACD,MAAM,EAAE,EAAE;QACV,QAAQ,EAAE;YACR,gBAAgB,EACd,8MAA8M;SACjN;KACF;IACD,cAAc,EAAE,EAAE;CACnB,CAAC,CAAC"}
|
|
@@ -20,7 +20,7 @@
|
|
|
20
20
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
21
21
|
exports.RequireAriaLabelForModals = void 0;
|
|
22
22
|
const utils_1 = require("@typescript-eslint/utils");
|
|
23
|
-
const modalComponents = ['EuiModal', 'EuiFlyout'];
|
|
23
|
+
const modalComponents = ['EuiModal', 'EuiFlyout', 'EuiFlyoutResizable'];
|
|
24
24
|
const confirmModalComponents = ['EuiConfirmModal'];
|
|
25
25
|
exports.RequireAriaLabelForModals = utils_1.ESLintUtils.RuleCreator.withoutDocs({
|
|
26
26
|
create(context) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"require_aria_label_for_modals.js","sourceRoot":"","sources":["../../../../src/rules/a11y/require_aria_label_for_modals.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;GAiBG;;;AAEH,oDAAiE;AAEjE,MAAM,eAAe,GAAG,CAAC,UAAU,EAAE,WAAW,CAAC,CAAC;
|
|
1
|
+
{"version":3,"file":"require_aria_label_for_modals.js","sourceRoot":"","sources":["../../../../src/rules/a11y/require_aria_label_for_modals.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;GAiBG;;;AAEH,oDAAiE;AAEjE,MAAM,eAAe,GAAG,CAAC,UAAU,EAAE,WAAW,EAAE,oBAAoB,CAAC,CAAC;AACxE,MAAM,sBAAsB,GAAG,CAAC,iBAAiB,CAAC,CAAC;AAEtC,QAAA,yBAAyB,GAAG,mBAAW,CAAC,WAAW,CAAC,WAAW,CAAC;IAC3E,MAAM,CAAC,OAAO;QACZ,SAAS,eAAe,CAAC,IAAgC,EAAE,aAAqB,EAAE,SAAyD;YACzI,MAAM,YAAY,GAAG,IAAI,CAAC,UAAU,CAAC,IAAI,CACvC,CAAC,IAAI,EAAE,EAAE,CACP,IAAI,CAAC,IAAI,KAAK,cAAc;gBAC5B,OAAO,IAAI,CAAC,IAAI,CAAC,IAAI,KAAK,QAAQ;gBAClC,CAAC,YAAY,EAAE,iBAAiB,CAAC,CAAC,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,CAC7D,CAAC;YAEF,IAAI,CAAC,YAAY,EAAE,CAAC;gBAClB,OAAO,CAAC,MAAM,CAAC;oBACb,IAAI;oBACJ,SAAS,EAAE,SAAS;oBACpB,IA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DAAyD;gBACzD,2BAA2B;gBAC3B,+CAA+C;gBAC/C,QAAQ;gBACR,qBAAqB;gBACrB,wDAAwD;gBACxD,qCAAqC;gBACrC,yCAAyC;gBACzC,kBAAkB;gBAClB,OAAO;gBACP,IAAI;gBACJ,iCAAiC;gBACjC,0FAA0F;aAC7F,CAAC,IAAI,CAAC,IAAI,CAAC;SACX;KACF;IACD,cAAc,EAAE,EAAE;CACnB,CAAC,CAAC"}
|
|
@@ -10,10 +10,10 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
10
10
|
exports.ScreenReaderOutputDisabledTooltip = void 0;
|
|
11
11
|
const utils_1 = require("@typescript-eslint/utils");
|
|
12
12
|
const get_attr_value_1 = require("../../utils/get_attr_value");
|
|
13
|
+
const are_attrs_equal_1 = require("../../utils/are_attrs_equal");
|
|
13
14
|
const tooltipComponent = 'EuiToolTip';
|
|
14
15
|
const disabledTooltipComponentProp = 'disableScreenReaderOutput';
|
|
15
16
|
const buttonComponents = ['EuiButtonIcon'];
|
|
16
|
-
const normalizeAttrString = (str) => str?.trim().replace(/\s+/g, ' ');
|
|
17
17
|
exports.ScreenReaderOutputDisabledTooltip = utils_1.ESLintUtils.RuleCreator.withoutDocs({
|
|
18
18
|
create(context) {
|
|
19
19
|
return {
|
|
@@ -39,7 +39,7 @@ exports.ScreenReaderOutputDisabledTooltip = utils_1.ESLintUtils.RuleCreator.with
|
|
|
39
39
|
const ariaLabel = (0, get_attr_value_1.getAttrValue)(context, buttonElement.openingElement.attributes, 'aria-label');
|
|
40
40
|
if (tooltipContent &&
|
|
41
41
|
ariaLabel &&
|
|
42
|
-
|
|
42
|
+
(0, are_attrs_equal_1.areAttrsEqual)(tooltipContent, ariaLabel)) {
|
|
43
43
|
const buttonElementName = buttonElement.openingElement.name.name;
|
|
44
44
|
context.report({
|
|
45
45
|
node: openingElement,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sr_output_disabled_tooltip.js","sourceRoot":"","sources":["../../../../src/rules/a11y/sr_output_disabled_tooltip.ts"],"names":[],"mappings":";AAAA;;;;;;GAMG;;;AAEH,oDAAsE;AACtE,+DAA0D;
|
|
1
|
+
{"version":3,"file":"sr_output_disabled_tooltip.js","sourceRoot":"","sources":["../../../../src/rules/a11y/sr_output_disabled_tooltip.ts"],"names":[],"mappings":";AAAA;;;;;;GAMG;;;AAEH,oDAAsE;AACtE,+DAA0D;AAC1D,iEAA4D;AAE5D,MAAM,gBAAgB,GAAG,YAAY,CAAC;AACtC,MAAM,4BAA4B,GAAG,2BAA2B,CAAC;AACjE,MAAM,gBAAgB,GAAG,CAAC,eAAe,CAAC,CAAC;AAE9B,QAAA,iCAAiC,GAC5C,mBAAW,CAAC,WAAW,CAAC,WAAW,CAAC;IAClC,MAAM,CAAC,OAAO;QACZ,OAAO;YACL,UAAU,CAAC,IAAI;gBACb,MAAM,cAAc,GAAG,IAAI,CAAC,cAAc,CAAC;gBAE3C,IACE,cAAc,EAAE,IAAI,CAAC,IAAI,KAAK,eAAe;oBAC7C,cAAc,CAAC,IAAI,CAAC,IAAI,KAAK,gBAAgB,EAC7C,CAAC;oBACD,OAAO;gBACT,CAAC;gBAED,MAAM,cAAc,GAAG,IAAA,6BAAY,EACjC,OAAO,EACP,cAAc,CAAC,UAAU,EACzB,SAAS,CACV,CAAC;gBAEF,MAAM,sBAAsB,GAAG,cAAc,CAAC,UAAU,CAAC,IAAI,CAC3D,CAAC,IAAI,EAAiC,EAAE,CACtC,IAAI,CAAC,IAAI,KAAK,cAAc;oBAC5B,IAAI,CAAC,IAAI,CAAC,IAAI,KAAK,eAAe;oBAClC,IAAI,CAAC,IAAI,CAAC,IAAI,KAAK,4BAA4B,CAClD,CAAC;gBAEF,IAAI,sBAAsB,EAAE,CAAC;oBAC3B,OAAO;gBACT,CAAC;gBAED,MAAM,aAAa,GAAG,IAAI,CAAC,QAAQ,CAAC,IAAI,CACtC,CAAC,KAAK,EAAgC,EAAE,CACtC,KAAK,CAAC,IAAI,KA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yIAAyI;SAC5I;QACD,OAAO,EAAE,MAAM;QACf,MAAM,EAAE,EAAE;QACV,QAAQ,EAAE;YACR,0BAA0B,EACxB,uLAAuL;SAC1L;KACF;IACD,cAAc,EAAE,EAAE;CACnB,CAAC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const areAttrsEqual: (...strings: Array<string | undefined>) => boolean;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/*
|
|
3
|
+
* Licensed to Elasticsearch B.V. under one or more contributor
|
|
4
|
+
* license agreements. See the NOTICE file distributed with
|
|
5
|
+
* this work for additional information regarding copyright
|
|
6
|
+
* ownership. Elasticsearch B.V. licenses this file to you under
|
|
7
|
+
* the Apache License, Version 2.0 (the "License"); you may
|
|
8
|
+
* not use this file except in compliance with the License.
|
|
9
|
+
* You may obtain a copy of the License at
|
|
10
|
+
*
|
|
11
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
12
|
+
*
|
|
13
|
+
* Unless required by applicable law or agreed to in writing,
|
|
14
|
+
* software distributed under the License is distributed on an
|
|
15
|
+
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
|
16
|
+
* KIND, either express or implied. See the License for the
|
|
17
|
+
* specific language governing permissions and limitations
|
|
18
|
+
* under the License.
|
|
19
|
+
*/
|
|
20
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
21
|
+
exports.areAttrsEqual = void 0;
|
|
22
|
+
const normalizeAttrString = (str) => str?.trim().replace(/\s+/g, ' ');
|
|
23
|
+
const areAttrsEqual = (...strings) => {
|
|
24
|
+
const [first, ...rest] = strings.map(normalizeAttrString);
|
|
25
|
+
return rest.every((s) => s === first);
|
|
26
|
+
};
|
|
27
|
+
exports.areAttrsEqual = areAttrsEqual;
|
|
28
|
+
//# sourceMappingURL=are_attrs_equal.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"are_attrs_equal.js","sourceRoot":"","sources":["../../../src/utils/are_attrs_equal.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;GAiBG;;;AAEH,MAAM,mBAAmB,GAAG,CAAC,GAAY,EAAE,EAAE,CAAC,GAAG,EAAE,IAAI,EAAE,CAAC,OAAO,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;AAExE,MAAM,aAAa,GAAG,CAAC,GAAG,OAAkC,EAAW,EAAE;IAC9E,MAAM,CAAC,KAAK,EAAE,GAAG,IAAI,CAAC,GAAG,OAAO,CAAC,GAAG,CAAC,mBAAmB,CAAC,CAAC;IAC1D,OAAO,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,KAAK,KAAK,CAAC,CAAC;AACxC,CAAC,CAAC;AAHW,QAAA,aAAa,iBAGxB"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Configuration describing which components accept a `label` prop
|
|
3
|
+
* and the baseline set of accessibility prop names allowed across components.
|
|
4
|
+
*/
|
|
5
|
+
export type A11yConfig = {
|
|
6
|
+
interactiveComponentsWithLabel: ReadonlyArray<string>;
|
|
7
|
+
wrappingComponents: ReadonlyArray<string>;
|
|
8
|
+
baseA11yProps: ReadonlyArray<string>;
|
|
9
|
+
};
|
|
10
|
+
/**
|
|
11
|
+
* Compute the set of allowed accessibility prop names for a given component.
|
|
12
|
+
*
|
|
13
|
+
* - Always includes the provided `baseA11yProps`.
|
|
14
|
+
* - Conditionally includes `label` if the component is listed in either
|
|
15
|
+
* `interactiveComponentsWithLabel` or `wrappingComponents`.
|
|
16
|
+
* - Does **not** mutate the provided configuration; a new array is returned.
|
|
17
|
+
*
|
|
18
|
+
* @param componentName - The EUI component name (e.g., `'EuiButtonIcon'`).
|
|
19
|
+
* @param cfg - The accessibility configuration to use when resolving allowed props.
|
|
20
|
+
* @returns A new array of allowed prop names for `componentName`.
|
|
21
|
+
*
|
|
22
|
+
*/
|
|
23
|
+
export declare function getAllowedA11yPropNamesForComponent(componentName: string, cfg: A11yConfig): string[];
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/*
|
|
3
|
+
* Licensed to Elasticsearch B.V. under one or more contributor
|
|
4
|
+
* license agreements. See the NOTICE file distributed with
|
|
5
|
+
* this work for additional information regarding copyright
|
|
6
|
+
* ownership. Elasticsearch B.V. licenses this file to you under
|
|
7
|
+
* the Apache License, Version 2.0 (the "License"); you may
|
|
8
|
+
* not use this file except in compliance with the License.
|
|
9
|
+
* You may obtain a copy of the License at
|
|
10
|
+
*
|
|
11
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
12
|
+
*
|
|
13
|
+
* Unless required by applicable law or agreed to in writing,
|
|
14
|
+
* software distributed under the License is distributed on an
|
|
15
|
+
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
|
16
|
+
* KIND, either express or implied. See the License for the
|
|
17
|
+
* specific language governing permissions and limitations
|
|
18
|
+
* under the License.
|
|
19
|
+
*/
|
|
20
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
21
|
+
exports.getAllowedA11yPropNamesForComponent = getAllowedA11yPropNamesForComponent;
|
|
22
|
+
/**
|
|
23
|
+
* Compute the set of allowed accessibility prop names for a given component.
|
|
24
|
+
*
|
|
25
|
+
* - Always includes the provided `baseA11yProps`.
|
|
26
|
+
* - Conditionally includes `label` if the component is listed in either
|
|
27
|
+
* `interactiveComponentsWithLabel` or `wrappingComponents`.
|
|
28
|
+
* - Does **not** mutate the provided configuration; a new array is returned.
|
|
29
|
+
*
|
|
30
|
+
* @param componentName - The EUI component name (e.g., `'EuiButtonIcon'`).
|
|
31
|
+
* @param cfg - The accessibility configuration to use when resolving allowed props.
|
|
32
|
+
* @returns A new array of allowed prop names for `componentName`.
|
|
33
|
+
*
|
|
34
|
+
*/
|
|
35
|
+
function getAllowedA11yPropNamesForComponent(componentName, cfg) {
|
|
36
|
+
const componentsWithLabel = new Set([
|
|
37
|
+
...cfg.interactiveComponentsWithLabel,
|
|
38
|
+
...cfg.wrappingComponents,
|
|
39
|
+
]);
|
|
40
|
+
if (componentsWithLabel.has(componentName)) {
|
|
41
|
+
return [...cfg.baseA11yProps, 'label'];
|
|
42
|
+
}
|
|
43
|
+
return [...cfg.baseA11yProps];
|
|
44
|
+
}
|
|
45
|
+
//# sourceMappingURL=get_allowed_a11y_prop_names_for_component.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"get_allowed_a11y_prop_names_for_component.js","sourceRoot":"","sources":["../../../src/utils/get_allowed_a11y_prop_names_for_component.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;GAiBG;;AAyBH,kFAaC;AA1BD;;;;;;;;;;;;GAYG;AACH,SAAgB,mCAAmC,CACjD,aAAqB,EACrB,GAAe;IAEf,MAAM,mBAAmB,GAAG,IAAI,GAAG,CAAS;QAC1C,GAAG,GAAG,CAAC,8BAA8B;QACrC,GAAG,GAAG,CAAC,kBAAkB;KAC1B,CAAC,CAAC;IAEH,IAAI,mBAAmB,CAAC,GAAG,CAAC,aAAa,CAAC,EAAE,CAAC;QAC3C,OAAO,CAAC,GAAG,GAAG,CAAC,aAAa,EAAE,OAAO,CAAC,CAAC;IACzC,CAAC;IACD,OAAO,CAAC,GAAG,GAAG,CAAC,aAAa,CAAC,CAAC;AAChC,CAAC"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { TSESTree } from '@typescript-eslint/utils';
|
|
2
|
+
import { type A11yConfig } from './get_allowed_a11y_prop_names_for_component';
|
|
3
|
+
/**
|
|
4
|
+
* Determines whether a JSX element declares at least one **allowed**
|
|
5
|
+
* accessibility-related prop for a given component.
|
|
6
|
+
*
|
|
7
|
+
* Allowed prop names are resolved via {@link getAllowedA11yPropNamesForComponent},
|
|
8
|
+
* which combines baseline a11y props (e.g. `aria-*`) and conditionally adds
|
|
9
|
+
* `label` for components that support it per the provided configuration.
|
|
10
|
+
*
|
|
11
|
+
* Only plain `JSXAttribute` nodes are considered—spread attributes are ignored here.
|
|
12
|
+
*
|
|
13
|
+
* @param componentName - The component name being checked (e.g., `"EuiButtonIcon"`).
|
|
14
|
+
* @param attrs - The attributes array from a `JSXOpeningElement` (ESTree).
|
|
15
|
+
* @param cfg - Accessibility configuration that defines base props and which
|
|
16
|
+
* components may accept a `label` prop.
|
|
17
|
+
* @returns `true` if any attribute name on the element is in the allowed set; otherwise `false`.
|
|
18
|
+
*/
|
|
19
|
+
export declare function hasA11yPropForComponent(componentName: string, attrs: TSESTree.JSXOpeningElement['attributes'], cfg: A11yConfig): boolean;
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/*
|
|
3
|
+
* Licensed to Elasticsearch B.V. under one or more contributor
|
|
4
|
+
* license agreements. See the NOTICE file distributed with
|
|
5
|
+
* this work for additional information regarding copyright
|
|
6
|
+
* ownership. Elasticsearch B.V. licenses this file to you under
|
|
7
|
+
* the Apache License, Version 2.0 (the "License"); you may
|
|
8
|
+
* not use this file except in compliance with the License.
|
|
9
|
+
* You may obtain a copy of the License at
|
|
10
|
+
*
|
|
11
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
12
|
+
*
|
|
13
|
+
* Unless required by applicable law or agreed to in writing,
|
|
14
|
+
* software distributed under the License is distributed on an
|
|
15
|
+
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
|
16
|
+
* KIND, either express or implied. See the License for the
|
|
17
|
+
* specific language governing permissions and limitations
|
|
18
|
+
* under the License.
|
|
19
|
+
*/
|
|
20
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
21
|
+
exports.hasA11yPropForComponent = hasA11yPropForComponent;
|
|
22
|
+
const get_allowed_a11y_prop_names_for_component_1 = require("./get_allowed_a11y_prop_names_for_component");
|
|
23
|
+
/**
|
|
24
|
+
* Determines whether a JSX element declares at least one **allowed**
|
|
25
|
+
* accessibility-related prop for a given component.
|
|
26
|
+
*
|
|
27
|
+
* Allowed prop names are resolved via {@link getAllowedA11yPropNamesForComponent},
|
|
28
|
+
* which combines baseline a11y props (e.g. `aria-*`) and conditionally adds
|
|
29
|
+
* `label` for components that support it per the provided configuration.
|
|
30
|
+
*
|
|
31
|
+
* Only plain `JSXAttribute` nodes are considered—spread attributes are ignored here.
|
|
32
|
+
*
|
|
33
|
+
* @param componentName - The component name being checked (e.g., `"EuiButtonIcon"`).
|
|
34
|
+
* @param attrs - The attributes array from a `JSXOpeningElement` (ESTree).
|
|
35
|
+
* @param cfg - Accessibility configuration that defines base props and which
|
|
36
|
+
* components may accept a `label` prop.
|
|
37
|
+
* @returns `true` if any attribute name on the element is in the allowed set; otherwise `false`.
|
|
38
|
+
*/
|
|
39
|
+
function hasA11yPropForComponent(componentName, attrs, cfg) {
|
|
40
|
+
const allowed = new Set((0, get_allowed_a11y_prop_names_for_component_1.getAllowedA11yPropNamesForComponent)(componentName, cfg));
|
|
41
|
+
return attrs.some((attr) => attr.type === 'JSXAttribute' &&
|
|
42
|
+
attr.name.type === 'JSXIdentifier' &&
|
|
43
|
+
allowed.has(attr.name.name));
|
|
44
|
+
}
|
|
45
|
+
//# sourceMappingURL=has_a11y_prop_for_component.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"has_a11y_prop_for_component.js","sourceRoot":"","sources":["../../../src/utils/has_a11y_prop_for_component.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;GAiBG;;AAyBH,0DAcC;AApCD,2GAGqD;AAErD;;;;;;;;;;;;;;;GAeG;AAEH,SAAgB,uBAAuB,CACrC,aAAqB,EACrB,KAA+C,EAC/C,GAAe;IAEf,MAAM,OAAO,GAAG,IAAI,GAAG,CACrB,IAAA,+EAAmC,EAAC,aAAa,EAAE,GAAG,CAAC,CACxD,CAAC;IACF,OAAO,KAAK,CAAC,IAAI,CACf,CAAC,IAAI,EAAiC,EAAE,CACtC,IAAI,CAAC,IAAI,KAAK,cAAc;QAC5B,IAAI,CAAC,IAAI,CAAC,IAAI,KAAK,eAAe;QAClC,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,CAC9B,CAAC;AACJ,CAAC"}
|