From 2c0c51a0df31bbc27ada3bcf3b2ea5584ef17846 Mon Sep 17 00:00:00 2001 From: Ashley Harrison Date: Thu, 16 Nov 2023 12:39:12 +0000 Subject: [PATCH] Chore: improve types (#78126) * fix some types * more type updates * some more fixes * more changes * string instead of unknown * more like original logic * remove outdated comment * update betterer --- .betterer.results | 181 ++++-------------- .../src/dataframe/DataFrameJSON.ts | 6 +- .../src/dataframe/DataFrameView.ts | 8 +- .../src/dataframe/StreamingDataFrame.ts | 2 +- .../src/dataframe/processDataFrame.ts | 3 +- .../src/field/displayProcessor.ts | 2 +- .../grafana-data/src/field/fieldOverrides.ts | 4 +- .../src/field/overrides/processors.ts | 2 +- packages/grafana-data/src/geo/layer.ts | 2 +- .../src/panel/getPanelOptionsWithDefaults.ts | 4 +- .../src/panel/registryFactories.ts | 10 +- .../src/transformations/fieldReducer.ts | 2 +- .../dashboard/components/GenAI/utils.ts | 3 +- .../dashboard/components/PanelEditor/types.ts | 2 +- .../dashboard/dashgrid/DashboardPanel.tsx | 4 +- .../dashboard/dashgrid/PanelStateWrapper.tsx | 4 +- .../dashboard/state/DashboardMigrator.ts | 22 ++- .../dashboard/state/DashboardModel.ts | 4 +- .../app/features/dashboard/state/reducers.ts | 2 +- public/app/features/dimensions/utils.ts | 2 +- .../expressions/ExpressionDatasource.ts | 2 +- public/app/features/geo/format/geohash.ts | 2 +- public/app/features/geo/format/geojson.ts | 2 +- .../features/inspector/InspectErrorTab.tsx | 2 +- .../app/features/inspector/QueryInspector.tsx | 4 +- .../app/features/invites/state/selectors.ts | 6 +- .../live/centrifuge/LiveDataStream.test.ts | 6 +- .../live/centrifuge/transferHandlers.ts | 4 +- public/app/features/org/OrgDetailsPage.tsx | 18 +- public/app/features/org/state/actions.ts | 8 +- .../panel/components/PanelRenderer.tsx | 2 +- .../panel/components/VizTypePicker/types.ts | 2 +- public/app/features/panel/state/actions.ts | 2 +- public/app/features/panel/state/reducers.ts | 4 +- .../plugins/admin/components/SearchField.tsx | 2 +- public/app/features/plugins/datasource_srv.ts | 2 +- public/app/features/plugins/pluginSettings.ts | 4 +- .../AwesomeQueryBuilder.tsx | 2 - .../plugins/sql/datasource/SqlDatasource.ts | 2 +- .../plugins/tests/datasource_srv.test.ts | 4 +- public/test/matchers/toEmitValuesWith.ts | 10 +- public/test/matchers/types.ts | 10 +- public/test/specs/helpers.ts | 2 +- 43 files changed, 135 insertions(+), 236 deletions(-) diff --git a/.betterer.results b/.betterer.results index fcc34c4f18e..31f7ab330d7 100644 --- a/.betterer.results +++ b/.betterer.results @@ -17,10 +17,7 @@ exports[`better eslint`] = { ], "packages/grafana-data/src/dataframe/DataFrameJSON.ts:5381": [ [0, 0, 0, "Do not use any type assertions.", "0"], - [0, 0, 0, "Do not use any type assertions.", "1"], - [0, 0, 0, "Do not use any type assertions.", "2"], - [0, 0, 0, "Do not use any type assertions.", "3"], - [0, 0, 0, "Unexpected any. Specify a different type.", "4"] + [0, 0, 0, "Do not use any type assertions.", "1"] ], "packages/grafana-data/src/dataframe/DataFrameView.test.ts:5381": [ [0, 0, 0, "Unexpected any. Specify a different type.", "0"], @@ -30,12 +27,7 @@ exports[`better eslint`] = { [0, 0, 0, "Unexpected any. Specify a different type.", "0"], [0, 0, 0, "Do not use any type assertions.", "1"], [0, 0, 0, "Do not use any type assertions.", "2"], - [0, 0, 0, "Do not use any type assertions.", "3"], - [0, 0, 0, "Unexpected any. Specify a different type.", "4"], - [0, 0, 0, "Do not use any type assertions.", "5"], - [0, 0, 0, "Unexpected any. Specify a different type.", "6"], - [0, 0, 0, "Do not use any type assertions.", "7"], - [0, 0, 0, "Unexpected any. Specify a different type.", "8"] + [0, 0, 0, "Unexpected any. Specify a different type.", "3"] ], "packages/grafana-data/src/dataframe/MutableDataFrame.ts:5381": [ [0, 0, 0, "Unexpected any. Specify a different type.", "0"], @@ -63,9 +55,8 @@ exports[`better eslint`] = { [0, 0, 0, "Do not use any type assertions.", "2"], [0, 0, 0, "Do not use any type assertions.", "3"], [0, 0, 0, "Do not use any type assertions.", "4"], - [0, 0, 0, "Unexpected any. Specify a different type.", "5"], - [0, 0, 0, "Do not use any type assertions.", "6"], - [0, 0, 0, "Do not use any type assertions.", "7"] + [0, 0, 0, "Do not use any type assertions.", "5"], + [0, 0, 0, "Do not use any type assertions.", "6"] ], "packages/grafana-data/src/dataframe/dimensions.ts:5381": [ [0, 0, 0, "Unexpected any. Specify a different type.", "0"] @@ -80,24 +71,23 @@ exports[`better eslint`] = { [0, 0, 0, "Do not use any type assertions.", "3"], [0, 0, 0, "Do not use any type assertions.", "4"], [0, 0, 0, "Do not use any type assertions.", "5"], - [0, 0, 0, "Do not use any type assertions.", "6"], - [0, 0, 0, "Unexpected any. Specify a different type.", "7"], + [0, 0, 0, "Unexpected any. Specify a different type.", "6"], + [0, 0, 0, "Do not use any type assertions.", "7"], [0, 0, 0, "Do not use any type assertions.", "8"], [0, 0, 0, "Do not use any type assertions.", "9"], - [0, 0, 0, "Do not use any type assertions.", "10"], - [0, 0, 0, "Unexpected any. Specify a different type.", "11"], - [0, 0, 0, "Do not use any type assertions.", "12"], - [0, 0, 0, "Unexpected any. Specify a different type.", "13"], - [0, 0, 0, "Do not use any type assertions.", "14"], - [0, 0, 0, "Unexpected any. Specify a different type.", "15"], + [0, 0, 0, "Unexpected any. Specify a different type.", "10"], + [0, 0, 0, "Do not use any type assertions.", "11"], + [0, 0, 0, "Unexpected any. Specify a different type.", "12"], + [0, 0, 0, "Do not use any type assertions.", "13"], + [0, 0, 0, "Unexpected any. Specify a different type.", "14"], + [0, 0, 0, "Do not use any type assertions.", "15"], [0, 0, 0, "Do not use any type assertions.", "16"], [0, 0, 0, "Do not use any type assertions.", "17"], [0, 0, 0, "Do not use any type assertions.", "18"], [0, 0, 0, "Do not use any type assertions.", "19"], [0, 0, 0, "Do not use any type assertions.", "20"], [0, 0, 0, "Do not use any type assertions.", "21"], - [0, 0, 0, "Do not use any type assertions.", "22"], - [0, 0, 0, "Do not use any type assertions.", "23"] + [0, 0, 0, "Do not use any type assertions.", "22"] ], "packages/grafana-data/src/datetime/datemath.ts:5381": [ [0, 0, 0, "Unexpected any. Specify a different type.", "0"], @@ -153,26 +143,20 @@ exports[`better eslint`] = { "packages/grafana-data/src/field/displayProcessor.ts:5381": [ [0, 0, 0, "Do not use any type assertions.", "0"], [0, 0, 0, "Do not use any type assertions.", "1"], - [0, 0, 0, "Do not use any type assertions.", "2"], - [0, 0, 0, "Unexpected any. Specify a different type.", "3"] - ], - "packages/grafana-data/src/field/fieldOverrides.ts:5381": [ - [0, 0, 0, "Unexpected any. Specify a different type.", "0"], - [0, 0, 0, "Unexpected any. Specify a different type.", "1"] + [0, 0, 0, "Do not use any type assertions.", "2"] ], "packages/grafana-data/src/field/overrides/processors.ts:5381": [ [0, 0, 0, "Unexpected any. Specify a different type.", "0"], [0, 0, 0, "Unexpected any. Specify a different type.", "1"], [0, 0, 0, "Unexpected any. Specify a different type.", "2"], - [0, 0, 0, "Unexpected any. Specify a different type.", "3"], - [0, 0, 0, "Do not use any type assertions.", "4"], - [0, 0, 0, "Unexpected any. Specify a different type.", "5"], - [0, 0, 0, "Do not use any type assertions.", "6"], + [0, 0, 0, "Do not use any type assertions.", "3"], + [0, 0, 0, "Unexpected any. Specify a different type.", "4"], + [0, 0, 0, "Do not use any type assertions.", "5"], + [0, 0, 0, "Unexpected any. Specify a different type.", "6"], [0, 0, 0, "Unexpected any. Specify a different type.", "7"], [0, 0, 0, "Unexpected any. Specify a different type.", "8"], [0, 0, 0, "Unexpected any. Specify a different type.", "9"], - [0, 0, 0, "Unexpected any. Specify a different type.", "10"], - [0, 0, 0, "Do not use any type assertions.", "11"] + [0, 0, 0, "Do not use any type assertions.", "10"] ], "packages/grafana-data/src/field/scale.ts:5381": [ [0, 0, 0, "Do not use any type assertions.", "0"], @@ -191,8 +175,7 @@ exports[`better eslint`] = { ], "packages/grafana-data/src/geo/layer.ts:5381": [ [0, 0, 0, "Unexpected any. Specify a different type.", "0"], - [0, 0, 0, "Unexpected any. Specify a different type.", "1"], - [0, 0, 0, "Unexpected any. Specify a different type.", "2"] + [0, 0, 0, "Unexpected any. Specify a different type.", "1"] ], "packages/grafana-data/src/panel/PanelPlugin.ts:5381": [ [0, 0, 0, "Unexpected any. Specify a different type.", "0"], @@ -205,15 +188,10 @@ exports[`better eslint`] = { [0, 0, 0, "Do not use any type assertions.", "7"] ], "packages/grafana-data/src/panel/getPanelOptionsWithDefaults.ts:5381": [ - [0, 0, 0, "Unexpected any. Specify a different type.", "0"], - [0, 0, 0, "Unexpected any. Specify a different type.", "1"], - [0, 0, 0, "Unexpected any. Specify a different type.", "2"] + [0, 0, 0, "Unexpected any. Specify a different type.", "0"] ], "packages/grafana-data/src/panel/registryFactories.ts:5381": [ - [0, 0, 0, "Do not use any type assertions.", "0"], - [0, 0, 0, "Do not use any type assertions.", "1"], - [0, 0, 0, "Do not use any type assertions.", "2"], - [0, 0, 0, "Do not use any type assertions.", "3"] + [0, 0, 0, "Do not use any type assertions.", "0"] ], "packages/grafana-data/src/themes/colorManipulator.ts:5381": [ [0, 0, 0, "Unexpected any. Specify a different type.", "0"], @@ -223,9 +201,6 @@ exports[`better eslint`] = { "packages/grafana-data/src/themes/createColors.ts:5381": [ [0, 0, 0, "Do not use any type assertions.", "0"] ], - "packages/grafana-data/src/transformations/fieldReducer.ts:5381": [ - [0, 0, 0, "Unexpected any. Specify a different type.", "0"] - ], "packages/grafana-data/src/transformations/matchers/valueMatchers/types.ts:5381": [ [0, 0, 0, "Unexpected any. Specify a different type.", "0"], [0, 0, 0, "Unexpected any. Specify a different type.", "1"] @@ -2989,9 +2964,6 @@ exports[`better eslint`] = { "public/app/features/dashboard/components/DeleteDashboard/DeleteDashboardModal.tsx:5381": [ [0, 0, 0, "Styles should be written using objects.", "0"] ], - "public/app/features/dashboard/components/GenAI/utils.ts:5381": [ - [0, 0, 0, "Unexpected any. Specify a different type.", "0"] - ], "public/app/features/dashboard/components/HelpWizard/HelpWizard.tsx:5381": [ [0, 0, 0, "Styles should be written using objects.", "0"], [0, 0, 0, "Styles should be written using objects.", "1"], @@ -3099,9 +3071,6 @@ exports[`better eslint`] = { [0, 0, 0, "Unexpected any. Specify a different type.", "1"], [0, 0, 0, "Unexpected any. Specify a different type.", "2"] ], - "public/app/features/dashboard/components/PanelEditor/types.ts:5381": [ - [0, 0, 0, "Unexpected any. Specify a different type.", "0"] - ], "public/app/features/dashboard/components/PanelEditor/utils.ts:5381": [ [0, 0, 0, "Unexpected any. Specify a different type.", "0"], [0, 0, 0, "Unexpected any. Specify a different type.", "1"], @@ -3270,13 +3239,8 @@ exports[`better eslint`] = { [0, 0, 0, "Unexpected any. Specify a different type.", "3"], [0, 0, 0, "Use data-testid for E2E selectors instead of aria-label", "4"] ], - "public/app/features/dashboard/dashgrid/DashboardPanel.tsx:5381": [ - [0, 0, 0, "Unexpected any. Specify a different type.", "0"] - ], "public/app/features/dashboard/dashgrid/PanelStateWrapper.tsx:5381": [ - [0, 0, 0, "Unexpected any. Specify a different type.", "0"], - [0, 0, 0, "Unexpected any. Specify a different type.", "1"], - [0, 0, 0, "Unexpected any. Specify a different type.", "2"] + [0, 0, 0, "Unexpected any. Specify a different type.", "0"] ], "public/app/features/dashboard/dashgrid/SeriesVisibilityConfigFactory.ts:5381": [ [0, 0, 0, "Do not use any type assertions.", "0"] @@ -3328,20 +3292,17 @@ exports[`better eslint`] = { [0, 0, 0, "Unexpected any. Specify a different type.", "17"], [0, 0, 0, "Unexpected any. Specify a different type.", "18"], [0, 0, 0, "Unexpected any. Specify a different type.", "19"], - [0, 0, 0, "Unexpected any. Specify a different type.", "20"], + [0, 0, 0, "Do not use any type assertions.", "20"], [0, 0, 0, "Unexpected any. Specify a different type.", "21"], - [0, 0, 0, "Do not use any type assertions.", "22"], + [0, 0, 0, "Unexpected any. Specify a different type.", "22"], [0, 0, 0, "Unexpected any. Specify a different type.", "23"], [0, 0, 0, "Unexpected any. Specify a different type.", "24"], [0, 0, 0, "Unexpected any. Specify a different type.", "25"], - [0, 0, 0, "Unexpected any. Specify a different type.", "26"], - [0, 0, 0, "Unexpected any. Specify a different type.", "27"], + [0, 0, 0, "Do not use any type assertions.", "26"], + [0, 0, 0, "Do not use any type assertions.", "27"], [0, 0, 0, "Unexpected any. Specify a different type.", "28"], - [0, 0, 0, "Do not use any type assertions.", "29"], - [0, 0, 0, "Do not use any type assertions.", "30"], - [0, 0, 0, "Unexpected any. Specify a different type.", "31"], - [0, 0, 0, "Unexpected any. Specify a different type.", "32"], - [0, 0, 0, "Do not use any type assertions.", "33"] + [0, 0, 0, "Unexpected any. Specify a different type.", "29"], + [0, 0, 0, "Do not use any type assertions.", "30"] ], "public/app/features/dashboard/state/DashboardModel.repeat.test.ts:5381": [ [0, 0, 0, "Unexpected any. Specify a different type.", "0"], @@ -3378,10 +3339,8 @@ exports[`better eslint`] = { [0, 0, 0, "Unexpected any. Specify a different type.", "19"], [0, 0, 0, "Unexpected any. Specify a different type.", "20"], [0, 0, 0, "Unexpected any. Specify a different type.", "21"], - [0, 0, 0, "Unexpected any. Specify a different type.", "22"], - [0, 0, 0, "Unexpected any. Specify a different type.", "23"], - [0, 0, 0, "Do not use any type assertions.", "24"], - [0, 0, 0, "Unexpected any. Specify a different type.", "25"] + [0, 0, 0, "Do not use any type assertions.", "22"], + [0, 0, 0, "Unexpected any. Specify a different type.", "23"] ], "public/app/features/dashboard/state/PanelModel.test.ts:5381": [ [0, 0, 0, "Unexpected any. Specify a different type.", "0"], @@ -3439,9 +3398,6 @@ exports[`better eslint`] = { "public/app/features/dashboard/state/initDashboard.ts:5381": [ [0, 0, 0, "Unexpected any. Specify a different type.", "0"] ], - "public/app/features/dashboard/state/reducers.ts:5381": [ - [0, 0, 0, "Unexpected any. Specify a different type.", "0"] - ], "public/app/features/dashboard/utils/getPanelMenu.test.ts:5381": [ [0, 0, 0, "Unexpected any. Specify a different type.", "0"] ], @@ -3619,8 +3575,7 @@ exports[`better eslint`] = { [0, 0, 0, "Unexpected any. Specify a different type.", "0"] ], "public/app/features/dimensions/utils.ts:5381": [ - [0, 0, 0, "Do not use any type assertions.", "0"], - [0, 0, 0, "Unexpected any. Specify a different type.", "1"] + [0, 0, 0, "Do not use any type assertions.", "0"] ], "public/app/features/explore/ContentOutline/ContentOutline.tsx:5381": [ [0, 0, 0, "Do not use any type assertions.", "0"] @@ -4137,9 +4092,8 @@ exports[`better eslint`] = { [0, 0, 0, "Do not use any type assertions.", "5"] ], "public/app/features/expressions/ExpressionDatasource.ts:5381": [ - [0, 0, 0, "Unexpected any. Specify a different type.", "0"], - [0, 0, 0, "Do not use any type assertions.", "1"], - [0, 0, 0, "Do not use any type assertions.", "2"] + [0, 0, 0, "Do not use any type assertions.", "0"], + [0, 0, 0, "Do not use any type assertions.", "1"] ], "public/app/features/expressions/components/Condition.tsx:5381": [ [0, 0, 0, "Styles should be written using objects.", "0"], @@ -4169,12 +4123,6 @@ exports[`better eslint`] = { [0, 0, 0, "Styles should be written using objects.", "0"], [0, 0, 0, "Styles should be written using objects.", "1"] ], - "public/app/features/geo/format/geohash.ts:5381": [ - [0, 0, 0, "Unexpected any. Specify a different type.", "0"] - ], - "public/app/features/geo/format/geojson.ts:5381": [ - [0, 0, 0, "Unexpected any. Specify a different type.", "0"] - ], "public/app/features/geo/gazetteer/gazetteer.ts:5381": [ [0, 0, 0, "Unexpected any. Specify a different type.", "0"], [0, 0, 0, "Do not use any type assertions.", "1"] @@ -4195,9 +4143,6 @@ exports[`better eslint`] = { "public/app/features/inspector/InspectDataTab.tsx:5381": [ [0, 0, 0, "Use data-testid for E2E selectors instead of aria-label", "0"] ], - "public/app/features/inspector/InspectErrorTab.tsx:5381": [ - [0, 0, 0, "Unexpected any. Specify a different type.", "0"] - ], "public/app/features/inspector/InspectJSONTab.tsx:5381": [ [0, 0, 0, "Use data-testid for E2E selectors instead of aria-label", "0"] ], @@ -4215,11 +4160,9 @@ exports[`better eslint`] = { ], "public/app/features/inspector/QueryInspector.tsx:5381": [ [0, 0, 0, "Unexpected any. Specify a different type.", "0"], - [0, 0, 0, "Unexpected any. Specify a different type.", "1"], - [0, 0, 0, "Unexpected any. Specify a different type.", "2"], - [0, 0, 0, "Styles should be written using objects.", "3"], - [0, 0, 0, "Use data-testid for E2E selectors instead of aria-label", "4"], - [0, 0, 0, "Use data-testid for E2E selectors instead of aria-label", "5"] + [0, 0, 0, "Styles should be written using objects.", "1"], + [0, 0, 0, "Use data-testid for E2E selectors instead of aria-label", "2"], + [0, 0, 0, "Use data-testid for E2E selectors instead of aria-label", "3"] ], "public/app/features/inspector/styles.ts:5381": [ [0, 0, 0, "Styles should be written using objects.", "0"], @@ -4234,9 +4177,6 @@ exports[`better eslint`] = { [0, 0, 0, "Styles should be written using objects.", "9"], [0, 0, 0, "Styles should be written using objects.", "10"] ], - "public/app/features/invites/state/selectors.ts:5381": [ - [0, 0, 0, "Unexpected any. Specify a different type.", "0"] - ], "public/app/features/library-panels/components/LibraryPanelCard/LibraryPanelCard.tsx:5381": [ [0, 0, 0, "Styles should be written using objects.", "0"] ], @@ -4288,11 +4228,6 @@ exports[`better eslint`] = { [0, 0, 0, "Styles should be written using objects.", "0"], [0, 0, 0, "Styles should be written using objects.", "1"] ], - "public/app/features/live/centrifuge/LiveDataStream.test.ts:5381": [ - [0, 0, 0, "Unexpected any. Specify a different type.", "0"], - [0, 0, 0, "Unexpected any. Specify a different type.", "1"], - [0, 0, 0, "Unexpected any. Specify a different type.", "2"] - ], "public/app/features/live/centrifuge/LiveDataStream.ts:5381": [ [0, 0, 0, "Do not use any type assertions.", "0"] ], @@ -4302,9 +4237,6 @@ exports[`better eslint`] = { "public/app/features/live/centrifuge/serviceWorkerProxy.ts:5381": [ [0, 0, 0, "Do not use any type assertions.", "0"] ], - "public/app/features/live/centrifuge/transferHandlers.ts:5381": [ - [0, 0, 0, "Unexpected any. Specify a different type.", "0"] - ], "public/app/features/live/data/amendTimeSeries.ts:5381": [ [0, 0, 0, "Unexpected any. Specify a different type.", "0"], [0, 0, 0, "Do not use any type assertions.", "1"], @@ -4460,11 +4392,7 @@ exports[`better eslint`] = { [0, 0, 0, "Unexpected any. Specify a different type.", "4"] ], "public/app/features/org/state/actions.ts:5381": [ - [0, 0, 0, "Unexpected any. Specify a different type.", "0"], - [0, 0, 0, "Unexpected any. Specify a different type.", "1"], - [0, 0, 0, "Unexpected any. Specify a different type.", "2"], - [0, 0, 0, "Unexpected any. Specify a different type.", "3"], - [0, 0, 0, "Unexpected any. Specify a different type.", "4"] + [0, 0, 0, "Unexpected any. Specify a different type.", "0"] ], "public/app/features/org/state/reducers.ts:5381": [ [0, 0, 0, "Do not use any type assertions.", "0"] @@ -4492,9 +4420,6 @@ exports[`better eslint`] = { "public/app/features/panel/components/VizTypePicker/VizTypePicker.tsx:5381": [ [0, 0, 0, "Styles should be written using objects.", "0"] ], - "public/app/features/panel/components/VizTypePicker/types.ts:5381": [ - [0, 0, 0, "Unexpected any. Specify a different type.", "0"] - ], "public/app/features/panel/panellinks/linkSuppliers.ts:5381": [ [0, 0, 0, "Unexpected any. Specify a different type.", "0"] ], @@ -4504,13 +4429,6 @@ exports[`better eslint`] = { [0, 0, 0, "Unexpected any. Specify a different type.", "2"], [0, 0, 0, "Unexpected any. Specify a different type.", "3"] ], - "public/app/features/panel/state/actions.ts:5381": [ - [0, 0, 0, "Unexpected any. Specify a different type.", "0"] - ], - "public/app/features/panel/state/reducers.ts:5381": [ - [0, 0, 0, "Unexpected any. Specify a different type.", "0"], - [0, 0, 0, "Unexpected any. Specify a different type.", "1"] - ], "public/app/features/playlist/EmptyQueryListBanner.tsx:5381": [ [0, 0, 0, "Styles should be written using objects.", "0"] ], @@ -4588,9 +4506,6 @@ exports[`better eslint`] = { [0, 0, 0, "Styles should be written using objects.", "0"], [0, 0, 0, "Styles should be written using objects.", "1"] ], - "public/app/features/plugins/admin/components/SearchField.tsx:5381": [ - [0, 0, 0, "Unexpected any. Specify a different type.", "0"] - ], "public/app/features/plugins/admin/components/VersionList.tsx:5381": [ [0, 0, 0, "Styles should be written using objects.", "0"], [0, 0, 0, "Styles should be written using objects.", "1"], @@ -4632,12 +4547,7 @@ exports[`better eslint`] = { [0, 0, 0, "Unexpected any. Specify a different type.", "9"], [0, 0, 0, "Do not use any type assertions.", "10"], [0, 0, 0, "Unexpected any. Specify a different type.", "11"], - [0, 0, 0, "Unexpected any. Specify a different type.", "12"], - [0, 0, 0, "Do not use any type assertions.", "13"] - ], - "public/app/features/plugins/pluginSettings.ts:5381": [ - [0, 0, 0, "Unexpected any. Specify a different type.", "0"], - [0, 0, 0, "Unexpected any. Specify a different type.", "1"] + [0, 0, 0, "Do not use any type assertions.", "12"] ], "public/app/features/plugins/sandbox/distortion_map.ts:5381": [ [0, 0, 0, "Do not use any type assertions.", "0"] @@ -4673,9 +4583,7 @@ exports[`better eslint`] = { [0, 0, 0, "Unexpected any. Specify a different type.", "0"], [0, 0, 0, "Unexpected any. Specify a different type.", "1"], [0, 0, 0, "Unexpected any. Specify a different type.", "2"], - [0, 0, 0, "Unexpected any. Specify a different type.", "3"], - [0, 0, 0, "Unexpected any. Specify a different type.", "4"], - [0, 0, 0, "Unexpected any. Specify a different type.", "5"] + [0, 0, 0, "Unexpected any. Specify a different type.", "3"] ], "public/app/features/plugins/utils.ts:5381": [ [0, 0, 0, "Do not use any type assertions.", "0"], @@ -7417,11 +7325,6 @@ exports[`better eslint`] = { "public/test/lib/common.ts:5381": [ [0, 0, 0, "Unexpected any. Specify a different type.", "0"] ], - "public/test/matchers/toEmitValuesWith.ts:5381": [ - [0, 0, 0, "Unexpected any. Specify a different type.", "0"], - [0, 0, 0, "Unexpected any. Specify a different type.", "1"], - [0, 0, 0, "Unexpected any. Specify a different type.", "2"] - ], "public/test/specs/helpers.ts:5381": [ [0, 0, 0, "Unexpected any. Specify a different type.", "0"], [0, 0, 0, "Unexpected any. Specify a different type.", "1"], @@ -7434,9 +7337,7 @@ exports[`better eslint`] = { [0, 0, 0, "Unexpected any. Specify a different type.", "8"], [0, 0, 0, "Unexpected any. Specify a different type.", "9"], [0, 0, 0, "Unexpected any. Specify a different type.", "10"], - [0, 0, 0, "Unexpected any. Specify a different type.", "11"], - [0, 0, 0, "Unexpected any. Specify a different type.", "12"], - [0, 0, 0, "Unexpected any. Specify a different type.", "13"] + [0, 0, 0, "Unexpected any. Specify a different type.", "11"] ] }` }; diff --git a/packages/grafana-data/src/dataframe/DataFrameJSON.ts b/packages/grafana-data/src/dataframe/DataFrameJSON.ts index c56842b33b6..4b4e69cd5ae 100644 --- a/packages/grafana-data/src/dataframe/DataFrameJSON.ts +++ b/packages/grafana-data/src/dataframe/DataFrameJSON.ts @@ -143,7 +143,7 @@ export function decodeFieldValueEntities(lookup: FieldValueEntityLookup, values: */ export function decodeFieldValueEnums(lookup: string[], values: FieldValues) { for (let i = 0; i < values.length; i++) { - values[i] = lookup[values[i] as number]; + values[i] = lookup[Number(values[i])]; } } @@ -240,7 +240,9 @@ export function dataFrameToJSON(frame: DataFrame): DataFrameJSON { name: frame.name, fields: frame.fields.map((f) => { const { values, nanos, state, display, ...sfield } = f; - delete (sfield as any).entities; + if ('entities' in sfield) { + delete sfield.entities; + } data.values.push(values); if (nanos != null) { diff --git a/packages/grafana-data/src/dataframe/DataFrameView.ts b/packages/grafana-data/src/dataframe/DataFrameView.ts index 33cac6a5144..6d8b523140d 100644 --- a/packages/grafana-data/src/dataframe/DataFrameView.ts +++ b/packages/grafana-data/src/dataframe/DataFrameView.ts @@ -13,7 +13,7 @@ import { FunctionalVector } from '../vector/FunctionalVector'; * @typeParam T - Type of object stored in the DataFrame. * @beta */ -export class DataFrameView extends FunctionalVector { +export class DataFrameView extends FunctionalVector { private index = 0; private obj: T; readonly fields: { @@ -22,7 +22,7 @@ export class DataFrameView extends FunctionalVector { constructor(private data: DataFrame) { super(); - const obj = {} as unknown as T; + const obj = {} as T; const fields = {} as any; for (let i = 0; i < data.fields.length; i++) { @@ -34,14 +34,14 @@ export class DataFrameView extends FunctionalVector { fields[field.name] = field; const getter = () => field.values.get(this.index); // .get() to support all Vector types - if (!(obj as any).hasOwnProperty(field.name)) { + if (!obj.hasOwnProperty(field.name)) { Object.defineProperty(obj, field.name, { enumerable: true, // Shows up as enumerable property get: getter, }); } - if (!(obj as any).hasOwnProperty(i.toString())) { + if (!obj.hasOwnProperty(i.toString())) { Object.defineProperty(obj, i, { enumerable: false, // Don't enumerate array index get: getter, diff --git a/packages/grafana-data/src/dataframe/StreamingDataFrame.ts b/packages/grafana-data/src/dataframe/StreamingDataFrame.ts index d98b6b93578..d0de4ef1eeb 100644 --- a/packages/grafana-data/src/dataframe/StreamingDataFrame.ts +++ b/packages/grafana-data/src/dataframe/StreamingDataFrame.ts @@ -488,7 +488,7 @@ export function getStreamingFrameOptions(opts?: Partial): // converts vertical insertion records with table keys in [0] and column values in [1...N] // to join()-able tables with column arrays -export function transpose(vrecs: any[][]) { +export function transpose(vrecs: unknown[][]) { let tableKeys = new Set(vrecs[0]); let tables = new Map(); diff --git a/packages/grafana-data/src/dataframe/processDataFrame.ts b/packages/grafana-data/src/dataframe/processDataFrame.ts index a0e95a773b6..e0b218c3d62 100644 --- a/packages/grafana-data/src/dataframe/processDataFrame.ts +++ b/packages/grafana-data/src/dataframe/processDataFrame.ts @@ -33,10 +33,11 @@ function convertTableToDataFrame(table: TableData): DataFrame { const fields = table.columns.map((c) => { // TODO: should be Column but type does not exists there so not sure whats up here. const { text, type, ...disp } = c as any; + const values: unknown[] = []; return { name: text?.length ? text : c, // rename 'text' to the 'name' field config: (disp || {}) as FieldConfig, - values: [] as unknown[], + values, type: type && Object.values(FieldType).includes(type as FieldType) ? (type as FieldType) : FieldType.other, }; }); diff --git a/packages/grafana-data/src/field/displayProcessor.ts b/packages/grafana-data/src/field/displayProcessor.ts index 1f8e7226414..9cdef2760a6 100644 --- a/packages/grafana-data/src/field/displayProcessor.ts +++ b/packages/grafana-data/src/field/displayProcessor.ts @@ -222,7 +222,7 @@ export function getRawDisplayProcessor(): DisplayProcessor { const getCircularReplacer = () => { const seen = new WeakSet(); - return (_key: any, value: object | null) => { + return (_key: string, value: object | null) => { if (typeof value === 'object' && value !== null) { if (seen.has(value)) { return; diff --git a/packages/grafana-data/src/field/fieldOverrides.ts b/packages/grafana-data/src/field/fieldOverrides.ts index 8316e1a7350..dcbd4fb97b3 100644 --- a/packages/grafana-data/src/field/fieldOverrides.ts +++ b/packages/grafana-data/src/field/fieldOverrides.ts @@ -238,7 +238,7 @@ export function applyFieldOverrides(options: ApplyFieldOverrideOptions): DataFra } function calculateRange( - config: FieldConfig, + config: FieldConfig, field: Field, globalRange: NumericRange | undefined, data: DataFrame[] @@ -269,7 +269,7 @@ function calculateRange( // 2. have the ability to selectively get display color or text (but not always both, which are each quite expensive) // 3. sufficently optimize text formatting and threshold color determinitation function cachingDisplayProcessor(disp: DisplayProcessor, maxCacheSize = 2500): DisplayProcessor { - type dispCache = Map; + type dispCache = Map; // decimals -> cache mapping, -1 is unspecified decimals const caches = new Map(); diff --git a/packages/grafana-data/src/field/overrides/processors.ts b/packages/grafana-data/src/field/overrides/processors.ts index d829f7963a9..409b0bdab68 100644 --- a/packages/grafana-data/src/field/overrides/processors.ts +++ b/packages/grafana-data/src/field/overrides/processors.ts @@ -8,7 +8,7 @@ import { ValueMapping, } from '../../types'; -export const identityOverrideProcessor = (value: T, _context: FieldOverrideContext, _settings: any) => { +export const identityOverrideProcessor = (value: T) => { return value; }; diff --git a/packages/grafana-data/src/geo/layer.ts b/packages/grafana-data/src/geo/layer.ts index c51750c3600..bb65b01dcb3 100644 --- a/packages/grafana-data/src/geo/layer.ts +++ b/packages/grafana-data/src/geo/layer.ts @@ -42,7 +42,7 @@ export interface MapLayerHandler { */ registerOptionsUI?: ( builder: PanelOptionsEditorBuilder>, - context: StandardEditorContext + context: StandardEditorContext ) => void; } diff --git a/packages/grafana-data/src/panel/getPanelOptionsWithDefaults.ts b/packages/grafana-data/src/panel/getPanelOptionsWithDefaults.ts index 1061054d1d1..584ea189989 100644 --- a/packages/grafana-data/src/panel/getPanelOptionsWithDefaults.ts +++ b/packages/grafana-data/src/panel/getPanelOptionsWithDefaults.ts @@ -17,12 +17,12 @@ import { PanelPlugin } from './PanelPlugin'; export interface Props { plugin: PanelPlugin; currentFieldConfig: FieldConfigSource; - currentOptions: Record; + currentOptions: Record; isAfterPluginChange: boolean; } export interface OptionDefaults { - options: any; + options: Record; fieldConfig: FieldConfigSource; } diff --git a/packages/grafana-data/src/panel/registryFactories.ts b/packages/grafana-data/src/panel/registryFactories.ts index 1cd6e8524d1..a312d0c128e 100644 --- a/packages/grafana-data/src/panel/registryFactories.ts +++ b/packages/grafana-data/src/panel/registryFactories.ts @@ -43,17 +43,17 @@ export function createFieldConfigRegistry( } for (let fieldConfigProp of standardConfigs) { + const id = fieldConfigProp.id as FieldConfigProperty; if (config.disableStandardOptions) { - const isDisabled = config.disableStandardOptions.indexOf(fieldConfigProp.id as FieldConfigProperty) > -1; + const isDisabled = config.disableStandardOptions.indexOf(id) > -1; if (isDisabled) { continue; } } if (config.standardOptions) { - const customHideFromDefaults = - config.standardOptions[fieldConfigProp.id as FieldConfigProperty]?.hideFromDefaults; - const customDefault = config.standardOptions[fieldConfigProp.id as FieldConfigProperty]?.defaultValue; - const customSettings = config.standardOptions[fieldConfigProp.id as FieldConfigProperty]?.settings; + const customHideFromDefaults = config.standardOptions[id]?.hideFromDefaults; + const customDefault = config.standardOptions[id]?.defaultValue; + const customSettings = config.standardOptions[id]?.settings; if (customHideFromDefaults) { fieldConfigProp = { diff --git a/packages/grafana-data/src/transformations/fieldReducer.ts b/packages/grafana-data/src/transformations/fieldReducer.ts index df2f690fbf3..dd8b1f98acf 100644 --- a/packages/grafana-data/src/transformations/fieldReducer.ts +++ b/packages/grafana-data/src/transformations/fieldReducer.ts @@ -39,7 +39,7 @@ type FieldReducer = (field: Field, ignoreNulls: boolean, nullAsZero: boolean) => export interface FieldReducerInfo extends RegistryItem { // Internal details - emptyInputResult?: any; // typically null, but some things like 'count' & 'sum' should be zero + emptyInputResult?: unknown; // typically null, but some things like 'count' & 'sum' should be zero standard: boolean; // The most common stats can all be calculated in a single pass reduce?: FieldReducer; } diff --git a/public/app/features/dashboard/components/GenAI/utils.ts b/public/app/features/dashboard/components/GenAI/utils.ts index d610c9426c9..3304a63029e 100644 --- a/public/app/features/dashboard/components/GenAI/utils.ts +++ b/public/app/features/dashboard/components/GenAI/utils.ts @@ -135,8 +135,7 @@ export function getFilteredPanelString(panel: PanelModel): string { 'yaxes', ]); - // This cannot avoid the use of any because the type of panelObj is any - const panelObjFiltered = Object.keys(panelObj).reduce((obj: { [key: string]: any }, key) => { + const panelObjFiltered = Object.keys(panelObj).reduce((obj: { [key: string]: unknown }, key) => { if (keysToKeep.has(key)) { obj[key] = panelObj[key]; } diff --git a/public/app/features/dashboard/components/PanelEditor/types.ts b/public/app/features/dashboard/components/PanelEditor/types.ts index 6c6148d5d67..59c917bf4d7 100644 --- a/public/app/features/dashboard/components/PanelEditor/types.ts +++ b/public/app/features/dashboard/components/PanelEditor/types.ts @@ -55,7 +55,7 @@ export interface OptionPaneRenderProps { plugin: PanelPlugin; data?: PanelData; dashboard: DashboardModel; - instanceState: any; + instanceState: unknown; onPanelConfigChange: (configKey: keyof PanelModel, value: unknown) => void; onPanelOptionsChanged: (options: PanelModel['options']) => void; onFieldConfigsChange: (config: FieldConfigSource) => void; diff --git a/public/app/features/dashboard/dashgrid/DashboardPanel.tsx b/public/app/features/dashboard/dashgrid/DashboardPanel.tsx index 89da60bb032..ffc36abee2b 100644 --- a/public/app/features/dashboard/dashgrid/DashboardPanel.tsx +++ b/public/app/features/dashboard/dashgrid/DashboardPanel.tsx @@ -28,7 +28,7 @@ export interface OwnProps { const mapStateToProps = (state: StoreState, props: OwnProps) => { const panelState = state.panels[props.stateKey]; if (!panelState) { - return { plugin: null }; + return { plugin: undefined }; } return { @@ -58,7 +58,7 @@ export class DashboardPanelUnconnected extends PureComponent { } } - onInstanceStateChange = (value: any) => { + onInstanceStateChange = (value: unknown) => { this.props.setPanelInstanceState({ key: this.props.stateKey, value }); }; diff --git a/public/app/features/dashboard/dashgrid/PanelStateWrapper.tsx b/public/app/features/dashboard/dashgrid/PanelStateWrapper.tsx index 786f314cdc0..0697af78451 100644 --- a/public/app/features/dashboard/dashgrid/PanelStateWrapper.tsx +++ b/public/app/features/dashboard/dashgrid/PanelStateWrapper.tsx @@ -65,7 +65,7 @@ export interface Props { isDraggable?: boolean; width: number; height: number; - onInstanceStateChange: (value: any) => void; + onInstanceStateChange: (value: unknown) => void; timezone?: string; hideMenu?: boolean; } @@ -129,7 +129,7 @@ export class PanelStateWrapper extends PureComponent { // Due to a mutable panel model we get the sync settings via function that proactively reads from the model getSync = () => (this.props.isEditing ? DashboardCursorSync.Off : this.props.dashboard.graphTooltip); - onInstanceStateChange = (value: any) => { + onInstanceStateChange = (value: unknown) => { this.props.onInstanceStateChange(value); this.setState({ diff --git a/public/app/features/dashboard/state/DashboardMigrator.ts b/public/app/features/dashboard/state/DashboardMigrator.ts index 6eece6a4515..419d3099998 100644 --- a/public/app/features/dashboard/state/DashboardMigrator.ts +++ b/public/app/features/dashboard/state/DashboardMigrator.ts @@ -187,7 +187,7 @@ export class DashboardMigrator { if (oldVersion < 6) { // move drop-downs to new schema - const annotations: any = find(old.pulldowns, { type: 'annotations' }); + const annotations = find(old.pulldowns, { type: 'annotations' }); if (annotations) { this.dashboard.annotations = { @@ -318,16 +318,18 @@ export class DashboardMigrator { if (oldVersion < 12) { // update template variables - each(this.dashboard.getVariables(), (templateVariable: any) => { - if (templateVariable.refresh) { - templateVariable.refresh = 1; - } - if (!templateVariable.refresh) { - templateVariable.refresh = 0; + each(this.dashboard.getVariables(), (templateVariable) => { + if ('refresh' in templateVariable) { + if (templateVariable.refresh) { + templateVariable.refresh = 1; + } + if (!templateVariable.refresh) { + templateVariable.refresh = 0; + } } - if (templateVariable.hideVariable) { + if ('hideVariable' in templateVariable && templateVariable.hideVariable) { templateVariable.hide = 2; - } else if (templateVariable.hideLabel) { + } else if ('hideLabel' in templateVariable && templateVariable.hideLabel) { templateVariable.hide = 1; } }); @@ -993,7 +995,7 @@ export class DashboardMigrator { continue; } - const height: any = row.height || DEFAULT_ROW_HEIGHT; + const height = row.height || DEFAULT_ROW_HEIGHT; const rowGridHeight = getGridHeight(height); const rowPanel: any = {}; diff --git a/public/app/features/dashboard/state/DashboardModel.ts b/public/app/features/dashboard/state/DashboardModel.ts index 7ce8db93d0e..c008a075363 100644 --- a/public/app/features/dashboard/state/DashboardModel.ts +++ b/public/app/features/dashboard/state/DashboardModel.ts @@ -157,7 +157,7 @@ export class DashboardModel implements TimeModel { this.version = data.version ?? 0; this.links = data.links ?? []; this.gnetId = data.gnetId || null; - this.panels = map(data.panels ?? [], (panelData: any) => new PanelModel(panelData)); + this.panels = map(data.panels ?? [], (panelData) => new PanelModel(panelData)); // Deep clone original dashboard to avoid mutations by object reference this.originalDashboard = cloneDeep(data); this.originalTemplating = cloneDeep(this.templating); @@ -331,7 +331,7 @@ export class DashboardModel implements TimeModel { return panel.getSaveModel(); }) - .map((model: any) => { + .map((model) => { if (this.isSnapshotTruthy()) { return model; } diff --git a/public/app/features/dashboard/state/reducers.ts b/public/app/features/dashboard/state/reducers.ts index 13c6d94dd32..3e7265eeb57 100644 --- a/public/app/features/dashboard/state/reducers.ts +++ b/public/app/features/dashboard/state/reducers.ts @@ -65,7 +65,7 @@ export interface SetPanelAngularComponentPayload { export interface SetPanelInstanceStatePayload { panelId: number; - value: any; + value: unknown; } export const { diff --git a/public/app/features/dimensions/utils.ts b/public/app/features/dimensions/utils.ts index e8c0c053f32..f04c597027b 100644 --- a/public/app/features/dimensions/utils.ts +++ b/public/app/features/dimensions/utils.ts @@ -132,5 +132,5 @@ export function getLastNotNullFieldValue(field: Field): T { return v; } } - return undefined as any; + return undefined as T; } diff --git a/public/app/features/expressions/ExpressionDatasource.ts b/public/app/features/expressions/ExpressionDatasource.ts index 795407c0d4a..06d31ca6757 100644 --- a/public/app/features/expressions/ExpressionDatasource.ts +++ b/public/app/features/expressions/ExpressionDatasource.ts @@ -22,7 +22,7 @@ export class ExpressionDatasourceApi extends DataSourceWithBackend { + applyTemplateVariables(query: ExpressionQuery, scopedVars: ScopedVars) { const templateSrv = getTemplateSrv(); return { ...query, diff --git a/public/app/features/geo/format/geohash.ts b/public/app/features/geo/format/geohash.ts index 1a2ebf0e0b6..8940b1d5ff5 100644 --- a/public/app/features/geo/format/geohash.ts +++ b/public/app/features/geo/format/geohash.ts @@ -33,7 +33,7 @@ export function decodeGeohash(geohash: string): [number, number] | undefined { return [lonCenter, latCenter]; } -function refineInterval(interval: any[], base32Decoded: number, mask: number) { +function refineInterval(interval: number[], base32Decoded: number, mask: number) { /* tslint:disable no-bitwise*/ if (base32Decoded & mask) { interval[0] = (interval[0] + interval[1]) / 2; diff --git a/public/app/features/geo/format/geojson.ts b/public/app/features/geo/format/geojson.ts index 521c7b8d91c..f2969e098cd 100644 --- a/public/app/features/geo/format/geojson.ts +++ b/public/app/features/geo/format/geojson.ts @@ -4,7 +4,7 @@ import { Geometry } from 'ol/geom'; import { DataFrame, Field, FieldType, getFieldTypeFromValue } from '@grafana/data'; interface FieldInfo { - values: any[]; + values: Array; types: Set; count: number; } diff --git a/public/app/features/inspector/InspectErrorTab.tsx b/public/app/features/inspector/InspectErrorTab.tsx index 554d79b89dc..d79768563d4 100644 --- a/public/app/features/inspector/InspectErrorTab.tsx +++ b/public/app/features/inspector/InspectErrorTab.tsx @@ -7,7 +7,7 @@ interface InspectErrorTabProps { errors?: DataQueryError[]; } -const parseErrorMessage = (message: string): { msg: string; json?: any } => { +const parseErrorMessage = (message: string) => { try { const [msg, json] = message.split(/(\{.+)/); const jsonError = JSON.parse(json); diff --git a/public/app/features/inspector/QueryInspector.tsx b/public/app/features/inspector/QueryInspector.tsx index c09f999d44d..ad857599173 100644 --- a/public/app/features/inspector/QueryInspector.tsx +++ b/public/app/features/inspector/QueryInspector.tsx @@ -32,7 +32,7 @@ interface State { } export class QueryInspector extends PureComponent { - private formattedJson: any; + private formattedJson?: {}; private subs = new Subscription(); constructor(props: Props) { @@ -146,7 +146,7 @@ export class QueryInspector extends PureComponent { }); } - setFormattedJson = (formattedJson: any) => { + setFormattedJson = (formattedJson: {}) => { this.formattedJson = formattedJson; }; diff --git a/public/app/features/invites/state/selectors.ts b/public/app/features/invites/state/selectors.ts index daf42e464bc..03733071079 100644 --- a/public/app/features/invites/state/selectors.ts +++ b/public/app/features/invites/state/selectors.ts @@ -1,10 +1,12 @@ -import { createSelector } from '@reduxjs/toolkit'; +import { EntityState, createSelector } from '@reduxjs/toolkit'; + +import { Invitee } from 'app/types'; import { selectors } from './reducers'; export const { selectAll, selectById, selectTotal } = selectors; -const selectQuery = (_: any, query: string) => query; +const selectQuery = (_state: EntityState, query: string) => query; export const selectInvitesMatchingQuery = createSelector([selectAll, selectQuery], (invites, searchQuery) => { const regex = new RegExp(searchQuery, 'i'); const matches = invites.filter((invite) => regex.test(invite.name) || regex.test(invite.email)); diff --git a/public/app/features/live/centrifuge/LiveDataStream.test.ts b/public/app/features/live/centrifuge/LiveDataStream.test.ts index 9a3bd331f5e..f8010aac647 100644 --- a/public/app/features/live/centrifuge/LiveDataStream.test.ts +++ b/public/app/features/live/centrifuge/LiveDataStream.test.ts @@ -25,9 +25,9 @@ type SubjectsInsteadOfObservables = { [key in keyof T]: T[key] extends Observable ? Subject : T[key]; }; -type DepsWithSubjectsInsteadOfObservables = SubjectsInsteadOfObservables>; +type DepsWithSubjectsInsteadOfObservables = SubjectsInsteadOfObservables>; -const createDeps = ( +const createDeps = ( overrides?: Partial> ): DepsWithSubjectsInsteadOfObservables => { return { @@ -43,7 +43,7 @@ const createDeps = ( class ValuesCollection implements Unsubscribable { values: T[] = []; - errors: any[] = []; + errors: unknown[] = []; receivedComplete = false; subscription: Subscription | undefined; diff --git a/public/app/features/live/centrifuge/transferHandlers.ts b/public/app/features/live/centrifuge/transferHandlers.ts index 7220003fc83..dafda35a4f6 100644 --- a/public/app/features/live/centrifuge/transferHandlers.ts +++ b/public/app/features/live/centrifuge/transferHandlers.ts @@ -3,8 +3,8 @@ import { Subscriber } from 'rxjs'; // Observers, ie. functions passed to `observable.subscribe(...)`, are converted to a subclass of `Subscriber` before they are sent to the source Observable. // The conversion happens internally in the RxJS library - this transfer handler is catches them and wraps them with a proxy -const subscriberTransferHandler: any = { - canHandle(value: unknown): boolean { +const subscriberTransferHandler = { + canHandle(value: unknown): value is Subscriber { return Boolean(value && value instanceof Subscriber); }, diff --git a/public/app/features/org/OrgDetailsPage.tsx b/public/app/features/org/OrgDetailsPage.tsx index b3340e841ec..98d181e368f 100644 --- a/public/app/features/org/OrgDetailsPage.tsx +++ b/public/app/features/org/OrgDetailsPage.tsx @@ -1,26 +1,19 @@ import React, { PureComponent } from 'react'; -import { connect } from 'react-redux'; +import { ConnectedProps, connect } from 'react-redux'; -import { NavModel } from '@grafana/data'; import { VerticalGroup } from '@grafana/ui'; import { Page } from 'app/core/components/Page/Page'; import SharedPreferences from 'app/core/components/SharedPreferences/SharedPreferences'; import { appEvents, contextSrv } from 'app/core/core'; import { getNavModel } from 'app/core/selectors/navModel'; -import { AccessControlAction, Organization, StoreState } from 'app/types'; +import { AccessControlAction, StoreState } from 'app/types'; import { ShowConfirmModalEvent } from 'app/types/events'; import OrgProfile from './OrgProfile'; import { loadOrganization, updateOrganization } from './state/actions'; import { setOrganizationName } from './state/reducers'; -export interface Props { - navModel: NavModel; - organization: Organization; - loadOrganization: typeof loadOrganization; - setOrganizationName: typeof setOrganizationName; - updateOrganization: typeof updateOrganization; -} +interface OwnProps {} export class OrgDetailsPage extends PureComponent { async componentDidMount() { @@ -89,4 +82,7 @@ const mapDispatchToProps = { updateOrganization, }; -export default connect(mapStateToProps, mapDispatchToProps)(OrgDetailsPage); +const connector = connect(mapStateToProps, mapDispatchToProps); +export type Props = OwnProps & ConnectedProps; + +export default connector(OrgDetailsPage); diff --git a/public/app/features/org/state/actions.ts b/public/app/features/org/state/actions.ts index 7b382a71751..ee39073640a 100644 --- a/public/app/features/org/state/actions.ts +++ b/public/app/features/org/state/actions.ts @@ -8,7 +8,7 @@ type OrganizationDependencies = { getBackendSrv: typeof getBackendSrv }; export function loadOrganization( dependencies: OrganizationDependencies = { getBackendSrv: getBackendSrv } -): ThunkResult { +): ThunkResult { return async (dispatch) => { const organizationResponse = await dependencies.getBackendSrv().get('/api/org'); dispatch(organizationLoaded(organizationResponse)); @@ -19,7 +19,7 @@ export function loadOrganization( export function updateOrganization( dependencies: OrganizationDependencies = { getBackendSrv: getBackendSrv } -): ThunkResult { +): ThunkResult { return async (dispatch, getStore) => { const organization = getStore().organization.organization; @@ -33,7 +33,7 @@ export function updateOrganization( export function setUserOrganization( orgId: number, dependencies: OrganizationDependencies = { getBackendSrv: getBackendSrv } -): ThunkResult { +): ThunkResult { return async (dispatch) => { const organizationResponse = await dependencies.getBackendSrv().post('/api/user/using/' + orgId); @@ -44,7 +44,7 @@ export function setUserOrganization( export function createOrganization( newOrg: { name: string }, dependencies: OrganizationDependencies = { getBackendSrv: getBackendSrv } -): ThunkResult { +): ThunkResult { return async (dispatch) => { const result = await dependencies.getBackendSrv().post('/api/orgs/', newOrg); diff --git a/public/app/features/panel/components/PanelRenderer.tsx b/public/app/features/panel/components/PanelRenderer.tsx index b8cb634c1dc..872e73fb8e4 100644 --- a/public/app/features/panel/components/PanelRenderer.tsx +++ b/public/app/features/panel/components/PanelRenderer.tsx @@ -107,7 +107,7 @@ export function PanelRenderer

(prop ); } -function useOptionDefaults

