[Discover] Enable consistent-type-imports eslint rule#212293
[Discover] Enable consistent-type-imports eslint rule#212293davismcphee merged 6 commits intoelastic:mainfrom
consistent-type-imports eslint rule#212293Conversation
|
Pinging @elastic/kibana-data-discovery (Team:DataDiscovery) |
jughosta
left a comment
There was a problem hiding this comment.
Nice idea!
We could also extend the list with our other plugins and packages like UnifiedHistogram and UnifiedDocViewer.
|
@jughosta Agreed! Now that I know I'm not the only one who thinks this is a good idea, I can definitely open another PR for our other plugins and packages 😁 |
yngrdyn
left a comment
There was a problem hiding this comment.
Obs-ux-logs changes LGTM
|
Related to #212221 |
|
I think it is worth addressing this globally for the whole repo, I'll create an issue for it. If we really want to add this ESLint constraint, best strategy, as Matt suggests, would be a divide & conquer approach:
|
|
@gsoldevila That sounds great to me. In the meantime would it be ok for us to get ahead of things in our plugins and merge this PR? |
Bamieh
left a comment
There was a problem hiding this comment.
Core changes LGTM (1 file change)
|
/ci |
💚 Build Succeeded
Metrics [docs]Async chunks
History
cc @davismcphee |
|
Starting backport for target branches: 8.x https://github.com/elastic/kibana/actions/runs/13756005544 |
💔 All backports failed
Manual backportTo create the backport manually run: Questions ?Please refer to the Backport tool documentation |
|
Friendly reminder: Looks like this PR hasn’t been backported yet. |
|
Friendly reminder: Looks like this PR hasn’t been backported yet. |
1 similar comment
|
Friendly reminder: Looks like this PR hasn’t been backported yet. |
💚 All backports created successfully
Note: Successful backport PRs will be merged automatically after passing CI. Questions ?Please refer to the Backport tool documentation |
## Summary This PR enables the `@typescript-eslint/consistent-type-imports` eslint rule for the Discover and saved search plugins. The benefits are that it keeps things a bit cleaner, but more importantly ensures we aren't accidentally importing more than types when all we need is types, which can cause side effects. I've added `backport:prev-major` and `backport:prev-minor` labels to the PR because I figure backporting this is safe and would reduce merge conflicts in future backports. We should consider enabling this for all of our plugins and packages, although that list might harder to maintain. I'm also curious if anyone knows of other eslint rules we don't currently use that we'd benefit from enabling. ### Checklist - [ ] 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/guide/en/kibana/master/contributing.html#kibana-release-notes-process) --------- Co-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com> (cherry picked from commit c398102) # Conflicts: # src/platform/plugins/shared/discover/public/application/context/context_app.tsx # src/platform/plugins/shared/discover/public/application/context/context_app_content.test.tsx # src/platform/plugins/shared/discover/public/application/context/context_app_content.tsx # src/platform/plugins/shared/discover/public/application/doc/components/doc.test.tsx # src/platform/plugins/shared/discover/public/application/main/components/layout/discover_layout.tsx # src/platform/plugins/shared/discover/public/application/main/components/loading_spinner/loading_spinner.tsx # src/platform/plugins/shared/discover/public/application/main/components/top_nav/on_save_search.tsx # src/platform/plugins/shared/discover/public/application/main/data_fetching/update_search_source.ts # src/platform/plugins/shared/discover/public/application/main/discover_main_route.test.tsx # src/platform/plugins/shared/discover/public/application/main/discover_main_route.tsx # src/platform/plugins/shared/discover/public/application/main/state_management/discover_state.ts # src/platform/plugins/shared/discover/public/application/main/state_management/utils/get_state_defaults.ts # src/platform/plugins/shared/discover/public/components/data_types/traces/summary_column.tsx # src/platform/plugins/shared/discover/public/context_awareness/profile_providers/observability/traces_data_source_profile/accessors/get_doc_viewer.tsx # src/platform/plugins/shared/discover/public/context_awareness/profile_providers/observability/traces_data_source_profile/profile.test.ts # src/platform/plugins/shared/discover/public/context_awareness/profile_providers/observability/traces_data_source_profile/profile.ts # src/platform/plugins/shared/discover/public/context_awareness/profile_providers/security/accessors/get_cell_renderer_accessor.test.tsx # src/platform/plugins/shared/discover/public/context_awareness/profile_providers/security/accessors/get_cell_renderer_accessor.tsx # src/platform/plugins/shared/discover/public/context_awareness/profile_providers/security/security_root_profile/profile.tsx # src/platform/plugins/shared/discover/public/embeddable/components/search_embeddable_grid_component.tsx # src/platform/plugins/shared/discover/public/plugin.tsx # src/platform/plugins/shared/discover/server/locator/columns_from_locator.ts
… (#214641) # Backport This will backport the following commits from `main` to `8.x`: - [[Discover] Enable `consistent-type-imports` eslint rule (#212293)](#212293) <!--- Backport version: 9.6.6 --> ### Questions ? Please refer to the [Backport tool documentation](https://github.com/sorenlouv/backport) <!--BACKPORT [{"author":{"name":"Davis McPhee","email":"davis.mcphee@elastic.co"},"sourceCommit":{"committedDate":"2025-03-10T03:09:57Z","message":"[Discover] Enable `consistent-type-imports` eslint rule (#212293)\n\n## Summary\n\nThis PR enables the `@typescript-eslint/consistent-type-imports` eslint\nrule for the Discover and saved search plugins. The benefits are that it\nkeeps things a bit cleaner, but more importantly ensures we aren't\naccidentally importing more than types when all we need is types, which\ncan cause side effects.\n\nI've added `backport:prev-major` and `backport:prev-minor` labels to the\nPR because I figure backporting this is safe and would reduce merge\nconflicts in future backports.\n\nWe should consider enabling this for all of our plugins and packages,\nalthough that list might harder to maintain. I'm also curious if anyone\nknows of other eslint rules we don't currently use that we'd benefit\nfrom enabling.\n\n### Checklist\n\n- [ ] Any text added follows [EUI's writing\nguidelines](https://elastic.github.io/eui/#/guidelines/writing), uses\nsentence case text and includes [i18n\nsupport](https://github.com/elastic/kibana/blob/main/src/platform/packages/shared/kbn-i18n/README.md)\n- [ ]\n[Documentation](https://www.elastic.co/guide/en/kibana/master/development-documentation.html)\nwas added for features that require explanation or tutorials\n- [ ] [Unit or functional\ntests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)\nwere updated or added to match the most common scenarios\n- [ ] If a plugin configuration key changed, check if it needs to be\nallowlisted in the cloud and added to the [docker\nlist](https://github.com/elastic/kibana/blob/main/src/dev/build/tasks/os_packages/docker_generator/resources/base/bin/kibana-docker)\n- [ ] This was checked for breaking HTTP API changes, and any breaking\nchanges have been approved by the breaking-change committee. The\n`release_note:breaking` label should be applied in these situations.\n- [ ] [Flaky Test\nRunner](https://ci-stats.kibana.dev/trigger_flaky_test_runner/1) was\nused on any tests changed\n- [ ] The PR description includes the appropriate Release Notes section,\nand the correct `release_note:*` label is applied per the\n[guidelines](https://www.elastic.co/guide/en/kibana/master/contributing.html#kibana-release-notes-process)\n\n---------\n\nCo-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com>","sha":"c398102c79a48d7f2c26c7f0b73bd16ee9ce9f7c","branchLabelMapping":{"^v9.1.0$":"main","^v8.19.0$":"8.x","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["Feature:Discover","release_note:skip","backport missing","Team:DataDiscovery","backport:version","v9.1.0","v8.19.0"],"title":"[Discover] Enable `consistent-type-imports` eslint rule","number":212293,"url":"https://github.com/elastic/kibana/pull/212293","mergeCommit":{"message":"[Discover] Enable `consistent-type-imports` eslint rule (#212293)\n\n## Summary\n\nThis PR enables the `@typescript-eslint/consistent-type-imports` eslint\nrule for the Discover and saved search plugins. The benefits are that it\nkeeps things a bit cleaner, but more importantly ensures we aren't\naccidentally importing more than types when all we need is types, which\ncan cause side effects.\n\nI've added `backport:prev-major` and `backport:prev-minor` labels to the\nPR because I figure backporting this is safe and would reduce merge\nconflicts in future backports.\n\nWe should consider enabling this for all of our plugins and packages,\nalthough that list might harder to maintain. I'm also curious if anyone\nknows of other eslint rules we don't currently use that we'd benefit\nfrom enabling.\n\n### Checklist\n\n- [ ] Any text added follows [EUI's writing\nguidelines](https://elastic.github.io/eui/#/guidelines/writing), uses\nsentence case text and includes [i18n\nsupport](https://github.com/elastic/kibana/blob/main/src/platform/packages/shared/kbn-i18n/README.md)\n- [ ]\n[Documentation](https://www.elastic.co/guide/en/kibana/master/development-documentation.html)\nwas added for features that require explanation or tutorials\n- [ ] [Unit or functional\ntests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)\nwere updated or added to match the most common scenarios\n- [ ] If a plugin configuration key changed, check if it needs to be\nallowlisted in the cloud and added to the [docker\nlist](https://github.com/elastic/kibana/blob/main/src/dev/build/tasks/os_packages/docker_generator/resources/base/bin/kibana-docker)\n- [ ] This was checked for breaking HTTP API changes, and any breaking\nchanges have been approved by the breaking-change committee. The\n`release_note:breaking` label should be applied in these situations.\n- [ ] [Flaky Test\nRunner](https://ci-stats.kibana.dev/trigger_flaky_test_runner/1) was\nused on any tests changed\n- [ ] The PR description includes the appropriate Release Notes section,\nand the correct `release_note:*` label is applied per the\n[guidelines](https://www.elastic.co/guide/en/kibana/master/contributing.html#kibana-release-notes-process)\n\n---------\n\nCo-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com>","sha":"c398102c79a48d7f2c26c7f0b73bd16ee9ce9f7c"}},"sourceBranch":"main","suggestedTargetBranches":["8.x"],"targetPullRequestStates":[{"branch":"main","label":"v9.1.0","branchLabelMappingKey":"^v9.1.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/212293","number":212293,"mergeCommit":{"message":"[Discover] Enable `consistent-type-imports` eslint rule (#212293)\n\n## Summary\n\nThis PR enables the `@typescript-eslint/consistent-type-imports` eslint\nrule for the Discover and saved search plugins. The benefits are that it\nkeeps things a bit cleaner, but more importantly ensures we aren't\naccidentally importing more than types when all we need is types, which\ncan cause side effects.\n\nI've added `backport:prev-major` and `backport:prev-minor` labels to the\nPR because I figure backporting this is safe and would reduce merge\nconflicts in future backports.\n\nWe should consider enabling this for all of our plugins and packages,\nalthough that list might harder to maintain. I'm also curious if anyone\nknows of other eslint rules we don't currently use that we'd benefit\nfrom enabling.\n\n### Checklist\n\n- [ ] Any text added follows [EUI's writing\nguidelines](https://elastic.github.io/eui/#/guidelines/writing), uses\nsentence case text and includes [i18n\nsupport](https://github.com/elastic/kibana/blob/main/src/platform/packages/shared/kbn-i18n/README.md)\n- [ ]\n[Documentation](https://www.elastic.co/guide/en/kibana/master/development-documentation.html)\nwas added for features that require explanation or tutorials\n- [ ] [Unit or functional\ntests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)\nwere updated or added to match the most common scenarios\n- [ ] If a plugin configuration key changed, check if it needs to be\nallowlisted in the cloud and added to the [docker\nlist](https://github.com/elastic/kibana/blob/main/src/dev/build/tasks/os_packages/docker_generator/resources/base/bin/kibana-docker)\n- [ ] This was checked for breaking HTTP API changes, and any breaking\nchanges have been approved by the breaking-change committee. The\n`release_note:breaking` label should be applied in these situations.\n- [ ] [Flaky Test\nRunner](https://ci-stats.kibana.dev/trigger_flaky_test_runner/1) was\nused on any tests changed\n- [ ] The PR description includes the appropriate Release Notes section,\nand the correct `release_note:*` label is applied per the\n[guidelines](https://www.elastic.co/guide/en/kibana/master/contributing.html#kibana-release-notes-process)\n\n---------\n\nCo-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com>","sha":"c398102c79a48d7f2c26c7f0b73bd16ee9ce9f7c"}},{"branch":"8.x","label":"v8.19.0","branchLabelMappingKey":"^v8.19.0$","isSourceBranch":false,"state":"NOT_CREATED"}]}] BACKPORT--> --------- Co-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com>
## Summary This PR enables the `@typescript-eslint/consistent-type-imports` eslint rule for the Discover and saved search plugins. The benefits are that it keeps things a bit cleaner, but more importantly ensures we aren't accidentally importing more than types when all we need is types, which can cause side effects. I've added `backport:prev-major` and `backport:prev-minor` labels to the PR because I figure backporting this is safe and would reduce merge conflicts in future backports. We should consider enabling this for all of our plugins and packages, although that list might harder to maintain. I'm also curious if anyone knows of other eslint rules we don't currently use that we'd benefit from enabling. ### Checklist - [ ] 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/guide/en/kibana/master/contributing.html#kibana-release-notes-process) --------- Co-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com>
Summary
This PR enables the
@typescript-eslint/consistent-type-importseslint rule for the Discover and saved search plugins. The benefits are that it keeps things a bit cleaner, but more importantly ensures we aren't accidentally importing more than types when all we need is types, which can cause side effects.I've added
backport:prev-majorandbackport:prev-minorlabels to the PR because I figure backporting this is safe and would reduce merge conflicts in future backports.We should consider enabling this for all of our plugins and packages, although that list might harder to maintain. I'm also curious if anyone knows of other eslint rules we don't currently use that we'd benefit from enabling.
Checklist
release_note:breakinglabel should be applied in these situations.release_note:*label is applied per the guidelines