Skip to content

[scout] adding ESLint rules for test package imports#225791

Merged
dmlemeshko merged 12 commits intoelastic:mainfrom
dmlemeshko:scout/add-eslint-rules
Jul 2, 2025
Merged

[scout] adding ESLint rules for test package imports#225791
dmlemeshko merged 12 commits intoelastic:mainfrom
dmlemeshko:scout/add-eslint-rules

Conversation

@dmlemeshko
Copy link
Copy Markdown
Contributor

@dmlemeshko dmlemeshko commented Jun 30, 2025

Summary

Adding ESLint rules to control the proper test package is used for testing:

  • platform tests should import only from @kbn/scout
  • solution tests should import only from solution-specific scout package (e.g. security plugins => @kbn/scout-security)

example:

ERROR
/Users/dmle/github/kibana/x-pack/solutions/observability/plugins/apm/ui_tests/parallel_tests/service_inventory/service_inventory.spec.ts
        7:1  error  '@kbn/scout' import is restricted from being used by a pattern.
Observability solution tests should import from '@kbn/scout-oblt' instead  no-restricted-imports

      ✖ 1 problem (1 error, 0 warnings)

@dmlemeshko dmlemeshko self-assigned this Jun 30, 2025
@dmlemeshko dmlemeshko added v9.1.0 v8.19.0 v9.2.0 release_note:skip Skip the PR/issue when compiling release notes backport:version Backport to applied version labels labels Jun 30, 2025
@dmlemeshko dmlemeshko force-pushed the scout/add-eslint-rules branch from 4f0625c to e6f8960 Compare June 30, 2025 12:24
@dmlemeshko dmlemeshko requested a review from csr June 30, 2025 12:25
@dmlemeshko
Copy link
Copy Markdown
Contributor Author

.../elastic/kibana-pull-request/kibana/x-pack/solutions/observability/plugins/observability/ui_tests/fixtures/generators.ts
-- | --
  | 2025-06-30 12:44:44 UTC | 7:1  error  '@kbn/scout' import is restricted from being used.
Observability solution tests should import from '@kbn/scout-oblt' instead  no-restricted-imports

I believe it works as expected now, I will push an update for this file

@dmlemeshko
Copy link
Copy Markdown
Contributor Author

@csr based on this error


  | 2025-06-30 22:48:55 UTC | x-pack/platform/plugins/shared/streams_app/ui_tests/tests/classic.spec.ts
  | 2025-06-30 22:48:55 UTC | 8:1   error  '@kbn/scout-oblt' import is restricted from being used. Platform tests should import only from '@kbn/scout'                                                                                                                                                                                                                                                                                                                                                           no-restricted-imports
  | 2025-06-30 22:48:55 UTC | 8:24  error  ⚠ Illegal import statement: "@kbn/streams-app-plugin" (platform) is importing "@kbn/scout-oblt" (observability/private). File: x-pack/platform/plugins/shared/streams_app/ui_tests/tests/classic.spec.ts
  | 2025-06-30 22:48:55 UTC |  
  | 2025-06-30 22:48:55 UTC | Suggestions:
  | 2025-06-30 22:48:55 UTC | - Please review the dependencies in your module's manifest (kibana.jsonc).
  | 2025-06-30 22:48:55 UTC | - Relocate this module to a different group, and/or make sure it has the right 'visibility'.
  | 2025-06-30 22:48:55 UTC | - Address the conflicting dependencies by refactoring the code

I think we are already guarded from solution packages being imported in platform plugins. I will simplify the PR

@csr
Copy link
Copy Markdown
Member

csr commented Jul 1, 2025

✅ Importing kbn/scout in observability plugins throws an error:

image

✅ Importing kbn/scout in security plugins throws an error:

image

✅ I can see the error you reported in your last comment when importing the Scout Observability package in a platform test:

image

✅ Importing Playwright in an observability test throws an error:

image

