From 34e51a6807b3c51edde2cc34159cbcf6ac3dccc1 Mon Sep 17 00:00:00 2001 From: Mario Castro Date: Wed, 11 May 2022 17:55:54 +0200 Subject: [PATCH 1/5] Add Elasticsearch Serverless Forwarder to integrations UI (#130085) --- .../custom_integrations/common/index.ts | 2 + .../public/assets/placeholders/logo_esf.svg | 84 +++++++++++++++++++ .../server/external_integration/index.ts | 74 ++++++++++++++++ .../custom_integrations/server/plugin.test.ts | 34 +++++--- .../custom_integrations/server/plugin.ts | 2 + .../apis/custom_integration/integrations.ts | 2 +- .../sections/epm/screens/home/index.tsx | 2 +- 7 files changed, 188 insertions(+), 12 deletions(-) create mode 100644 src/plugins/custom_integrations/public/assets/placeholders/logo_esf.svg create mode 100644 src/plugins/custom_integrations/server/external_integration/index.ts diff --git a/src/plugins/custom_integrations/common/index.ts b/src/plugins/custom_integrations/common/index.ts index 46cf778bf0139..3aa911087ea89 100755 --- a/src/plugins/custom_integrations/common/index.ts +++ b/src/plugins/custom_integrations/common/index.ts @@ -82,6 +82,7 @@ export const SHIPPER_DISPLAY = { sample_data: 'Sample data', tests: 'Tests', tutorial: 'Tutorials', + placeholders: 'Extra Integrations', }; /** @@ -113,6 +114,7 @@ export interface CustomIntegration { description: string; type: 'ui_link'; uiInternalPath: string; + uiExternalLink?: string; isBeta: boolean; icons: CustomIntegrationIcon[]; categories: IntegrationCategory[]; diff --git a/src/plugins/custom_integrations/public/assets/placeholders/logo_esf.svg b/src/plugins/custom_integrations/public/assets/placeholders/logo_esf.svg new file mode 100644 index 0000000000000..0c5ed76799a1f --- /dev/null +++ b/src/plugins/custom_integrations/public/assets/placeholders/logo_esf.svg @@ -0,0 +1,84 @@ + + + + + + + + + + + + + + + + + + diff --git a/src/plugins/custom_integrations/server/external_integration/index.ts b/src/plugins/custom_integrations/server/external_integration/index.ts new file mode 100644 index 0000000000000..01227bf71a29b --- /dev/null +++ b/src/plugins/custom_integrations/server/external_integration/index.ts @@ -0,0 +1,74 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License + * 2.0 and the Server Side Public License, v 1; you may not use this file except + * in compliance with, at your election, the Elastic License 2.0 or the Server + * Side Public License, v 1. + */ + +import { i18n } from '@kbn/i18n'; +import { CoreSetup } from '@kbn/core/server'; +import { CustomIntegrationRegistry } from '../custom_integration_registry'; +import { CustomIntegrationIcon, IntegrationCategory, PLUGIN_ID } from '../../common'; + +interface ExternalIntegration { + id: string; + title: string; + icon?: string; + euiIconName?: string; + description: string; + docUrlTemplate: string; + categories: IntegrationCategory[]; +} + +export const integrations: ExternalIntegration[] = [ + { + id: 'esf', + title: i18n.translate('customIntegrations.placeholders.EsfTitle', { + defaultMessage: 'AWS Serverless Application Repository', + }), + icon: 'logo_esf.svg', + description: i18n.translate('customIntegrations.placeholders.EsfDescription', { + defaultMessage: + 'Collect logs using AWS Lambda application available in AWS Serverless Application Repository.', + }), + docUrlTemplate: `https://serverlessrepo.aws.amazon.com/applications/eu-central-1/267093732750/elastic-serverless-forwarder`, + categories: ['aws', 'custom'], + }, +]; + +export function registerExternalIntegrations( + core: CoreSetup, + registry: CustomIntegrationRegistry, + branch: string +) { + integrations.forEach((integration: ExternalIntegration) => { + const icons: CustomIntegrationIcon[] = []; + if (integration.euiIconName) { + icons.push({ + type: 'eui', + src: integration.euiIconName, + }); + } else if (integration.icon) { + icons.push({ + type: 'svg', + src: core.http.basePath.prepend( + `/plugins/${PLUGIN_ID}/assets/placeholders/${integration.icon}` + ), + }); + } + + registry.registerCustomIntegration({ + uiInternalPath: '', + id: `placeholder.${integration.id}`, + title: integration.title, + description: integration.description, + type: 'ui_link', + shipper: 'placeholders', + uiExternalLink: integration.docUrlTemplate, + isBeta: false, + icons, + categories: integration.categories, + }); + }); +} diff --git a/src/plugins/custom_integrations/server/plugin.test.ts b/src/plugins/custom_integrations/server/plugin.test.ts index 7e08fc3cb1d55..0bfc014ed5cdd 100644 --- a/src/plugins/custom_integrations/server/plugin.test.ts +++ b/src/plugins/custom_integrations/server/plugin.test.ts @@ -28,7 +28,7 @@ describe('CustomIntegrationsPlugin', () => { expect(setup).toHaveProperty('getAppendCustomIntegrations'); }); - test('should register language clients', () => { + test('should register custom integrations', () => { const setup = new CustomIntegrationsPlugin(initContext).setup(mockCoreSetup); expect(setup.getAppendCustomIntegrations()).toEqual([ { @@ -40,7 +40,7 @@ describe('CustomIntegrationsPlugin', () => { uiInternalPath: 'https://www.elastic.co/guide/en/elasticsearch/client/javascript-api/branch/introduction.html', isBeta: false, - icons: [{ type: 'svg' }], + icons: [{ type: 'svg', src: undefined }], categories: ['elastic_stack', 'custom', 'language_client'], }, { @@ -52,7 +52,7 @@ describe('CustomIntegrationsPlugin', () => { uiInternalPath: 'https://www.elastic.co/guide/en/elasticsearch/client/ruby-api/branch/ruby_client.html', isBeta: false, - icons: [{ type: 'svg' }], + icons: [{ type: 'svg', src: undefined }], categories: ['elastic_stack', 'custom', 'language_client'], }, { @@ -64,7 +64,7 @@ describe('CustomIntegrationsPlugin', () => { uiInternalPath: 'https://www.elastic.co/guide/en/elasticsearch/client/go-api/branch/overview.html', isBeta: false, - icons: [{ type: 'svg' }], + icons: [{ type: 'svg', src: undefined }], categories: ['elastic_stack', 'custom', 'language_client'], }, { @@ -76,7 +76,7 @@ describe('CustomIntegrationsPlugin', () => { uiInternalPath: 'https://www.elastic.co/guide/en/elasticsearch/client/net-api/branch/index.html', isBeta: false, - icons: [{ type: 'svg' }], + icons: [{ type: 'svg', src: undefined }], categories: ['elastic_stack', 'custom', 'language_client'], }, { @@ -88,7 +88,7 @@ describe('CustomIntegrationsPlugin', () => { uiInternalPath: 'https://www.elastic.co/guide/en/elasticsearch/client/php-api/branch/index.html', isBeta: false, - icons: [{ type: 'svg' }], + icons: [{ type: 'svg', src: undefined }], categories: ['elastic_stack', 'custom', 'language_client'], }, { @@ -100,7 +100,7 @@ describe('CustomIntegrationsPlugin', () => { uiInternalPath: 'https://www.elastic.co/guide/en/elasticsearch/client/perl-api/branch/index.html', isBeta: false, - icons: [{ type: 'svg' }], + icons: [{ type: 'svg', src: undefined }], categories: ['elastic_stack', 'custom', 'language_client'], }, { @@ -112,7 +112,7 @@ describe('CustomIntegrationsPlugin', () => { uiInternalPath: 'https://www.elastic.co/guide/en/elasticsearch/client/python-api/branch/index.html', isBeta: false, - icons: [{ type: 'svg' }], + icons: [{ type: 'svg', src: undefined }], categories: ['elastic_stack', 'custom', 'language_client'], }, { @@ -124,7 +124,7 @@ describe('CustomIntegrationsPlugin', () => { uiInternalPath: 'https://www.elastic.co/guide/en/elasticsearch/client/rust-api/branch/index.html', isBeta: false, - icons: [{ type: 'svg' }], + icons: [{ type: 'svg', src: undefined }], categories: ['elastic_stack', 'custom', 'language_client'], }, { @@ -136,9 +136,23 @@ describe('CustomIntegrationsPlugin', () => { uiInternalPath: 'https://www.elastic.co/guide/en/elasticsearch/client/java-api-client/branch/index.html', isBeta: false, - icons: [{ type: 'svg' }], + icons: [{ type: 'svg', src: undefined }], categories: ['elastic_stack', 'custom', 'language_client'], }, + { + id: 'placeholder.esf', + title: 'AWS Serverless Application Repository', + description: + 'Collect logs using AWS Lambda application available in AWS Serverless Application Repository.', + type: 'ui_link', + shipper: 'placeholders', + uiInternalPath: '', + uiExternalLink: + 'https://serverlessrepo.aws.amazon.com/applications/eu-central-1/267093732750/elastic-serverless-forwarder', + isBeta: false, + icons: [{ type: 'svg' }], + categories: ['aws', 'custom'], + }, ]); }); }); diff --git a/src/plugins/custom_integrations/server/plugin.ts b/src/plugins/custom_integrations/server/plugin.ts index 4e7c4cffe03d4..0f2cb2ecd216a 100755 --- a/src/plugins/custom_integrations/server/plugin.ts +++ b/src/plugins/custom_integrations/server/plugin.ts @@ -13,6 +13,7 @@ import { CustomIntegration } from '../common'; import { CustomIntegrationRegistry } from './custom_integration_registry'; import { defineRoutes } from './routes/define_routes'; import { registerLanguageClients } from './language_clients'; +import { registerExternalIntegrations } from './external_integration'; export class CustomIntegrationsPlugin implements Plugin @@ -37,6 +38,7 @@ export class CustomIntegrationsPlugin defineRoutes(router, this.customIngegrationRegistry); registerLanguageClients(core, this.customIngegrationRegistry, this.branch); + registerExternalIntegrations(core, this.customIngegrationRegistry, this.branch); return { registerCustomIntegration: (integration: Omit) => { diff --git a/test/api_integration/apis/custom_integration/integrations.ts b/test/api_integration/apis/custom_integration/integrations.ts index c4fda918328f8..c1b6518f6684a 100644 --- a/test/api_integration/apis/custom_integration/integrations.ts +++ b/test/api_integration/apis/custom_integration/integrations.ts @@ -22,7 +22,7 @@ export default function ({ getService }: FtrProviderContext) { expect(resp.body).to.be.an('array'); - expect(resp.body.length).to.be(42); + expect(resp.body.length).to.be(43); // Test for sample data card expect(resp.body.findIndex((c: { id: string }) => c.id === 'sample_data_all')).to.be.above( diff --git a/x-pack/plugins/fleet/public/applications/integrations/sections/epm/screens/home/index.tsx b/x-pack/plugins/fleet/public/applications/integrations/sections/epm/screens/home/index.tsx index 944cb8f94cfb2..0898f099e3e8c 100644 --- a/x-pack/plugins/fleet/public/applications/integrations/sections/epm/screens/home/index.tsx +++ b/x-pack/plugins/fleet/public/applications/integrations/sections/epm/screens/home/index.tsx @@ -51,7 +51,7 @@ export const mapToCard = ( let uiInternalPathUrl; if (item.type === 'ui_link') { - uiInternalPathUrl = getAbsolutePath(item.uiInternalPath); + uiInternalPathUrl = item.uiExternalLink || getAbsolutePath(item.uiInternalPath); } else { let urlVersion = item.version; From ca0f874c2a2e6991c2cbf5bd33d9a183ca289ebe Mon Sep 17 00:00:00 2001 From: "Joey F. Poon" Date: Wed, 11 May 2022 11:10:43 -0500 Subject: [PATCH 2/5] [Security Solution] fix flaky api integ tests (#131939) --- .../apis/data_stream_helper.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/x-pack/test/security_solution_endpoint_api_int/apis/data_stream_helper.ts b/x-pack/test/security_solution_endpoint_api_int/apis/data_stream_helper.ts index d6d759d3830f5..1caef61bec80c 100644 --- a/x-pack/test/security_solution_endpoint_api_int/apis/data_stream_helper.ts +++ b/x-pack/test/security_solution_endpoint_api_int/apis/data_stream_helper.ts @@ -137,7 +137,7 @@ export function bulkIndex( return client.bulk({ index, - refresh: true, + refresh: 'wait_for', body, }); } From 67376ed53ef34e537084bdb5c37c2aae19e2b493 Mon Sep 17 00:00:00 2001 From: Spencer Date: Wed, 11 May 2022 11:16:48 -0500 Subject: [PATCH 3/5] [eslint] add rule for auto-fixing unused imports (#131772) * [eslint] add rule for auto-fixing unused imports * [CI] Auto-commit changed files from 'node scripts/eslint --no-cache --fix' * Update index_table.test.js * Update follower_indices_list.test.js Co-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com> --- .../elastic-eslint-config-kibana/.eslintrc.js | 1 + packages/kbn-eslint-plugin-imports/README.md | 6 +- .../src/helpers/running_in_editor.ts | 7 +- .../kbn-eslint-plugin-imports/src/index.ts | 2 + .../src/rules/no_unused_imports.test.ts | 151 ++++++++++++++ .../src/rules/no_unused_imports.ts | 184 ++++++++++++++++++ packages/kbn-i18n-react/src/index.tsx | 2 - .../kbn-test/types/ftr_globals/mocha.d.ts | 2 +- src/dev/build/lib/scan.ts | 3 - src/dev/i18n/utils/verify_icu_message.ts | 2 +- src/dev/run_precommit_hook.js | 2 + .../actions/add_to_library_action.tsx | 2 - .../actions/unlink_from_library_action.tsx | 1 - .../embeddable/dashboard_container.tsx | 1 - .../hooks/use_dashboard_app_state.ts | 1 - .../lib/build_dashboard_container.ts | 1 - .../lib/load_saved_dashboard_state.ts | 2 - .../common/search/aggs/utils/time_splits.ts | 2 +- .../components/import_summary.test.tsx | 3 - .../create_index_pattern_select.tsx | 1 - .../vislib/percentage_mode_transform.ts | 2 - test/functional/page_objects/common_page.ts | 2 - test/functional/services/combo_box.ts | 2 - .../functions/browser/esdocs.ts | 3 - .../components/asset_manager/asset_manager.ts | 6 +- .../home/hooks/use_import_workpad.ts | 2 - .../home/my_workpads/upload_dropzone.tsx | 2 - .../sidebar/global_config/filter_config.tsx | 2 - .../workpad_header/edit_menu/edit_menu.tsx | 2 - .../canvas/public/services/stubs/workpad.ts | 2 +- .../canvas/storybook/addon/src/state.ts | 5 - .../storybook/decorators/redux_decorator.tsx | 2 - .../follower_indices_list.test.js | 7 - .../components/remote_clusters_provider.js | 2 +- .../__jest__/components/index_table.test.js | 9 +- x-pack/plugins/infra/types/eui.d.ts | 2 +- .../logstash/public/application/index.tsx | 2 - .../data_mapping/percentiles_form.tsx | 1 - .../vector/components/row_action_buttons.tsx | 1 - .../properties/dynamic_icon_property.tsx | 1 - .../classes/styles/vector/vector_style.tsx | 3 +- .../map_container/map_container.tsx | 1 - .../map_settings_panel/custom_icons_panel.tsx | 2 - .../analysis_fields_table.tsx | 2 +- .../application/services/job_service.d.ts | 2 - .../public/application/util/time_buckets.d.ts | 1 - .../bucket_span_estimator.d.ts | 3 - .../monitoring/public/alerts/badge.tsx | 2 - .../application/pages/logstash/advanced.tsx | 2 - .../application/pages/logstash/node.tsx | 2 - .../pages/logstash/node_pipelines.tsx | 4 - .../lib/cluster/flag_supported_clusters.ts | 2 - .../server/lib/cluster/get_cluster_license.ts | 2 - .../server/lib/cluster/get_clusters_state.ts | 2 - .../server/lib/cluster/get_clusters_stats.ts | 2 - .../server/lib/elasticsearch/ccr.ts | 2 - .../lib/elasticsearch/get_last_recovery.ts | 2 - .../server/lib/elasticsearch/get_ml_jobs.ts | 2 - .../indices/get_index_summary.ts | 2 - .../lib/elasticsearch/indices/get_indices.ts | 2 - .../elasticsearch/nodes/get_node_summary.ts | 2 - .../get_indices_unassigned_shard_stats.ts | 2 - .../shards/get_nodes_shard_count.ts | 2 - .../shards/get_shard_allocation.ts | 2 - .../server/lib/kibana/get_kibana_info.ts | 2 +- .../server/lib/kibana/get_kibanas.ts | 2 - .../server/routes/bulk_update_alerts.ts | 1 - .../rule_registry/server/routes/find.ts | 1 - .../server/routes/get_alert_index.ts | 1 - .../server/routes/update_alert_by_id.ts | 1 - .../timeline_templates/export.spec.ts | 1 - .../integration/timelines/export.spec.ts | 1 - .../view/trusted_apps_list.test.tsx | 1 - .../public/components/process_tree/hooks.ts | 1 - .../server/ephemeral_task_lifecycle.test.ts | 1 - .../polling/delay_on_claim_conflicts.test.ts | 1 - .../server/polling/task_poller.test.ts | 1 - .../server/polling_lifecycle.test.ts | 1 - .../mark_available_tasks_as_claimed.test.ts | 1 - .../server/queries/query_clauses.test.ts | 1 - .../server/task_scheduling.test.ts | 1 - .../sections/rule_details/components/rule.tsx | 2 - .../server/lib/kibana_status.test.ts | 1 - .../page_objects/geo_file_upload.ts | 1 - .../task_management_removed_types.ts | 1 - .../apis/resolver/common.ts | 1 - 86 files changed, 360 insertions(+), 148 deletions(-) create mode 100644 packages/kbn-eslint-plugin-imports/src/rules/no_unused_imports.test.ts create mode 100644 packages/kbn-eslint-plugin-imports/src/rules/no_unused_imports.ts diff --git a/packages/elastic-eslint-config-kibana/.eslintrc.js b/packages/elastic-eslint-config-kibana/.eslintrc.js index eba5332ca71e3..a12417411a1f8 100644 --- a/packages/elastic-eslint-config-kibana/.eslintrc.js +++ b/packages/elastic-eslint-config-kibana/.eslintrc.js @@ -196,5 +196,6 @@ module.exports = { '@kbn/eslint/no_this_in_property_initializers': 'error', '@kbn/imports/no_unresolvable_imports': 'error', '@kbn/imports/uniform_imports': 'error', + '@kbn/imports/no_unused_imports': 'error', }, }; diff --git a/packages/kbn-eslint-plugin-imports/README.md b/packages/kbn-eslint-plugin-imports/README.md index ba22ed2400643..e4708eb3f925f 100644 --- a/packages/kbn-eslint-plugin-imports/README.md +++ b/packages/kbn-eslint-plugin-imports/README.md @@ -53,4 +53,8 @@ Config example: This config will find any import of `@kbn/kitchen-sink` which specifically references the `Spatula` or `isSpatula` exports, remove the old exports from the import (potentially removing the entire import), and add a new import after the previous following it's style pointing to the new package. -The auto-fixer here covers the vast majority of import styles in the repository but might not cover everything, including `import * as Namespace from '@kbn/kitchen-sink'`. Imports like this will need to be found and updated manually, though TypeScript should be able to find the vast majority of those. \ No newline at end of file +The auto-fixer here covers the vast majority of import styles in the repository but might not cover everything, including `import * as Namespace from '@kbn/kitchen-sink'`. Imports like this will need to be found and updated manually, though TypeScript should be able to find the vast majority of those. + +## `@kbn/imports/no_unused_imports` + +This rule finds imports that are unused and provides an auto-fix to remove them. When ESLint appears to be running in an editor, as defined by [`helpers/running_in_editor.ts`](src/helpers/running_in_editor.ts), this rule provided suggestions instead of fixes so that the removals are not applied automatically in case you are debugging, returning early, or something else which makes ESLint think that the import is unused when it isn't. On CI and in the pre-commit hook though, this fix will be applied automatically. \ No newline at end of file diff --git a/packages/kbn-eslint-plugin-imports/src/helpers/running_in_editor.ts b/packages/kbn-eslint-plugin-imports/src/helpers/running_in_editor.ts index 3067cc9d1005f..02a2b737fda9e 100644 --- a/packages/kbn-eslint-plugin-imports/src/helpers/running_in_editor.ts +++ b/packages/kbn-eslint-plugin-imports/src/helpers/running_in_editor.ts @@ -7,7 +7,8 @@ */ export const RUNNING_IN_EDITOR = + !process.env.IS_KIBANA_PRECOMIT_HOOK && // vscode sets this in the env for all workers - !!process.env.VSCODE_CWD || - // MacOS sets this for intellij processes, not sure if it works in webstorm but we could expand this check later - !!process.env.__CFBundleIdentifier?.startsWith('com.jetbrains.intellij'); + (!!process.env.VSCODE_CWD || + // MacOS sets this for intellij processes, not sure if it works in webstorm but we could expand this check later + !!process.env.__CFBundleIdentifier?.startsWith('com.jetbrains.intellij')); diff --git a/packages/kbn-eslint-plugin-imports/src/index.ts b/packages/kbn-eslint-plugin-imports/src/index.ts index 24dd819502b58..ca1050f9ba406 100644 --- a/packages/kbn-eslint-plugin-imports/src/index.ts +++ b/packages/kbn-eslint-plugin-imports/src/index.ts @@ -10,6 +10,7 @@ export * from './get_import_resolver'; import { NoUnresolvableImportsRule } from './rules/no_unresolvable_imports'; import { UniformImportsRule } from './rules/uniform_imports'; import { ExportsMovedPackagesRule } from './rules/exports_moved_packages'; +import { NoUnusedImportsRule } from './rules/no_unused_imports'; /** * Custom ESLint rules, add `'@kbn/eslint-plugin-imports'` to your eslint config to use them @@ -19,4 +20,5 @@ export const rules = { no_unresolvable_imports: NoUnresolvableImportsRule, uniform_imports: UniformImportsRule, exports_moved_packages: ExportsMovedPackagesRule, + no_unused_imports: NoUnusedImportsRule, }; diff --git a/packages/kbn-eslint-plugin-imports/src/rules/no_unused_imports.test.ts b/packages/kbn-eslint-plugin-imports/src/rules/no_unused_imports.test.ts new file mode 100644 index 0000000000000..3511a3720a90e --- /dev/null +++ b/packages/kbn-eslint-plugin-imports/src/rules/no_unused_imports.test.ts @@ -0,0 +1,151 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License + * 2.0 and the Server Side Public License, v 1; you may not use this file except + * in compliance with, at your election, the Elastic License 2.0 or the Server + * Side Public License, v 1. + */ + +import { RuleTester } from 'eslint'; +import { NoUnusedImportsRule } from './no_unused_imports'; +import dedent from 'dedent'; + +const fmt = (str: TemplateStringsArray) => dedent(str) + '\n'; + +const tsTester = [ + '@typescript-eslint/parser', + new RuleTester({ + parser: require.resolve('@typescript-eslint/parser'), + parserOptions: { + sourceType: 'module', + ecmaVersion: 2018, + ecmaFeatures: { + jsx: true, + }, + }, + }), +] as const; + +const babelTester = [ + '@babel/eslint-parser', + new RuleTester({ + parser: require.resolve('@babel/eslint-parser'), + parserOptions: { + sourceType: 'module', + ecmaVersion: 2018, + requireConfigFile: false, + babelOptions: { + presets: ['@kbn/babel-preset/node_preset'], + }, + }, + }), +] as const; + +for (const [name, tester] of [tsTester, babelTester]) { + describe(name, () => { + tester.run('@kbn/imports/no_unused_imports', NoUnusedImportsRule, { + valid: [ + { + filename: 'foo.ts', + code: fmt` + import { foo, bar as Bar } from 'new' + use(foo, Bar) + `, + }, + { + filename: 'foo.ts', + code: fmt` + import Old from 'old' + use(Old) + `, + }, + ], + + invalid: [ + { + filename: 'foo.ts', + code: fmt` + import { foo, bar as Bar } from 'old' + `, + errors: [ + { + line: 1, + message: 'All imports from "old" are unused and should be removed', + }, + ], + output: '', + }, + { + filename: 'foo.ts', + code: fmt` + import type { foo, bar as Bar } from 'old' + `, + errors: [ + { + line: 1, + message: 'All imports from "old" are unused and should be removed', + }, + ], + output: '', + }, + { + filename: 'foo.ts', + code: fmt` + import type { foo, bar as Bar } from 'old' + use(foo) + `, + errors: [ + { + line: 1, + message: 'Bar is unused and should be removed', + }, + ], + output: fmt` + import type { foo, } from 'old' + use(foo) + `, + }, + { + filename: 'foo.ts', + code: fmt` + import type { foo, bar as Bar } from 'old' + use(Bar) + `, + errors: [ + { + line: 1, + message: 'foo is unused and should be removed', + }, + ], + output: fmt` + import type { bar as Bar } from 'old' + use(Bar) + `, + }, + { + filename: 'foo.ts', + code: fmt` + // @ts-expect-error + // @ts-ignore + // foo message + // eslint-disable-next-line some-other-rule + import type { foo, bar as Bar } from 'old' + `, + errors: [ + { + line: 4, + message: `Definition for rule 'some-other-rule' was not found.`, + }, + { + line: 5, + message: 'All imports from "old" are unused and should be removed', + }, + ], + output: fmt` + // foo message + `, + }, + ], + }); + }); +} diff --git a/packages/kbn-eslint-plugin-imports/src/rules/no_unused_imports.ts b/packages/kbn-eslint-plugin-imports/src/rules/no_unused_imports.ts new file mode 100644 index 0000000000000..88153f6f914e5 --- /dev/null +++ b/packages/kbn-eslint-plugin-imports/src/rules/no_unused_imports.ts @@ -0,0 +1,184 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License + * 2.0 and the Server Side Public License, v 1; you may not use this file except + * in compliance with, at your election, the Elastic License 2.0 or the Server + * Side Public License, v 1. + */ + +import { Rule, Scope, AST } from 'eslint'; +import type { Comment } from 'estree'; +import * as T from '@babel/types'; +import { TSESTree } from '@typescript-eslint/typescript-estree'; + +import { RUNNING_IN_EDITOR } from '../helpers/running_in_editor'; + +type WithParent = T & { parent?: WithParent }; +type SomeNode = WithParent | TSESTree.Node; +type SomeImportNode = NonNullable>; + +function findImportParent(def: Scope.Definition) { + let cursor: SomeNode | undefined = def.node; + while (cursor) { + if ( + T.isImportDeclaration(cursor) || + cursor.type === TSESTree.AST_NODE_TYPES.ImportDeclaration + ) { + return cursor; + } + cursor = cursor.parent; + } + return; +} + +function isEslintUsed(variable: any) { + return !!variable.eslintUsed; +} + +function findUnusedImportDefs(globalScope: Scope.Scope) { + if (globalScope.type !== 'global') { + throw new Error('pass the global scope'); + } + + const unused = []; + + for (const scope of globalScope.childScopes) { + if (scope.type !== 'module') { + continue; + } + + for (const variable of scope.variables) { + if (variable.references.length > 0 || isEslintUsed(variable)) { + continue; + } + + for (const def of variable.defs) { + const importParent = findImportParent(def); + if (importParent) { + unused.push({ + def, + importParent, + }); + } + } + } + } + + return unused; +} + +function isTsOrEslintIgnore(comment: Comment) { + const value = comment.value.trim(); + return ( + value.startsWith('@ts-ignore') || + value.startsWith('@ts-expect-error') || + value.startsWith('eslint-disable') + ); +} + +export const NoUnusedImportsRule: Rule.RuleModule = { + meta: { + fixable: 'code', + docs: { + url: 'https://github.com/elastic/kibana/blob/main/packages/kbn-eslint-plugin-imports/README.md#kbnimportsno_unused_imports', + }, + }, + create(context) { + const source = context.getSourceCode(); + + function getRange( + nodeA: { loc?: AST.SourceLocation | null }, + nodeB: { loc?: AST.SourceLocation | null } | number = nodeA + ): AST.Range { + if (!nodeA.loc) { + throw new Error('unable to use babel AST nodes without locations'); + } + const nodeBLoc = typeof nodeB === 'number' ? nodeB : nodeB.loc; + if (nodeBLoc == null) { + throw new Error('unable to use babel AST nodes without locations'); + } + return [ + source.getIndexFromLoc(nodeA.loc.start), + typeof nodeBLoc === 'number' + ? source.getIndexFromLoc(nodeA.loc.end) + nodeBLoc + : source.getIndexFromLoc(nodeBLoc.end), + ]; + } + + function report( + node: SomeNode, + msg: string, + fix: (fixer: Rule.RuleFixer) => IterableIterator + ) { + context.report({ + node: node as any, + message: msg, + ...(RUNNING_IN_EDITOR + ? { + suggest: [ + { + desc: 'Remove', + fix, + }, + ], + } + : { + fix, + }), + }); + } + + return { + 'Program:exit': () => { + const unusedByImport = new Map(); + for (const { importParent, def } of findUnusedImportDefs(context.getScope())) { + const group = unusedByImport.get(importParent); + if (group) { + group.push(def); + } else { + unusedByImport.set(importParent, [def]); + } + } + + for (const [importParent, defs] of unusedByImport) { + if (importParent.specifiers.length === defs.length) { + report( + importParent, + `All imports from "${importParent.source.value}" are unused and should be removed`, + function* (fixer) { + // remove entire import including trailing newline if it's detected + const textPlus1 = source.getText(importParent as any, 0, 1); + const range = getRange(importParent, textPlus1.endsWith('\n') ? 1 : importParent); + + // if the import is preceeded by one or more eslint/tslint disable comments then remove them + for (const comment of source.getCommentsBefore(importParent as any)) { + if (isTsOrEslintIgnore(comment)) { + const cRange = getRange(comment); + yield fixer.removeRange( + source.text[cRange[1]] !== '\n' ? cRange : getRange(comment, 1) + ); + } + } + + yield fixer.removeRange(range); + } + ); + } else { + for (const def of defs) { + report( + def.node, + `${def.name.name} is unused and should be removed`, + function* (fixer) { + const nextToken = source.getTokenAfter(def.node); + yield fixer.removeRange( + getRange(def.node, nextToken?.value === ',' ? nextToken : undefined) + ); + } + ); + } + } + } + }, + }; + }, +}; diff --git a/packages/kbn-i18n-react/src/index.tsx b/packages/kbn-i18n-react/src/index.tsx index a6d8ed17d3b66..abc9a510cc48b 100644 --- a/packages/kbn-i18n-react/src/index.tsx +++ b/packages/kbn-i18n-react/src/index.tsx @@ -6,8 +6,6 @@ * Side Public License, v 1. */ -// eslint-disable-next-line @kbn/eslint/module_migration -import { InjectedIntl as _InjectedIntl, InjectedIntlProps as _InjectedIntlProps } from 'react-intl'; // eslint-disable-next-line @kbn/eslint/module_migration export type { InjectedIntl, InjectedIntlProps } from 'react-intl'; diff --git a/packages/kbn-test/types/ftr_globals/mocha.d.ts b/packages/kbn-test/types/ftr_globals/mocha.d.ts index d5895b40f1245..b9975d4476c90 100644 --- a/packages/kbn-test/types/ftr_globals/mocha.d.ts +++ b/packages/kbn-test/types/ftr_globals/mocha.d.ts @@ -6,7 +6,7 @@ * Side Public License, v 1. */ -import { Suite } from 'mocha'; +import 'mocha'; declare module 'mocha' { interface Suite { diff --git a/src/dev/build/lib/scan.ts b/src/dev/build/lib/scan.ts index 5ba7385792d74..1c1a198d6d97d 100644 --- a/src/dev/build/lib/scan.ts +++ b/src/dev/build/lib/scan.ts @@ -12,9 +12,6 @@ import { join } from 'path'; import * as Rx from 'rxjs'; import { map, mergeAll, mergeMap } from 'rxjs/operators'; -// @ts-ignore -import { assertAbsolute } from './fs'; - const getStat$ = Rx.bindNodeCallback<[string], [Fs.Stats]>(Fs.stat); const getReadDir$ = Rx.bindNodeCallback<[string], [string[]]>(Fs.readdir); diff --git a/src/dev/i18n/utils/verify_icu_message.ts b/src/dev/i18n/utils/verify_icu_message.ts index 8cfc80146d0f1..5243dfb4396b8 100644 --- a/src/dev/i18n/utils/verify_icu_message.ts +++ b/src/dev/i18n/utils/verify_icu_message.ts @@ -9,7 +9,7 @@ // @ts-ignore import parser from 'intl-messageformat-parser'; // @ts-ignore -import { createParserErrorMessage, traverseNodes } from './utils'; +import { createParserErrorMessage } from './utils'; import { SelectFormatNode } from './intl_types'; export function checkEnglishOnly(message: string) { diff --git a/src/dev/run_precommit_hook.js b/src/dev/run_precommit_hook.js index dfa3a94426bb2..bc50aeddc619e 100644 --- a/src/dev/run_precommit_hook.js +++ b/src/dev/run_precommit_hook.js @@ -16,6 +16,8 @@ import { getFilesForCommit, checkFileCasing } from './precommit_hook'; run( async ({ log, flags }) => { + process.env.IS_KIBANA_PRECOMIT_HOOK = 'true'; + const files = await getFilesForCommit(flags.ref); const errors = []; diff --git a/src/plugins/dashboard/public/application/actions/add_to_library_action.tsx b/src/plugins/dashboard/public/application/actions/add_to_library_action.tsx index fa102a9415b3f..456af80c1bb4c 100644 --- a/src/plugins/dashboard/public/application/actions/add_to_library_action.tsx +++ b/src/plugins/dashboard/public/application/actions/add_to_library_action.tsx @@ -6,8 +6,6 @@ * Side Public License, v 1. */ -import _ from 'lodash'; - import { Action, IncompatibleActionError } from '../../services/ui_actions'; import { ViewMode, diff --git a/src/plugins/dashboard/public/application/actions/unlink_from_library_action.tsx b/src/plugins/dashboard/public/application/actions/unlink_from_library_action.tsx index 506d847d87b57..c0b5162cb019b 100644 --- a/src/plugins/dashboard/public/application/actions/unlink_from_library_action.tsx +++ b/src/plugins/dashboard/public/application/actions/unlink_from_library_action.tsx @@ -6,7 +6,6 @@ * Side Public License, v 1. */ -import _ from 'lodash'; import { NotificationsStart } from '@kbn/core/public'; import { Action, IncompatibleActionError } from '../../services/ui_actions'; import { diff --git a/src/plugins/dashboard/public/application/embeddable/dashboard_container.tsx b/src/plugins/dashboard/public/application/embeddable/dashboard_container.tsx index 4fd7bd83014ce..39a7f8f0d152e 100644 --- a/src/plugins/dashboard/public/application/embeddable/dashboard_container.tsx +++ b/src/plugins/dashboard/public/application/embeddable/dashboard_container.tsx @@ -6,7 +6,6 @@ * Side Public License, v 1. */ -import _ from 'lodash'; import React from 'react'; import ReactDOM from 'react-dom'; import { I18nProvider } from '@kbn/i18n-react'; diff --git a/src/plugins/dashboard/public/application/hooks/use_dashboard_app_state.ts b/src/plugins/dashboard/public/application/hooks/use_dashboard_app_state.ts index 50c40e4863bee..9dcc241f7669e 100644 --- a/src/plugins/dashboard/public/application/hooks/use_dashboard_app_state.ts +++ b/src/plugins/dashboard/public/application/hooks/use_dashboard_app_state.ts @@ -6,7 +6,6 @@ * Side Public License, v 1. */ -import _ from 'lodash'; import { History } from 'history'; import { debounceTime, switchMap } from 'rxjs/operators'; import { useCallback, useEffect, useMemo, useState } from 'react'; diff --git a/src/plugins/dashboard/public/application/lib/build_dashboard_container.ts b/src/plugins/dashboard/public/application/lib/build_dashboard_container.ts index 4befdfc188df3..8d4193c0923e0 100644 --- a/src/plugins/dashboard/public/application/lib/build_dashboard_container.ts +++ b/src/plugins/dashboard/public/application/lib/build_dashboard_container.ts @@ -6,7 +6,6 @@ * Side Public License, v 1. */ -import _ from 'lodash'; import type { KibanaExecutionContext } from '@kbn/core/public'; import { DashboardSavedObject } from '../../saved_dashboards'; import { DashboardContainer, DASHBOARD_CONTAINER_TYPE } from '../embeddable'; diff --git a/src/plugins/dashboard/public/application/lib/load_saved_dashboard_state.ts b/src/plugins/dashboard/public/application/lib/load_saved_dashboard_state.ts index 45eda98dcc498..7753a45fc0096 100644 --- a/src/plugins/dashboard/public/application/lib/load_saved_dashboard_state.ts +++ b/src/plugins/dashboard/public/application/lib/load_saved_dashboard_state.ts @@ -6,8 +6,6 @@ * Side Public License, v 1. */ -import _ from 'lodash'; - import { getDashboard60Warning, dashboardLoadingErrorStrings } from '../../dashboard_strings'; import { savedObjectToDashboardState } from './convert_dashboard_state'; import { DashboardState, DashboardBuildContext } from '../../types'; diff --git a/src/plugins/data/common/search/aggs/utils/time_splits.ts b/src/plugins/data/common/search/aggs/utils/time_splits.ts index 3f8783a05f91a..eb47181080dd3 100644 --- a/src/plugins/data/common/search/aggs/utils/time_splits.ts +++ b/src/plugins/data/common/search/aggs/utils/time_splits.ts @@ -7,7 +7,7 @@ */ import moment from 'moment'; -import _, { isArray } from 'lodash'; +import { isArray } from 'lodash'; import type * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; import { RangeFilter } from '@kbn/es-query'; diff --git a/src/plugins/saved_objects_management/public/management_section/objects_table/components/import_summary.test.tsx b/src/plugins/saved_objects_management/public/management_section/objects_table/components/import_summary.test.tsx index bb949f855ff18..14c8c6e0c47c3 100644 --- a/src/plugins/saved_objects_management/public/management_section/objects_table/components/import_summary.test.tsx +++ b/src/plugins/saved_objects_management/public/management_section/objects_table/components/import_summary.test.tsx @@ -13,9 +13,6 @@ import { httpServiceMock } from '@kbn/core/public/mocks'; import { ImportSummary, ImportSummaryProps } from './import_summary'; import { FailedImport } from '../../../lib'; -// @ts-expect-error -import { findTestSubject } from '@elastic/eui/lib/test'; - describe('ImportSummary', () => { let basePath: ReturnType; diff --git a/src/plugins/unified_search/public/index_pattern_select/create_index_pattern_select.tsx b/src/plugins/unified_search/public/index_pattern_select/create_index_pattern_select.tsx index 505b1deda7cdf..04b15aac84778 100644 --- a/src/plugins/unified_search/public/index_pattern_select/create_index_pattern_select.tsx +++ b/src/plugins/unified_search/public/index_pattern_select/create_index_pattern_select.tsx @@ -6,7 +6,6 @@ * Side Public License, v 1. */ -import _ from 'lodash'; import React from 'react'; import { IndexPatternsContract } from '@kbn/data-plugin/public'; diff --git a/src/plugins/vis_types/vislib/public/vislib/percentage_mode_transform.ts b/src/plugins/vis_types/vislib/public/vislib/percentage_mode_transform.ts index 2aa33dc4a5459..c93784ec9c9f8 100644 --- a/src/plugins/vis_types/vislib/public/vislib/percentage_mode_transform.ts +++ b/src/plugins/vis_types/vislib/public/vislib/percentage_mode_transform.ts @@ -6,8 +6,6 @@ * Side Public License, v 1. */ -// @ts-ignore -import numeral from '@elastic/numeral'; import { getFormatService } from '../services'; export function getValueForPercentageMode(value: string | number, percentageFormatPattern: string) { diff --git a/test/functional/page_objects/common_page.ts b/test/functional/page_objects/common_page.ts index 206cc82912c36..83bb0567a02f5 100644 --- a/test/functional/page_objects/common_page.ts +++ b/test/functional/page_objects/common_page.ts @@ -8,8 +8,6 @@ import { setTimeout as setTimeoutAsync } from 'timers/promises'; import expect from '@kbn/expect'; -// @ts-ignore -import fetch from 'node-fetch'; import { getUrl } from '@kbn/test'; import moment from 'moment'; import { FtrService } from '../ftr_provider_context'; diff --git a/test/functional/services/combo_box.ts b/test/functional/services/combo_box.ts index 8b43364c23a22..98b04f83aa47f 100644 --- a/test/functional/services/combo_box.ts +++ b/test/functional/services/combo_box.ts @@ -8,8 +8,6 @@ import { FtrService } from '../ftr_provider_context'; import { WebElementWrapper } from './lib/web_element_wrapper'; -// @ts-ignore not supported yet -import { scrollIntoViewIfNecessary } from './lib/web_element_wrapper/scroll_into_view_if_necessary'; /** * wrapper around EuiComboBox interactions diff --git a/x-pack/plugins/canvas/canvas_plugin_src/functions/browser/esdocs.ts b/x-pack/plugins/canvas/canvas_plugin_src/functions/browser/esdocs.ts index f4349af6e785e..ac946ea885ed0 100644 --- a/x-pack/plugins/canvas/canvas_plugin_src/functions/browser/esdocs.ts +++ b/x-pack/plugins/canvas/canvas_plugin_src/functions/browser/esdocs.ts @@ -11,9 +11,6 @@ import { } from '@kbn/expressions-plugin/common'; import { lastValueFrom } from 'rxjs'; -// @ts-expect-error untyped local -import { buildESRequest } from '../../../common/lib/request/build_es_request'; - import { searchService } from '../../../public/services'; import { ESSQL_SEARCH_STRATEGY } from '../../../common/lib/constants'; import { EssqlSearchStrategyRequest, EssqlSearchStrategyResponse } from '../../../types'; diff --git a/x-pack/plugins/canvas/public/components/asset_manager/asset_manager.ts b/x-pack/plugins/canvas/public/components/asset_manager/asset_manager.ts index 6475202bacf30..7e37d0db36fdf 100644 --- a/x-pack/plugins/canvas/public/components/asset_manager/asset_manager.ts +++ b/x-pack/plugins/canvas/public/components/asset_manager/asset_manager.ts @@ -13,13 +13,9 @@ import { encode } from '@kbn/presentation-util-plugin/public'; import { findExistingAsset } from '../../lib/find_existing_asset'; import { VALID_IMAGE_TYPES } from '../../../common/lib/constants'; import { getId } from '../../lib/get_id'; -// @ts-expect-error untyped local -import { elementsRegistry } from '../../lib/elements_registry'; -// @ts-expect-error untyped local -import { addElement } from '../../state/actions/elements'; import { getAssets } from '../../state/selectors/assets'; // @ts-expect-error untyped local -import { removeAsset, createAsset } from '../../state/actions/assets'; +import { createAsset } from '../../state/actions/assets'; import { State, AssetType } from '../../../types'; import { AssetManager as Component } from './asset_manager.component'; diff --git a/x-pack/plugins/canvas/public/components/home/hooks/use_import_workpad.ts b/x-pack/plugins/canvas/public/components/home/hooks/use_import_workpad.ts index 8c8d2e26d8a22..bd780ee01507d 100644 --- a/x-pack/plugins/canvas/public/components/home/hooks/use_import_workpad.ts +++ b/x-pack/plugins/canvas/public/components/home/hooks/use_import_workpad.ts @@ -9,8 +9,6 @@ import { useCallback } from 'react'; import { useHistory } from 'react-router-dom'; import { i18n } from '@kbn/i18n'; -// @ts-expect-error -import { getDefaultWorkpad } from '../../../state/defaults'; import { useNotifyService, useWorkpadService } from '../../../services'; import type { CanvasWorkpad } from '../../../../types'; diff --git a/x-pack/plugins/canvas/public/components/home/my_workpads/upload_dropzone.tsx b/x-pack/plugins/canvas/public/components/home/my_workpads/upload_dropzone.tsx index 962f616515396..83a044dd934b0 100644 --- a/x-pack/plugins/canvas/public/components/home/my_workpads/upload_dropzone.tsx +++ b/x-pack/plugins/canvas/public/components/home/my_workpads/upload_dropzone.tsx @@ -6,8 +6,6 @@ */ import React, { FC, useState } from 'react'; -// @ts-expect-error untyped library -import Dropzone from 'react-dropzone'; import { useNotifyService } from '../../../services'; import { ErrorStrings } from '../../../../i18n'; diff --git a/x-pack/plugins/canvas/public/components/sidebar/global_config/filter_config.tsx b/x-pack/plugins/canvas/public/components/sidebar/global_config/filter_config.tsx index 305ad9f7931f3..c62af4eede0d5 100644 --- a/x-pack/plugins/canvas/public/components/sidebar/global_config/filter_config.tsx +++ b/x-pack/plugins/canvas/public/components/sidebar/global_config/filter_config.tsx @@ -7,8 +7,6 @@ import React, { FC } from 'react'; import { WorkpadFilters } from '../../workpad_filters'; -// @ts-expect-error unconverted component -import { SidebarSection } from '../sidebar_section'; export const FilterConfig: FC = () => { return ; diff --git a/x-pack/plugins/canvas/public/components/workpad_header/edit_menu/edit_menu.tsx b/x-pack/plugins/canvas/public/components/workpad_header/edit_menu/edit_menu.tsx index f7373c6e58484..42d24770462ab 100644 --- a/x-pack/plugins/canvas/public/components/workpad_header/edit_menu/edit_menu.tsx +++ b/x-pack/plugins/canvas/public/components/workpad_header/edit_menu/edit_menu.tsx @@ -20,8 +20,6 @@ import { crawlTree } from '../../workpad_page/integration_utils'; // @ts-expect-error untyped local import { insertNodes, elementLayer, removeElements } from '../../../state/actions/elements'; // @ts-expect-error untyped local -import { undoHistory, redoHistory } from '../../../state/actions/history'; -// @ts-expect-error untyped local import { selectToplevelNodes } from '../../../state/actions/transient'; import { getSelectedPage, diff --git a/x-pack/plugins/canvas/public/services/stubs/workpad.ts b/x-pack/plugins/canvas/public/services/stubs/workpad.ts index f0f877d6d33c2..51be4e150ebe5 100644 --- a/x-pack/plugins/canvas/public/services/stubs/workpad.ts +++ b/x-pack/plugins/canvas/public/services/stubs/workpad.ts @@ -9,7 +9,7 @@ import moment from 'moment'; import { PluginServiceFactory } from '@kbn/presentation-util-plugin/public'; // @ts-expect-error -import { getDefaultWorkpad, getExportedWorkpad } from '../../state/defaults'; +import { getDefaultWorkpad } from '../../state/defaults'; import { CanvasWorkpadService } from '../workpad'; import { CanvasTemplate, CanvasWorkpad } from '../../../types'; diff --git a/x-pack/plugins/canvas/storybook/addon/src/state.ts b/x-pack/plugins/canvas/storybook/addon/src/state.ts index 4128273a6d9f9..f1fca104b62ef 100644 --- a/x-pack/plugins/canvas/storybook/addon/src/state.ts +++ b/x-pack/plugins/canvas/storybook/addon/src/state.ts @@ -13,14 +13,9 @@ import { isFunction } from 'lodash'; import { EVENTS } from './constants'; -// @ts-expect-error untyped local -import { resolvedArgs } from '../../../public/state/middleware/resolved_args'; - // @ts-expect-error untyped local import { getRootReducer } from '../../../public/state/reducers'; -// @ts-expect-error Untyped local -import { getDefaultWorkpad } from '../../../public/state/defaults'; // @ts-expect-error Untyped local import { getInitialState as getState } from '../../../public/state/initial_state'; import { State } from '../../../types'; diff --git a/x-pack/plugins/canvas/storybook/decorators/redux_decorator.tsx b/x-pack/plugins/canvas/storybook/decorators/redux_decorator.tsx index 553cba07d7269..22dd3fcbd711e 100644 --- a/x-pack/plugins/canvas/storybook/decorators/redux_decorator.tsx +++ b/x-pack/plugins/canvas/storybook/decorators/redux_decorator.tsx @@ -11,8 +11,6 @@ import { Provider as ReduxProvider } from 'react-redux'; import { cloneDeep } from 'lodash'; import { set } from '@elastic/safer-lodash-set'; -// @ts-expect-error Untyped local -import { getDefaultWorkpad } from '../../public/state/defaults'; import { CanvasWorkpad, CanvasElement, CanvasAsset, CanvasPage } from '../../types'; // @ts-expect-error untyped local diff --git a/x-pack/plugins/cross_cluster_replication/public/__jest__/client_integration/follower_indices_list.test.js b/x-pack/plugins/cross_cluster_replication/public/__jest__/client_integration/follower_indices_list.test.js index 3e48c82f21fbe..16d38d42d46b2 100644 --- a/x-pack/plugins/cross_cluster_replication/public/__jest__/client_integration/follower_indices_list.test.js +++ b/x-pack/plugins/cross_cluster_replication/public/__jest__/client_integration/follower_indices_list.test.js @@ -5,13 +5,6 @@ * 2.0. */ -/** - * The below import is required to avoid a console error warn from brace package - * console.warn ../node_modules/brace/index.js:3999 - Could not load worker ReferenceError: Worker is not defined - at createWorker (//node_modules/brace/index.js:17992:5) - */ -import { stubWebWorker } from '@kbn/test-jest-helpers'; // eslint-disable-line no-unused-vars import { act } from 'react-dom/test-utils'; import { getFollowerIndexMock } from './fixtures/follower_index'; diff --git a/x-pack/plugins/cross_cluster_replication/public/app/components/remote_clusters_provider.js b/x-pack/plugins/cross_cluster_replication/public/app/components/remote_clusters_provider.js index f9ad9ba2a8d7d..c8993441f2672 100644 --- a/x-pack/plugins/cross_cluster_replication/public/app/components/remote_clusters_provider.js +++ b/x-pack/plugins/cross_cluster_replication/public/app/components/remote_clusters_provider.js @@ -5,7 +5,7 @@ * 2.0. */ -import React, { PureComponent } from 'react'; // eslint-disable-line no-unused-vars +import { PureComponent } from 'react'; // eslint-disable-line no-unused-vars import { loadRemoteClusters } from '../services/api'; export class RemoteClustersProvider extends PureComponent { diff --git a/x-pack/plugins/index_management/__jest__/components/index_table.test.js b/x-pack/plugins/index_management/__jest__/components/index_table.test.js index 740e19bc62671..2446461d1580b 100644 --- a/x-pack/plugins/index_management/__jest__/components/index_table.test.js +++ b/x-pack/plugins/index_management/__jest__/components/index_table.test.js @@ -9,14 +9,7 @@ import React from 'react'; import { Provider } from 'react-redux'; import { MemoryRouter } from 'react-router-dom'; import { findTestSubject } from '@elastic/eui/lib/test'; - -/** - * The below import is required to avoid a console error warn from brace package - * console.warn ../node_modules/brace/index.js:3999 - Could not load worker ReferenceError: Worker is not defined - at createWorker (//node_modules/brace/index.js:17992:5) - */ -import { mountWithIntl, stubWebWorker } from '@kbn/test-jest-helpers'; // eslint-disable-line no-unused-vars +import { mountWithIntl } from '@kbn/test-jest-helpers'; // eslint-disable-line no-unused-vars import { init as initHttpRequests } from '../client_integration/helpers/http_requests'; import { BASE_PATH } from '../../common/constants'; diff --git a/x-pack/plugins/infra/types/eui.d.ts b/x-pack/plugins/infra/types/eui.d.ts index a44f9414ad65e..6196b6d890d82 100644 --- a/x-pack/plugins/infra/types/eui.d.ts +++ b/x-pack/plugins/infra/types/eui.d.ts @@ -10,7 +10,7 @@ * package includes them. */ -import { IconType, ToolTipPositions } from '@elastic/eui'; +import { IconType } from '@elastic/eui'; import { CommonProps } from '@elastic/eui/src/components/common'; declare module '@elastic/eui' { diff --git a/x-pack/plugins/logstash/public/application/index.tsx b/x-pack/plugins/logstash/public/application/index.tsx index d4b4a39b6df9f..03c2d9d878e2e 100644 --- a/x-pack/plugins/logstash/public/application/index.tsx +++ b/x-pack/plugins/logstash/public/application/index.tsx @@ -25,8 +25,6 @@ import { import { PipelineList } from './components/pipeline_list'; import { PipelineEditView } from './pipeline_edit_view'; // @ts-ignore -import { Pipeline } from '../models/pipeline'; -// @ts-ignore import * as Breadcrumbs from './breadcrumbs'; export const renderApp = async ( diff --git a/x-pack/plugins/maps/public/classes/styles/vector/components/data_mapping/percentiles_form.tsx b/x-pack/plugins/maps/public/classes/styles/vector/components/data_mapping/percentiles_form.tsx index 6276e622b07ad..1797249fa9343 100644 --- a/x-pack/plugins/maps/public/classes/styles/vector/components/data_mapping/percentiles_form.tsx +++ b/x-pack/plugins/maps/public/classes/styles/vector/components/data_mapping/percentiles_form.tsx @@ -5,7 +5,6 @@ * 2.0. */ -import _ from 'lodash'; import React, { ChangeEvent, Component } from 'react'; import { EuiFieldNumber, EuiFormRow } from '@elastic/eui'; import { i18n } from '@kbn/i18n'; diff --git a/x-pack/plugins/maps/public/classes/styles/vector/components/row_action_buttons.tsx b/x-pack/plugins/maps/public/classes/styles/vector/components/row_action_buttons.tsx index 6078f74a91068..6d2579876514b 100644 --- a/x-pack/plugins/maps/public/classes/styles/vector/components/row_action_buttons.tsx +++ b/x-pack/plugins/maps/public/classes/styles/vector/components/row_action_buttons.tsx @@ -5,7 +5,6 @@ * 2.0. */ -import _ from 'lodash'; import React from 'react'; import { i18n } from '@kbn/i18n'; import { EuiButtonIcon } from '@elastic/eui'; diff --git a/x-pack/plugins/maps/public/classes/styles/vector/properties/dynamic_icon_property.tsx b/x-pack/plugins/maps/public/classes/styles/vector/properties/dynamic_icon_property.tsx index db295f200a148..f63e02db6ec6f 100644 --- a/x-pack/plugins/maps/public/classes/styles/vector/properties/dynamic_icon_property.tsx +++ b/x-pack/plugins/maps/public/classes/styles/vector/properties/dynamic_icon_property.tsx @@ -5,7 +5,6 @@ * 2.0. */ -import _ from 'lodash'; import React from 'react'; import { EuiTextColor } from '@elastic/eui'; import type { Map as MbMap } from '@kbn/mapbox-gl'; diff --git a/x-pack/plugins/maps/public/classes/styles/vector/vector_style.tsx b/x-pack/plugins/maps/public/classes/styles/vector/vector_style.tsx index 395f8b6391cad..d9a296031b5a1 100644 --- a/x-pack/plugins/maps/public/classes/styles/vector/vector_style.tsx +++ b/x-pack/plugins/maps/public/classes/styles/vector/vector_style.tsx @@ -5,7 +5,6 @@ * 2.0. */ -import _ from 'lodash'; import React, { CSSProperties, ReactElement } from 'react'; import { FeatureIdentifier, Map as MbMap } from '@kbn/mapbox-gl'; import { FeatureCollection } from 'geojson'; @@ -27,7 +26,7 @@ import { } from '../../../../common/constants'; import { StyleMeta } from './style_meta'; // @ts-expect-error -import { getMakiSymbol, PREFERRED_ICONS } from './symbol_utils'; +import { getMakiSymbol } from './symbol_utils'; import { VectorIcon } from './components/legend/vector_icon'; import { VectorStyleLegend } from './components/legend/vector_style_legend'; import { getHasLabel } from './style_util'; diff --git a/x-pack/plugins/maps/public/connected_components/map_container/map_container.tsx b/x-pack/plugins/maps/public/connected_components/map_container/map_container.tsx index 9d3e875ad0084..969a985601452 100644 --- a/x-pack/plugins/maps/public/connected_components/map_container/map_container.tsx +++ b/x-pack/plugins/maps/public/connected_components/map_container/map_container.tsx @@ -5,7 +5,6 @@ * 2.0. */ -import _ from 'lodash'; import React, { Component } from 'react'; import classNames from 'classnames'; import { EuiFlexGroup, EuiFlexItem, EuiCallOut } from '@elastic/eui'; diff --git a/x-pack/plugins/maps/public/connected_components/map_settings_panel/custom_icons_panel.tsx b/x-pack/plugins/maps/public/connected_components/map_settings_panel/custom_icons_panel.tsx index acc205a084b5d..0488c44008f80 100644 --- a/x-pack/plugins/maps/public/connected_components/map_settings_panel/custom_icons_panel.tsx +++ b/x-pack/plugins/maps/public/connected_components/map_settings_panel/custom_icons_panel.tsx @@ -20,8 +20,6 @@ import { i18n } from '@kbn/i18n'; import { FormattedMessage } from '@kbn/i18n-react'; import { DEFAULT_CUSTOM_ICON_CUTOFF, DEFAULT_CUSTOM_ICON_RADIUS } from '../../../common/constants'; import { getIsDarkMode } from '../../kibana_services'; -// @ts-expect-error -import { getCustomIconId } from '../../classes/styles/vector/symbol_utils'; import { SymbolIcon } from '../../classes/styles/vector/components/legend/symbol_icon'; import { CustomIconModal } from '../../classes/styles/vector/components/symbol/custom_icon_modal'; import { CustomIcon } from '../../../common/descriptor_types'; diff --git a/x-pack/plugins/ml/public/application/data_frame_analytics/pages/analytics_creation/components/configuration_step/analysis_fields_table.tsx b/x-pack/plugins/ml/public/application/data_frame_analytics/pages/analytics_creation/components/configuration_step/analysis_fields_table.tsx index cfdd2de06e0db..d98940588f48f 100644 --- a/x-pack/plugins/ml/public/application/data_frame_analytics/pages/analytics_creation/components/configuration_step/analysis_fields_table.tsx +++ b/x-pack/plugins/ml/public/application/data_frame_analytics/pages/analytics_creation/components/configuration_step/analysis_fields_table.tsx @@ -9,7 +9,7 @@ import React, { FC, Fragment, useEffect, useState } from 'react'; import { EuiCallOut, EuiFormRow, EuiPanel, EuiSpacer, EuiText } from '@elastic/eui'; import { isEqual } from 'lodash'; // @ts-ignore no declaration -import { LEFT_ALIGNMENT, CENTER_ALIGNMENT, SortableProperties } from '@elastic/eui/lib/services'; +import { LEFT_ALIGNMENT, SortableProperties } from '@elastic/eui/lib/services'; import { i18n } from '@kbn/i18n'; import { FormattedMessage } from '@kbn/i18n-react'; import { FieldSelectionItem } from '../../../../common/analytics'; diff --git a/x-pack/plugins/ml/public/application/services/job_service.d.ts b/x-pack/plugins/ml/public/application/services/job_service.d.ts index ad1cef009edba..be0f035786923 100644 --- a/x-pack/plugins/ml/public/application/services/job_service.d.ts +++ b/x-pack/plugins/ml/public/application/services/job_service.d.ts @@ -5,8 +5,6 @@ * 2.0. */ -import type * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; - import { TimeRange } from '@kbn/data-plugin/common/query/timefilter/types'; import { CombinedJob, Datafeed, Job } from '../../../common/types/anomaly_detection_jobs'; import { Calendar } from '../../../common/types/calendars'; diff --git a/x-pack/plugins/ml/public/application/util/time_buckets.d.ts b/x-pack/plugins/ml/public/application/util/time_buckets.d.ts index 8d8618aa7c97b..9a5410918a099 100644 --- a/x-pack/plugins/ml/public/application/util/time_buckets.d.ts +++ b/x-pack/plugins/ml/public/application/util/time_buckets.d.ts @@ -6,7 +6,6 @@ */ import { Moment } from 'moment'; -import { UI_SETTINGS } from '@kbn/data-plugin/public'; export interface TimeRangeBounds { min?: Moment; diff --git a/x-pack/plugins/ml/server/models/bucket_span_estimator/bucket_span_estimator.d.ts b/x-pack/plugins/ml/server/models/bucket_span_estimator/bucket_span_estimator.d.ts index 30d9c76cd9dcb..0216f88219637 100644 --- a/x-pack/plugins/ml/server/models/bucket_span_estimator/bucket_span_estimator.d.ts +++ b/x-pack/plugins/ml/server/models/bucket_span_estimator/bucket_span_estimator.d.ts @@ -6,9 +6,6 @@ */ import { IScopedClusterClient } from '@kbn/core/server'; -import { ES_AGGREGATION } from '../../../common/constants/aggregation_types'; -import { RuntimeMappings } from '../../../common/types/fields'; -import { IndicesOptions } from '../../../common/types/anomaly_detection_jobs'; import { BucketSpanEstimatorData } from '../../../common/types/job_service'; export function estimateBucketSpanFactory({ diff --git a/x-pack/plugins/monitoring/public/alerts/badge.tsx b/x-pack/plugins/monitoring/public/alerts/badge.tsx index 6ccca9278edc0..260a739ba0fb8 100644 --- a/x-pack/plugins/monitoring/public/alerts/badge.tsx +++ b/x-pack/plugins/monitoring/public/alerts/badge.tsx @@ -10,8 +10,6 @@ import { i18n } from '@kbn/i18n'; import { EuiContextMenu, EuiPopover, EuiBadge, EuiSwitch } from '@elastic/eui'; import { AlertState, CommonAlertStatus } from '../../common/types/alerts'; import { AlertSeverity } from '../../common/enums'; -// @ts-ignore -import { formatDateTimeLocal } from '../../common/formatting'; import { isInSetupMode } from '../lib/setup_mode'; import { SetupModeContext } from '../components/setup_mode/setup_mode_context'; import { getAlertPanelsByCategory } from './lib/get_alert_panels_by_category'; diff --git a/x-pack/plugins/monitoring/public/application/pages/logstash/advanced.tsx b/x-pack/plugins/monitoring/public/application/pages/logstash/advanced.tsx index 10c2a1f9761de..29b2e4f6c1e44 100644 --- a/x-pack/plugins/monitoring/public/application/pages/logstash/advanced.tsx +++ b/x-pack/plugins/monitoring/public/application/pages/logstash/advanced.tsx @@ -20,8 +20,6 @@ import { useRouteMatch } from 'react-router-dom'; import { useKibana } from '@kbn/kibana-react-plugin/public'; import { GlobalStateContext } from '../../contexts/global_state_context'; import { ComponentProps } from '../../route_init'; -// @ts-ignore -import { Listing } from '../../../components/logstash/listing'; import { LogstashTemplate } from './logstash_template'; // @ts-ignore import { DetailStatus } from '../../../components/logstash/detail_status'; diff --git a/x-pack/plugins/monitoring/public/application/pages/logstash/node.tsx b/x-pack/plugins/monitoring/public/application/pages/logstash/node.tsx index 32e4eb1dd7a7b..772bf5718c4ec 100644 --- a/x-pack/plugins/monitoring/public/application/pages/logstash/node.tsx +++ b/x-pack/plugins/monitoring/public/application/pages/logstash/node.tsx @@ -21,8 +21,6 @@ import { useKibana } from '@kbn/kibana-react-plugin/public'; import { GlobalStateContext } from '../../contexts/global_state_context'; import { ComponentProps } from '../../route_init'; // @ts-ignore -import { List } from '../../../components/logstash/pipeline_viewer/models/list'; -// @ts-ignore import { LogstashTemplate } from './logstash_template'; // @ts-ignore import { DetailStatus } from '../../../components/logstash/detail_status'; diff --git a/x-pack/plugins/monitoring/public/application/pages/logstash/node_pipelines.tsx b/x-pack/plugins/monitoring/public/application/pages/logstash/node_pipelines.tsx index a04d55a249734..90c8421a31eb0 100644 --- a/x-pack/plugins/monitoring/public/application/pages/logstash/node_pipelines.tsx +++ b/x-pack/plugins/monitoring/public/application/pages/logstash/node_pipelines.tsx @@ -13,13 +13,9 @@ import { useKibana } from '@kbn/kibana-react-plugin/public'; import { isPipelineMonitoringSupportedInVersion } from '../../../lib/logstash/pipelines'; import { GlobalStateContext } from '../../contexts/global_state_context'; import { ComponentProps } from '../../route_init'; -// @ts-expect-error -import { Listing } from '../../../components/logstash/listing'; import { LogstashTemplate } from './logstash_template'; // @ts-expect-error import { DetailStatus } from '../../../components/logstash/detail_status'; -// @ts-expect-error -import { MonitoringTimeseriesContainer } from '../../../components/chart'; import { useTable } from '../../hooks/use_table'; // @ts-expect-error import { PipelineListing } from '../../../components/logstash/pipeline_listing/pipeline_listing'; diff --git a/x-pack/plugins/monitoring/server/lib/cluster/flag_supported_clusters.ts b/x-pack/plugins/monitoring/server/lib/cluster/flag_supported_clusters.ts index 189f94976a035..80d17a8ad0627 100644 --- a/x-pack/plugins/monitoring/server/lib/cluster/flag_supported_clusters.ts +++ b/x-pack/plugins/monitoring/server/lib/cluster/flag_supported_clusters.ts @@ -5,8 +5,6 @@ * 2.0. */ -// @ts-ignore -import { checkParam } from '../error_missing_required'; import { STANDALONE_CLUSTER_CLUSTER_UUID } from '../../../common/constants'; import { ElasticsearchResponse } from '../../../common/types/es'; import { LegacyRequest, Cluster } from '../../types'; diff --git a/x-pack/plugins/monitoring/server/lib/cluster/get_cluster_license.ts b/x-pack/plugins/monitoring/server/lib/cluster/get_cluster_license.ts index 108e88529bf7c..f785c85476254 100644 --- a/x-pack/plugins/monitoring/server/lib/cluster/get_cluster_license.ts +++ b/x-pack/plugins/monitoring/server/lib/cluster/get_cluster_license.ts @@ -5,8 +5,6 @@ * 2.0. */ -// @ts-ignore -import { checkParam } from '../error_missing_required'; // @ts-ignore import { createQuery } from '../create_query'; // @ts-ignore diff --git a/x-pack/plugins/monitoring/server/lib/cluster/get_clusters_state.ts b/x-pack/plugins/monitoring/server/lib/cluster/get_clusters_state.ts index fab74ef1d979f..8d685baf6a65a 100644 --- a/x-pack/plugins/monitoring/server/lib/cluster/get_clusters_state.ts +++ b/x-pack/plugins/monitoring/server/lib/cluster/get_clusters_state.ts @@ -6,8 +6,6 @@ */ import { find } from 'lodash'; -// @ts-ignore -import { checkParam } from '../error_missing_required'; import { ElasticsearchResponse, ElasticsearchModifiedSource } from '../../../common/types/es'; import { LegacyRequest } from '../../types'; import { getNewIndexPatterns } from './get_index_patterns'; diff --git a/x-pack/plugins/monitoring/server/lib/cluster/get_clusters_stats.ts b/x-pack/plugins/monitoring/server/lib/cluster/get_clusters_stats.ts index 07cb8751d0bd8..4ee5a5f8cffb4 100644 --- a/x-pack/plugins/monitoring/server/lib/cluster/get_clusters_stats.ts +++ b/x-pack/plugins/monitoring/server/lib/cluster/get_clusters_stats.ts @@ -5,8 +5,6 @@ * 2.0. */ -// @ts-ignore -import { checkParam } from '../error_missing_required'; // @ts-ignore import { createQuery } from '../create_query'; // @ts-ignore diff --git a/x-pack/plugins/monitoring/server/lib/elasticsearch/ccr.ts b/x-pack/plugins/monitoring/server/lib/elasticsearch/ccr.ts index 902e4bf784a09..7cad6a66416ca 100644 --- a/x-pack/plugins/monitoring/server/lib/elasticsearch/ccr.ts +++ b/x-pack/plugins/monitoring/server/lib/elasticsearch/ccr.ts @@ -7,8 +7,6 @@ import moment from 'moment'; // @ts-ignore -import { checkParam } from '../error_missing_required'; -// @ts-ignore import { ElasticsearchMetric } from '../metrics'; // @ts-ignore import { createQuery } from '../create_query'; diff --git a/x-pack/plugins/monitoring/server/lib/elasticsearch/get_last_recovery.ts b/x-pack/plugins/monitoring/server/lib/elasticsearch/get_last_recovery.ts index 7f6eea717be76..2364e71ab1094 100644 --- a/x-pack/plugins/monitoring/server/lib/elasticsearch/get_last_recovery.ts +++ b/x-pack/plugins/monitoring/server/lib/elasticsearch/get_last_recovery.ts @@ -8,8 +8,6 @@ import moment from 'moment'; import _ from 'lodash'; // @ts-ignore -import { checkParam } from '../error_missing_required'; -// @ts-ignore import { createQuery } from '../create_query'; // @ts-ignore import { ElasticsearchMetric } from '../metrics'; diff --git a/x-pack/plugins/monitoring/server/lib/elasticsearch/get_ml_jobs.ts b/x-pack/plugins/monitoring/server/lib/elasticsearch/get_ml_jobs.ts index 0a2143a185c16..d2fdba54e1d60 100644 --- a/x-pack/plugins/monitoring/server/lib/elasticsearch/get_ml_jobs.ts +++ b/x-pack/plugins/monitoring/server/lib/elasticsearch/get_ml_jobs.ts @@ -7,8 +7,6 @@ import { includes } from 'lodash'; // @ts-ignore -import { checkParam } from '../error_missing_required'; -// @ts-ignore import { createQuery } from '../create_query'; // @ts-ignore import { ElasticsearchMetric } from '../metrics'; diff --git a/x-pack/plugins/monitoring/server/lib/elasticsearch/indices/get_index_summary.ts b/x-pack/plugins/monitoring/server/lib/elasticsearch/indices/get_index_summary.ts index 388c3a364c77a..9602b99b3377b 100644 --- a/x-pack/plugins/monitoring/server/lib/elasticsearch/indices/get_index_summary.ts +++ b/x-pack/plugins/monitoring/server/lib/elasticsearch/indices/get_index_summary.ts @@ -8,8 +8,6 @@ import { get } from 'lodash'; import { i18n } from '@kbn/i18n'; // @ts-ignore -import { checkParam } from '../../error_missing_required'; -// @ts-ignore import { createQuery } from '../../create_query'; // @ts-ignore import { ElasticsearchMetric } from '../../metrics'; diff --git a/x-pack/plugins/monitoring/server/lib/elasticsearch/indices/get_indices.ts b/x-pack/plugins/monitoring/server/lib/elasticsearch/indices/get_indices.ts index 548416d3d5244..1ec6fb476b6ce 100644 --- a/x-pack/plugins/monitoring/server/lib/elasticsearch/indices/get_indices.ts +++ b/x-pack/plugins/monitoring/server/lib/elasticsearch/indices/get_indices.ts @@ -8,8 +8,6 @@ import { get } from 'lodash'; import { i18n } from '@kbn/i18n'; // @ts-ignore -import { checkParam } from '../../error_missing_required'; -// @ts-ignore import { ElasticsearchMetric } from '../../metrics'; // @ts-ignore import { createQuery } from '../../create_query'; diff --git a/x-pack/plugins/monitoring/server/lib/elasticsearch/nodes/get_node_summary.ts b/x-pack/plugins/monitoring/server/lib/elasticsearch/nodes/get_node_summary.ts index a422ccf95527c..ba9573d3fe956 100644 --- a/x-pack/plugins/monitoring/server/lib/elasticsearch/nodes/get_node_summary.ts +++ b/x-pack/plugins/monitoring/server/lib/elasticsearch/nodes/get_node_summary.ts @@ -7,8 +7,6 @@ import { i18n } from '@kbn/i18n'; // @ts-ignore -import { checkParam } from '../../error_missing_required'; -// @ts-ignore import { createQuery } from '../../create_query'; // @ts-ignore import { ElasticsearchMetric } from '../../metrics'; diff --git a/x-pack/plugins/monitoring/server/lib/elasticsearch/shards/get_indices_unassigned_shard_stats.ts b/x-pack/plugins/monitoring/server/lib/elasticsearch/shards/get_indices_unassigned_shard_stats.ts index 20f5134012c29..68d68dba2f83e 100644 --- a/x-pack/plugins/monitoring/server/lib/elasticsearch/shards/get_indices_unassigned_shard_stats.ts +++ b/x-pack/plugins/monitoring/server/lib/elasticsearch/shards/get_indices_unassigned_shard_stats.ts @@ -7,8 +7,6 @@ import { get } from 'lodash'; // @ts-ignore -import { checkParam } from '../../error_missing_required'; -// @ts-ignore import { createQuery } from '../../create_query'; // @ts-ignore import { ElasticsearchMetric } from '../../metrics'; diff --git a/x-pack/plugins/monitoring/server/lib/elasticsearch/shards/get_nodes_shard_count.ts b/x-pack/plugins/monitoring/server/lib/elasticsearch/shards/get_nodes_shard_count.ts index 535070a15a55e..0c77cd92d3a07 100644 --- a/x-pack/plugins/monitoring/server/lib/elasticsearch/shards/get_nodes_shard_count.ts +++ b/x-pack/plugins/monitoring/server/lib/elasticsearch/shards/get_nodes_shard_count.ts @@ -7,8 +7,6 @@ import { get } from 'lodash'; // @ts-ignore -import { checkParam } from '../../error_missing_required'; -// @ts-ignore import { createQuery } from '../../create_query'; // @ts-ignore import { ElasticsearchMetric } from '../../metrics'; diff --git a/x-pack/plugins/monitoring/server/lib/elasticsearch/shards/get_shard_allocation.ts b/x-pack/plugins/monitoring/server/lib/elasticsearch/shards/get_shard_allocation.ts index ad306d9c50354..16189b0983aca 100644 --- a/x-pack/plugins/monitoring/server/lib/elasticsearch/shards/get_shard_allocation.ts +++ b/x-pack/plugins/monitoring/server/lib/elasticsearch/shards/get_shard_allocation.ts @@ -5,8 +5,6 @@ * 2.0. */ -// @ts-ignore -import { StringOptions } from '@kbn/config-schema/target_types/types'; // @ts-ignore import { createQuery } from '../../create_query'; // @ts-ignore diff --git a/x-pack/plugins/monitoring/server/lib/kibana/get_kibana_info.ts b/x-pack/plugins/monitoring/server/lib/kibana/get_kibana_info.ts index 4116e9e5b86ac..9b939ad83c089 100644 --- a/x-pack/plugins/monitoring/server/lib/kibana/get_kibana_info.ts +++ b/x-pack/plugins/monitoring/server/lib/kibana/get_kibana_info.ts @@ -7,7 +7,7 @@ import { merge } from 'lodash'; // @ts-ignore -import { checkParam, MissingRequiredError } from '../error_missing_required'; +import { MissingRequiredError } from '../error_missing_required'; // @ts-ignore import { calculateAvailability } from '../calculate_availability'; import { LegacyRequest } from '../../types'; diff --git a/x-pack/plugins/monitoring/server/lib/kibana/get_kibanas.ts b/x-pack/plugins/monitoring/server/lib/kibana/get_kibanas.ts index 5f9cd6b53a6bb..7f6f45cc98500 100644 --- a/x-pack/plugins/monitoring/server/lib/kibana/get_kibanas.ts +++ b/x-pack/plugins/monitoring/server/lib/kibana/get_kibanas.ts @@ -7,8 +7,6 @@ import moment from 'moment'; // @ts-ignore -import { checkParam } from '../error_missing_required'; -// @ts-ignore import { createQuery } from '../create_query'; // @ts-ignore import { calculateAvailability } from '../calculate_availability'; diff --git a/x-pack/plugins/rule_registry/server/routes/bulk_update_alerts.ts b/x-pack/plugins/rule_registry/server/routes/bulk_update_alerts.ts index a1a316200e5ee..01f9d5c594068 100644 --- a/x-pack/plugins/rule_registry/server/routes/bulk_update_alerts.ts +++ b/x-pack/plugins/rule_registry/server/routes/bulk_update_alerts.ts @@ -7,7 +7,6 @@ import { IRouter } from '@kbn/core/server'; import * as t from 'io-ts'; -import { id as _id } from '@kbn/securitysolution-io-ts-list-types'; import { transformError } from '@kbn/securitysolution-es-utils'; import { buildRouteValidation } from './utils/route_validation'; diff --git a/x-pack/plugins/rule_registry/server/routes/find.ts b/x-pack/plugins/rule_registry/server/routes/find.ts index 675037baa312a..09ce3893f35a1 100644 --- a/x-pack/plugins/rule_registry/server/routes/find.ts +++ b/x-pack/plugins/rule_registry/server/routes/find.ts @@ -7,7 +7,6 @@ import { IRouter } from '@kbn/core/server'; import * as t from 'io-ts'; -import { id as _id } from '@kbn/securitysolution-io-ts-list-types'; import { transformError } from '@kbn/securitysolution-es-utils'; import { PositiveInteger } from '@kbn/securitysolution-io-ts-types'; diff --git a/x-pack/plugins/rule_registry/server/routes/get_alert_index.ts b/x-pack/plugins/rule_registry/server/routes/get_alert_index.ts index 3da040de66963..8140f413c96f9 100644 --- a/x-pack/plugins/rule_registry/server/routes/get_alert_index.ts +++ b/x-pack/plugins/rule_registry/server/routes/get_alert_index.ts @@ -7,7 +7,6 @@ import { IRouter } from '@kbn/core/server'; import * as t from 'io-ts'; -import { id as _id } from '@kbn/securitysolution-io-ts-list-types'; import { transformError } from '@kbn/securitysolution-es-utils'; import { validFeatureIds } from '@kbn/rule-data-utils'; import { buildRouteValidation } from './utils/route_validation'; diff --git a/x-pack/plugins/rule_registry/server/routes/update_alert_by_id.ts b/x-pack/plugins/rule_registry/server/routes/update_alert_by_id.ts index 69f6b338bfda8..67743a2d82680 100644 --- a/x-pack/plugins/rule_registry/server/routes/update_alert_by_id.ts +++ b/x-pack/plugins/rule_registry/server/routes/update_alert_by_id.ts @@ -7,7 +7,6 @@ import { IRouter } from '@kbn/core/server'; import * as t from 'io-ts'; -import { id as _id } from '@kbn/securitysolution-io-ts-list-types'; import { transformError } from '@kbn/securitysolution-es-utils'; import { buildRouteValidation } from './utils/route_validation'; diff --git a/x-pack/plugins/security_solution/cypress/integration/timeline_templates/export.spec.ts b/x-pack/plugins/security_solution/cypress/integration/timeline_templates/export.spec.ts index 66d279b8ba895..3a45338d3cd52 100644 --- a/x-pack/plugins/security_solution/cypress/integration/timeline_templates/export.spec.ts +++ b/x-pack/plugins/security_solution/cypress/integration/timeline_templates/export.spec.ts @@ -5,7 +5,6 @@ * 2.0. */ -import _ from 'lodash'; import { exportTimeline } from '../../tasks/timelines'; import { login, visitWithoutDateRange } from '../../tasks/login'; import { diff --git a/x-pack/plugins/security_solution/cypress/integration/timelines/export.spec.ts b/x-pack/plugins/security_solution/cypress/integration/timelines/export.spec.ts index 27d51a4a855bf..1711e86b62369 100644 --- a/x-pack/plugins/security_solution/cypress/integration/timelines/export.spec.ts +++ b/x-pack/plugins/security_solution/cypress/integration/timelines/export.spec.ts @@ -5,7 +5,6 @@ * 2.0. */ -import _ from 'lodash'; import { exportTimeline } from '../../tasks/timelines'; import { login, visitWithoutDateRange } from '../../tasks/login'; diff --git a/x-pack/plugins/security_solution/public/management/pages/trusted_apps/view/trusted_apps_list.test.tsx b/x-pack/plugins/security_solution/public/management/pages/trusted_apps/view/trusted_apps_list.test.tsx index f778e6f471e1f..6f919a4488549 100644 --- a/x-pack/plugins/security_solution/public/management/pages/trusted_apps/view/trusted_apps_list.test.tsx +++ b/x-pack/plugins/security_solution/public/management/pages/trusted_apps/view/trusted_apps_list.test.tsx @@ -14,7 +14,6 @@ import { TrustedAppsList } from './trusted_apps_list'; import { exceptionsListAllHttpMocks } from '../../mocks/exceptions_list_http_mocks'; import { SEARCHABLE_FIELDS } from '../constants'; import { parseQueryFilterToKQL } from '../../../common/utils'; -import { useUserPrivileges as _useUserPrivileges } from '../../../../common/components/user_privileges'; jest.mock('../../../../common/components/user_privileges'); diff --git a/x-pack/plugins/session_view/public/components/process_tree/hooks.ts b/x-pack/plugins/session_view/public/components/process_tree/hooks.ts index 7054bdade9546..fe4c5c24afe78 100644 --- a/x-pack/plugins/session_view/public/components/process_tree/hooks.ts +++ b/x-pack/plugins/session_view/public/components/process_tree/hooks.ts @@ -4,7 +4,6 @@ * 2.0; you may not use this file except in compliance with the Elastic License * 2.0. */ -import _ from 'lodash'; import memoizeOne from 'memoize-one'; import { useState, useEffect } from 'react'; import { diff --git a/x-pack/plugins/task_manager/server/ephemeral_task_lifecycle.test.ts b/x-pack/plugins/task_manager/server/ephemeral_task_lifecycle.test.ts index 46105747f52a4..f43bc0799ad73 100644 --- a/x-pack/plugins/task_manager/server/ephemeral_task_lifecycle.test.ts +++ b/x-pack/plugins/task_manager/server/ephemeral_task_lifecycle.test.ts @@ -5,7 +5,6 @@ * 2.0. */ -import _ from 'lodash'; import { Subject } from 'rxjs'; import { TaskLifecycleEvent } from './polling_lifecycle'; diff --git a/x-pack/plugins/task_manager/server/polling/delay_on_claim_conflicts.test.ts b/x-pack/plugins/task_manager/server/polling/delay_on_claim_conflicts.test.ts index d93c187615355..cdfebd1156c55 100644 --- a/x-pack/plugins/task_manager/server/polling/delay_on_claim_conflicts.test.ts +++ b/x-pack/plugins/task_manager/server/polling/delay_on_claim_conflicts.test.ts @@ -5,7 +5,6 @@ * 2.0. */ -import _ from 'lodash'; import { Subject, of, firstValueFrom } from 'rxjs'; import { fakeSchedulers } from 'rxjs-marbles/jest'; import { sleep } from '../test_utils'; diff --git a/x-pack/plugins/task_manager/server/polling/task_poller.test.ts b/x-pack/plugins/task_manager/server/polling/task_poller.test.ts index 3d0deccec1b03..f01ea2f018cb9 100644 --- a/x-pack/plugins/task_manager/server/polling/task_poller.test.ts +++ b/x-pack/plugins/task_manager/server/polling/task_poller.test.ts @@ -5,7 +5,6 @@ * 2.0. */ -import _ from 'lodash'; import { Subject, of, BehaviorSubject } from 'rxjs'; import { Option, none, some } from 'fp-ts/lib/Option'; import { createTaskPoller, PollingError, PollingErrorType } from './task_poller'; diff --git a/x-pack/plugins/task_manager/server/polling_lifecycle.test.ts b/x-pack/plugins/task_manager/server/polling_lifecycle.test.ts index b92ef758bdafb..6419bea7eb59e 100644 --- a/x-pack/plugins/task_manager/server/polling_lifecycle.test.ts +++ b/x-pack/plugins/task_manager/server/polling_lifecycle.test.ts @@ -5,7 +5,6 @@ * 2.0. */ -import _ from 'lodash'; import sinon from 'sinon'; import { Observable, of, Subject } from 'rxjs'; diff --git a/x-pack/plugins/task_manager/server/queries/mark_available_tasks_as_claimed.test.ts b/x-pack/plugins/task_manager/server/queries/mark_available_tasks_as_claimed.test.ts index 4e2308f283edf..086a435a39fa9 100644 --- a/x-pack/plugins/task_manager/server/queries/mark_available_tasks_as_claimed.test.ts +++ b/x-pack/plugins/task_manager/server/queries/mark_available_tasks_as_claimed.test.ts @@ -5,7 +5,6 @@ * 2.0. */ -import _ from 'lodash'; import sinon from 'sinon'; import { shouldBeOneOf, mustBeAllOf } from './query_clauses'; diff --git a/x-pack/plugins/task_manager/server/queries/query_clauses.test.ts b/x-pack/plugins/task_manager/server/queries/query_clauses.test.ts index 5f99682718f1d..9bb3bc272bde7 100644 --- a/x-pack/plugins/task_manager/server/queries/query_clauses.test.ts +++ b/x-pack/plugins/task_manager/server/queries/query_clauses.test.ts @@ -5,7 +5,6 @@ * 2.0. */ -import _ from 'lodash'; import { MustCondition, shouldBeOneOf, mustBeAllOf, matchesClauses } from './query_clauses'; describe('matchesClauses', () => { diff --git a/x-pack/plugins/task_manager/server/task_scheduling.test.ts b/x-pack/plugins/task_manager/server/task_scheduling.test.ts index f593363c53bcf..6fe368d495ade 100644 --- a/x-pack/plugins/task_manager/server/task_scheduling.test.ts +++ b/x-pack/plugins/task_manager/server/task_scheduling.test.ts @@ -5,7 +5,6 @@ * 2.0. */ -import _ from 'lodash'; import { Subject } from 'rxjs'; import { none, some } from 'fp-ts/lib/Option'; diff --git a/x-pack/plugins/triggers_actions_ui/public/application/sections/rule_details/components/rule.tsx b/x-pack/plugins/triggers_actions_ui/public/application/sections/rule_details/components/rule.tsx index 9d62fc2f8e37a..89bb6ba186103 100644 --- a/x-pack/plugins/triggers_actions_ui/public/application/sections/rule_details/components/rule.tsx +++ b/x-pack/plugins/triggers_actions_ui/public/application/sections/rule_details/components/rule.tsx @@ -18,8 +18,6 @@ import { EuiTabbedContent, EuiText, } from '@elastic/eui'; -// @ts-ignore -import { RIGHT_ALIGNMENT, CENTER_ALIGNMENT } from '@elastic/eui/lib/services'; import { FormattedMessage } from '@kbn/i18n-react'; import moment from 'moment'; import { diff --git a/x-pack/plugins/upgrade_assistant/server/lib/kibana_status.test.ts b/x-pack/plugins/upgrade_assistant/server/lib/kibana_status.test.ts index cc0b270c61f41..4e7aeefd33711 100644 --- a/x-pack/plugins/upgrade_assistant/server/lib/kibana_status.test.ts +++ b/x-pack/plugins/upgrade_assistant/server/lib/kibana_status.test.ts @@ -5,7 +5,6 @@ * 2.0. */ -import _ from 'lodash'; import { deprecationsServiceMock } from '@kbn/core/server/mocks'; import { DomainDeprecationDetails } from '@kbn/core/server/types'; diff --git a/x-pack/test/functional/page_objects/geo_file_upload.ts b/x-pack/test/functional/page_objects/geo_file_upload.ts index 9d729b37fe8b2..b0f1d36e8e7e8 100644 --- a/x-pack/test/functional/page_objects/geo_file_upload.ts +++ b/x-pack/test/functional/page_objects/geo_file_upload.ts @@ -5,7 +5,6 @@ * 2.0. */ -import _ from 'lodash'; import { FtrService } from '../ftr_provider_context'; export class GeoFileUploadPageObject extends FtrService { diff --git a/x-pack/test/plugin_api_integration/test_suites/task_manager/task_management_removed_types.ts b/x-pack/test/plugin_api_integration/test_suites/task_manager/task_management_removed_types.ts index 14f75191322b6..e35c2c4730815 100644 --- a/x-pack/test/plugin_api_integration/test_suites/task_manager/task_management_removed_types.ts +++ b/x-pack/test/plugin_api_integration/test_suites/task_manager/task_management_removed_types.ts @@ -5,7 +5,6 @@ * 2.0. */ -import _ from 'lodash'; import expect from '@kbn/expect'; import url from 'url'; import supertest from 'supertest'; diff --git a/x-pack/test/security_solution_endpoint_api_int/apis/resolver/common.ts b/x-pack/test/security_solution_endpoint_api_int/apis/resolver/common.ts index 6c1ee98a153e4..88d31aea15813 100644 --- a/x-pack/test/security_solution_endpoint_api_int/apis/resolver/common.ts +++ b/x-pack/test/security_solution_endpoint_api_int/apis/resolver/common.ts @@ -5,7 +5,6 @@ * 2.0. */ -import _ from 'lodash'; import expect from '@kbn/expect'; import { firstNonNullValue } from '@kbn/security-solution-plugin/common/endpoint/models/ecs_safety_helpers'; import { NodeID } from '@kbn/security-solution-plugin/server/endpoint/routes/resolver/tree/utils'; From 410f5cd36921e71b278c2bd663923ec6df2798e3 Mon Sep 17 00:00:00 2001 From: spalger Date: Wed, 11 May 2022 12:02:42 -0500 Subject: [PATCH 4/5] prevent failure screenshot names from being over 100 characters in length --- test/functional/services/common/failure_debugging.ts | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/test/functional/services/common/failure_debugging.ts b/test/functional/services/common/failure_debugging.ts index 1d0b99ff26da9..30eaafdaff64a 100644 --- a/test/functional/services/common/failure_debugging.ts +++ b/test/functional/services/common/failure_debugging.ts @@ -9,6 +9,7 @@ import { resolve } from 'path'; import { writeFile, mkdir } from 'fs'; import { promisify } from 'util'; +import Uuid from 'uuid'; import del from 'del'; import { FtrProviderContext } from '../../ftr_provider_context'; @@ -49,7 +50,10 @@ export async function FailureDebuggingProvider({ getService }: FtrProviderContex async function onFailure(_: any, test: Test) { // Replace characters in test names which can't be used in filenames, like * - const name = test.fullTitle().replace(/([^ a-zA-Z0-9-]+)/g, '_'); + let name = test.fullTitle().replace(/([^ a-zA-Z0-9-]+)/g, '_'); + if (name.length > 100) { + name = `truncated-${name.slice(-100)}-${Uuid.v4()}`; + } await Promise.all([screenshots.takeForFailure(name), logCurrentUrl(), savePageHtml(name)]); } From 4e2989bf107e89cd54816afa54c90eacac0e58c3 Mon Sep 17 00:00:00 2001 From: spalger Date: Wed, 11 May 2022 12:04:46 -0500 Subject: [PATCH 5/5] skip failing suite (#132049) --- .../apps/dashboard_elements/controls/options_list.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/test/functional/apps/dashboard_elements/controls/options_list.ts b/test/functional/apps/dashboard_elements/controls/options_list.ts index e9afe1a254cdb..09584dd7f6a51 100644 --- a/test/functional/apps/dashboard_elements/controls/options_list.ts +++ b/test/functional/apps/dashboard_elements/controls/options_list.ts @@ -27,7 +27,8 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { 'header', ]); - describe('Dashboard options list integration', () => { + // FAILING: https://github.com/elastic/kibana/issues/132049 + describe.skip('Dashboard options list integration', () => { before(async () => { await common.navigateToApp('dashboard'); await dashboard.gotoDashboardLandingPage();