@elastic/eslint-plugin-eui 2.16.0 → 3.0.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.
Files changed (35) hide show
  1. package/README.md +99 -3
  2. package/lib/cjs/index.js +4 -1
  3. package/lib/cjs/rules/button_group_no_invalid_children.d.ts +1 -1
  4. package/lib/cjs/rules/button_group_no_invalid_children.d.ts.map +1 -1
  5. package/lib/cjs/rules/button_group_no_invalid_children.js +76 -48
  6. package/lib/cjs/rules/button_group_selection_require_id.d.ts +3 -0
  7. package/lib/cjs/rules/button_group_selection_require_id.d.ts.map +1 -0
  8. package/lib/cjs/rules/button_group_selection_require_id.js +114 -0
  9. package/lib/cjs/rules/no_deprecated_icon_aliases.d.ts +54 -5
  10. package/lib/cjs/rules/no_deprecated_icon_aliases.d.ts.map +1 -1
  11. package/lib/cjs/rules/no_deprecated_icon_aliases.js +70 -8
  12. package/lib/cjs/utils/button_group_constants.d.ts +6 -0
  13. package/lib/cjs/utils/button_group_constants.d.ts.map +1 -0
  14. package/lib/cjs/utils/button_group_constants.js +19 -0
  15. package/lib/cjs/utils/collect_jsx_children.d.ts +3 -0
  16. package/lib/cjs/utils/collect_jsx_children.d.ts.map +1 -0
  17. package/lib/cjs/utils/collect_jsx_children.js +26 -0
  18. package/lib/esm/index.js +3 -0
  19. package/lib/esm/index.js.map +1 -1
  20. package/lib/esm/rules/button_group_no_invalid_children.d.ts +1 -1
  21. package/lib/esm/rules/button_group_no_invalid_children.js +81 -48
  22. package/lib/esm/rules/button_group_no_invalid_children.js.map +1 -1
  23. package/lib/esm/rules/button_group_selection_require_id.d.ts +2 -0
  24. package/lib/esm/rules/button_group_selection_require_id.js +118 -0
  25. package/lib/esm/rules/button_group_selection_require_id.js.map +1 -0
  26. package/lib/esm/rules/no_deprecated_icon_aliases.d.ts +54 -5
  27. package/lib/esm/rules/no_deprecated_icon_aliases.js +75 -6
  28. package/lib/esm/rules/no_deprecated_icon_aliases.js.map +1 -1
  29. package/lib/esm/utils/button_group_constants.d.ts +5 -0
  30. package/lib/esm/utils/button_group_constants.js +20 -0
  31. package/lib/esm/utils/button_group_constants.js.map +1 -0
  32. package/lib/esm/utils/collect_jsx_children.d.ts +2 -0
  33. package/lib/esm/utils/collect_jsx_children.js +21 -0
  34. package/lib/esm/utils/collect_jsx_children.js.map +1 -0
  35. package/package.json +1 -1
@@ -12,39 +12,32 @@ const utils_1 = require("@typescript-eslint/utils");
12
12
  const has_spread_1 = require("../utils/has_spread");
13
13
  const flat_map_1 = require("../utils/flat_map");
14
14
  const get_element_name_1 = require("../utils/get_element_name");
15
- const walk_jsx_children_1 = require("../utils/walk_jsx_children");
16
15
  const get_attr_value_1 = require("../utils/get_attr_value");
17
- const BUTTON_GROUP = 'EuiButtonGroup';
18
- const VALID_BUTTONS = new Set(['EuiButton', 'EuiButtonEmpty', 'EuiButtonIcon']);
19
- const VALID_WRAPPERS = new Set(['EuiToolTip', 'EuiPopover', 'EuiCopy']);
20
- const VALID_BUTTONS_LIST = Array.from(VALID_BUTTONS).join(', ');
21
- const VALID_WRAPPERS_LIST = Array.from(VALID_WRAPPERS).join(', ');
16
+ const collect_jsx_children_1 = require("../utils/collect_jsx_children");
17
+ const button_group_constants_1 = require("../utils/button_group_constants");
18
+ const VALID_WRAPPERS_LIST = Array.from(button_group_constants_1.VALID_WRAPPERS).join(', ');
22
19
  function isCustomComponent(name) {
23
20
  return name[0] === name[0].toUpperCase();
24
21
  }