@dmlemeshko dmlemeshko marked this pull request as ready for review July 1, 2025 12:27
@dmlemeshko dmlemeshko requested review from a team as code owners July 1, 2025 12:27
@botelastic botelastic bot added the Team:actionable-obs Formerly "obs-ux-management", responsible for SLO, o11y alerting, significant events, & synthetics. label Jul 1, 2025
@elasticmachine
Copy link
Copy Markdown
Contributor

Pinging @elastic/obs-ux-management-team (Team:obs-ux-management)

@elasticmachine
Copy link
Copy Markdown
Contributor

💛 Build succeeded, but was flaky

Failed CI Steps

Test Failures

  • [job] [logs] FTR Configs #49 / Search solution tests Search Home page Solution Nav - Search search home page with existing indices "before each" hook for "renders Elasticsearch Documentation content"

Metrics [docs]

Public APIs missing comments

Total count of every public API that lacks a comment. Target amount is 0. Run node scripts/build_api_docs --plugin [yourplugin] --stats comments for more detailed information.

id before after diff
@kbn/scout-oblt 71 76 +5
Unknown metric groups

API count

id before after diff
@kbn/scout-oblt 365 370 +5

History

cc @dmlemeshko

Copy link
Copy Markdown
Contributor

@cesco-f cesco-f left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changes in x-pack/solutions/observability/plugins/observability/tsconfig.json and x-pack/solutions/observability/plugins/observability/ui_tests/fixtures/generators.ts LGTM.

Copy link
Copy Markdown
Contributor

@flash1293 flash1293 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just adding a comma, what could go wrong?

@dmlemeshko dmlemeshko merged commit 4c6ab87 into elastic:main Jul 2, 2025
11 checks passed
@kibanamachine
Copy link
Copy Markdown
Contributor

Starting backport for target branches: 8.19, 9.1

https://github.com/elastic/kibana/actions/runs/16019965408

@kibanamachine
Copy link
Copy Markdown
Contributor

💔 All backports failed

Status Branch Result
8.19 Backport failed because of merge conflicts
9.1 Backport failed because of merge conflicts

Manual backport

To create the backport manually run:

node scripts/backport --pr 225791

Questions ?

Please refer to the Backport tool documentation

@dmlemeshko
Copy link
Copy Markdown
Contributor Author

💚 All backports created successfully

Status Branch Result
9.1

Note: Successful backport PRs will be merged automatically after passing CI.

Questions ?

Please refer to the Backport tool documentation

dmlemeshko added a commit to dmlemeshko/kibana that referenced this pull request Jul 2, 2025
## Summary

Adding ESLint rules to control the proper test package is used for
testing:

- platform tests should import only from `@kbn/scout`
- solution tests should import only from solution-specific scout package
(e.g. security plugins => `@kbn/scout-security`)

example:

```
ERROR
/Users/dmle/github/kibana/x-pack/solutions/observability/plugins/apm/ui_tests/parallel_tests/service_inventory/service_inventory.spec.ts
        7:1  error  '@kbn/scout' import is restricted from being used by a pattern.
Observability solution tests should import from '@kbn/scout-oblt' instead  no-restricted-imports

      ✖ 1 problem (1 error, 0 warnings)
```

---------

Co-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com>
(cherry picked from commit 4c6ab87)

# Conflicts:
#	x-pack/solutions/observability/plugins/observability/tsconfig.json
#	x-pack/solutions/observability/plugins/observability/ui_tests/fixtures/generators.ts
@dmlemeshko
Copy link
Copy Markdown
Contributor Author

💚 All backports created successfully

Status Branch Result
8.19

Note: Successful backport PRs will be merged automatically after passing CI.

Questions ?

Please refer to the Backport tool documentation

dmlemeshko added a commit to dmlemeshko/kibana that referenced this pull request Jul 2, 2025
## Summary

Adding ESLint rules to control the proper test package is used for
testing:

