Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Lens] re-introduce no-explicit-any #41454

Merged
merged 5 commits into from
Jul 19, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -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',
},
Expand Down
4 changes: 4 additions & 0 deletions src/legacy/plugin_discovery/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -66,6 +68,8 @@ export interface LegacyPluginOptions {
home: string[];
mappings: any;
savedObjectSchemas: SavedObjectsSchemaDefinition;
savedObjectsManagement: SavedObjectsManagementDefinition;
visTypes: string[];
embeddableActions?: string[];
embeddableFactories?: string[];
}>;
Expand Down
5 changes: 1 addition & 4 deletions x-pack/legacy/plugins/lens/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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[] }
>;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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: {
Expand Down Expand Up @@ -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', () => {
Expand Down Expand Up @@ -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', () => {
Expand All @@ -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,
Expand Down Expand Up @@ -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,
Expand Down