[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 <32842468+weronikaolejniczak@users.noreply.github.com>
…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)
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