[eslint] Update button-group-no-invalid-children rule to support selection variant and add button-group-selection-require-id rule - #9950
Merged
mgadewoll merged 7 commits intoAug 25, 2026
Conversation
- flags if button group child buttons don't have the required id attribute
Contributor
There was a problem hiding this comment.
Pull request overview
This PR updates the @elastic/eslint-plugin-eui rules that validate EuiButtonGroup Children API usage to support the new variant="selection" behavior and to enforce that selection children provide ids.
Changes:
- Extend
button-group-no-invalid-childrenvalidation to includevariant="selection"and enforce the same “no mixedEuiButton/EuiButtonIcontypes” rule as segmented. - Add
button-group-selection-require-idto requireidonEuiButton/EuiButtonIconchildren (including supported wrappers) whenvariant="selection". - Refactor shared constants/utilities into centralized
utils/modules and update docs/changelog.
Reviewed changes
Copilot reviewed 9 out of 9 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| packages/eslint-plugin/src/utils/collect_jsx_children.ts | New shared helper to collect JSX element “leaf” children via walkJsxChildren. |
| packages/eslint-plugin/src/utils/button_group_constants.ts | Centralizes button-group-related constants (valid buttons/wrappers). |
| packages/eslint-plugin/src/rules/button_group_selection_require_id.ts | New rule enforcing required id on selection-variant children (and supported wrapper patterns). |
| packages/eslint-plugin/src/rules/button_group_selection_require_id.test.ts | Adds unit coverage for the new button-group-selection-require-id rule. |
| packages/eslint-plugin/src/rules/button_group_no_invalid_children.ts | Updates existing rule to validate variant="selection" and generalizes mixed-type error messaging. |
| packages/eslint-plugin/src/rules/button_group_no_invalid_children.test.ts | Updates/extends tests for selection variant validation and new mixed-type message shape. |
| packages/eslint-plugin/src/index.ts | Registers the new rule and enables it in the recommended config. |
| packages/eslint-plugin/README.md | Documents selection-variant behavior for both rules, including examples. |
| packages/eslint-plugin/changelogs/upcoming/9950.md | Changelog entry for the rule update + new rule. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
mgadewoll
marked this pull request as ready for review
August 25, 2026 06:26
weronikaolejniczak
approved these changes
Aug 25, 2026
weronikaolejniczak
left a comment
Contributor
There was a problem hiding this comment.
LGTM 🟢 Only one non-blocking comment.
💚 Build Succeeded
History
cc @mgadewoll |
💚 Build Succeeded
History
cc @mgadewoll |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Note
This PR is related to #9929 which adds
variant="selection"toEuiButtonGroup.This PR should be rebased after merging the implementation PR.
button-group-no-invalid-childrenESLint rule with validation forvariant="selection"button-group-selection-require-idrule that enforces a requiredidprop on each child buttonbutton-group-no-invalid-childrento support checks onvariant="selection"button-group-selection-require-idwhich checks if button group children withvariant="selection" each have an requiredid`Examples -
button-group-no-invalid-childrenforvariant="selection"✅ valid
❌ invalid
Examples -
button-group-selection-require-id✅ valid
❌ invalid
What the rules validate for
variant="selection"button-group-no-invalid-children:EuiButton,EuiButtonIconEuiToolTip,EuiPopover,EuiCopy)invalidMixedTypeswhen bothEuiButtonandEuiButtonIconappear in the same groupbutton-group-selection-require-id:missingIdfor anyEuiButton/EuiButtonIconwithout an explicitidattribute{...props}) are skipped conservatively (idmay be passed via the spread)variant="selection"(static string); dynamic variants are skippedAPI 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 rootyarn workspace @elastic/eui linton rootChecklist before marking Ready for Review
breaking changelabel (if applicable)Reviewer checklist