Repository navigation
[eslint-plugin] update button-group-no-invalid-children rule to support segmented variant - #9890
Conversation
There was a problem hiding this comment.
Pull request overview
Extends the @elastic/eslint-plugin-eui button-group-no-invalid-children rule to lint EuiButtonGroup usages with variant="segmented", enforcing stricter allowed children and adding a mixed-type check to match the new segmented design constraints.
Changes:
- Added segmented-specific allowed child validation (
EuiButton,EuiButtonIcon) and dynamic “allowed children” messaging. - Added segmented-only validation that disallows mixing
EuiButtonandEuiButtonIconwithin the same group (with limited wrapper introspection as documented in the rule). - Expanded/updated rule tests to cover segmented valid/invalid scenarios and updated expected message data payloads.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| packages/eslint-plugin/src/rules/button_group_no_invalid_children.ts | Adds segmented variant validation, dynamic allowed-list messaging, and mixed-type detection for segmented groups. |
| packages/eslint-plugin/src/rules/button_group_no_invalid_children.test.ts | Adds comprehensive segmented test coverage and updates expected error data to include the dynamic allowed string. |
| packages/eslint-plugin/changelogs/upcoming/9890.md | Adds a changelog entry for the rule enhancement (but currently links the wrong PR number). |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
There was a problem hiding this comment.
Couple of nits. Blocking:
README.mdrule section should document these changes.- We already check for
EuiPopoverandEuiCopyrender props, so we can actually resolve:
<EuiButtonGroup legend="Actions" variant="segmented">
<EuiButton>Save</EuiButton>
<EuiPopover button={<EuiButtonIcon iconType="menu" aria-label="More" />} … />
</EuiButtonGroup>and warn about mixed usage.
- The rule reports: "EuiButtonEmpty cannot be verified as a valid child of EuiButtonGroup. Allowed children: EuiButton, EuiButtonIcon. If EuiButtonEmpty is a shared button wrapper component... suppress this rule..." but this is kinda misleading. It should report
invalidChild.
This is a side effect of the changes we did here. We either filter for There are Eui-prefixed custom components on Kibana (which is honestly a bit unexpected) like |
|
@mgadewoll I understand but in my mind, we could just simply re-route to |
Ah ok, you meant specifically for |
Co-authored-by: Weronika Olejniczak <[email protected]>
…hild for EuiButtonEmpty
💚 Build Succeeded
History
cc @mgadewoll |
💚 Build Succeeded
History
cc @mgadewoll |
There was a problem hiding this comment.
Thanks for addressing my feedback, Lene! LGTM 🟢
Btw the PR still mentions "EuiButtonEmpty is excluded".
Mentioned sth relevant to this PR here: #9929 (review)
…port segmented variant (elastic#9890) Co-authored-by: Weronika Olejniczak <[email protected]>
## Dependency updates `@elastic/eui` - 119.1.0 ⏩ 120.0.0 `@elastic/eui-test-helpers` - 1.4.0 ⏩ 1.5.0 `@elastic/eslint-plugin-eui` - 2.16.0 ⏩ 3.0.0 `@elastic/eui-illustrations` - 1.0.1 ⏩ 1.0.2 > [!WARNING] > Removed unused `EuiIcon` types ([#9884](elastic/eui#9884)): `branchUser`, `continuityAboveBelow`, `continuityBelow`, `function`, `magnet`, `pageSelect`, `securitySignalResolved`, `tear`. ## Package updates ### `@elastic/eui` [v120.0.0](https://github.com/elastic/eui/blob/main/packages/eui/changelogs/CHANGELOG_2026.md) - Updated `EuiButtonGroup` (Children API only): ([#9929](elastic/eui#9929)) - Added `variant="selection"` to render the group as selection group - Added `type` prop (values `'single' | 'multi'`) to switch between single or multi selection - Added `display` prop (values: `'regular' | 'highlighted' | 'inverse'`) to render different visual variants - Added `idSelected` prop for single-state selection - Added `idToSelectedMap` prop for multi-state selection - Added `onChange` prop which returns the selected child button `id` - Added `cloudBolt`, `cloudRain`, `cloudSun`, `kubernetesNamespace`, `productTimelion`, `productTSVB`, `push`, `transitionRightIn`, and `transitionRightOut` glyphs to `EuiIcon` ([#9923](elastic/eui#9923)) - Updated the `cube`, `memory`, and `wrench` glyphs in `EuiIcon` with redesigned artwork ([#9923](elastic/eui#9923)) - Updated search synonyms for the `bolt`, `memory`, `plugs`, and `wrench` glyphs in `EuiIcon` ([#9923](elastic/eui#9923)) - Updated `EuiResizableContainer` collapse buttons to use the `transition*` glyphs in place of the `menu*` glyphs ([#9923](elastic/eui#9923)) - Hid undocumented `swatchInput` from glyph docs by categorizing it as `internal` ([#9884](elastic/eui#9884)) **Bug fixes** - Fixed `EuiDatePicker` throwing an error in React 19 when opening the month or year dropdown ([#9960](elastic/eui#9960)) - Fixed the icon documentation listing glyphs and Elastic logos out of alphabetical order ([#9923](elastic/eui#9923)) **Deprecations** - Updated deprecated icon alias mappings: ([#9974](elastic/eui#9974)) - `folderClosed` and `folderClose` → `folder` - Deprecated the `cloudDrizzle`, `cloudStormy`, `cloudSunny`, `kqlFunction`, `namespace`, `visTimelion`, and `visVisualBuilder` `EuiIcon` types in favor of `cloudRain`, `cloudBolt`, `cloudSun`, `push`, `kubernetesNamespace`, `productTimelion`, and `productTSVB` respectively. The deprecated types now render the new glyphs, no longer appear in the icon documentation, and will be removed in a future release ([#9923](elastic/eui#9923)) - Deprecated the `menuDown` and `menuUp` `EuiIcon` types in favor of `transitionBottomOut` and `transitionTopOut` respectively. The deprecated types now render the new glyphs, no longer appear in the icon documentation, and will be removed in a future release ([#9923](elastic/eui#9923)) - Deprecated `EuiIcon` types with no replacement: ([#9884](elastic/eui#9884)) - `article` - `dotInCircle` - `kubernetesNode` - `scale` - `securitySignalDetected` - Deprecated `EuiIcon` types with a contextual replacement: ([#9884](elastic/eui#9884)) - `folderExclamation` — `linkSlash` (unlink) or `hourglass` (Cases status) - `stopFill` / `stopSlash` — `EuiColorPickerSwatch` for color chips or `stop` otherwise - Deprecated `EuiIcon` types (use the replacements): ([#9884](elastic/eui#9884)) - `analyzeEvent` → `cube` - `annotation` → `flag` - `anomalySwimLane` → `chartHeatmap` - `apps` → `grid` - `container` → `package` - `continuityAbove` → `upload` - `continuityWithin` → `maximize` - `esqlVis` → `query` - `fold` → `minimize` - `frameNext` → `chevronSingleRight` - `framePrevious` → `chevronSingleLeft` - `help` → `question` - `index` → `table` - `ip` → `tokenIP` - `logstashFilter` → `filter` - `logstashInput` → `download` - `logstashOutput` → `upload` - `payment` → `money` - `sessionViewer` → `commandLine` - `singleMetricViewer` → `chartArea` - `spaces` → `grid` - `starEmptySpace` → `star` - `starFillSpace` → `starFill` - `starMinusEmpty` → `star` - `starMinusFill` → `starFill` - `starPlusEmpty` → `star` - `starPlusFill` → `starFill` - `stats` → `chartLine` - `string` → `tokenString` - `tableOfContents` → `listBullet` - `unfold` → `maximize` - `visGoal` → `chartGauge` - `wordWrap` → `lineBreak` - `wordWrapDisabled` → `lineBreakSlash` **Breaking changes** - Removed unused `EuiIcon` types: ([#9884](elastic/eui#9884)) - `branchUser` - `continuityAboveBelow` - `continuityBelow` - `function` - `magnet` - `pageSelect` - `securitySignalResolved` - `tear` ### `@elastic/eslint-plugin-eui` [v3.0.0](https://github.com/elastic/eui/blob/main/packages/eslint-plugin/changelogs/CHANGELOG_2026.md) - Updated `button-group-no-invalid-children` rule to support checking button groups with `variant="selection"` ([#9950](elastic/eui#9950)) - Added new `button-group-selection-require-id` rule to enforce a required `id` prop on each child button of `EuiButtonGroup` with `variant="selection"` ([#9950](elastic/eui#9950)) - Updated `@elastic/eui/no-deprecated-icon-aliases` with the newly deprecated `cloudDrizzle`, `cloudStormy`, `cloudSunny`, `kqlFunction`, `menuDown`, `menuUp`, `namespace`, `visTimelion`, and `visVisualBuilder` icon aliases ([#9923](elastic/eui#9923)) - Updated `button-group-no-invalid-children` rule to support segmented variant checks ([#9890](elastic/eui#9890)) - Updated `no-deprecated-icon-aliases` with icons that have no replacement: ([#9884](elastic/eui#9884)) - `article` - `dotInCircle` - `kubernetesNode` - `scale` - `securitySignalDetected` - Updated `no-deprecated-icon-aliases` with icons that have a contextual replacement (warn only, no autofix): ([#9884](elastic/eui#9884)) - `folderExclamation` - `linkSlash` (unlink) or `hourglass` (Kibana Cases status) - `stopFill` / `stopSlash` - `EuiColorPickerSwatch` for color chips or `stop` otherwise - Updated `no-deprecated-icon-aliases` with new icon aliases: ([#9884](elastic/eui#9884)) - `analyzeEvent` → `cube` - `annotation` → `flag` - `anomalySwimLane` → `chartHeatmap` - `apps` → `grid` - `container` → `package` - `continuityAbove` → `upload` - `continuityWithin` → `maximize` - `esqlVis` → `query` - `fold` → `minimize` - `frameNext` → `chevronSingleRight` - `framePrevious` → `chevronSingleLeft` - `help` → `question` - `index` → `table` - `ip` → `tokenIP` - `logstashFilter` → `filter` - `logstashInput` → `download` - `logstashOutput` → `upload` - `payment` → `money` - `sessionViewer` → `commandLine` - `singleMetricViewer` → `chartArea` - `spaces` → `grid` - `starEmptySpace` → `star` - `starFillSpace` → `starFill` - `starMinusEmpty` → `star` - `starMinusFill` → `starFill` - `starPlusEmpty` → `star` - `starPlusFill` → `starFill` - `stats` → `chartLine` - `string` → `tokenString` - `tableOfContents` → `listBullet` - `unfold` → `maximize` - `visGoal` → `chartGauge` - `wordWrap` → `lineBreak` - `wordWrapDisabled` → `lineBreakSlash` - Updated `starFilledSpace`, `starMinusFilled` and `starPlusFilled` mappings to `starFill` ([#9884](elastic/eui#9884)) **Deprecations** - Updated deprecated icon alias mappings: ([#9974](elastic/eui#9974)) - `folderClosed` and `folderClose` → `folder` **Breaking changes** - Removed the `push` icon alias from `@elastic/eui/no-deprecated-icon-aliases`. `push` is now a supported `EuiIcon` glyph again and is no longer autofixed to `send` ([#9923](elastic/eui#9923)) ### `@elastic/eui-illustrations` [v1.0.2](https://github.com/elastic/eui/blob/main/packages/illustrations/changelogs/CHANGELOG_2026.md) **Bug fixes** - Fixed illustrations rendering cropped when more than one was inlined on the same page ([#9973](elastic/eui#9973)) ### `@elastic/eui-test-helpers` [v1.5.0](https://github.com/elastic/eui/blob/main/packages/test-helpers/changelogs/CHANGELOG_2026.md) - Added `EuiRangeObject`, a Playwright Component Object for `EuiRange`/`EuiDualRange` ([#9957](elastic/eui#9957)) - Added `EuiDraggableObject` with `reorder(steps)` ([#9936](elastic/eui#9936)) - Added `EuiBasicTableObject` with `rows` and `cells(field)` ([#9933](elastic/eui#9933)) - Added `EuiFilterButtonObject`, a Playwright Component Object for `EuiFilterButton` ([#9942](elastic/eui#9942))
## Dependency updates `@elastic/eui` - 119.1.0 ⏩ 120.0.0 `@elastic/eui-test-helpers` - 1.4.0 ⏩ 1.5.0 `@elastic/eslint-plugin-eui` - 2.16.0 ⏩ 3.0.0 `@elastic/eui-illustrations` - 1.0.1 ⏩ 1.0.2 > [!WARNING] > Removed unused `EuiIcon` types ([elastic#9884](elastic/eui#9884)): `branchUser`, `continuityAboveBelow`, `continuityBelow`, `function`, `magnet`, `pageSelect`, `securitySignalResolved`, `tear`. ## Package updates ### `@elastic/eui` [v120.0.0](https://github.com/elastic/eui/blob/main/packages/eui/changelogs/CHANGELOG_2026.md) - Updated `EuiButtonGroup` (Children API only): ([elastic#9929](elastic/eui#9929)) - Added `variant="selection"` to render the group as selection group - Added `type` prop (values `'single' | 'multi'`) to switch between single or multi selection - Added `display` prop (values: `'regular' | 'highlighted' | 'inverse'`) to render different visual variants - Added `idSelected` prop for single-state selection - Added `idToSelectedMap` prop for multi-state selection - Added `onChange` prop which returns the selected child button `id` - Added `cloudBolt`, `cloudRain`, `cloudSun`, `kubernetesNamespace`, `productTimelion`, `productTSVB`, `push`, `transitionRightIn`, and `transitionRightOut` glyphs to `EuiIcon` ([elastic#9923](elastic/eui#9923)) - Updated the `cube`, `memory`, and `wrench` glyphs in `EuiIcon` with redesigned artwork ([elastic#9923](elastic/eui#9923)) - Updated search synonyms for the `bolt`, `memory`, `plugs`, and `wrench` glyphs in `EuiIcon` ([elastic#9923](elastic/eui#9923)) - Updated `EuiResizableContainer` collapse buttons to use the `transition*` glyphs in place of the `menu*` glyphs ([elastic#9923](elastic/eui#9923)) - Hid undocumented `swatchInput` from glyph docs by categorizing it as `internal` ([elastic#9884](elastic/eui#9884)) **Bug fixes** - Fixed `EuiDatePicker` throwing an error in React 19 when opening the month or year dropdown ([elastic#9960](elastic/eui#9960)) - Fixed the icon documentation listing glyphs and Elastic logos out of alphabetical order ([elastic#9923](elastic/eui#9923)) **Deprecations** - Updated deprecated icon alias mappings: ([elastic#9974](elastic/eui#9974)) - `folderClosed` and `folderClose` → `folder` - Deprecated the `cloudDrizzle`, `cloudStormy`, `cloudSunny`, `kqlFunction`, `namespace`, `visTimelion`, and `visVisualBuilder` `EuiIcon` types in favor of `cloudRain`, `cloudBolt`, `cloudSun`, `push`, `kubernetesNamespace`, `productTimelion`, and `productTSVB` respectively. The deprecated types now render the new glyphs, no longer appear in the icon documentation, and will be removed in a future release ([elastic#9923](elastic/eui#9923)) - Deprecated the `menuDown` and `menuUp` `EuiIcon` types in favor of `transitionBottomOut` and `transitionTopOut` respectively. The deprecated types now render the new glyphs, no longer appear in the icon documentation, and will be removed in a future release ([elastic#9923](elastic/eui#9923)) - Deprecated `EuiIcon` types with no replacement: ([elastic#9884](elastic/eui#9884)) - `article` - `dotInCircle` - `kubernetesNode` - `scale` - `securitySignalDetected` - Deprecated `EuiIcon` types with a contextual replacement: ([elastic#9884](elastic/eui#9884)) - `folderExclamation` — `linkSlash` (unlink) or `hourglass` (Cases status) - `stopFill` / `stopSlash` — `EuiColorPickerSwatch` for color chips or `stop` otherwise - Deprecated `EuiIcon` types (use the replacements): ([elastic#9884](elastic/eui#9884)) - `analyzeEvent` → `cube` - `annotation` → `flag` - `anomalySwimLane` → `chartHeatmap` - `apps` → `grid` - `container` → `package` - `continuityAbove` → `upload` - `continuityWithin` → `maximize` - `esqlVis` → `query` - `fold` → `minimize` - `frameNext` → `chevronSingleRight` - `framePrevious` → `chevronSingleLeft` - `help` → `question` - `index` → `table` - `ip` → `tokenIP` - `logstashFilter` → `filter` - `logstashInput` → `download` - `logstashOutput` → `upload` - `payment` → `money` - `sessionViewer` → `commandLine` - `singleMetricViewer` → `chartArea` - `spaces` → `grid` - `starEmptySpace` → `star` - `starFillSpace` → `starFill` - `starMinusEmpty` → `star` - `starMinusFill` → `starFill` - `starPlusEmpty` → `star` - `starPlusFill` → `starFill` - `stats` → `chartLine` - `string` → `tokenString` - `tableOfContents` → `listBullet` - `unfold` → `maximize` - `visGoal` → `chartGauge` - `wordWrap` → `lineBreak` - `wordWrapDisabled` → `lineBreakSlash` **Breaking changes** - Removed unused `EuiIcon` types: ([elastic#9884](elastic/eui#9884)) - `branchUser` - `continuityAboveBelow` - `continuityBelow` - `function` - `magnet` - `pageSelect` - `securitySignalResolved` - `tear` ### `@elastic/eslint-plugin-eui` [v3.0.0](https://github.com/elastic/eui/blob/main/packages/eslint-plugin/changelogs/CHANGELOG_2026.md) - Updated `button-group-no-invalid-children` rule to support checking button groups with `variant="selection"` ([elastic#9950](elastic/eui#9950)) - Added new `button-group-selection-require-id` rule to enforce a required `id` prop on each child button of `EuiButtonGroup` with `variant="selection"` ([elastic#9950](elastic/eui#9950)) - Updated `@elastic/eui/no-deprecated-icon-aliases` with the newly deprecated `cloudDrizzle`, `cloudStormy`, `cloudSunny`, `kqlFunction`, `menuDown`, `menuUp`, `namespace`, `visTimelion`, and `visVisualBuilder` icon aliases ([elastic#9923](elastic/eui#9923)) - Updated `button-group-no-invalid-children` rule to support segmented variant checks ([elastic#9890](elastic/eui#9890)) - Updated `no-deprecated-icon-aliases` with icons that have no replacement: ([elastic#9884](elastic/eui#9884)) - `article` - `dotInCircle` - `kubernetesNode` - `scale` - `securitySignalDetected` - Updated `no-deprecated-icon-aliases` with icons that have a contextual replacement (warn only, no autofix): ([elastic#9884](elastic/eui#9884)) - `folderExclamation` - `linkSlash` (unlink) or `hourglass` (Kibana Cases status) - `stopFill` / `stopSlash` - `EuiColorPickerSwatch` for color chips or `stop` otherwise - Updated `no-deprecated-icon-aliases` with new icon aliases: ([elastic#9884](elastic/eui#9884)) - `analyzeEvent` → `cube` - `annotation` → `flag` - `anomalySwimLane` → `chartHeatmap` - `apps` → `grid` - `container` → `package` - `continuityAbove` → `upload` - `continuityWithin` → `maximize` - `esqlVis` → `query` - `fold` → `minimize` - `frameNext` → `chevronSingleRight` - `framePrevious` → `chevronSingleLeft` - `help` → `question` - `index` → `table` - `ip` → `tokenIP` - `logstashFilter` → `filter` - `logstashInput` → `download` - `logstashOutput` → `upload` - `payment` → `money` - `sessionViewer` → `commandLine` - `singleMetricViewer` → `chartArea` - `spaces` → `grid` - `starEmptySpace` → `star` - `starFillSpace` → `starFill` - `starMinusEmpty` → `star` - `starMinusFill` → `starFill` - `starPlusEmpty` → `star` - `starPlusFill` → `starFill` - `stats` → `chartLine` - `string` → `tokenString` - `tableOfContents` → `listBullet` - `unfold` → `maximize` - `visGoal` → `chartGauge` - `wordWrap` → `lineBreak` - `wordWrapDisabled` → `lineBreakSlash` - Updated `starFilledSpace`, `starMinusFilled` and `starPlusFilled` mappings to `starFill` ([elastic#9884](elastic/eui#9884)) **Deprecations** - Updated deprecated icon alias mappings: ([elastic#9974](elastic/eui#9974)) - `folderClosed` and `folderClose` → `folder` **Breaking changes** - Removed the `push` icon alias from `@elastic/eui/no-deprecated-icon-aliases`. `push` is now a supported `EuiIcon` glyph again and is no longer autofixed to `send` ([elastic#9923](elastic/eui#9923)) ### `@elastic/eui-illustrations` [v1.0.2](https://github.com/elastic/eui/blob/main/packages/illustrations/changelogs/CHANGELOG_2026.md) **Bug fixes** - Fixed illustrations rendering cropped when more than one was inlined on the same page ([elastic#9973](elastic/eui#9973)) ### `@elastic/eui-test-helpers` [v1.5.0](https://github.com/elastic/eui/blob/main/packages/test-helpers/changelogs/CHANGELOG_2026.md) - Added `EuiRangeObject`, a Playwright Component Object for `EuiRange`/`EuiDualRange` ([elastic#9957](elastic/eui#9957)) - Added `EuiDraggableObject` with `reorder(steps)` ([elastic#9936](elastic/eui#9936)) - Added `EuiBasicTableObject` with `rows` and `cells(field)` ([elastic#9933](elastic/eui#9933)) - Added `EuiFilterButtonObject`, a Playwright Component Object for `EuiFilterButton` ([elastic#9942](elastic/eui#9942))
…port segmented variant (elastic#9890) Co-authored-by: Weronika Olejniczak <[email protected]>
Summary
Note
This PR is related to #9862 which adds
variant="segmented"toEuiButtonGroup.This PR should be rebased after merging the implementation PR.
button-group-no-invalid-childrenESLint rule with validation forvariant="segmented".SEGMENTED_VALID_BUTTONSset (EuiButton,EuiButtonIcon—EuiButtonEmptyis excluded) and a mixed-type check that reports an error when bothEuiButtonandEuiButtonIconappear in the same segmented group.Examples
✅ valid
❌ invalid
Additional information
What the rule validates for variant="segmented"
Error message changes
The allowed list in all error messages is now dynamic (interpolated via {{ allowed }}) so segmented errors list only EuiButton, EuiButtonIcon while default-variant errors continue to list EuiButton, EuiButtonEmpty, EuiButtonIcon.
API Changes
⚪ No API changes
Screenshots
Impact Assessment
Note: Most PRs should be tested in Kibana to help gauge their Impact before merging.
Impact level: 🟢 None
Release Readiness
QA instructions for reviewer
yarn workspace @elastic/eslint-plugin-eui buildon rootyarn workspace @elastic/eui build:workspaceson rootbutton_group_children.stories.tsxand run eslint check withyarn workspace @elastic/eui linton rootChecklist before marking Ready for Review
breaking changelabel (if applicable)Reviewer checklist