From 8d6bbb4e7e7fabc7530efa9136629edc9f90136d Mon Sep 17 00:00:00 2001 From: Krist Wongsuphasawat Date: Thu, 30 Apr 2020 13:50:06 -0700 Subject: [PATCH] fix: lint errors (#420) * fix: lint errors * fix: lint * fix: more lints * fix: broken test * fix: singleton type --- .../src/ChartFrame.tsx | 2 +- .../test/legend/WithLegend.test.tsx | 8 +++++++ .../src/clients/ChartClient.ts | 2 +- .../src/components/ChartDataProvider.tsx | 2 +- .../src/components/SuperChart.tsx | 1 + .../src/components/SuperChartCore.tsx | 6 +++-- .../src/components/createLoadableRenderer.ts | 2 ++ .../src/models/ChartControlPanel.ts | 1 + .../src/models/ChartPlugin.ts | 22 +++++++++---------- .../src/models/ChartProps.ts | 2 +- .../superset-ui-chart/src/types/Base.ts | 3 ++- .../src/types/TransformFunction.ts | 1 + .../test/components/SuperChart.test.tsx | 5 +++++ .../test/components/reactify.test.tsx | 8 ++++--- .../test/models/ChartProps.test.ts | 2 +- .../test/callApi/rejectAfterTimeout.test.ts | 2 +- .../test/utils/throwIfCalled.ts | 2 +- .../superset-ui-core/src/models/Plugin.ts | 1 + .../src/utils/convertKeysToCamelCase.ts | 5 +++-- .../superset-ui-core/src/utils/isDefined.ts | 2 +- .../src/utils/makeSingleton.ts | 9 +++++--- .../src/utils/promiseTimeout.ts | 6 ++--- .../test/models/Preset.test.ts | 2 +- .../test/models/Registry.test.ts | 2 +- .../test/utils/makeSingleton.test.ts | 4 ++-- .../src/Heatmap.js | 2 +- .../src/HorizonRow.jsx | 2 +- .../src/ScatterPlotGlowOverlay.jsx | 1 - .../src/utils/geo.js | 1 - .../src/TTestTable.jsx | 2 +- .../src/Partition.js | 1 - .../legacy-plugin-chart-rose/src/Rose.js | 2 +- .../src/Sunburst.js | 1 - .../src/utils/wrapSvgText.js | 2 -- .../legacy-preset-chart-nvd3/src/NVD3Vis.js | 1 - .../src/components/Line/Line.tsx | 1 + 36 files changed, 70 insertions(+), 48 deletions(-) diff --git a/superset-frontend/temporary_superset_ui/superset-ui/packages/superset-ui-chart-composition/src/ChartFrame.tsx b/superset-frontend/temporary_superset_ui/superset-ui/packages/superset-ui-chart-composition/src/ChartFrame.tsx index 63ed6a37f87f4..79d4f052b1f50 100644 --- a/superset-frontend/temporary_superset_ui/superset-ui/packages/superset-ui-chart-composition/src/ChartFrame.tsx +++ b/superset-frontend/temporary_superset_ui/superset-ui/packages/superset-ui-chart-composition/src/ChartFrame.tsx @@ -1,7 +1,7 @@ import React, { PureComponent } from 'react'; import { isDefined } from '@superset-ui/core'; -function checkNumber(input: any): input is number { +function checkNumber(input: unknown): input is number { return isDefined(input) && typeof input === 'number'; } diff --git a/superset-frontend/temporary_superset_ui/superset-ui/packages/superset-ui-chart-composition/test/legend/WithLegend.test.tsx b/superset-frontend/temporary_superset_ui/superset-ui/packages/superset-ui-chart-composition/test/legend/WithLegend.test.tsx index eb5af0de58625..cc5ef4ce71b49 100644 --- a/superset-frontend/temporary_superset_ui/superset-ui/packages/superset-ui-chart-composition/test/legend/WithLegend.test.tsx +++ b/superset-frontend/temporary_superset_ui/superset-ui/packages/superset-ui-chart-composition/test/legend/WithLegend.test.tsx @@ -29,6 +29,7 @@ describe('WithLegend', () => { , ); + // eslint-disable-next-line @typescript-eslint/no-unsafe-call triggerResizeObserver(); // Have to delay more than debounceTime (1ms) return promiseTimeout(() => { @@ -49,6 +50,7 @@ describe('WithLegend', () => { />, ); + // eslint-disable-next-line @typescript-eslint/no-unsafe-call triggerResizeObserver(); // Have to delay more than debounceTime (1ms) return promiseTimeout(() => { @@ -64,6 +66,7 @@ describe('WithLegend', () => { , ); + // eslint-disable-next-line @typescript-eslint/no-unsafe-call triggerResizeObserver(); // Have to delay more than debounceTime (1ms) return promiseTimeout(() => { @@ -84,6 +87,7 @@ describe('WithLegend', () => { />, ); + // eslint-disable-next-line @typescript-eslint/no-unsafe-call triggerResizeObserver(); // Have to delay more than debounceTime (1ms) return promiseTimeout(() => { @@ -104,6 +108,7 @@ describe('WithLegend', () => { />, ); + // eslint-disable-next-line @typescript-eslint/no-unsafe-call triggerResizeObserver(); // Have to delay more than debounceTime (1ms) return promiseTimeout(() => { @@ -124,6 +129,7 @@ describe('WithLegend', () => { />, ); + // eslint-disable-next-line @typescript-eslint/no-unsafe-call triggerResizeObserver(); // Have to delay more than debounceTime (1ms) return promiseTimeout(() => { @@ -144,6 +150,7 @@ describe('WithLegend', () => { />, ); + // eslint-disable-next-line @typescript-eslint/no-unsafe-call triggerResizeObserver(); // Have to delay more than debounceTime (1ms) return promiseTimeout(() => { @@ -165,6 +172,7 @@ describe('WithLegend', () => { />, ); + // eslint-disable-next-line @typescript-eslint/no-unsafe-call triggerResizeObserver(); // Have to delay more than debounceTime (1ms) return promiseTimeout(() => { diff --git a/superset-frontend/temporary_superset_ui/superset-ui/packages/superset-ui-chart/src/clients/ChartClient.ts b/superset-frontend/temporary_superset_ui/superset-ui/packages/superset-ui-chart/src/clients/ChartClient.ts index bf7f6eb782cf0..daddfa1b20fc7 100644 --- a/superset-frontend/temporary_superset_ui/superset-ui/packages/superset-ui-chart/src/clients/ChartClient.ts +++ b/superset-frontend/temporary_superset_ui/superset-ui/packages/superset-ui-chart/src/clients/ChartClient.ts @@ -56,7 +56,7 @@ export default class ChartClient { ...options, } as RequestConfig) .then(response => response.json as Json) - .then(json => json.form_data); + .then(json => json.form_data as QueryFormData); /* * If formData is also specified, override API result diff --git a/superset-frontend/temporary_superset_ui/superset-ui/packages/superset-ui-chart/src/components/ChartDataProvider.tsx b/superset-frontend/temporary_superset_ui/superset-ui/packages/superset-ui-chart/src/components/ChartDataProvider.tsx index b32191758ed69..e401f6d03282f 100644 --- a/superset-frontend/temporary_superset_ui/superset-ui/packages/superset-ui-chart/src/components/ChartDataProvider.tsx +++ b/superset-frontend/temporary_superset_ui/superset-ui/packages/superset-ui-chart/src/components/ChartDataProvider.tsx @@ -102,7 +102,7 @@ class ChartDataProvider extends React.PureComponent { .then(this.handleReceiveData) .catch(this.handleError); } catch (error) { - this.handleError(error); + this.handleError(error as Error); } }); }; diff --git a/superset-frontend/temporary_superset_ui/superset-ui/packages/superset-ui-chart/src/components/SuperChart.tsx b/superset-frontend/temporary_superset_ui/superset-ui/packages/superset-ui-chart/src/components/SuperChart.tsx index dbe533f99d51a..ecad1ed6ef18e 100644 --- a/superset-frontend/temporary_superset_ui/superset-ui/packages/superset-ui-chart/src/components/SuperChart.tsx +++ b/superset-frontend/temporary_superset_ui/superset-ui/packages/superset-ui-chart/src/components/SuperChart.tsx @@ -127,6 +127,7 @@ export default class SuperChart extends React.PureComponent { if ( queryData == null || queryData.data === null || + // eslint-disable-next-line @typescript-eslint/no-unsafe-call (Array.isArray(queryData.data) && queryData.data.length === 0) ) { chart = ; diff --git a/superset-frontend/temporary_superset_ui/superset-ui/packages/superset-ui-chart/src/components/SuperChartCore.tsx b/superset-frontend/temporary_superset_ui/superset-ui/packages/superset-ui-chart/src/components/SuperChartCore.tsx index 8c08b0d7f68a6..4e3d78fc29093 100644 --- a/superset-frontend/temporary_superset_ui/superset-ui/packages/superset-ui-chart/src/components/SuperChartCore.tsx +++ b/superset-frontend/temporary_superset_ui/superset-ui/packages/superset-ui-chart/src/components/SuperChartCore.tsx @@ -9,7 +9,9 @@ import { ChartType } from '../models/ChartPlugin'; import { PreTransformProps, TransformProps, PostTransformProps } from '../types/TransformFunction'; import { HandlerFunction } from '../types/Base'; -const IDENTITY = (x: any) => x; +function IDENTITY(x: T) { + return x; +} const EMPTY = () => null; @@ -24,7 +26,7 @@ const defaultProps = { }; interface LoadingProps { - error: any; + error: { toString(): string }; } interface LoadedModules { diff --git a/superset-frontend/temporary_superset_ui/superset-ui/packages/superset-ui-chart/src/components/createLoadableRenderer.ts b/superset-frontend/temporary_superset_ui/superset-ui/packages/superset-ui-chart/src/components/createLoadableRenderer.ts index b196625053295..e774c17f69852 100644 --- a/superset-frontend/temporary_superset_ui/superset-ui/packages/superset-ui-chart/src/components/createLoadableRenderer.ts +++ b/superset-frontend/temporary_superset_ui/superset-ui/packages/superset-ui-chart/src/components/createLoadableRenderer.ts @@ -36,7 +36,9 @@ export default function createLoadableRenderer( const { onRenderFailure, onRenderSuccess } = this.props; if (!loading) { if (error) { + // eslint-disable-next-line @typescript-eslint/no-unsafe-call (onRenderFailure as Function)(error); + // eslint-disable-next-line @typescript-eslint/no-unsafe-call } else if (loaded && Object.keys(loaded).length > 0) { (onRenderSuccess as Function)(); } diff --git a/superset-frontend/temporary_superset_ui/superset-ui/packages/superset-ui-chart/src/models/ChartControlPanel.ts b/superset-frontend/temporary_superset_ui/superset-ui/packages/superset-ui-chart/src/models/ChartControlPanel.ts index 9900cab734687..86da034afc04d 100644 --- a/superset-frontend/temporary_superset_ui/superset-ui/packages/superset-ui-chart/src/models/ChartControlPanel.ts +++ b/superset-frontend/temporary_superset_ui/superset-ui/packages/superset-ui-chart/src/models/ChartControlPanel.ts @@ -1 +1,2 @@ +// eslint-disable-next-line @typescript-eslint/no-explicit-any export type ChartControlPanel = { [key: string]: any }; diff --git a/superset-frontend/temporary_superset_ui/superset-ui/packages/superset-ui-chart/src/models/ChartPlugin.ts b/superset-frontend/temporary_superset_ui/superset-ui/packages/superset-ui-chart/src/models/ChartPlugin.ts index f1d84f1f3c13c..dd84d7709d2cf 100644 --- a/superset-frontend/temporary_superset_ui/superset-ui/packages/superset-ui-chart/src/models/ChartPlugin.ts +++ b/superset-frontend/temporary_superset_ui/superset-ui/packages/superset-ui-chart/src/models/ChartPlugin.ts @@ -97,12 +97,12 @@ export default class ChartPlugin extend register() { const { key = isRequired('config.key') } = this.config; - getChartMetadataRegistry().registerValue(key, this.metadata); - getChartComponentRegistry().registerLoader(key, this.loadChart); - getChartControlPanelRegistry().registerValue(key, this.controlPanel); - getChartTransformPropsRegistry().registerLoader(key, this.loadTransformProps); + getChartMetadataRegistry().registerValue(key as string, this.metadata); + getChartComponentRegistry().registerLoader(key as string, this.loadChart); + getChartControlPanelRegistry().registerValue(key as string, this.controlPanel); + getChartTransformPropsRegistry().registerLoader(key as string, this.loadTransformProps); if (this.loadBuildQuery) { - getChartBuildQueryRegistry().registerLoader(key, this.loadBuildQuery); + getChartBuildQueryRegistry().registerLoader(key as string, this.loadBuildQuery); } return this; @@ -110,16 +110,16 @@ export default class ChartPlugin extend unregister() { const { key = isRequired('config.key') } = this.config; - getChartMetadataRegistry().remove(key); - getChartComponentRegistry().remove(key); - getChartControlPanelRegistry().remove(key); - getChartTransformPropsRegistry().remove(key); - getChartBuildQueryRegistry().remove(key); + getChartMetadataRegistry().remove(key as string); + getChartComponentRegistry().remove(key as string); + getChartControlPanelRegistry().remove(key as string); + getChartTransformPropsRegistry().remove(key as string); + getChartBuildQueryRegistry().remove(key as string); return this; } - configure(config: { [key: string]: any }, replace?: boolean) { + configure(config: { [key: string]: unknown }, replace?: boolean) { super.configure(config, replace); return this; diff --git a/superset-frontend/temporary_superset_ui/superset-ui/packages/superset-ui-chart/src/models/ChartProps.ts b/superset-frontend/temporary_superset_ui/superset-ui/packages/superset-ui-chart/src/models/ChartProps.ts index 2767155ce05e9..4b0db7f0e756b 100644 --- a/superset-frontend/temporary_superset_ui/superset-ui/packages/superset-ui-chart/src/models/ChartProps.ts +++ b/superset-frontend/temporary_superset_ui/superset-ui/packages/superset-ui-chart/src/models/ChartProps.ts @@ -92,7 +92,7 @@ export default class ChartProps { this.width = width; this.height = height; this.annotationData = annotationData; - this.datasource = convertKeysToCamelCase(datasource); + this.datasource = convertKeysToCamelCase(datasource) as Datasource; this.rawDatasource = datasource; this.formData = convertKeysToCamelCase(formData); this.rawFormData = formData; diff --git a/superset-frontend/temporary_superset_ui/superset-ui/packages/superset-ui-chart/src/types/Base.ts b/superset-frontend/temporary_superset_ui/superset-ui/packages/superset-ui-chart/src/types/Base.ts index b542b256a3b5b..70573a48a25ce 100644 --- a/superset-frontend/temporary_superset_ui/superset-ui/packages/superset-ui-chart/src/types/Base.ts +++ b/superset-frontend/temporary_superset_ui/superset-ui/packages/superset-ui-chart/src/types/Base.ts @@ -1,5 +1,6 @@ -export type HandlerFunction = (...args: any[]) => void; +export type HandlerFunction = (...args: unknown[]) => void; export interface PlainObject { + // eslint-disable-next-line @typescript-eslint/no-explicit-any [key: string]: any; } diff --git a/superset-frontend/temporary_superset_ui/superset-ui/packages/superset-ui-chart/src/types/TransformFunction.ts b/superset-frontend/temporary_superset_ui/superset-ui/packages/superset-ui-chart/src/types/TransformFunction.ts index 933b7eae8ece6..bc458c820daf0 100644 --- a/superset-frontend/temporary_superset_ui/superset-ui/packages/superset-ui-chart/src/types/TransformFunction.ts +++ b/superset-frontend/temporary_superset_ui/superset-ui/packages/superset-ui-chart/src/types/TransformFunction.ts @@ -2,6 +2,7 @@ import { QueryFormData, QueryContext } from '@superset-ui/query'; import ChartProps from '../models/ChartProps'; export interface PlainProps { + // eslint-disable-next-line @typescript-eslint/no-explicit-any [key: string]: any; } diff --git a/superset-frontend/temporary_superset_ui/superset-ui/packages/superset-ui-chart/test/components/SuperChart.test.tsx b/superset-frontend/temporary_superset_ui/superset-ui/packages/superset-ui-chart/test/components/SuperChart.test.tsx index d79b855f91917..d5c745ba90b79 100644 --- a/superset-frontend/temporary_superset_ui/superset-ui/packages/superset-ui-chart/test/components/SuperChart.test.tsx +++ b/superset-frontend/temporary_superset_ui/superset-ui/packages/superset-ui-chart/test/components/SuperChart.test.tsx @@ -225,6 +225,7 @@ describe('SuperChart', () => { height="100%" />, ); + // eslint-disable-next-line @typescript-eslint/no-unsafe-call triggerResizeObserver(); return promiseTimeout(() => { @@ -243,6 +244,7 @@ describe('SuperChart', () => { height="125" />, ); + // eslint-disable-next-line @typescript-eslint/no-unsafe-call triggerResizeObserver([{ contentRect: { height: 125, width: 150 } }]); return promiseTimeout(() => { @@ -264,6 +266,7 @@ describe('SuperChart', () => { height="25%" />, ); + // eslint-disable-next-line @typescript-eslint/no-unsafe-call triggerResizeObserver([{ contentRect: { height: 75, width: 50 } }]); return promiseTimeout(() => { @@ -283,6 +286,7 @@ describe('SuperChart', () => { debounceTime={1} />, ); + // eslint-disable-next-line @typescript-eslint/no-unsafe-call triggerResizeObserver(); return promiseTimeout(() => { @@ -336,6 +340,7 @@ describe('SuperChart', () => { Wrapper={MyWrapper} />, ); + // eslint-disable-next-line @typescript-eslint/no-unsafe-call triggerResizeObserver(); return promiseTimeout(() => { diff --git a/superset-frontend/temporary_superset_ui/superset-ui/packages/superset-ui-chart/test/components/reactify.test.tsx b/superset-frontend/temporary_superset_ui/superset-ui/packages/superset-ui-chart/test/components/reactify.test.tsx index 8fb58b5cf7b09..d4cb004c56862 100644 --- a/superset-frontend/temporary_superset_ui/superset-ui/packages/superset-ui-chart/test/components/reactify.test.tsx +++ b/superset-frontend/temporary_superset_ui/superset-ui/packages/superset-ui-chart/test/components/reactify.test.tsx @@ -27,7 +27,7 @@ describe('reactify(renderFn)', () => { const TheChart = reactify(renderFn); const TheChartWithWillUnmountHook = reactify(renderFn, { componentWillUnmount: willUnmountCb }); - class TestComponent extends React.PureComponent<{}, { content: string }, any> { + class TestComponent extends React.PureComponent<{}, { content: string }> { constructor(props = {}) { super(props); this.state = { content: 'abc' }; @@ -46,7 +46,7 @@ describe('reactify(renderFn)', () => { } } - class AnotherTestComponent extends React.PureComponent<{}, {}, any> { + class AnotherTestComponent extends React.PureComponent<{}, {}> { render() { return ; } @@ -99,7 +99,9 @@ describe('reactify(renderFn)', () => { }); it('does not try to render if not mounted', () => { const anotherRenderFn = jest.fn(); - const AnotherChart = reactify(anotherRenderFn) as any; // enables valid new AnotherChart() call + const AnotherChart = reactify(anotherRenderFn); // enables valid new AnotherChart() call + // @ts-ignore + // eslint-disable-next-line @typescript-eslint/no-unsafe-call new AnotherChart({ id: 'test' }).execute(); expect(anotherRenderFn).not.toHaveBeenCalled(); }); diff --git a/superset-frontend/temporary_superset_ui/superset-ui/packages/superset-ui-chart/test/models/ChartProps.test.ts b/superset-frontend/temporary_superset_ui/superset-ui/packages/superset-ui-chart/test/models/ChartProps.test.ts index b55c8e784efb1..16c0844795d68 100644 --- a/superset-frontend/temporary_superset_ui/superset-ui/packages/superset-ui-chart/test/models/ChartProps.test.ts +++ b/superset-frontend/temporary_superset_ui/superset-ui/packages/superset-ui-chart/test/models/ChartProps.test.ts @@ -32,7 +32,7 @@ describe('ChartProps', () => { formData: RAW_FORM_DATA, queryData: QUERY_DATA, }); - expect(props.formData.someField).toEqual(1); + expect(props.formData.someField as number).toEqual(1); expect(props.datasource.columnFormats).toEqual(RAW_DATASOURCE.column_formats); expect(props.rawFormData).toEqual(RAW_FORM_DATA); expect(props.rawDatasource).toEqual(RAW_DATASOURCE); diff --git a/superset-frontend/temporary_superset_ui/superset-ui/packages/superset-ui-connection/test/callApi/rejectAfterTimeout.test.ts b/superset-frontend/temporary_superset_ui/superset-ui/packages/superset-ui-connection/test/callApi/rejectAfterTimeout.test.ts index 89a0e42178fe5..b7aedb023b0f0 100644 --- a/superset-frontend/temporary_superset_ui/superset-ui/packages/superset-ui-connection/test/callApi/rejectAfterTimeout.test.ts +++ b/superset-frontend/temporary_superset_ui/superset-ui/packages/superset-ui-connection/test/callApi/rejectAfterTimeout.test.ts @@ -10,7 +10,7 @@ describe('rejectAfterTimeout()', () => { rejectAfterTimeout(10) .then(throwIfCalled) - .catch(error => { + .catch((error: Error) => { expect(error).toBeDefined(); return done(); diff --git a/superset-frontend/temporary_superset_ui/superset-ui/packages/superset-ui-connection/test/utils/throwIfCalled.ts b/superset-frontend/temporary_superset_ui/superset-ui/packages/superset-ui-connection/test/utils/throwIfCalled.ts index 735a345a3d414..c0b11ee8f0cd3 100644 --- a/superset-frontend/temporary_superset_ui/superset-ui/packages/superset-ui-connection/test/utils/throwIfCalled.ts +++ b/superset-frontend/temporary_superset_ui/superset-ui/packages/superset-ui-connection/test/utils/throwIfCalled.ts @@ -1,3 +1,3 @@ -export default function throwIfCalled(args: any) { +export default function throwIfCalled(args: unknown) { throw new Error(`Unexpected call to throwIfCalled(): ${JSON.stringify(args)}`); } diff --git a/superset-frontend/temporary_superset_ui/superset-ui/packages/superset-ui-core/src/models/Plugin.ts b/superset-frontend/temporary_superset_ui/superset-ui/packages/superset-ui-core/src/models/Plugin.ts index 31dab73228b13..519883d1bbff7 100644 --- a/superset-frontend/temporary_superset_ui/superset-ui/packages/superset-ui-core/src/models/Plugin.ts +++ b/superset-frontend/temporary_superset_ui/superset-ui/packages/superset-ui-core/src/models/Plugin.ts @@ -1,4 +1,5 @@ interface PlainObject { + // eslint-disable-next-line @typescript-eslint/no-explicit-any [key: string]: any; } diff --git a/superset-frontend/temporary_superset_ui/superset-ui/packages/superset-ui-core/src/utils/convertKeysToCamelCase.ts b/superset-frontend/temporary_superset_ui/superset-ui/packages/superset-ui-core/src/utils/convertKeysToCamelCase.ts index e4e9aaa9ccdbf..88d9da0c4e7a8 100644 --- a/superset-frontend/temporary_superset_ui/superset-ui/packages/superset-ui-core/src/utils/convertKeysToCamelCase.ts +++ b/superset-frontend/temporary_superset_ui/superset-ui/packages/superset-ui-core/src/utils/convertKeysToCamelCase.ts @@ -2,12 +2,13 @@ import camelCase from 'lodash/camelCase'; import isPlainObject from 'lodash/isPlainObject'; import mapKeys from 'lodash/mapKeys'; -export default function convertKeysToCamelCase(object: any) { +export default function convertKeysToCamelCase(object: T) { if (object === null || object === undefined) { return object; } if (isPlainObject(object)) { - return mapKeys(object, (_, k) => camelCase(k)); + // eslint-disable-next-line @typescript-eslint/no-explicit-any + return mapKeys(object as { [key: string]: any }, (_, k) => camelCase(k)) as T; } throw new Error(`Cannot convert input that is not a plain object: ${object}`); } diff --git a/superset-frontend/temporary_superset_ui/superset-ui/packages/superset-ui-core/src/utils/isDefined.ts b/superset-frontend/temporary_superset_ui/superset-ui/packages/superset-ui-core/src/utils/isDefined.ts index 30adf7959ddf0..63e5fbcbf80e2 100644 --- a/superset-frontend/temporary_superset_ui/superset-ui/packages/superset-ui-core/src/utils/isDefined.ts +++ b/superset-frontend/temporary_superset_ui/superset-ui/packages/superset-ui-core/src/utils/isDefined.ts @@ -1,3 +1,3 @@ -export default function isDefined(x: any) { +export default function isDefined(x: unknown) { return x !== null && x !== undefined; } diff --git a/superset-frontend/temporary_superset_ui/superset-ui/packages/superset-ui-core/src/utils/makeSingleton.ts b/superset-frontend/temporary_superset_ui/superset-ui/packages/superset-ui-core/src/utils/makeSingleton.ts index b2ce0e84d13ad..a2426cff73dcd 100644 --- a/superset-frontend/temporary_superset_ui/superset-ui/packages/superset-ui-core/src/utils/makeSingleton.ts +++ b/superset-frontend/temporary_superset_ui/superset-ui/packages/superset-ui-core/src/utils/makeSingleton.ts @@ -1,8 +1,11 @@ -interface ClassInterface { - new (...args: any[]): T; +interface ClassInterface { + new (...args: Args): T; } -export default function makeSingleton(BaseClass: ClassInterface, ...args: any[]): () => T { +export default function makeSingleton( + BaseClass: ClassInterface, + ...args: Args +): () => T { let singleton: T; return function getInstance() { diff --git a/superset-frontend/temporary_superset_ui/superset-ui/packages/superset-ui-core/src/utils/promiseTimeout.ts b/superset-frontend/temporary_superset_ui/superset-ui/packages/superset-ui-core/src/utils/promiseTimeout.ts index c5d9af996368b..523816dbb9a42 100644 --- a/superset-frontend/temporary_superset_ui/superset-ui/packages/superset-ui-core/src/utils/promiseTimeout.ts +++ b/superset-frontend/temporary_superset_ui/superset-ui/packages/superset-ui-core/src/utils/promiseTimeout.ts @@ -1,11 +1,11 @@ /** setTimeout that returns a promise */ -export default function promiseTimeout( +export default function promiseTimeout( /** A function to be executed after the timer expires. */ - func: Function, + func: (...args: unknown[]) => T, /** The time, in milliseconds (thousandths of a second), the timer should wait before the specified function or code is executed. If this parameter is omitted, a value of 0 is used, meaning execute "immediately", or more accurately, as soon as possible. */ delay?: number, ) { - return new Promise(resolve => { + return new Promise(resolve => { setTimeout(() => { resolve(func()); }, delay); diff --git a/superset-frontend/temporary_superset_ui/superset-ui/packages/superset-ui-core/test/models/Preset.test.ts b/superset-frontend/temporary_superset_ui/superset-ui/packages/superset-ui-core/test/models/Preset.test.ts index 513353d5e7cd9..2732262380db5 100644 --- a/superset-frontend/temporary_superset_ui/superset-ui/packages/superset-ui-core/test/models/Preset.test.ts +++ b/superset-frontend/temporary_superset_ui/superset-ui/packages/superset-ui-core/test/models/Preset.test.ts @@ -39,7 +39,7 @@ describe('Preset', () => { class Plugin4 extends Plugin { register() { const { key } = this.config; - values.push(key); + values.push(key as number); return this; } diff --git a/superset-frontend/temporary_superset_ui/superset-ui/packages/superset-ui-core/test/models/Registry.test.ts b/superset-frontend/temporary_superset_ui/superset-ui/packages/superset-ui-core/test/models/Registry.test.ts index 5fff6d520eedd..cfe1bbd3a9f6b 100644 --- a/superset-frontend/temporary_superset_ui/superset-ui/packages/superset-ui-core/test/models/Registry.test.ts +++ b/superset-frontend/temporary_superset_ui/superset-ui/packages/superset-ui-core/test/models/Registry.test.ts @@ -159,7 +159,7 @@ describe('Registry', () => { it('returns a rejected promise if the item with specified key does not exist', () => { const registry = new Registry(); - return registry.getAsPromise('a').then(null, err => { + return registry.getAsPromise('a').then(null, (err: Error) => { expect(err.toString()).toEqual('Error: Item with key "a" is not registered.'); }); }); diff --git a/superset-frontend/temporary_superset_ui/superset-ui/packages/superset-ui-core/test/utils/makeSingleton.test.ts b/superset-frontend/temporary_superset_ui/superset-ui/packages/superset-ui-core/test/utils/makeSingleton.test.ts index 59c5cf81dc4a4..4ab96e1d10c58 100644 --- a/superset-frontend/temporary_superset_ui/superset-ui/packages/superset-ui-core/test/utils/makeSingleton.test.ts +++ b/superset-frontend/temporary_superset_ui/superset-ui/packages/superset-ui-core/test/utils/makeSingleton.test.ts @@ -6,8 +6,8 @@ describe('makeSingleton()', () => { isSitting?: boolean; - constructor(name: string) { - this.name = name; + constructor(name?: string) { + this.name = name || 'Pluto'; } sit() { diff --git a/superset-frontend/temporary_superset_ui/superset-ui/plugins/legacy-plugin-chart-heatmap/src/Heatmap.js b/superset-frontend/temporary_superset_ui/superset-ui/plugins/legacy-plugin-chart-heatmap/src/Heatmap.js index 8017941ee3eda..c07dea1b36ed4 100644 --- a/superset-frontend/temporary_superset_ui/superset-ui/plugins/legacy-plugin-chart-heatmap/src/Heatmap.js +++ b/superset-frontend/temporary_superset_ui/superset-ui/plugins/legacy-plugin-chart-heatmap/src/Heatmap.js @@ -16,7 +16,7 @@ * specific language governing permissions and limitations * under the License. */ -/* eslint-disable func-names, no-plusplus, react/sort-prop-types */ +/* eslint-disable func-names, react/sort-prop-types */ import d3 from 'd3'; import PropTypes from 'prop-types'; import 'd3-svg-legend'; diff --git a/superset-frontend/temporary_superset_ui/superset-ui/plugins/legacy-plugin-chart-horizon/src/HorizonRow.jsx b/superset-frontend/temporary_superset_ui/superset-ui/plugins/legacy-plugin-chart-horizon/src/HorizonRow.jsx index 9e5f2926268f2..ae2770d935926 100644 --- a/superset-frontend/temporary_superset_ui/superset-ui/plugins/legacy-plugin-chart-horizon/src/HorizonRow.jsx +++ b/superset-frontend/temporary_superset_ui/superset-ui/plugins/legacy-plugin-chart-horizon/src/HorizonRow.jsx @@ -16,7 +16,7 @@ * specific language governing permissions and limitations * under the License. */ -/* eslint-disable no-continue, no-plusplus, no-bitwise */ +/* eslint-disable no-continue, no-bitwise */ /* eslint-disable react/jsx-sort-default-props */ /* eslint-disable react/sort-prop-types */ import React from 'react'; diff --git a/superset-frontend/temporary_superset_ui/superset-ui/plugins/legacy-plugin-chart-map-box/src/ScatterPlotGlowOverlay.jsx b/superset-frontend/temporary_superset_ui/superset-ui/plugins/legacy-plugin-chart-map-box/src/ScatterPlotGlowOverlay.jsx index 9f07488c2b3a2..1e8f8d94cd088 100644 --- a/superset-frontend/temporary_superset_ui/superset-ui/plugins/legacy-plugin-chart-map-box/src/ScatterPlotGlowOverlay.jsx +++ b/superset-frontend/temporary_superset_ui/superset-ui/plugins/legacy-plugin-chart-map-box/src/ScatterPlotGlowOverlay.jsx @@ -150,7 +150,6 @@ class ScatterPlotGlowOverlay extends React.PureComponent { ctx.beginPath(); if (location.get('properties').get('cluster')) { let clusterLabel = clusterLabelMap[i]; - // eslint-disable-next-line no-restricted-properties, unicorn/prefer-exponentiation-operator const scaledRadius = roundDecimal((clusterLabel / maxLabel) ** 0.5 * radius, 1); const fontHeight = roundDecimal(scaledRadius * 0.5, 1); const [x, y] = pixelRounded; diff --git a/superset-frontend/temporary_superset_ui/superset-ui/plugins/legacy-plugin-chart-map-box/src/utils/geo.js b/superset-frontend/temporary_superset_ui/superset-ui/plugins/legacy-plugin-chart-map-box/src/utils/geo.js index b3d0d12205bbd..e1777e71c7b64 100644 --- a/superset-frontend/temporary_superset_ui/superset-ui/plugins/legacy-plugin-chart-map-box/src/utils/geo.js +++ b/superset-frontend/temporary_superset_ui/superset-ui/plugins/legacy-plugin-chart-map-box/src/utils/geo.js @@ -7,7 +7,6 @@ export function kmToPixels(kilometers, latitude, zoomLevel) { // Algorithm from: http://wiki.openstreetmap.org/wiki/Zoom_levels const latitudeRad = latitude * (Math.PI / 180); // Seems like the zoomLevel is off by one - // eslint-disable-next-line no-restricted-properties, unicorn/prefer-exponentiation-operator const kmPerPixel = (EARTH_CIRCUMFERENCE_KM * Math.cos(latitudeRad)) / 2 ** (zoomLevel + 9); return roundDecimal(kilometers / kmPerPixel, 2); diff --git a/superset-frontend/temporary_superset_ui/superset-ui/plugins/legacy-plugin-chart-paired-t-test/src/TTestTable.jsx b/superset-frontend/temporary_superset_ui/superset-ui/plugins/legacy-plugin-chart-paired-t-test/src/TTestTable.jsx index 7d47a8af6e689..f0aa5d1381298 100644 --- a/superset-frontend/temporary_superset_ui/superset-ui/plugins/legacy-plugin-chart-paired-t-test/src/TTestTable.jsx +++ b/superset-frontend/temporary_superset_ui/superset-ui/plugins/legacy-plugin-chart-paired-t-test/src/TTestTable.jsx @@ -16,7 +16,7 @@ * specific language governing permissions and limitations * under the License. */ -/* eslint-disable no-plusplus, react/no-array-index-key, react/jsx-no-bind */ +/* eslint-disable react/no-array-index-key, react/jsx-no-bind */ import dist from 'distributions'; import React from 'react'; import { Table, Tr, Td, Thead, Th } from 'reactable-arc'; diff --git a/superset-frontend/temporary_superset_ui/superset-ui/plugins/legacy-plugin-chart-partition/src/Partition.js b/superset-frontend/temporary_superset_ui/superset-ui/plugins/legacy-plugin-chart-partition/src/Partition.js index 20b94e897bc51..b6bc542a2d6c9 100644 --- a/superset-frontend/temporary_superset_ui/superset-ui/plugins/legacy-plugin-chart-partition/src/Partition.js +++ b/superset-frontend/temporary_superset_ui/superset-ui/plugins/legacy-plugin-chart-partition/src/Partition.js @@ -18,7 +18,6 @@ * under the License. */ /* eslint no-param-reassign: [2, {"props": false}] */ -/* eslint-disable no-plusplus */ import d3 from 'd3'; import PropTypes from 'prop-types'; import { hierarchy } from 'd3-hierarchy'; diff --git a/superset-frontend/temporary_superset_ui/superset-ui/plugins/legacy-plugin-chart-rose/src/Rose.js b/superset-frontend/temporary_superset_ui/superset-ui/plugins/legacy-plugin-chart-rose/src/Rose.js index da6bff9262562..eb97a0e60553d 100644 --- a/superset-frontend/temporary_superset_ui/superset-ui/plugins/legacy-plugin-chart-rose/src/Rose.js +++ b/superset-frontend/temporary_superset_ui/superset-ui/plugins/legacy-plugin-chart-rose/src/Rose.js @@ -17,7 +17,7 @@ * under the License. */ /* eslint no-use-before-define: ["error", { "functions": false }] */ -/* eslint-disable no-restricted-syntax, no-plusplus */ +/* eslint-disable no-restricted-syntax */ /* eslint-disable react/sort-prop-types */ import d3 from 'd3'; import PropTypes from 'prop-types'; diff --git a/superset-frontend/temporary_superset_ui/superset-ui/plugins/legacy-plugin-chart-sunburst/src/Sunburst.js b/superset-frontend/temporary_superset_ui/superset-ui/plugins/legacy-plugin-chart-sunburst/src/Sunburst.js index 5221157cf420e..285309c4b3b4b 100644 --- a/superset-frontend/temporary_superset_ui/superset-ui/plugins/legacy-plugin-chart-sunburst/src/Sunburst.js +++ b/superset-frontend/temporary_superset_ui/superset-ui/plugins/legacy-plugin-chart-sunburst/src/Sunburst.js @@ -17,7 +17,6 @@ * under the License. */ /* eslint-disable no-param-reassign, react/sort-prop-types */ -/* eslint-disable no-plusplus */ import d3 from 'd3'; import PropTypes from 'prop-types'; import { CategoricalColorNamespace } from '@superset-ui/color'; diff --git a/superset-frontend/temporary_superset_ui/superset-ui/plugins/legacy-plugin-chart-sunburst/src/utils/wrapSvgText.js b/superset-frontend/temporary_superset_ui/superset-ui/plugins/legacy-plugin-chart-sunburst/src/utils/wrapSvgText.js index 036ace63de756..12a394a8894cd 100644 --- a/superset-frontend/temporary_superset_ui/superset-ui/plugins/legacy-plugin-chart-sunburst/src/utils/wrapSvgText.js +++ b/superset-frontend/temporary_superset_ui/superset-ui/plugins/legacy-plugin-chart-sunburst/src/utils/wrapSvgText.js @@ -1,5 +1,3 @@ -/* eslint-disable no-plusplus */ - /* Utility function that takes a d3 svg:text selection and a max width, and splits the text's text across multiple tspan lines such that any given line does not exceed max width diff --git a/superset-frontend/temporary_superset_ui/superset-ui/plugins/legacy-preset-chart-nvd3/src/NVD3Vis.js b/superset-frontend/temporary_superset_ui/superset-ui/plugins/legacy-preset-chart-nvd3/src/NVD3Vis.js index 18ab5f60f90c8..7737cf343cb75 100644 --- a/superset-frontend/temporary_superset_ui/superset-ui/plugins/legacy-preset-chart-nvd3/src/NVD3Vis.js +++ b/superset-frontend/temporary_superset_ui/superset-ui/plugins/legacy-preset-chart-nvd3/src/NVD3Vis.js @@ -17,7 +17,6 @@ * specific language governing permissions and limitations * under the License. */ -/* eslint-disable no-plusplus */ import { kebabCase, throttle } from 'lodash'; import d3 from 'd3'; import nv from 'nvd3'; diff --git a/superset-frontend/temporary_superset_ui/superset-ui/plugins/preset-chart-xy/src/components/Line/Line.tsx b/superset-frontend/temporary_superset_ui/superset-ui/plugins/preset-chart-xy/src/components/Line/Line.tsx index c93948680ac4e..b4fdcb06c0cae 100644 --- a/superset-frontend/temporary_superset_ui/superset-ui/plugins/preset-chart-xy/src/components/Line/Line.tsx +++ b/superset-frontend/temporary_superset_ui/superset-ui/plugins/preset-chart-xy/src/components/Line/Line.tsx @@ -99,6 +99,7 @@ export default class LineChart extends PureComponent { const allSeries = values(groups).map(seriesData => { const firstDatum = seriesData[0]; + // eslint-disable-next-line @typescript-eslint/no-unsafe-return const key = fieldNames.map(f => firstDatum[f]).join(','); const series: Series = { key: key.length === 0 ? channels.y.getTitle() : key,