- platform tests should import only from `@kbn/scout`
- solution tests should import only from solution-specific scout package
(e.g. security plugins => `@kbn/scout-security`)

example:

```
ERROR
/Users/dmle/github/kibana/x-pack/solutions/observability/plugins/apm/ui_tests/parallel_tests/service_inventory/service_inventory.spec.ts
        7:1  error  '@kbn/scout' import is restricted from being used by a pattern.
Observability solution tests should import from '@kbn/scout-oblt' instead  no-restricted-imports

      ✖ 1 problem (1 error, 0 warnings)
```

---------

Co-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com>
(cherry picked from commit 4c6ab87)

# Conflicts:
#	x-pack/platform/plugins/shared/streams_app/tsconfig.json
#	x-pack/solutions/observability/plugins/observability/tsconfig.json
#	x-pack/solutions/observability/plugins/observability/ui_tests/fixtures/generators.ts
@kibanamachine kibanamachine added the backport missing Added to PRs automatically when the are determined to be missing a backport. label Jul 4, 2025
@kibanamachine
Copy link
Copy Markdown
Contributor

Looks like this PR has backport PRs but they still haven't been merged. Please merge them ASAP to keep the branches relatively in sync.
cc: @dmlemeshko

1 similar comment
@kibanamachine
Copy link
Copy Markdown
Contributor

Looks like this PR has backport PRs but they still haven't been merged. Please merge them ASAP to keep the branches relatively in sync.
cc: @dmlemeshko

dmlemeshko added a commit that referenced this pull request Jul 7, 2025
…226138)

# Backport

