diff --git a/.eslintrc.js b/.eslintrc.js index 293a15cd528cb..c7726b16b1937 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -626,7 +626,7 @@ module.exports = { * Lens overrides */ { - files: ['x-pack/plugins/lens/**/*.ts', 'x-pack/plugins/lens/**/*.tsx'], + files: ['x-pack/legacy/plugins/lens/**/*.ts', 'x-pack/legacy/plugins/lens/**/*.tsx'], rules: { '@typescript-eslint/no-explicit-any': 'error', }, diff --git a/src/legacy/plugin_discovery/types.ts b/src/legacy/plugin_discovery/types.ts index eb772e9970ed4..76b62b7eb693c 100644 --- a/src/legacy/plugin_discovery/types.ts +++ b/src/legacy/plugin_discovery/types.ts @@ -22,6 +22,8 @@ import { Capabilities } from '../../core/public'; // Disable lint errors for imports from src/core/* until SavedObjects migration is complete // eslint-disable-next-line @kbn/eslint/no-restricted-paths import { SavedObjectsSchemaDefinition } from '../../core/server/saved_objects/schema'; +// eslint-disable-next-line @kbn/eslint/no-restricted-paths +import { SavedObjectsManagementDefinition } from '../../core/server/saved_objects/management'; /** * Usage @@ -66,6 +68,8 @@ export interface LegacyPluginOptions { home: string[]; mappings: any; savedObjectSchemas: SavedObjectsSchemaDefinition; + savedObjectsManagement: SavedObjectsManagementDefinition; + visTypes: string[]; embeddableActions?: string[]; embeddableFactories?: string[]; }>; diff --git a/x-pack/legacy/plugins/lens/index.ts b/x-pack/legacy/plugins/lens/index.ts index 88a1b25fc4e39..d0e550be6e235 100644 --- a/x-pack/legacy/plugins/lens/index.ts +++ b/x-pack/legacy/plugins/lens/index.ts @@ -40,10 +40,7 @@ export const lens: LegacyPluginInitializer = kibana => { }), }, }, - // TODO: savedObjectsManagement is not in the uiExports type definition, - // so, we have to either fix the type signature and deal with merge - // conflicts, or simply cas to any here, and fix this later. - } as any, + }, config: () => { return Joi.object({ diff --git a/x-pack/legacy/plugins/lens/public/drag_drop/providers.test.tsx b/x-pack/legacy/plugins/lens/public/drag_drop/providers.test.tsx index c296dd9ab063a..2a8735be426c0 100644 --- a/x-pack/legacy/plugins/lens/public/drag_drop/providers.test.tsx +++ b/x-pack/legacy/plugins/lens/public/drag_drop/providers.test.tsx @@ -12,7 +12,7 @@ jest.useFakeTimers(); describe('RootDragDropProvider', () => { test('reuses contexts for each render', () => { - const contexts: any[] = []; + const contexts: Array<{}> = []; const TestComponent = ({ name }: { name: string }) => { const context = useContext(DragContext); contexts.push(context); diff --git a/x-pack/legacy/plugins/lens/public/indexpattern_plugin/datapanel.tsx b/x-pack/legacy/plugins/lens/public/indexpattern_plugin/datapanel.tsx index 4491050150f50..d13142e150740 100644 --- a/x-pack/legacy/plugins/lens/public/indexpattern_plugin/datapanel.tsx +++ b/x-pack/legacy/plugins/lens/public/indexpattern_plugin/datapanel.tsx @@ -32,7 +32,7 @@ import { FieldItem } from './field_item'; import { FieldIcon } from './field_icon'; // TODO the typings for EuiContextMenuPanel are incorrect - watchedItemProps is missing. This can be removed when the types are adjusted -const FixedEuiContextMenuPanel = (EuiContextMenuPanel as any) as React.FunctionComponent< +const FixedEuiContextMenuPanel = (EuiContextMenuPanel as unknown) as React.FunctionComponent< EuiContextMenuPanelProps & { watchedItemProps: string[] } >; diff --git a/x-pack/legacy/plugins/lens/public/indexpattern_plugin/loader.ts b/x-pack/legacy/plugins/lens/public/indexpattern_plugin/loader.ts index 41989427c3e0f..74b0ff434f4cb 100644 --- a/x-pack/legacy/plugins/lens/public/indexpattern_plugin/loader.ts +++ b/x-pack/legacy/plugins/lens/public/indexpattern_plugin/loader.ts @@ -6,6 +6,7 @@ import { Chrome } from 'ui/chrome'; import { ToastNotifications } from 'ui/notify/toasts/toast_notifications'; +// eslint-disable-next-line @kbn/eslint/no-restricted-paths import { SavedObjectAttributes } from 'src/core/server/saved_objects'; import { IndexPatternField } from './indexpattern'; diff --git a/x-pack/legacy/plugins/lens/public/indexpattern_plugin/operation_definitions/filter_ratio.test.tsx b/x-pack/legacy/plugins/lens/public/indexpattern_plugin/operation_definitions/filter_ratio.test.tsx index 9dd6b06eb5c59..49358316ec8d5 100644 --- a/x-pack/legacy/plugins/lens/public/indexpattern_plugin/operation_definitions/filter_ratio.test.tsx +++ b/x-pack/legacy/plugins/lens/public/indexpattern_plugin/operation_definitions/filter_ratio.test.tsx @@ -9,13 +9,25 @@ import { shallowWithIntl } from 'test_utils/enzyme_helpers'; import { act } from 'react-dom/test-utils'; import { filterRatioOperation } from './filter_ratio'; import { FilterRatioIndexPatternColumn, IndexPatternPrivateState } from '../indexpattern'; +import { Storage } from 'ui/storage'; +import { DataSetup } from '../../../../../../../src/legacy/core_plugins/data/public'; describe('filter_ratio', () => { let state: IndexPatternPrivateState; - let storageMock: any; - let dataMock: any; + let storageMock: Storage; + let dataMock: DataSetup; const InlineOptions = filterRatioOperation.paramEditor!; + class MockQueryBarInput { + props: {}; + constructor(props: {}) { + this.props = props; + } + render() { + return <></>; + } + } + beforeEach(() => { state = { indexPatterns: { @@ -44,22 +56,10 @@ describe('filter_ratio', () => { }, }; - class QueryBarInput { - props: any; - constructor(props: any) { - this.props = props; - } - render() { - return <></>; - } - } - - storageMock = { - getItem() {}, - }; - dataMock = { - query: { ui: { QueryBarInput } }, - }; + storageMock = {} as Storage; + dataMock = ({ + query: { ui: { QueryBarInput: MockQueryBarInput } }, + } as unknown) as DataSetup; }); describe('buildColumn', () => { @@ -121,8 +121,8 @@ describe('filter_ratio', () => { /> ); - expect(wrapper.find('QueryBarInput')).toHaveLength(1); - expect(wrapper.find('QueryBarInput').prop('indexPatterns')).toEqual(['1']); + expect(wrapper.find(MockQueryBarInput)).toHaveLength(1); + expect(wrapper.find(MockQueryBarInput).prop('indexPatterns')).toEqual(['1']); }); it('should update the state when typing into the query bar', () => { @@ -137,10 +137,10 @@ describe('filter_ratio', () => { /> ); - wrapper.find('QueryBarInput').prop('onChange')!({ + wrapper.find(MockQueryBarInput).prop('onChange')!({ query: 'geo.src : "US"', language: 'kuery', - } as any); + }); expect(setState).toHaveBeenCalledWith({ ...state, @@ -175,15 +175,15 @@ describe('filter_ratio', () => { .simulate('click'); }); - expect(wrapper.find('QueryBarInput')).toHaveLength(2); + expect(wrapper.find(MockQueryBarInput)).toHaveLength(2); wrapper - .find('QueryBarInput') + .find(MockQueryBarInput) .at(1) .prop('onChange')!({ query: 'geo.src : "US"', language: 'kuery', - } as any); + }); expect(setState).toHaveBeenCalledWith({ ...state,