[8.10] [Ops] Fix @kbn/imports/no_unused_imports rule (#164870) (#164906)

# Backport

This will backport the following commits from `main` to `8.10`:
- [[Ops] Fix @kbn/imports/no_unused_imports rule
(#164870)](https://github.com/elastic/kibana/pull/164870)

<!--- Backport version: 8.9.7 -->

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

<!--BACKPORT [{"author":{"name":"Alex
Szabo","email":"alex.szabo@elastic.co"},"sourceCommit":{"committedDate":"2023-08-25T23:13:57Z","message":"[Ops]
Fix @kbn/imports/no_unused_imports rule (#164870)\n\n##
Summary\r\n@jloleysens reported that ESLint breaks (probably in IDEs
only) because\r\nof this bug. When there's an unused import, linting
stops for the whole\r\nfile.\r\n\r\nBy adding this flag, it no longer
breaks on my machine, however,\r\nauto-fixing still doesn't work from
the CLI. The IDE auto-fixes because\r\nit also recognizes it as a
non-unsed variable.\r\n\r\n- add `meta.hasSuggestions` to
`@kbn/imports/no_unused_imports` prevent\r\nESLint from
breaking","sha":"d8d355dd7b4184127a760261178daf0f8a94af86","branchLabelMapping":{"^v8.11.0$":"main","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["chore","Team:Operations","release_note:skip","backport:all-open","v8.11.0"],"number":164870,"url":"https://github.com/elastic/kibana/pull/164870","mergeCommit":{"message":"[Ops]
Fix @kbn/imports/no_unused_imports rule (#164870)\n\n##
Summary\r\n@jloleysens reported that ESLint breaks (probably in IDEs
only) because\r\nof this bug. When there's an unused import, linting
stops for the whole\r\nfile.\r\n\r\nBy adding this flag, it no longer
breaks on my machine, however,\r\nauto-fixing still doesn't work from
the CLI. The IDE auto-fixes because\r\nit also recognizes it as a
non-unsed variable.\r\n\r\n- add `meta.hasSuggestions` to
`@kbn/imports/no_unused_imports` prevent\r\nESLint from
breaking","sha":"d8d355dd7b4184127a760261178daf0f8a94af86"}},"sourceBranch":"main","suggestedTargetBranches":[],"targetPullRequestStates":[{"branch":"main","label":"v8.11.0","labelRegex":"^v8.11.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/164870","number":164870,"mergeCommit":{"message":"[Ops]
Fix @kbn/imports/no_unused_imports rule (#164870)\n\n##
Summary\r\n@jloleysens reported that ESLint breaks (probably in IDEs
only) because\r\nof this bug. When there's an unused import, linting
stops for the whole\r\nfile.\r\n\r\nBy adding this flag, it no longer
breaks on my machine, however,\r\nauto-fixing still doesn't work from
the CLI. The IDE auto-fixes because\r\nit also recognizes it as a
non-unsed variable.\r\n\r\n- add `meta.hasSuggestions` to
`@kbn/imports/no_unused_imports` prevent\r\nESLint from
breaking","sha":"d8d355dd7b4184127a760261178daf0f8a94af86"}}]}]
BACKPORT-->

Co-authored-by: Alex Szabo <alex.szabo@elastic.co>
This commit is contained in:
Kibana Machine 2023-08-25 20:24:13 -04:00 committed by GitHub
parent a768f1cb2a
commit 73c44a148a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -78,6 +78,7 @@ function isTsOrEslintIgnore(comment: Comment) {
export const NoUnusedImportsRule: Rule.RuleModule = {
meta: {
hasSuggestions: true,
fixable: 'code',
docs: {
url: 'https://github.com/elastic/kibana/blob/main/packages/kbn-eslint-plugin-imports/README.mdx#kbnimportsno_unused_imports',