25
- function collectJsxChildren(node, sourceCode) {
26
- const results = [];
27
- (0, walk_jsx_children_1.walkJsxChildren)(node, (leaf) => {
28
- if (leaf.type === 'JSXElement') {
29
- results.push(leaf);
30
- }
31
- }, { sourceCode });
32
- return results;
33
- }
34
- function reportInvalidWrapperChildren(wrapper, wrapperName, context) {
35
- const children = (0, flat_map_1.flatMap)(wrapper.children, (c) => collectJsxChildren(c, context.sourceCode));
22
+ function reportInvalidWrapperChildren(wrapper, wrapperName, context, validButtons, allowed, seenButtonTypes) {
23
+ const children = (0, flat_map_1.flatMap)(wrapper.children, (c) => (0, collect_jsx_children_1.collectJsxChildren)(c, context.sourceCode));
36
24
  for (const wrapperChild of children) {
37
25
  if ((0, has_spread_1.hasSpread)(wrapperChild.openingElement.attributes))
38
26
  continue;
39
27
  const wrapperChildName = (0, get_element_name_1.getElementName)(wrapperChild.openingElement);
40
- if (wrapperChildName === null || VALID_BUTTONS.has(wrapperChildName))
28
+ if (wrapperChildName === null)
29
+ continue;
30
+ if (validButtons.has(wrapperChildName)) {
31
+ seenButtonTypes?.add(wrapperChildName);
41
32
  continue;
33
+ }
42
34
  context.report({
43
35
  node: wrapperChild.openingElement,
44
- messageId: isCustomComponent(wrapperChildName)
36
+ messageId: isCustomComponent(wrapperChildName) &&
37
+ !button_group_constants_1.VALID_BUTTONS.has(wrapperChildName)
45
38
  ? 'invalidUnresolvableWrapperChild'
46
39
  : 'invalidWrapperChild',
47
- data: { name: wrapperChildName, wrapper: wrapperName },
40
+ data: { name: wrapperChildName, wrapper: wrapperName, allowed },
48
41
  });
49
42
  }
50
43
  }
@@ -54,28 +47,44 @@ exports.ButtonGroupNoInvalidChildren = utils_1.ESLintUtils.RuleCreator.withoutDo
54
47
  JSXElement(node) {
55
48
  const { openingElement } = node;
56
49
  if (openingElement.name.type !== 'JSXIdentifier' ||
57
- openingElement.name.name !== BUTTON_GROUP) {
50
+ openingElement.name.name !== button_group_constants_1.BUTTON_GROUP) {
58
51
  return;
59
52
  }
60
- // Only validate when the variant is "default" (or absent the default).
61
- // Rules for "segmented" and "selection" are added in later chunks.
53
+ // Validate "default", "segmented", and "selection" variants.
62
54
  // Dynamic variant values (variables) are conservatively skipped.
63
55
  const variant = (0, get_attr_value_1.findAttrValue)(context, openingElement.attributes, 'variant');
64
- if (variant !== undefined && variant !== 'default')
56
+ if (variant !== undefined &&
57
+ variant !== 'default' &&
58
+ variant !== 'segmented' &&
59
+ variant !== 'selection')
65
60
  return;
66
- const children = (0, flat_map_1.flatMap)(node.children, (c) => collectJsxChildren(c, context.sourceCode));
61
+ const isSegmented = variant === 'segmented';
62
+ const isSelection = variant === 'selection';
63
+ const validButtons = isSegmented
64
+ ? button_group_constants_1.SEGMENTED_VALID_BUTTONS
65
+ : isSelection
66
+ ? button_group_constants_1.SELECTION_VALID_BUTTONS
67
+ : button_group_constants_1.VALID_BUTTONS;
68
+ const allowed = Array.from(validButtons).join(', ');
69
+ const children = (0, flat_map_1.flatMap)(node.children, (c) => (0, collect_jsx_children_1.collectJsxChildren)(c, context.sourceCode));
67
70
  if (children.length === 0)
68
71
  return;
72
+ // Collect seen button types for the segmented/selection mixed-type check.
73
+ // Populated during the main loop to avoid a second traversal.
74
+ const seenButtonTypes = isSegmented || isSelection ? new Set() : null;
69
75
  for (const child of children) {
70
76
  const name = (0, get_element_name_1.getElementName)(child.openingElement);
71
77
  if (name === null)
72
78
  continue;
73
- if (VALID_BUTTONS.has(name))
79
+ if (validButtons.has(name)) {
80
+ seenButtonTypes?.add(name);
74
81
  continue;
75
- if (VALID_WRAPPERS.has(name)) {
82
+ }
83
+ if (button_group_constants_1.VALID_WRAPPERS.has(name)) {
76
84
  if (name === 'EuiToolTip') {
77
85
  // Validate JSX children (expanding fragments/conditionals).
78
- reportInvalidWrapperChildren(child, name, context);
86
+ // Also collects button types for the segmented mixed-type check.
87
+ reportInvalidWrapperChildren(child, name, context, validButtons, allowed, seenButtonTypes ?? undefined);
79
88
  }
80
89
  else if (name === 'EuiPopover') {
81
90
  // The trigger is the `button` prop, not JSX children (panel
@@ -86,40 +95,48 @@ exports.ButtonGroupNoInvalidChildren = utils_1.ESLintUtils.RuleCreator.withoutDo
86
95
  attr.name.type === 'JSXIdentifier' &&
87
96
  attr.name.name === 'button');
88
97
  if (buttonProp?.value != null) {
89
- const triggerElements = collectJsxChildren(buttonProp.value, context.sourceCode);
98
+ const triggerElements = (0, collect_jsx_children_1.collectJsxChildren)(buttonProp.value, context.sourceCode);
90
99
  for (const triggerElement of triggerElements) {
91
100
  if ((0, has_spread_1.hasSpread)(triggerElement.openingElement.attributes))
92
101
  continue;
93
102
  const triggerElementName = (0, get_element_name_1.getElementName)(triggerElement.openingElement);
94
- if (triggerElementName === null ||
95
- VALID_BUTTONS.has(triggerElementName))
103
+ if (triggerElementName === null)
104
+ continue;
105
+ if (validButtons.has(triggerElementName)) {
106
+ seenButtonTypes?.add(triggerElementName);
96
107
  continue;
108
+ }
97
109
  if (triggerElementName === 'EuiToolTip') {
98
110
  // EuiToolTip wrapping the trigger — validate its children.
99
- const tooltipChildren = (0, flat_map_1.flatMap)(triggerElement.children, (c) => collectJsxChildren(c, context.sourceCode));
111
+ const tooltipChildren = (0, flat_map_1.flatMap)(triggerElement.children, (c) => (0, collect_jsx_children_1.collectJsxChildren)(c, context.sourceCode));
100
112
  for (const tooltipChild of tooltipChildren) {
101
113
  if ((0, has_spread_1.hasSpread)(tooltipChild.openingElement.attributes))
102
114
  continue;
103
115
  const tooltipChildName = (0, get_element_name_1.getElementName)(tooltipChild.openingElement);
104
- if (tooltipChildName === null ||
105
- VALID_BUTTONS.has(tooltipChildName))
116
+ if (tooltipChildName === null)
117
+ continue;
118
+ if (validButtons.has(tooltipChildName)) {
119
+ seenButtonTypes?.add(tooltipChildName);
106
120
  continue;
121
+ }
107
122
  context.report({
108
123
  node: tooltipChild.openingElement,
109
- messageId: isCustomComponent(tooltipChildName)
124
+ messageId: isCustomComponent(tooltipChildName) &&
125
+ !button_group_constants_1.VALID_BUTTONS.has(tooltipChildName)
110
126
  ? 'invalidUnresolvablePopoverButton'
111
127
  : 'invalidPopoverButton',
112
- data: { name: tooltipChildName },
128
+ data: { name: tooltipChildName, allowed },
113
129
  });
114
130
  }
115
131
  continue;
116
132
  }
117
133
  context.report({
118
134
  node: triggerElement.openingElement,
119
- messageId: isCustomComponent(triggerElementName)
135
+ messageId: isCustomComponent(triggerElementName) &&
136
+ !button_group_constants_1.VALID_BUTTONS.has(triggerElementName)
120
137
  ? 'invalidUnresolvablePopoverButton'
121
138
  : 'invalidPopoverButton',
122
- data: { name: triggerElementName },
139
+ data: { name: triggerElementName, allowed },
123
140
  });
124
141
  }
125
142
  }
@@ -128,7 +145,8 @@ exports.ButtonGroupNoInvalidChildren = utils_1.ESLintUtils.RuleCreator.withoutDo
128
145
  // Children is a render prop: {(copy) => <EuiButton />}
129
146
  // ArrowFunctionExpression with expression body is expanded by
130
147
  // collectJsxChildren, so validation works the same as EuiToolTip.
131
- reportInvalidWrapperChildren(child, name, context);
148
+ // Also collects button types for the segmented mixed-type check.
149
+ reportInvalidWrapperChildren(child, name, context, validButtons, allowed, seenButtonTypes ?? undefined);
132
150
  }
133
151
  continue;
134
152
  }
@@ -138,10 +156,21 @@ exports.ButtonGroupNoInvalidChildren = utils_1.ESLintUtils.RuleCreator.withoutDo
138
156
  continue;
139
157
  context.report({
140
158
  node: child.openingElement,
141
- messageId: isCustomComponent(name)
159
+ messageId: isCustomComponent(name) && !button_group_constants_1.VALID_BUTTONS.has(name)
142
160
  ? 'invalidUnresolvableChild'
143
161
  : 'invalidChild',
144
- data: { name },
162
+ data: { name, allowed },
163
+ });
164
+ }
165
+ // For segmented/selection, all children must be the same button type —
166
+ // either all EuiButton or all EuiButtonIcon. Types are collected during
167
+ // the main loop above, including from EuiToolTip, EuiPopover, and EuiCopy.
168
+ if (seenButtonTypes?.has('EuiButton') &&
169
+ seenButtonTypes.has('EuiButtonIcon')) {
170
+ context.report({
171
+ node: openingElement,
172
+ messageId: 'invalidMixedTypes',
173
+ data: { variant: isSelection ? 'selection' : 'segmented' },
145
174
  });
146
175
  }
147
176
  },
@@ -150,18 +179,18 @@ exports.ButtonGroupNoInvalidChildren = utils_1.ESLintUtils.RuleCreator.withoutDo
150
179
  meta: {
151
180
  type: 'problem',
152
181
  docs: {
153
- description: `Enforce that EuiButtonGroup children are ${VALID_BUTTONS_LIST}, or a supported wrapper (${VALID_WRAPPERS_LIST})`,
182
+ description: `Enforce that EuiButtonGroup children are valid button components, or a supported wrapper (${VALID_WRAPPERS_LIST})`,
154
183
  },
155
184
  schema: [],
156
185
  messages: {
157
186
  invalidChild: [
158
187
  `{{ name }} is not a valid child of EuiButtonGroup.`,
159
- `Allowed children: ${VALID_BUTTONS_LIST}.`,
188
+ `Allowed children: {{ allowed }}.`,
160
189
  `Allowed wrappers: ${VALID_WRAPPERS_LIST}.`,
161
190
  ].join(' '),
162
191
  invalidUnresolvableChild: [
163
192
  `{{ name }} cannot be verified as a valid child of EuiButtonGroup.`,
164
- `Allowed children: ${VALID_BUTTONS_LIST}.`,
193
+ `Allowed children: {{ allowed }}.`,
165
194
  `Allowed wrappers: ${VALID_WRAPPERS_LIST}.`,
166
195
  `If {{ name }} is a shared button wrapper component only containing`,
167
196
  `valid button children, suppress this rule inline with a comment`,
@@ -170,11 +199,11 @@ exports.ButtonGroupNoInvalidChildren = utils_1.ESLintUtils.RuleCreator.withoutDo
170
199
  ].join(' '),
171
200
  invalidPopoverButton: [
172
201
  `{{ name }} is not a valid trigger button for EuiPopover in EuiButtonGroup.`,
173
- `The \`button\` prop must be ${VALID_BUTTONS_LIST}.`,
202
+ `The \`button\` prop must be {{ allowed }}.`,
174
203
  ].join(' '),
175
204
  invalidUnresolvablePopoverButton: [
176
205
  `{{ name }} cannot be verified as a valid trigger button for EuiPopover in EuiButtonGroup.`,
177
- `The \`button\` prop must be ${VALID_BUTTONS_LIST}.`,
206
+ `The \`button\` prop must be {{ allowed }}.`,
178
207
  `If {{ name }} is a shared button wrapper component only containing`,
179
208
  `valid button children, suppress this rule inline with a comment`,
180
209
  `explaining why it's valid.`,
@@ -182,15 +211,19 @@ exports.ButtonGroupNoInvalidChildren = utils_1.ESLintUtils.RuleCreator.withoutDo
182
211
  ].join(' '),
183
212
  invalidWrapperChild: [
184
213
  `{{ name }} inside {{ wrapper }} is not a valid button for EuiButtonGroup.`,
185
- `The wrapper must contain ${VALID_BUTTONS_LIST}.`,
214
+ `The wrapper must contain {{ allowed }}.`,
186
215
  ].join(' '),
187
216
  invalidUnresolvableWrapperChild: [
188
217
  `{{ name }} inside {{ wrapper }} cannot be verified as a valid button for EuiButtonGroup.`,
189
- `The wrapper must contain ${VALID_BUTTONS_LIST}.`,
218
+ `The wrapper must contain {{ allowed }}.`,
190
219
  `If {{ name }} is a shared button wrapper component, suppress this rule inline`,
191
220
  `with a comment explaining why it renders valid button children:`,
192
221
  `// eslint-disable-next-line @elastic/eui/button-group-no-invalid-children -- SaveButton wraps EuiButton`,
193
222
  ].join(' '),
223
+ invalidMixedTypes: [
224
+ `EuiButtonGroup with variant="{{ variant }}" must use a single button type throughout.`,
225
+ `Use either all EuiButton or all EuiButtonIcon children — not both.`,
226
+ ].join(' '),
194
227
  },
195
228
  },
196
229
  defaultOptions: [],
@@ -1 +1 @@
1
- {"version":3,"file":"button_group_no_invalid_children.js","sourceRoot":"","sources":["../../../src/rules/button_group_no_invalid_children.ts"],"names":[],"mappings":";AAAA;;;;;;GAMG;;;AAEH,oDAIkC;AAClC,oDAAgD;AAChD,gDAA4C;AAC5C,gEAA2D;AAC3D,kEAA6D;AAC7D,4DAAwD;AAExD,MAAM,YAAY,GAAG,gBAAgB,CAAC;AACtC,MAAM,aAAa,GAAG,IAAI,GAAG,CAAC,CAAC,WAAW,EAAE,gBAAgB,EAAE,eAAe,CAAC,CAAC,CAAC;AAChF,MAAM,cAAc,GAAG,IAAI,GAAG,CAAC,CAAC,YAAY,EAAE,YAAY,EAAE,SAAS,CAAC,CAAC,CAAC;AAExE,MAAM,kBAAkB,GAAG,KAAK,CAAC,IAAI,CAAC,aAAa,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AAChE,MAAM,mBAAmB,GAAG,KAAK,CAAC,IAAI,CAAC,cAAc,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AAElE,SAAS,iBAAiB,CAAC,IAAY;IACrC,OAAO,IAAI,CAAC,CAAC,CAAC,KAAK,IAAI,CAAC,CAAC,CAAC,CAAC,WAAW,EAAE,CAAC;AAC3C,CAAC;A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,MAAM,EAAE,EAAE;QACV,QAAQ,EAAE;YACR,YAAY,EAAE;gBACZ,oDAAoD;gBACpD,qBAAqB,kBAAkB,GAAG;gBAC1C,qBAAqB,mBAAmB,GAAG;aAC5C,CAAC,IAAI,CAAC,GAAG,CAAC;YACX,wBAAwB,EAAE;gBACxB,mEAAmE;gBACnE,qBAAqB,kBAAkB,GAAG;gBAC1C,qBAAqB,mBAAmB,GAAG;gBAC3C,oEAAoE;gBACpE,iEAAiE;gBACjE,4BAA4B;gBAC5B,8GAA8G;aAC/G,CAAC,IAAI,CAAC,GAAG,CAAC;YACX,oBAAoB,EAAE;gBACpB,4EAA4E;gBAC5E,+BAA+B,kBAAkB,GAAG;aACrD,CAAC,IAAI,CAAC,GAAG,CAAC;YACX,gCAAgC,EAAE;gBAChC,2FAA2F;gBAC3F,+BAA+B,kBAAkB,GAAG;gBACpD,oEAAoE;gBACpE,iEAAiE;gBACjE,4BAA4B;gBAC5B,8GAA8G;aAC/G,CAAC,IAAI,CAAC,GAAG,CAAC;YACX,mBAAmB,EAAE;gBACnB,2EAA2E;gBAC3E,4BAA4B,kBAAkB,GAAG;aAClD,CAAC,IAAI,CAAC,GAAG,CAAC;YACX,+BAA+B,EAAE;gBAC/B,0FAA0F;gBAC1F,4BAA4B,kBAAkB,GAAG;gBACjD,+EAA+E;gBAC/E,iEAAiE;gBACjE,yGAAyG;aAC1G,CAAC,IAAI,CAAC,GAAG,CAAC;SACZ;KACF;IACD,cAAc,EAAE,EAAE;CACnB,CACF,CAAC"}
1
+ {"version":3,"file":"button_group_no_invalid_children.js","sourceRoot":"","sources":["../../../src/rules/button_group_no_invalid_children.ts"],"names":[],"mappings":";AAAA;;;;;;GAMG;;;AAEH,oDAIkC;AAClC,oDAAgD;AAChD,gDAA4C;AAC5C,gEAA2D;AAC3D,4DAAwD;AACxD,wEAAmE;AACnE,4EAMyC;AAEzC,MAAM,mBAAmB,GAAG,KAAK,CAAC,IAAI,CAAC,uCAAc,CAAC,CAAC,I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TSESLint } from '@typescript-eslint/utils';
2
+ export declare const ButtonGroupSelectionRequireId: TSESLint.RuleModule<"missingId", [], unknown, TSESLint.RuleListener>;
@@ -0,0 +1,118 @@
1
+ "use strict";
2
+ /*
3
+ * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
4
+ * or more contributor license agreements. Licensed under the Elastic License
5
+ * 2.0 and the Server Side Public License, v 1; you may not use this file except
6
+ * in compliance with, at your election, the Elastic License 2.0 or the Server
7
+ * Side Public License, v 1.
8
+ */
9
+ Object.defineProperty(exports, "__esModule", { value: true });
10
+ exports.ButtonGroupSelectionRequireId = void 0;
11
+ const utils_1 = require("@typescript-eslint/utils");
12
+ const has_spread_1 = require("../utils/has_spread");
13
+ const flat_map_1 = require("../utils/flat_map");
14
+ const get_element_name_1 = require("../utils/get_element_name");
15
+ const get_attr_value_1 = require("../utils/get_attr_value");
16
+ const has_meaningful_attr_1 = require("../utils/has_meaningful_attr");
17
+ const collect_jsx_children_1 = require("../utils/collect_jsx_children");
18
+ const button_group_constants_1 = require("../utils/button_group_constants");
19
+ function checkButtonForId(element, context) {
20
+ const name = (0, get_element_name_1.getElementName)(element.openingElement);
21
+ if (name === null || !button_group_constants_1.SELECTION_VALID_BUTTONS.has(name))
22
+ return;
23
+ const { attributes } = element.openingElement;
24
+ if ((0, has_meaningful_attr_1.hasMeaningfulAttr)(element.openingElement, 'id'))
25
+ return;
26
+ if ((0, has_spread_1.hasSpread)(attributes))
27
+ return;
28
+ context.report({
29
+ node: element.openingElement,
30
+ messageId: 'missingId',
31
+ data: { name },
32
+ });
33
+ }
34
+ exports.ButtonGroupSelectionRequireId = utils_1.ESLintUtils.RuleCreator.withoutDocs({
35
+ create(context) {
36
+ return {
37
+ JSXElement(node) {
38
+ const { openingElement } = node;
39
+ if (openingElement.name.type !== 'JSXIdentifier' ||
40
+ openingElement.name.name !== button_group_constants_1.BUTTON_GROUP) {
41
+ return;
42
+ }
43
+ // Only validate variant="selection". Dynamic or other variants are skipped.
44
+ const variant = (0, get_attr_value_1.findAttrValue)(context, openingElement.attributes, 'variant');
45
+ if (variant !== 'selection')
46
+ return;
47
+ const children = (0, flat_map_1.flatMap)(node.children, (c) => (0, collect_jsx_children_1.collectJsxChildren)(c, context.sourceCode));
48
+ if (children.length === 0)
49
+ return;
50
+ for (const child of children) {
51
+ const name = (0, get_element_name_1.getElementName)(child.openingElement);
52
+ if (name === null)
53
+ continue;
54
+ if (button_group_constants_1.SELECTION_VALID_BUTTONS.has(name)) {
55
+ checkButtonForId(child, context);
56
+ continue;
57
+ }
58
+ if (button_group_constants_1.VALID_WRAPPERS.has(name)) {
59
+ if (name === 'EuiToolTip') {
60
+ const wrapperChildren = (0, flat_map_1.flatMap)(child.children, (c) => (0, collect_jsx_children_1.collectJsxChildren)(c, context.sourceCode));
61
+ for (const wrapperChild of wrapperChildren) {
62
+ checkButtonForId(wrapperChild, context);
63
+ }
64
+ }
65
+ else if (name === 'EuiPopover') {
66
+ const buttonProp = child.openingElement.attributes.find((attr) => attr.type === 'JSXAttribute' &&
67
+ attr.name.type === 'JSXIdentifier' &&
68
+ attr.name.name === 'button');
69
+ if (buttonProp?.value != null) {
70
+ const triggerElements = (0, collect_jsx_children_1.collectJsxChildren)(buttonProp.value, context.sourceCode);
71
+ for (const triggerElement of triggerElements) {
72
+ const triggerName = (0, get_element_name_1.getElementName)(triggerElement.openingElement);
73
+ if (triggerName === null)
74
+ continue;
75
+ if (button_group_constants_1.SELECTION_VALID_BUTTONS.has(triggerName)) {
76
+ checkButtonForId(triggerElement, context);
77
+ continue;
78
+ }
79
+ if (triggerName === 'EuiToolTip') {
80
+ // EuiToolTip wrapping the popover trigger — check its children.
81
+ const tooltipChildren = (0, flat_map_1.flatMap)(triggerElement.children, (c) => (0, collect_jsx_children_1.collectJsxChildren)(c, context.sourceCode));
82
+ for (const tooltipChild of tooltipChildren) {
83
+ checkButtonForId(tooltipChild, context);
84
+ }
85
+ }
86
+ }
87
+ }
88
+ }
89
+ else if (name === 'EuiCopy') {
90
+ // Children is a render prop; walkJsxChildren expands it.
91
+ const wrapperChildren = (0, flat_map_1.flatMap)(child.children, (c) => (0, collect_jsx_children_1.collectJsxChildren)(c, context.sourceCode));
92
+ for (const wrapperChild of wrapperChildren) {
93
+ checkButtonForId(wrapperChild, context);
94
+ }
95
+ }
96
+ continue;
97
+ }
98
+ // Non-button, non-wrapper children are skipped — the other rule handles those.
99
+ }
100
+ },
101
+ };
102
+ },
103
+ meta: {
104
+ type: 'problem',
105
+ docs: {
106
+ description: 'Enforce that EuiButtonGroup children have an id prop when variant="selection"',
107
+ },
108
+ schema: [],
109
+ messages: {
110
+ missingId: [
111
+ `{{ name }} inside EuiButtonGroup with variant="selection" is missing a required id prop.`,
112
+ `Each button must have a unique id so the group can track selection state.`,
113
+ ].join(' '),
114
+ },
115
+ },
116
+ defaultOptions: [],
117
+ });
118
+ //# sourceMappingURL=button_group_selection_require_id.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"button_group_selection_require_id.js","sourceRoot":"","sources":["../../../src/rules/button_group_selection_require_id.ts"],"names":[],"mappings":";AAAA;;;;;;GAMG;;;AAEH,oDAIkC;AAClC,oDAAgD;AAChD,gDAA4C;AAC5C,gEAA2D;AAC3D,4DAAwD;AACxD,sEAAiE;AACjE,wEAAmE;AACnE,4EAIyC;AAEzC,SAAS,gBAAgB,CAEvB,OAA4B,EAAE,OAAiB;IAC/C,MAAM,IAAI,GAAG,IAAA,iCAAc,EAAC,OAAO,CAAC,cAAc,CAAC,CAAC;IACpD,IAAI,IAAI,KAAK,IAAI,IAAI,CAAC,gDAAuB,CAAC,GAAG,CAAC,IAAI,CAAC;QAAE,OAAO;IAEhE,MAAM,EAAE,UAAU,EAAE,GAAG,OAAO,CAAC,cAAc,CAAC;IAC9C,IAAI,IAAA,uCAAiB,EAAC,OAAO,CAAC,cAAc,EAAE,IAAI,CAAC;QAAE,OAAO;IAC5D,IAAI,IAAA,sBAAS,EAAC,UAAU,CAAC;QAAE,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EACvB,CAAC,CAAC,EAAE,EAAE,CAAC,IAAA,yCAAkB,EAAC,CAAC,EAAE,OAAO,CAAC,UAAU,CAAC,CACjD,CAAC;wCACF,KAAK,MAAM,YAAY,IAAI,eAAe,EAAE,CAAC;4CAC3C,gBAAgB,CAAC,YAAY,EAAE,OAAO,CAAC,CAAC;wCAC1C,CAAC;oCACH,CAAC;gCACH,CAAC;4BACH,CAAC;wBACH,CAAC;6BAAM,IAAI,IAAI,KAAK,SAAS,EAAE,CAAC;4BAC9B,yDAAyD;4BACzD,MAAM,eAAe,GAAG,IAAA,kBAAO,EAAC,KAAK,CAAC,QAAQ,EAAE,CAAC,CAAC,EAAE,EAAE,CACpD,IAAA,yCAAkB,EAAC,CAAC,EAAE,OAAO,CAAC,UAAU,CAAC,CAC1C,CAAC;4BACF,KAAK,MAAM,YAAY,IAAI,eAAe,EAAE,CAAC;gCAC3C,gBAAgB,CAAC,YAAY,EAAE,OAAO,CAAC,CAAC;4BAC1C,CAAC;wBACH,CAAC;wBACD,SAAS;oBACX,CAAC;oBAED,+EAA+E;gBACjF,CAAC;YACH,CAAC;SACF,CAAC;IACJ,CAAC;IACD,IAAI,EAAE;QACJ,IAAI,EAAE,SAAS;QACf,IAAI,EAAE;YACJ,WAAW,EACT,+EAA+E;SAClF;QACD,MAAM,EAAE,EAAE;QACV,QAAQ,EAAE;YACR,SAAS,EAAE;gBACT,0FAA0F;gBAC1F,2EAA2E;aAC5E,CAAC,IAAI,CAAC,GAAG,CAAC;SACZ;KACF;IACD,cAAc,EAAE,EAAE;CACnB,CAAC,CAAC"}
@@ -1,7 +1,11 @@
1
1
  import { ESLintUtils } from '@typescript-eslint/utils';
2
2
  export declare const DEPRECATED_ICON_ALIASES: {
3
3
  readonly alert: "warning";
4
+ readonly analyzeEvent: "cube";
4
5
  readonly anomalyChart: "chartAnomaly";
6
+ readonly anomalySwimLane: "chartHeatmap";
7
+ readonly annotation: "flag";
8
+ readonly apps: "grid";
5
9
  readonly apmTrace: "chartWaterfall";
6
10
  readonly arrowDown: "chevronSingleDown";
7
11
  readonly arrowEnd: "chevronLimitRight";
@@ -15,9 +19,15 @@ export declare const DEPRECATED_ICON_ALIASES: {
15
19
  readonly changePointDetection: "chartChangePoint";
16
20
  readonly checkInCircleFilled: "checkCircleFill";
17
21
  readonly cheer: "popper";
22
+ readonly cloudDrizzle: "cloudRain";
23
+ readonly cloudStormy: "cloudBolt";
24
+ readonly cloudSunny: "cloudSun";
18
25
  readonly color: "paintBucket";
19
26
  readonly compute: "processor";
20
27
  readonly console: "commandLine";
28
+ readonly container: "package";
29
+ readonly continuityAbove: "upload";
30
+ readonly continuityWithin: "maximize";
21
31
  readonly contrastHigh: "contrastFill";
22
32
  readonly controlsHorizontal: "controls";
23
33
  readonly controlsVertical: "controls";
@@ -64,6 +74,7 @@ export declare const DEPRECATED_ICON_ALIASES: {
64
74
  readonly editorUnorderedList: "listBullet";
65
75
  readonly email: "mail";
66
76
  readonly eql: "query";
77
+ readonly esqlVis: "query";
67
78
  readonly errorFilled: "errorFill";
68
79
  readonly exit: "logOut";
69
80
  readonly expand: "maximize";
@@ -73,15 +84,23 @@ export declare const DEPRECATED_ICON_ALIASES: {
73
84
  readonly eyeClosed: "eyeSlash";
74
85
  readonly fieldStatistics: "tableInfo";
75
86
  readonly filterInCircle: "filter";
87
+ readonly fold: "minimize";
76
88
  readonly folderCheck: "check";
89
+ readonly folderClose: "folder";
90
+ readonly folderClosed: "folder";
77
91
  readonly folderOpened: "folderOpen";
92
+ readonly frameNext: "chevronSingleRight";
93
+ readonly framePrevious: "chevronSingleLeft";
78
94
  readonly glasses: "readOnly";
95
+ readonly help: "question";
79
96
  readonly grab: "dragVertical";
80
97
  readonly grabHorizontal: "dragHorizontal";
81
98
  readonly grabOmnidirectional: "drag";
82
99
  readonly heatmap: "chartHeatmap";
83
100
  readonly importAction: "download";
101
+ readonly index: "table";
84
102
  readonly indexClose: "tableCross";
103
+ readonly ip: "tokenIP";
85
104
  readonly indexEdit: "tablePencil";
86
105
  readonly indexFlush: "chartThreshold";
87
106
  readonly indexMapping: "mapping";
@@ -91,6 +110,7 @@ export declare const DEPRECATED_ICON_ALIASES: {
91
110
  readonly indexTemporary: "tableTime";
92
111
  readonly invert: "contrast";
93
112
  readonly kqlField: "queryField";
113
+ readonly kqlFunction: "push";
94
114
  readonly kqlOperand: "queryOperand";
95
115
  readonly kqlSelector: "querySelector";
96
116
  readonly kqlValue: "queryValue";
@@ -103,20 +123,27 @@ export declare const DEPRECATED_ICON_ALIASES: {
103
123
  readonly listAdd: "plusCircle";
104
124
  readonly logPatternAnalysis: "pattern";
105
125
  readonly logRateAnalysis: "chartBarVertical";
126
+ readonly logstashFilter: "filter";
106
127
  readonly logstashIf: "if";
128
+ readonly logstashInput: "download";
129
+ readonly logstashOutput: "upload";
107
130
  readonly logstashQueue: "queue";
108
131
  readonly magnifyWithExclamation: "magnifyExclamation";
109
132
  readonly magnifyWithMinus: "magnifyMinus";
110
133
  readonly magnifyWithPlus: "magnifyPlus";
111
134
  readonly mapMarker: "waypoint";
135
+ readonly menuDown: "transitionBottomOut";
136
+ readonly menuUp: "transitionTopOut";
112
137
  readonly minusInCircle: "minusCircle";
113
138
  readonly minusInCircleFilled: "minusCircle";
114
139
  readonly minusInSquare: "minusSquare";
140
+ readonly namespace: "kubernetesNamespace";
115
141
  readonly newChat: "plusCircle";
116
142
  readonly node: "vectorTriangle";
117
143
  readonly offline: "wifiSlash";
118
144
  readonly online: "wifi";
119
145
  readonly pagesSelect: "documentsCheck";
146
+ readonly payment: "money";
120
147
  readonly pinFilled: "pinFill";
121
148
  readonly pipeBreaks: "lineBreak";
122
149
  readonly pipeNoBreaks: "lineBreakSlash";
@@ -126,19 +153,30 @@ export declare const DEPRECATED_ICON_ALIASES: {
126
153
  readonly plusInSquare: "plusSquare";
127
154
  readonly popout: "external";
128
155
  readonly productRobot: "productAgent";
129
- readonly push: "send";
130
156
  readonly returnKey: "return";
131
157
  readonly search: "magnify";
132
158
  readonly securitySignal: "radar";
159
+ readonly sessionViewer: "commandLine";
160
+ readonly singleMetricViewer: "chartArea";
161
+ readonly spaces: "grid";
133
162
  readonly starEmpty: "star";
163
+ readonly starEmptySpace: "star";
164
+ readonly starFillSpace: "starFill";
134
165
  readonly starFilled: "starFill";
135
- readonly starFilledSpace: "starFillSpace";
136
- readonly starMinusFilled: "starMinusFill";
137
- readonly starPlusFilled: "starPlusFill";
166
+ readonly starFilledSpace: "starFill";
167
+ readonly starMinusEmpty: "star";
168
+ readonly starMinusFill: "starFill";
169
+ readonly starMinusFilled: "starFill";
170
+ readonly starPlusEmpty: "star";
171
+ readonly starPlusFill: "starFill";
172
+ readonly starPlusFilled: "starFill";
138
173
  readonly stopFilled: "stopFill";
174
+ readonly stats: "chartLine";
139
175
  readonly streamsClassic: "productStreamsClassic";
140
176
  readonly streamsWired: "productStreamsWired";
177
+ readonly string: "tokenString";
141
178
  readonly submodule: "merge";
179
+ readonly tableOfContents: "listBullet";
142
180
  readonly tableDensityCompact: "tableDensityHigh";
143
181
  readonly tableDensityExpanded: "tableDensityLow";
144
182
  readonly tableDensityNormal: "table";
@@ -148,6 +186,7 @@ export declare const DEPRECATED_ICON_ALIASES: {
148
186
  readonly timeslider: "clockControl";
149
187
  readonly tokenDenseVector: "tokenVectorDense";
150
188
  readonly training: "presentation";
189
+ readonly unfold: "maximize";
151
190
  readonly unlink: "linkSlash";
152
191
  readonly userAvatar: "user";
153
192
  readonly vector: "vectorSquare";
@@ -158,6 +197,7 @@ export declare const DEPRECATED_ICON_ALIASES: {
158
197
  readonly visBarVertical: "chartBarVertical";
159
198
  readonly visBarVerticalStacked: "chartBarVerticalStack";
160
199
  readonly visGauge: "chartGauge";
200
+ readonly visGoal: "chartGauge";
161
201
  readonly visLine: "chartLine";
162
202
  readonly visMapCoordinate: "waypoint";
163
203
  readonly visMapRegion: "map";
@@ -166,8 +206,17 @@ export declare const DEPRECATED_ICON_ALIASES: {
166
206
  readonly visTable: "table";
167
207
  readonly visTagCloud: "chartTagCloud";
168
208
  readonly visText: "text";
209
+ readonly visTimelion: "productTimelion";
169
210
  readonly visVega: "code";
211
+ readonly visVisualBuilder: "productTSVB";
170
212
  readonly warningFilled: "warningFill";
213
+ readonly wordWrap: "lineBreak";
214
+ readonly wordWrapDisabled: "lineBreakSlash";
171
215
  };
172
216
  export declare const DEPRECATED_ICONS_WITHOUT_REPLACEMENT: ReadonlySet<string>;
173
- export declare const NoDeprecatedIconAliases: ESLintUtils.RuleModule<"deprecatedIcon" | "deprecatedIconAlias", [], unknown, ESLintUtils.RuleListener>;
217
+ export declare const DEPRECATED_ICONS_WITH_GUIDANCE: {
218
+ readonly folderExclamation: "Use `linkSlash` for unlink actions or `hourglass` for Kibana Cases status.";
219
+ readonly stopFill: "Use `EuiColorPickerSwatch` for a color chip or `stop` otherwise.";
220
+ readonly stopSlash: "Use `EuiColorPickerSwatch` for no/transparent color or `stop` otherwise.";
221
+ };
222
+ export declare const NoDeprecatedIconAliases: ESLintUtils.RuleModule<"deprecatedIcon" | "deprecatedIconAlias" | "deprecatedIconGuidance", [], unknown, ESLintUtils.RuleListener>;