This will backport the following commits from `main` to `9.1`:
- [[scout] adding ESLint rules for test package imports
(#225791)](#225791)

<!--- Backport version: 10.0.1 -->

### Questions ?
Please refer to the [Backport tool
documentation](https://github.com/sorenlouv/backport)

<!--BACKPORT [{"author":{"name":"Dzmitry
Lemechko","email":"dzmitry.lemechko@elastic.co"},"sourceCommit":{"committedDate":"2025-07-02T08:23:16Z","message":"[scout]
adding ESLint rules for test package imports (#225791)\n\n##
Summary\n\nAdding ESLint rules to control the proper test package is
used for\ntesting:\n\n- platform tests should import only from
`@kbn/scout`\n- solution tests should import only from solution-specific
scout package\n(e.g. security plugins =>
`@kbn/scout-security`)\n\n\nexample:
\n\n```\nERROR\n/Users/dmle/github/kibana/x-pack/solutions/observability/plugins/apm/ui_tests/parallel_tests/service_inventory/service_inventory.spec.ts\n
7:1 error '@kbn/scout' import is restricted from being used by a
pattern.\nObservability solution tests should import from
'@kbn/scout-oblt' instead no-restricted-imports\n\n ✖ 1 problem (1
error, 0 warnings)\n```\n\n---------\n\nCo-authored-by: kibanamachine
<42973632+kibanamachine@users.noreply.github.com>","sha":"4c6ab87ddf409ca92db7f8278a851e3751c6bb99","branchLabelMapping":{"^v9.2.0$":"main","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["release_note:skip","Team:obs-ux-management","backport:version","test:scout","v9.1.0","v8.19.0","v9.2.0"],"title":"[scout]
adding ESLint rules for test package
imports","number":225791,"url":"https://github.com/elastic/kibana/pull/225791","mergeCommit":{"message":"[scout]
adding ESLint rules for test package imports (#225791)\n\n##
Summary\n\nAdding ESLint rules to control the proper test package is
used for\ntesting:\n\n- platform tests should import only from
`@kbn/scout`\n- solution tests should import only from solution-specific
scout package\n(e.g. security plugins =>
`@kbn/scout-security`)\n\n\nexample:
\n\n```\nERROR\n/Users/dmle/github/kibana/x-pack/solutions/observability/plugins/apm/ui_tests/parallel_tests/service_inventory/service_inventory.spec.ts\n
7:1 error '@kbn/scout' import is restricted from being used by a
pattern.\nObservability solution tests should import from
'@kbn/scout-oblt' instead no-restricted-imports\n\n ✖ 1 problem (1
error, 0 warnings)\n```\n\n---------\n\nCo-authored-by: kibanamachine
<42973632+kibanamachine@users.noreply.github.com>","sha":"4c6ab87ddf409ca92db7f8278a851e3751c6bb99"}},"sourceBranch":"main","suggestedTargetBranches":["9.1","8.19"],"targetPullRequestStates":[{"branch":"9.1","label":"v9.1.0","branchLabelMappingKey":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"},{"branch":"8.19","label":"v8.19.0","branchLabelMappingKey":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"},{"branch":"main","label":"v9.2.0","branchLabelMappingKey":"^v9.2.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/225791","number":225791,"mergeCommit":{"message":"[scout]
adding ESLint rules for test package imports (#225791)\n\n##
Summary\n\nAdding ESLint rules to control the proper test package is
used for\ntesting:\n\n- platform tests should import only from
`@kbn/scout`\n- solution tests should import only from solution-specific
scout package\n(e.g. security plugins =>
`@kbn/scout-security`)\n\n\nexample:
\n\n```\nERROR\n/Users/dmle/github/kibana/x-pack/solutions/observability/plugins/apm/ui_tests/parallel_tests/service_inventory/service_inventory.spec.ts\n
7:1 error '@kbn/scout' import is restricted from being used by a
pattern.\nObservability solution tests should import from
'@kbn/scout-oblt' instead no-restricted-imports\n\n ✖ 1 problem (1
error, 0 warnings)\n```\n\n---------\n\nCo-authored-by: kibanamachine
<42973632+kibanamachine@users.noreply.github.com>","sha":"4c6ab87ddf409ca92db7f8278a851e3751c6bb99"}}]}]
BACKPORT-->

---------

Co-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com>
dmlemeshko added a commit that referenced this pull request Jul 7, 2025
…#226146)

# Backport

This will backport the following commits from `main` to `8.19`:
- [[scout] adding ESLint rules for test package imports
(#225791)](#225791)

<!--- Backport version: 10.0.1 -->

### Questions ?
Please refer to the [Backport tool
documentation](https://github.com/sorenlouv/backport)

<!--BACKPORT [{"author":{"name":"Dzmitry
Lemechko","email":"dzmitry.lemechko@elastic.co"},"sourceCommit":{"committedDate":"2025-07-02T08:23:16Z","message":"[scout]
adding ESLint rules for test package imports (#225791)\n\n##
Summary\n\nAdding ESLint rules to control the proper test package is
used for\ntesting:\n\n- platform tests should import only from
`@kbn/scout`\n- solution tests should import only from solution-specific
scout package\n(e.g. security plugins =>
`@kbn/scout-security`)\n\n\nexample:
\n\n```\nERROR\n/Users/dmle/github/kibana/x-pack/solutions/observability/plugins/apm/ui_tests/parallel_tests/service_inventory/service_inventory.spec.ts\n
7:1 error '@kbn/scout' import is restricted from being used by a
pattern.\nObservability solution tests should import from
'@kbn/scout-oblt' instead no-restricted-imports\n\n ✖ 1 problem (1
error, 0 warnings)\n```\n\n---------\n\nCo-authored-by: kibanamachine
<42973632+kibanamachine@users.noreply.github.com>","sha":"4c6ab87ddf409ca92db7f8278a851e3751c6bb99","branchLabelMapping":{"^v9.2.0$":"main","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["release_note:skip","Team:obs-ux-management","backport:version","test:scout","v9.1.0","v8.19.0","v9.2.0"],"title":"[scout]
adding ESLint rules for test package
imports","number":225791,"url":"https://github.com/elastic/kibana/pull/225791","mergeCommit":{"message":"[scout]
adding ESLint rules for test package imports (#225791)\n\n##
Summary\n\nAdding ESLint rules to control the proper test package is
used for\ntesting:\n\n- platform tests should import only from
`@kbn/scout`\n- solution tests should import only from solution-specific
scout package\n(e.g. security plugins =>
`@kbn/scout-security`)\n\n\nexample:
\n\n```\nERROR\n/Users/dmle/github/kibana/x-pack/solutions/observability/plugins/apm/ui_tests/parallel_tests/service_inventory/service_inventory.spec.ts\n
7:1 error '@kbn/scout' import is restricted from being used by a
pattern.\nObservability solution tests should import from
'@kbn/scout-oblt' instead no-restricted-imports\n\n ✖ 1 problem (1
error, 0 warnings)\n```\n\n---------\n\nCo-authored-by: kibanamachine
<42973632+kibanamachine@users.noreply.github.com>","sha":"4c6ab87ddf409ca92db7f8278a851e3751c6bb99"}},"sourceBranch":"main","suggestedTargetBranches":["8.19"],"targetPullRequestStates":[{"branch":"9.1","label":"v9.1.0","branchLabelMappingKey":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"url":"https://github.com/elastic/kibana/pull/226138","number":226138,"state":"OPEN"},{"branch":"8.19","label":"v8.19.0","branchLabelMappingKey":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"},{"branch":"main","label":"v9.2.0","branchLabelMappingKey":"^v9.2.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/225791","number":225791,"mergeCommit":{"message":"[scout]
adding ESLint rules for test package imports (#225791)\n\n##
Summary\n\nAdding ESLint rules to control the proper test package is
used for\ntesting:\n\n- platform tests should import only from
`@kbn/scout`\n- solution tests should import only from solution-specific
scout package\n(e.g. security plugins =>
`@kbn/scout-security`)\n\n\nexample:
\n\n```\nERROR\n/Users/dmle/github/kibana/x-pack/solutions/observability/plugins/apm/ui_tests/parallel_tests/service_inventory/service_inventory.spec.ts\n
7:1 error '@kbn/scout' import is restricted from being used by a
pattern.\nObservability solution tests should import from
'@kbn/scout-oblt' instead no-restricted-imports\n\n ✖ 1 problem (1
error, 0 warnings)\n```\n\n---------\n\nCo-authored-by: kibanamachine
<42973632+kibanamachine@users.noreply.github.com>","sha":"4c6ab87ddf409ca92db7f8278a851e3751c6bb99"}}]}]
BACKPORT-->

---------

Co-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com>
@kibanamachine kibanamachine removed the backport missing Added to PRs automatically when the are determined to be missing a backport. label Jul 7, 2025
kertal pushed a commit to kertal/kibana that referenced this pull request Jul 25, 2025
## Summary

Adding ESLint rules to control the proper test package is used for
testing:

- platform tests should import only from `@kbn/scout`
- solution tests should import only from solution-specific scout package
(e.g. security plugins => `@kbn/scout-security`)


example: 

```
ERROR
/Users/dmle/github/kibana/x-pack/solutions/observability/plugins/apm/ui_tests/parallel_tests/service_inventory/service_inventory.spec.ts
        7:1  error  '@kbn/scout' import is restricted from being used by a pattern.
Observability solution tests should import from '@kbn/scout-oblt' instead  no-restricted-imports

      ✖ 1 problem (1 error, 0 warnings)
```

---------

Co-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backport:version Backport to applied version labels release_note:skip Skip the PR/issue when compiling release notes Team:actionable-obs Formerly "obs-ux-management", responsible for SLO, o11y alerting, significant events, & synthetics. test:scout v8.19.0 v9.1.0 v9.2.0

Projects

None yet

Development

Successfully merging this pull request may close these issues.

8 participants