Repository navigation
[ESLint] Add callout usage rules - #9821
Conversation
There was a problem hiding this comment.
Pull request overview
This PR adds a new @elastic/eslint-plugin-eui rule to help migrate EuiCallOut usage away from legacy children content toward the newer text and actionProps props introduced alongside the CallOut UI/API updates.
Changes:
- Added the
callout-prefer-props-for-contentESLint rule to detect text/action content passed viaEuiCallOutchildren. - Added a comprehensive RuleTester suite covering common text/action patterns, including fragments and layout wrappers.
- Registered the rule in the plugin’s exported config and added an upcoming changelog entry.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| packages/eslint-plugin/src/rules/callout_prefer_props_for_content.ts | Implements the new rule’s AST traversal and reporting logic for EuiCallOut children content. |
| packages/eslint-plugin/src/rules/callout_prefer_props_for_content.test.ts | Adds unit tests validating valid/invalid EuiCallOut patterns for the new rule. |
| packages/eslint-plugin/src/index.ts | Registers the new rule and enables it in the recommended config (as warn). |
| packages/eslint-plugin/changelogs/upcoming/9821.md | Records the addition of the new rule in the plugin changelog. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
weronikaolejniczak
left a comment
There was a problem hiding this comment.
I found mostly nits, I have one question and we should add an entry to README.md that explains the rule (blocking).
Potential cases that aren't checked:
- (Kibana)
FormattedMessage:
<EuiCallOut ...>
<FormattedMessage ... />
</EuiCallOut>- (Kibana)
MemberExpression:{i18n.NO_DIFF_AVAILABLE_CALLOUT} - (Cloud UI):
{body},{this.renderDescription()}(expected? they may contain complex compositions) TemplateLiteral:<EuiCallOut>{Plain text}</EuiCallOut>(edge-casey)ArrayExpression:<EuiCallOut>{[<p key="1">Text</p>]}</EuiCallOut>(edge-casey){validationChecks.map(...)}(expected?)
These become MemberExpression, Identifier or CallExpression, and all fall through the default.
ℹ️ ESLint tests are finally evaluated in CI: run (🟢)
@weronikaolejniczak Thanks for the check, good catches! What I added support for:
What I didn't add (If we see trouble with these, we could still update the rule as needed):
|
weronikaolejniczak
left a comment
There was a problem hiding this comment.
@mgadewoll I don't see the MemberExpression ({i18n.NO_DIFF_AVAILABLE_CALLOUT}) being handled, I think you might've missed it? 🤔 Or do we not want to handle it after all?
Lol woops, yes I actually missed it and then copied it wrongly into the update list 🫠 Sorry for the confusion. 🙏 |
weronikaolejniczak
left a comment
There was a problem hiding this comment.
LGTM! 🟢 Thanks for addressing my feedback
weronikaolejniczak
left a comment
There was a problem hiding this comment.
Wait! Now every member expression will be reported, including props.body, content.widget. We should only check for i18n.
weronikaolejniczak
left a comment
There was a problem hiding this comment.
Now everything looks perfect 👌🏻 Thanks, Lene!
|
@weronikaolejniczak I added an additional change (commit) to support different callout components via
|
💚 Build Succeeded
History
cc @mgadewoll |
💚 Build Succeeded
History
cc @mgadewoll |
## Dependency updates `@elastic/eui` - v117.1.0 ⏩ v118.0.0 `@elastic/eslint-plugin-eui` - v2.14.1 ⏩ v2.15.0 ## Changes Fixes for the failures surfaced by the [nightly build CI](#279387): - **Nested tooltips ([eui#9749](elastic/eui#9749 Cherry-picked the prepared migration commit [`383f06f5b57f`](383f06f) from [#278588](#278588): nested tooltips are no longer supported, so they are removed where exposed (`hoverable_avatar`, `small_user_avatar`, `user_avatar_tip`) and the affected components/tests updated. Fixes the `add to timeline`, `AllCasesListGeneric`, `AnonymizedStat`, `HoverableAvatar`, `InfrastructureTabHelpPopover`, `LabelNode`/`RelationshipNode` tooltip test failures. - **Removed beta nav i18n tokens ([eui#9813](elastic/eui#9813 `EuiCollapsibleNavBeta` and the related beta nav components were removed, so their now-orphaned i18n tokens are deleted from the EUI mapping and the `de`/`fr`/`ja`/`zh` translation files. Fixes the `@elastic/eui i18n tokens` test and the type/i18n quick checks. - **Internal display-name renames.** EUI renamed some internal component display names (`EuiSideNavClass` → `EuiSideNav`, `EuiFilterSelectItemClass` → `EuiFilterSelectItemComponent`); refreshed the affected `SolutionNav` snapshots and the `GroupsFilterPopover` snapshot + enzyme selector. ## Package updates ### `@elastic/eui` [v118.0.0](https://github.com/elastic/eui/blob/main/packages/eui/changelogs/CHANGELOG_2026.md) - Added new `translate` icon. ([#9842](elastic/eui#9842)) - Updated `EuiToolTip` to skip the entry animation when hovering between adjacent triggers in quick succession, so a group of tooltips behaves like a single continuous tooltip following the cursor ([#9749](elastic/eui#9749)) **Bug fixes** - Fixed `EuiToolTip` rare flicker when the cursor moved between inner children of the trigger ([#9749](elastic/eui#9749)) **Breaking changes** - Removed `EuiCollapsibleNavBeta` and all related beta navigation components (`EuiCollapsibleNavItem`, `EuiCollapsibleNavButton`, `KibanaCollapsibleNavSolution`, etc.). ([#9813](elastic/eui#9813)) - Hover behavior for nested `EuiToolTip` triggers has changed - parent tooltips will not open when the pointer is over a child tooltip trigger (only the innermost tooltip is shown) ([#9749](elastic/eui#9749)) ### `@elastic/eslint-plugin-eui` [v2.15.0](https://github.com/elastic/eui/blob/main/packages/eslint-plugin/changelogs/CHANGELOG_2026.md) - Added `callout-prefer-props-for-content` rule ([#9821](elastic/eui#9821)) --------- Co-authored-by: Claude Sonnet 4.6 <[email protected]> Co-authored-by: kibanamachine <[email protected]>
`@elastic/eui` - v117.1.0 ⏩ v118.0.0 `@elastic/eslint-plugin-eui` - v2.14.1 ⏩ v2.15.0 Fixes for the failures surfaced by the [nightly build CI](elastic#279387): - **Nested tooltips ([eui#9749](elastic/eui#9749 Cherry-picked the prepared migration commit [`383f06f5b57f`](elastic@383f06f) from [elastic#278588](elastic#278588): nested tooltips are no longer supported, so they are removed where exposed (`hoverable_avatar`, `small_user_avatar`, `user_avatar_tip`) and the affected components/tests updated. Fixes the `add to timeline`, `AllCasesListGeneric`, `AnonymizedStat`, `HoverableAvatar`, `InfrastructureTabHelpPopover`, `LabelNode`/`RelationshipNode` tooltip test failures. - **Removed beta nav i18n tokens ([eui#9813](elastic/eui#9813 `EuiCollapsibleNavBeta` and the related beta nav components were removed, so their now-orphaned i18n tokens are deleted from the EUI mapping and the `de`/`fr`/`ja`/`zh` translation files. Fixes the `@elastic/eui i18n tokens` test and the type/i18n quick checks. - **Internal display-name renames.** EUI renamed some internal component display names (`EuiSideNavClass` → `EuiSideNav`, `EuiFilterSelectItemClass` → `EuiFilterSelectItemComponent`); refreshed the affected `SolutionNav` snapshots and the `GroupsFilterPopover` snapshot + enzyme selector. [v118.0.0](https://github.com/elastic/eui/blob/main/packages/eui/changelogs/CHANGELOG_2026.md) - Added new `translate` icon. ([elastic#9842](elastic/eui#9842)) - Updated `EuiToolTip` to skip the entry animation when hovering between adjacent triggers in quick succession, so a group of tooltips behaves like a single continuous tooltip following the cursor ([elastic#9749](elastic/eui#9749)) **Bug fixes** - Fixed `EuiToolTip` rare flicker when the cursor moved between inner children of the trigger ([elastic#9749](elastic/eui#9749)) **Breaking changes** - Removed `EuiCollapsibleNavBeta` and all related beta navigation components (`EuiCollapsibleNavItem`, `EuiCollapsibleNavButton`, `KibanaCollapsibleNavSolution`, etc.). ([elastic#9813](elastic/eui#9813)) - Hover behavior for nested `EuiToolTip` triggers has changed - parent tooltips will not open when the pointer is over a child tooltip trigger (only the innermost tooltip is shown) ([elastic#9749](elastic/eui#9749)) [v2.15.0](https://github.com/elastic/eui/blob/main/packages/eslint-plugin/changelogs/CHANGELOG_2026.md) - Added `callout-prefer-props-for-content` rule ([elastic#9821](elastic/eui#9821)) --------- Co-authored-by: Claude Sonnet 4.6 <[email protected]> Co-authored-by: kibanamachine <[email protected]>
…or `@kbn/ui-callout` components (#282292) ## Summary After adding `@kbn/ui-callout` wrapper components in #277978 and adding an ESLint rule to help migrating `EuiCallOut` usages to those kbn-ui components in #280951, we also want to ensure that the correct prop API is used for the new components. Since EUI added such a rule for the `EuiCallOut` component in elastic/eui#9821, we simply reuse it for the `@kbn/ui-callout` components by defining applicable components. ### Checklist Check the PR satisfies following conditions. Reviewers should verify this PR satisfies this list as well. - [ ] Any text added follows [EUI's writing guidelines](https://elastic.github.io/eui/#/guidelines/writing), uses sentence case text and includes [i18n support](https://github.com/elastic/kibana/blob/main/src/platform/packages/shared/kbn-i18n/README.md) - [ ] [Documentation](https://www.elastic.co/guide/en/kibana/master/development-documentation.html) was added for features that require explanation or tutorials - [ ] [Unit or functional tests](https://www.elastic.co/guide/en/kibana/master/development-tests.html) were updated or added to match the most common scenarios - [ ] If a plugin configuration key changed, check if it needs to be allowlisted in the cloud and added to the [docker list](https://github.com/elastic/kibana/blob/main/src/dev/build/tasks/os_packages/docker_generator/resources/base/bin/kibana-docker) - [ ] This was checked for breaking HTTP API changes, and any breaking changes have been approved by the breaking-change committee. The `release_note:breaking` label should be applied in these situations. - [ ] [Flaky Test Runner](https://ci-stats.kibana.dev/trigger_flaky_test_runner/1) was used on any tests changed - [ ] The PR description includes the appropriate Release Notes section, and the correct `release_note:*` label is applied per the [guidelines](https://www.elastic.co/docs/extend/kibana/contributing/workflow/how-we-use-github#release-notes) - [ ] Review the [backport guidelines](https://docs.google.com/document/d/1VyN5k91e5OVumlc0Gb9RPa3h1ewuPE705nRtioPiTvY/edit?usp=sharing) and apply applicable `backport:*` labels. ### Identify risks Does this PR introduce any risks? For example, consider risks like hard to test bugs, performance regression, potential of data loss. Describe the risk, its severity, and mitigation for each identified risk. Invite stakeholders and evaluate how to proceed before merging. - [ ] [See some risk examples](https://github.com/elastic/kibana/blob/main/RISK_MATRIX.mdx) - [ ] ...
…or `@kbn/ui-callout` components (elastic#282292) ## Summary After adding `@kbn/ui-callout` wrapper components in elastic#277978 and adding an ESLint rule to help migrating `EuiCallOut` usages to those kbn-ui components in elastic#280951, we also want to ensure that the correct prop API is used for the new components. Since EUI added such a rule for the `EuiCallOut` component in elastic/eui#9821, we simply reuse it for the `@kbn/ui-callout` components by defining applicable components. ### Checklist Check the PR satisfies following conditions. Reviewers should verify this PR satisfies this list as well. - [ ] Any text added follows [EUI's writing guidelines](https://elastic.github.io/eui/#/guidelines/writing), uses sentence case text and includes [i18n support](https://github.com/elastic/kibana/blob/main/src/platform/packages/shared/kbn-i18n/README.md) - [ ] [Documentation](https://www.elastic.co/guide/en/kibana/master/development-documentation.html) was added for features that require explanation or tutorials - [ ] [Unit or functional tests](https://www.elastic.co/guide/en/kibana/master/development-tests.html) were updated or added to match the most common scenarios - [ ] If a plugin configuration key changed, check if it needs to be allowlisted in the cloud and added to the [docker list](https://github.com/elastic/kibana/blob/main/src/dev/build/tasks/os_packages/docker_generator/resources/base/bin/kibana-docker) - [ ] This was checked for breaking HTTP API changes, and any breaking changes have been approved by the breaking-change committee. The `release_note:breaking` label should be applied in these situations. - [ ] [Flaky Test Runner](https://ci-stats.kibana.dev/trigger_flaky_test_runner/1) was used on any tests changed - [ ] The PR description includes the appropriate Release Notes section, and the correct `release_note:*` label is applied per the [guidelines](https://www.elastic.co/docs/extend/kibana/contributing/workflow/how-we-use-github#release-notes) - [ ] Review the [backport guidelines](https://docs.google.com/document/d/1VyN5k91e5OVumlc0Gb9RPa3h1ewuPE705nRtioPiTvY/edit?usp=sharing) and apply applicable `backport:*` labels. ### Identify risks Does this PR introduce any risks? For example, consider risks like hard to test bugs, performance regression, potential of data loss. Describe the risk, its severity, and mitigation for each identified risk. Invite stakeholders and evaluate how to proceed before merging. - [ ] [See some risk examples](https://github.com/elastic/kibana/blob/main/RISK_MATRIX.mdx) - [ ] ...
…or `@kbn/ui-callout` components (elastic#282292) ## Summary After adding `@kbn/ui-callout` wrapper components in elastic#277978 and adding an ESLint rule to help migrating `EuiCallOut` usages to those kbn-ui components in elastic#280951, we also want to ensure that the correct prop API is used for the new components. Since EUI added such a rule for the `EuiCallOut` component in elastic/eui#9821, we simply reuse it for the `@kbn/ui-callout` components by defining applicable components. ### Checklist Check the PR satisfies following conditions. Reviewers should verify this PR satisfies this list as well. - [ ] Any text added follows [EUI's writing guidelines](https://elastic.github.io/eui/#/guidelines/writing), uses sentence case text and includes [i18n support](https://github.com/elastic/kibana/blob/main/src/platform/packages/shared/kbn-i18n/README.md) - [ ] [Documentation](https://www.elastic.co/guide/en/kibana/master/development-documentation.html) was added for features that require explanation or tutorials - [ ] [Unit or functional tests](https://www.elastic.co/guide/en/kibana/master/development-tests.html) were updated or added to match the most common scenarios - [ ] If a plugin configuration key changed, check if it needs to be allowlisted in the cloud and added to the [docker list](https://github.com/elastic/kibana/blob/main/src/dev/build/tasks/os_packages/docker_generator/resources/base/bin/kibana-docker) - [ ] This was checked for breaking HTTP API changes, and any breaking changes have been approved by the breaking-change committee. The `release_note:breaking` label should be applied in these situations. - [ ] [Flaky Test Runner](https://ci-stats.kibana.dev/trigger_flaky_test_runner/1) was used on any tests changed - [ ] The PR description includes the appropriate Release Notes section, and the correct `release_note:*` label is applied per the [guidelines](https://www.elastic.co/docs/extend/kibana/contributing/workflow/how-we-use-github#release-notes) - [ ] Review the [backport guidelines](https://docs.google.com/document/d/1VyN5k91e5OVumlc0Gb9RPa3h1ewuPE705nRtioPiTvY/edit?usp=sharing) and apply applicable `backport:*` labels. ### Identify risks Does this PR introduce any risks? For example, consider risks like hard to test bugs, performance regression, potential of data loss. Describe the risk, its severity, and mitigation for each identified risk. Invite stakeholders and evaluate how to proceed before merging. - [ ] [See some risk examples](https://github.com/elastic/kibana/blob/main/RISK_MATRIX.mdx) - [ ] ...

Summary
EuiCallOutspecific ESLint rulecallout-prefer-props-for-contentto@elastic/eslint-plugin-eui.childrento move towards using dedicated propstextandactionPropsafter updates done in [EuiCallOut] UI enhancements #9642callout-prefer-props-for-contentwhich checks for usages of text and action elements inchildrenand flags them. It's set towarnto not become a bottleneck while migrating.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
Checklist before marking Ready for Review
breaking changelabel (if applicable)Reviewer checklist