( +function useOptionDefaults

= {}, F extends object = {}>( plugin: PanelPlugin | undefined, options: P, fieldConfig: FieldConfigSource diff --git a/public/app/features/panel/components/VizTypePicker/types.ts b/public/app/features/panel/components/VizTypePicker/types.ts index d656b2e19f8..4dbab692faf 100644 --- a/public/app/features/panel/components/VizTypePicker/types.ts +++ b/public/app/features/panel/components/VizTypePicker/types.ts @@ -2,7 +2,7 @@ import { FieldConfigSource } from '@grafana/data'; export interface VizTypeChangeDetails { pluginId: string; - options?: any; + options?: Record; fieldConfig?: FieldConfigSource; withModKey?: boolean; } diff --git a/public/app/features/panel/state/actions.ts b/public/app/features/panel/state/actions.ts index 1bf3e1d549c..2e01dd5a732 100644 --- a/public/app/features/panel/state/actions.ts +++ b/public/app/features/panel/state/actions.ts @@ -46,7 +46,7 @@ export function cleanUpPanelState(panelKey: string): ThunkResult { export interface ChangePanelPluginAndOptionsArgs { panel: PanelModel; pluginId: string; - options?: any; + options?: Record; fieldConfig?: FieldConfigSource; transformations?: DataTransformerConfig[]; } diff --git a/public/app/features/panel/state/reducers.ts b/public/app/features/panel/state/reducers.ts index 262b7430af3..b63619d6cb5 100644 --- a/public/app/features/panel/state/reducers.ts +++ b/public/app/features/panel/state/reducers.ts @@ -8,7 +8,7 @@ export type RootPanelsState = Record; export interface PanelState { plugin?: PanelPlugin; angularComponent?: AngularComponent; - instanceState?: any | null; + instanceState?: unknown | null; } export const initialState: RootPanelsState = {}; @@ -54,7 +54,7 @@ export interface SetPanelAngularComponentPayload { export interface SetPanelInstanceStatePayload { key: string; - value: any; + value: unknown; } export const { diff --git a/public/app/features/plugins/admin/components/SearchField.tsx b/public/app/features/plugins/admin/components/SearchField.tsx index c251f34b1cc..6c43e063e1d 100644 --- a/public/app/features/plugins/admin/components/SearchField.tsx +++ b/public/app/features/plugins/admin/components/SearchField.tsx @@ -10,7 +10,7 @@ interface Props { // useDebounce has a bug which causes it to fire on first render. This wrapper prevents that. // https://github.com/streamich/react-use/issues/759 -const useDebounceWithoutFirstRender = (callBack: () => any, delay = 0, deps: React.DependencyList = []) => { +const useDebounceWithoutFirstRender = (callBack: () => void, delay = 0, deps: React.DependencyList = []) => { const isFirstRender = useRef(true); const debounceDeps = [...deps, isFirstRender]; diff --git a/public/app/features/plugins/datasource_srv.ts b/public/app/features/plugins/datasource_srv.ts index df342cb746b..16f4c08f541 100644 --- a/public/app/features/plugins/datasource_srv.ts +++ b/public/app/features/plugins/datasource_srv.ts @@ -356,7 +356,7 @@ export function getNameOrUid(ref?: string | DataSourceRef | null): string | unde return isString ? ref : ref?.uid; } -export function variableInterpolation(value: any[]) { +export function variableInterpolation(value: T | T[]) { if (Array.isArray(value)) { return value[0]; } diff --git a/public/app/features/plugins/pluginSettings.ts b/public/app/features/plugins/pluginSettings.ts index 5febcc68739..81458fedcaa 100644 --- a/public/app/features/plugins/pluginSettings.ts +++ b/public/app/features/plugins/pluginSettings.ts @@ -14,11 +14,11 @@ export function getPluginSettings(pluginId: string, options?: Partial { + .then((settings) => { pluginInfoCache[pluginId] = settings; return settings; }) - .catch((err: any) => { + .catch(() => { return Promise.reject(new Error('Unknown Plugin')); }); } diff --git a/public/app/features/plugins/sql/components/visual-query-builder/AwesomeQueryBuilder.tsx b/public/app/features/plugins/sql/components/visual-query-builder/AwesomeQueryBuilder.tsx index 9ddf96dc600..a9e8400f6cd 100644 --- a/public/app/features/plugins/sql/components/visual-query-builder/AwesomeQueryBuilder.tsx +++ b/public/app/features/plugins/sql/components/visual-query-builder/AwesomeQueryBuilder.tsx @@ -182,7 +182,6 @@ const enum Op { NOT_IN = 'select_not_any_in', MACROS = 'macros', } -// eslint-ignore const customOperators = getCustomOperators(BasicConfig); const textWidget = BasicConfig.types.text.widgets.text; const opers = [...(textWidget.operators || []), Op.IN, Op.NOT_IN]; @@ -317,7 +316,6 @@ function getCustomOperators(config: BasicConfig) { } // value: string | List but AQB uses a different version of Immutable -// eslint-ignore function splitIfString(value: any) { if (isString(value)) { return value.split(','); diff --git a/public/app/features/plugins/sql/datasource/SqlDatasource.ts b/public/app/features/plugins/sql/datasource/SqlDatasource.ts index 1d73bdd393e..0d4540e91ce 100644 --- a/public/app/features/plugins/sql/datasource/SqlDatasource.ts +++ b/public/app/features/plugins/sql/datasource/SqlDatasource.ts @@ -217,7 +217,7 @@ export abstract class SqlDatasource extends DataSourceWithBackend(query: string, options?: RunSQLOptions) { + async runSql(query: string, options?: RunSQLOptions) { const range = getDefaultTimeRange(); const frame = await this.runMetaQuery({ rawSql: query, format: QueryFormat.Table, refId: options?.refId }, range); return new DataFrameView(frame); diff --git a/public/app/features/plugins/tests/datasource_srv.test.ts b/public/app/features/plugins/tests/datasource_srv.test.ts index 0acd249100b..6c348c672c7 100644 --- a/public/app/features/plugins/tests/datasource_srv.test.ts +++ b/public/app/features/plugins/tests/datasource_srv.test.ts @@ -75,7 +75,7 @@ describe('datasource_srv', () => { type: 'test-db', name: 'mmm', uid: 'uid-code-mmm', - meta: { metrics: true, annotations: true } as any, + meta: { metrics: true, annotations: true }, }, '-- Grafana --': { type: 'grafana', @@ -169,7 +169,7 @@ describe('datasource_srv', () => { }); it('Can get by variable', async () => { - const ds = (await dataSourceSrv.get('${datasource}')) as any; + const ds = await dataSourceSrv.get('${datasource}'); expect(ds.meta).toBe(dataSourceInit.BBB.meta); const ds2 = await dataSourceSrv.get('${datasource}', { datasource: { text: 'Prom', value: 'uid-code-aaa' } }); diff --git a/public/test/matchers/toEmitValuesWith.ts b/public/test/matchers/toEmitValuesWith.ts index d9a53e965a0..23d9e819e41 100644 --- a/public/test/matchers/toEmitValuesWith.ts +++ b/public/test/matchers/toEmitValuesWith.ts @@ -3,7 +3,7 @@ import { Observable, Subscription } from 'rxjs'; import { expectObservable, forceObservableCompletion } from './utils'; -function tryExpectations(received: unknown[], expectations: (received: unknown[]) => void): jest.CustomMatcherResult { +function tryExpectations(received: T[], expectations: (received: T[]) => void): jest.CustomMatcherResult { try { expectations(received); return { @@ -27,9 +27,9 @@ function tryExpectations(received: unknown[], expectations: (received: unknown[] * the observable ended (or emitted error). If Observable does not complete within OBSERVABLE_TEST_TIMEOUT_IN_MS the * test fails. */ -export function toEmitValuesWith( - received: Observable, - expectations: (actual: any[]) => void +export function toEmitValuesWith( + received: Observable, + expectations: (actual: T[]) => void ): Promise { const failsChecks = expectObservable(received); if (failsChecks) { @@ -37,7 +37,7 @@ export function toEmitValuesWith( } return new Promise((resolve) => { - const receivedValues: any[] = []; + const receivedValues: T[] = []; const subscription = new Subscription(); subscription.add( diff --git a/public/test/matchers/types.ts b/public/test/matchers/types.ts index c67b32897f5..2c8cd92ff3b 100644 --- a/public/test/matchers/types.ts +++ b/public/test/matchers/types.ts @@ -2,12 +2,10 @@ import { Observable } from 'rxjs'; export const OBSERVABLE_TEST_TIMEOUT_IN_MS = 1000; -export type ObservableType = T extends Observable ? V : never; - export interface ObservableMatchers extends jest.ExpectExtendMap { - toEmitValues>(received: T, expected: E[]): Promise; - toEmitValuesWith>( - received: T, - expectations: (received: E[]) => void + toEmitValues(received: Observable, expected: T[]): Promise; + toEmitValuesWith( + received: Observable, + expectations: (received: T[]) => void ): Promise; } diff --git a/public/test/specs/helpers.ts b/public/test/specs/helpers.ts index d094d019b6a..ebce099682d 100644 --- a/public/test/specs/helpers.ts +++ b/public/test/specs/helpers.ts @@ -39,7 +39,7 @@ export function ControllerTestContext(this: any) { $provide.value('templateSrv', self.templateSrv); $provide.value('$element', self.$element); $provide.value('$sanitize', self.$sanitize); - each(mocks, (value: any, key: any) => { + each(mocks, (value, key) => { $provide.value(key, value); }); });