diff --git a/.betterer.results b/.betterer.results index b50283447cd..a63e905a236 100644 --- a/.betterer.results +++ b/.betterer.results @@ -302,10 +302,7 @@ exports[`better eslint`] = { [0, 0, 0, "Unexpected any. Specify a different type.", "30"], [0, 0, 0, "Unexpected any. Specify a different type.", "31"], [0, 0, 0, "Unexpected any. Specify a different type.", "32"], - [0, 0, 0, "Unexpected any. Specify a different type.", "33"], - [0, 0, 0, "Unexpected any. Specify a different type.", "34"], - [0, 0, 0, "Unexpected any. Specify a different type.", "35"], - [0, 0, 0, "Unexpected any. Specify a different type.", "36"] + [0, 0, 0, "Unexpected any. Specify a different type.", "33"] ], "packages/grafana-data/src/field/fieldOverrides.ts:5381": [ [0, 0, 0, "Unexpected any. Specify a different type.", "0"], @@ -1063,9 +1060,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"] ], "packages/grafana-runtime/src/utils/queryResponse.ts:5381": [ [0, 0, 0, "Do not use any type assertions.", "0"], @@ -2253,10 +2248,6 @@ exports[`better eslint`] = { [0, 0, 0, "Do not use any type assertions.", "0"], [0, 0, 0, "Unexpected any. Specify a different type.", "1"] ], - "public/app/angular/promiseToDigest.test.ts:5381": [ - [0, 0, 0, "Unexpected any. Specify a different type.", "0"], - [0, 0, 0, "Unexpected any. Specify a different type.", "1"] - ], "public/app/angular/promiseToDigest.ts:5381": [ [0, 0, 0, "Unexpected any. Specify a different type.", "0"] ], @@ -2386,30 +2377,14 @@ exports[`better eslint`] = { [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.", "6"], - [0, 0, 0, "Do not use any type assertions.", "7"], - [0, 0, 0, "Do not use any type assertions.", "8"], - [0, 0, 0, "Unexpected any. Specify a different type.", "9"], - [0, 0, 0, "Do not use any type assertions.", "10"] - ], - "public/app/core/components/ColorScale/ColorScale.tsx:5381": [ - [0, 0, 0, "Do not use any type assertions.", "0"], - [0, 0, 0, "Do not use any type assertions.", "1"], - [0, 0, 0, "Unexpected any. Specify a different type.", "2"] + [0, 0, 0, "Unexpected any. Specify a different type.", "6"] ], "public/app/core/components/DynamicImports/SafeDynamicImport.tsx:5381": [ [0, 0, 0, "Unexpected any. Specify a different type.", "0"] ], - "public/app/core/components/Layers/LayerName.tsx:5381": [ - [0, 0, 0, "Do not use any type assertions.", "0"], - [0, 0, 0, "Unexpected any. Specify a different type.", "1"] - ], "public/app/core/components/Login/LoginCtrl.tsx:5381": [ [0, 0, 0, "Unexpected any. Specify a different type.", "0"] ], - "public/app/core/components/Login/LoginPage.test.tsx:5381": [ - [0, 0, 0, "Unexpected any. Specify a different type.", "0"] - ], "public/app/core/components/NavBar/NavBarItem.test.tsx:5381": [ [0, 0, 0, "Unexpected any. Specify a different type.", "0"] ], @@ -2418,15 +2393,6 @@ exports[`better eslint`] = { [0, 0, 0, "Do not use any type assertions.", "1"], [0, 0, 0, "Do not use any type assertions.", "2"] ], - "public/app/core/components/OptionsUI/DashboardPicker.tsx:5381": [ - [0, 0, 0, "Unexpected any. Specify a different type.", "0"] - ], - "public/app/core/components/OptionsUI/DashboardPickerByID.tsx:5381": [ - [0, 0, 0, "Do not use any type assertions.", "0"] - ], - "public/app/core/components/OptionsUI/fieldColor.tsx:5381": [ - [0, 0, 0, "Do not use any type assertions.", "0"] - ], "public/app/core/components/OptionsUI/registry.tsx:5381": [ [0, 0, 0, "Do not use any type assertions.", "0"], [0, 0, 0, "Unexpected any. Specify a different type.", "1"], @@ -2556,13 +2522,6 @@ exports[`better eslint`] = { "public/app/core/components/modals/AngularModalProxy.tsx:5381": [ [0, 0, 0, "Unexpected any. Specify a different type.", "0"] ], - "public/app/core/history/RichHistoryRemoteStorage.test.ts:5381": [ - [0, 0, 0, "Unexpected any. Specify a different type.", "0"] - ], - "public/app/core/history/RichHistoryRemoteStorage.ts:5381": [ - [0, 0, 0, "Do not use any type assertions.", "0"], - [0, 0, 0, "Do not use any type assertions.", "1"] - ], "public/app/core/history/richHistoryLocalStorageUtils.ts:5381": [ [0, 0, 0, "Unexpected any. Specify a different type.", "0"] ], @@ -2583,21 +2542,10 @@ 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/core/navigation/hooks.ts:5381": [ - [0, 0, 0, "Unexpected any. Specify a different type.", "0"], - [0, 0, 0, "Unexpected any. Specify a different type.", "1"] - ], "public/app/core/navigation/patch/interceptLinkClicks.ts:5381": [ [0, 0, 0, "Do not use any type assertions.", "0"], [0, 0, 0, "Do not use any type assertions.", "1"] ], - "public/app/core/navigation/queryString.ts:5381": [ - [0, 0, 0, "Unexpected any. Specify a different type.", "0"] - ], - "public/app/core/navigation/testRoutes.tsx:5381": [ - [0, 0, 0, "Do not use any type assertions.", "0"], - [0, 0, 0, "Unexpected any. Specify a different type.", "1"] - ], "public/app/core/navigation/types.ts:5381": [ [0, 0, 0, "Unexpected any. Specify a different type.", "0"], [0, 0, 0, "Unexpected any. Specify a different type.", "1"] @@ -2606,9 +2554,6 @@ exports[`better eslint`] = { [0, 0, 0, "Do not use any type assertions.", "0"], [0, 0, 0, "Unexpected any. Specify a different type.", "1"] ], - "public/app/core/reducers/appNotification.ts:5381": [ - [0, 0, 0, "Unexpected any. Specify a different type.", "0"] - ], "public/app/core/reducers/processsAclItems.ts:5381": [ [0, 0, 0, "Do not use any type assertions.", "0"] ], @@ -2617,12 +2562,7 @@ exports[`better eslint`] = { [0, 0, 0, "Unexpected any. Specify a different type.", "1"] ], "public/app/core/services/FetchQueue.ts:5381": [ - [0, 0, 0, "Do not use any type assertions.", "0"], - [0, 0, 0, "Do not use any type assertions.", "1"] - ], - "public/app/core/services/FetchQueueWorker.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.", "0"] ], "public/app/core/services/PreferencesService.ts:5381": [ [0, 0, 0, "Unexpected any. Specify a different type.", "0"], @@ -2659,18 +2599,14 @@ exports[`better eslint`] = { "public/app/core/services/context_srv.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, "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.", "2"], + [0, 0, 0, "Unexpected any. Specify a different type.", "3"] ], "public/app/core/services/echo/backends/analytics/ApplicationInsightsBackend.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, "Unexpected any. Specify a different type.", "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.", "0"], + [0, 0, 0, "Unexpected any. Specify a different type.", "1"], + [0, 0, 0, "Do not use any type assertions.", "2"], + [0, 0, 0, "Unexpected any. Specify a different type.", "3"] ], "public/app/core/services/echo/backends/analytics/RudderstackBackend.ts:5381": [ [0, 0, 0, "Do not use any type assertions.", "0"], @@ -2678,16 +2614,6 @@ exports[`better eslint`] = { [0, 0, 0, "Do not use any type assertions.", "2"], [0, 0, 0, "Unexpected any. Specify a different type.", "3"] ], - "public/app/core/services/echo/backends/sentry/transports/CustomEndpointTransport.test.ts:5381": [ - [0, 0, 0, "Unexpected any. Specify a different type.", "0"], - [0, 0, 0, "Unexpected any. Specify a different type.", "1"] - ], - "public/app/core/services/echo/backends/sentry/transports/CustomEndpointTransport.ts:5381": [ - [0, 0, 0, "Do not use any type assertions.", "0"] - ], - "public/app/core/services/echo/backends/sentry/transports/EchoSrvTransport.ts:5381": [ - [0, 0, 0, "Do not use any type assertions.", "0"] - ], "public/app/core/services/search_srv.ts:5381": [ [0, 0, 0, "Unexpected any. Specify a different type.", "0"], [0, 0, 0, "Unexpected any. Specify a different type.", "1"], @@ -2699,9 +2625,6 @@ exports[`better eslint`] = { [0, 0, 0, "Unexpected any. Specify a different type.", "7"], [0, 0, 0, "Unexpected any. Specify a different type.", "8"] ], - "public/app/core/specs/TableModel.test.ts:5381": [ - [0, 0, 0, "Unexpected any. Specify a different type.", "0"] - ], "public/app/core/specs/backend_srv.test.ts:5381": [ [0, 0, 0, "Unexpected any. Specify a different type.", "0"], [0, 0, 0, "Unexpected any. Specify a different type.", "1"], @@ -2709,11 +2632,7 @@ exports[`better eslint`] = { [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.", "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, "Unexpected any. Specify a different type.", "6"] ], "public/app/core/specs/flatten.test.ts:5381": [ [0, 0, 0, "Unexpected any. Specify a different type.", "0"], @@ -2780,15 +2699,8 @@ exports[`better eslint`] = { [0, 0, 0, "Unexpected any. Specify a different type.", "8"], [0, 0, 0, "Unexpected any. Specify a different type.", "9"] ], - "public/app/core/utils/css_loader.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"] - ], "public/app/core/utils/deferred.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.", "0"] ], "public/app/core/utils/errors.test.ts:5381": [ [0, 0, 0, "Unexpected any. Specify a different type.", "0"], @@ -2796,14 +2708,10 @@ exports[`better eslint`] = { [0, 0, 0, "Unexpected any. Specify a different type.", "2"] ], "public/app/core/utils/errors.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, "Unexpected any. Specify a different type.", "0"] ], "public/app/core/utils/explore.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"], - [0, 0, 0, "Unexpected any. Specify a different type.", "3"] + [0, 0, 0, "Unexpected any. Specify a different type.", "0"] ], "public/app/core/utils/explore.ts:5381": [ [0, 0, 0, "Do not use any type assertions.", "0"], @@ -2845,11 +2753,6 @@ exports[`better eslint`] = { [0, 0, 0, "Do not use any type assertions.", "0"], [0, 0, 0, "Do not use any type assertions.", "1"] ], - "public/app/core/utils/model_utils.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/core/utils/object.ts:5381": [ [0, 0, 0, "Do not use any type assertions.", "0"], [0, 0, 0, "Do not use any type assertions.", "1"], @@ -2960,19 +2863,7 @@ exports[`better eslint`] = { [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.", "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, "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.", "14"], - [0, 0, 0, "Unexpected any. Specify a different type.", "15"], - [0, 0, 0, "Unexpected any. Specify a different type.", "16"], - [0, 0, 0, "Unexpected any. Specify a different type.", "17"] + [0, 0, 0, "Unexpected any. Specify a different type.", "5"] ], "public/app/features/alerting/getAlertingValidationMessage.ts:5381": [ [0, 0, 0, "Do not use any type assertions.", "0"], @@ -3161,15 +3052,14 @@ exports[`better eslint`] = { [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"], - [0, 0, 0, "Do not use any type assertions.", "4"], + [0, 0, 0, "Do not use any type assertions.", "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.", "6"], + [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.", "8"], + [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"] ], "public/app/features/alerting/unified/state/actions.ts:5381": [ [0, 0, 0, "Do not use any type assertions.", "0"], @@ -4171,8 +4061,7 @@ exports[`better eslint`] = { [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.", "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.", "7"] ], "public/app/features/explore/state/time.test.ts:5381": [ [0, 0, 0, "Unexpected any. Specify a different type.", "0"], @@ -4366,8 +4255,7 @@ exports[`better eslint`] = { [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.", "3"] ], "public/app/features/logs/components/LogRows.tsx:5381": [ [0, 0, 0, "Unexpected any. Specify a different type.", "0"] @@ -4908,9 +4796,6 @@ exports[`better eslint`] = { [0, 0, 0, "Do not use any type assertions.", "3"], [0, 0, 0, "Unexpected any. Specify a different type.", "4"] ], - "public/app/features/teams/CreateTeam.test.tsx:5381": [ - [0, 0, 0, "Unexpected any. Specify a different type.", "0"] - ], "public/app/features/teams/TeamGroupSync.tsx:5381": [ [0, 0, 0, "Unexpected any. Specify a different type.", "0"], [0, 0, 0, "Unexpected any. Specify a different type.", "1"] @@ -5586,9 +5471,6 @@ exports[`better eslint`] = { "public/app/plugins/datasource/cloud-monitoring/types.ts:5381": [ [0, 0, 0, "Unexpected any. Specify a different type.", "0"] ], - "public/app/plugins/datasource/cloudwatch/__mocks__/monarch/Monaco.ts:5381": [ - [0, 0, 0, "Unexpected any. Specify a different type.", "0"] - ], "public/app/plugins/datasource/cloudwatch/components/ConfigEditor.test.tsx:5381": [ [0, 0, 0, "Unexpected any. Specify a different type.", "0"] ], @@ -6123,9 +6005,7 @@ exports[`better eslint`] = { [0, 0, 0, "Unexpected any. Specify a different type.", "62"] ], "public/app/plugins/datasource/graphite/datasource_integration.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"] + [0, 0, 0, "Unexpected any. Specify a different type.", "0"] ], "public/app/plugins/datasource/graphite/gfunc.ts:5381": [ [0, 0, 0, "Unexpected any. Specify a different type.", "0"], @@ -6901,9 +6781,7 @@ exports[`better eslint`] = { [0, 0, 0, "Unexpected any. Specify a different type.", "103"], [0, 0, 0, "Unexpected any. Specify a different type.", "104"], [0, 0, 0, "Unexpected any. Specify a different type.", "105"], - [0, 0, 0, "Unexpected any. Specify a different type.", "106"], - [0, 0, 0, "Unexpected any. Specify a different type.", "107"], - [0, 0, 0, "Unexpected any. Specify a different type.", "108"] + [0, 0, 0, "Unexpected any. Specify a different type.", "106"] ], "public/app/plugins/datasource/prometheus/datasource.tsx:5381": [ [0, 0, 0, "Unexpected any. Specify a different type.", "0"], @@ -6944,21 +6822,7 @@ exports[`better eslint`] = { "public/app/plugins/datasource/prometheus/language_provider.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"], - [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.", "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, "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.", "14"], - [0, 0, 0, "Unexpected any. Specify a different type.", "15"], - [0, 0, 0, "Unexpected any. Specify a different type.", "16"] + [0, 0, 0, "Unexpected any. Specify a different type.", "2"] ], "public/app/plugins/datasource/prometheus/language_provider.ts:5381": [ [0, 0, 0, "Unexpected any. Specify a different type.", "0"], @@ -7000,8 +6864,7 @@ exports[`better eslint`] = { [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, "Do not use any type assertions.", "4"] ], "public/app/plugins/datasource/prometheus/querybuilder/binaryScalarOperations.ts:5381": [ [0, 0, 0, "Do not use any type assertions.", "0"], @@ -7036,17 +6899,13 @@ exports[`better eslint`] = { "public/app/plugins/datasource/prometheus/querybuilder/shared/LabelFilterItem.tsx:5381": [ [0, 0, 0, "Do not use any type assertions.", "0"], [0, 0, 0, "Do not use any type assertions.", "1"], - [0, 0, 0, "Unexpected any. Specify a different type.", "2"], + [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.", "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.", "9"], - [0, 0, 0, "Do not use any type assertions.", "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.", "8"] ], "public/app/plugins/datasource/prometheus/querybuilder/shared/LabelFilters.tsx:5381": [ [0, 0, 0, "Do not use any type assertions.", "0"] @@ -7596,8 +7455,7 @@ exports[`better eslint`] = { [0, 0, 0, "Unexpected any. Specify a different type.", "1"] ], "public/app/plugins/panel/geomap/migrations.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.", "0"] ], "public/app/plugins/panel/geomap/migrations.ts:5381": [ [0, 0, 0, "Unexpected any. Specify a different type.", "0"], @@ -8867,9 +8725,6 @@ exports[`better eslint`] = { [0, 0, 0, "Do not use any type assertions.", "4"], [0, 0, 0, "Do not use any type assertions.", "5"] ], - "public/test/mocks/getGrafanaContextMock.ts:5381": [ - [0, 0, 0, "Unexpected any. Specify a different type.", "0"] - ], "public/test/mocks/workers.ts:5381": [ [0, 0, 0, "Unexpected any. Specify a different type.", "0"], [0, 0, 0, "Do not use any type assertions.", "1"], diff --git a/packages/grafana-data/src/field/fieldOverrides.test.ts b/packages/grafana-data/src/field/fieldOverrides.test.ts index a276248862b..7b5d8ee5cd7 100644 --- a/packages/grafana-data/src/field/fieldOverrides.test.ts +++ b/packages/grafana-data/src/field/fieldOverrides.test.ts @@ -258,7 +258,7 @@ describe('applyFieldOverrides', () => { const data = applyFieldOverrides({ data: [f0], // the frame fieldConfig: src as FieldConfigSource, // defaults + overrides - replaceVariables: undefined as any as InterpolateFunction, + replaceVariables: undefined as unknown as InterpolateFunction, theme: createTheme(), fieldConfigRegistry: customFieldRegistry, })[0]; @@ -285,7 +285,7 @@ describe('applyFieldOverrides', () => { const data = applyFieldOverrides({ data: [f0], // the frame fieldConfig: src as FieldConfigSource, // defaults + overrides - replaceVariables: undefined as any as InterpolateFunction, + replaceVariables: undefined as unknown as InterpolateFunction, theme: createTheme(), })[0]; const valueColumn = data.fields[1]; @@ -322,7 +322,7 @@ describe('applyFieldOverrides', () => { const data = applyFieldOverrides({ data: [f0], // the frame fieldConfig: src as FieldConfigSource, // defaults + overrides - replaceVariables: undefined as any as InterpolateFunction, + replaceVariables: undefined as unknown as InterpolateFunction, theme: createTheme(), })[0]; diff --git a/packages/grafana-runtime/src/utils/queryResponse.test.ts b/packages/grafana-runtime/src/utils/queryResponse.test.ts index 149c88526ac..f99fb5b2dc8 100644 --- a/packages/grafana-runtime/src/utils/queryResponse.test.ts +++ b/packages/grafana-runtime/src/utils/queryResponse.test.ts @@ -47,7 +47,7 @@ const resp = { }, }, }, -} as any as FetchResponse; +} as unknown as FetchResponse; const resWithError = { data: { @@ -75,7 +75,7 @@ const resWithError = { }, }, }, -} as any as FetchResponse; +} as unknown as FetchResponse; const emptyResults = { data: { results: { '': { refId: '' } } }, diff --git a/public/app/angular/promiseToDigest.test.ts b/public/app/angular/promiseToDigest.test.ts index 3bc81b36b31..8f312d62074 100644 --- a/public/app/angular/promiseToDigest.test.ts +++ b/public/app/angular/promiseToDigest.test.ts @@ -5,7 +5,7 @@ import { promiseToDigest } from './promiseToDigest'; describe('promiseToDigest', () => { describe('when called with a promise that resolves', () => { it('then evalAsync should be called on $scope', async () => { - const $scope: IScope = { $evalAsync: jest.fn() } as any as IScope; + const $scope = { $evalAsync: jest.fn() } as jest.MockedObject; await promiseToDigest($scope)(Promise.resolve(123)); @@ -15,7 +15,7 @@ describe('promiseToDigest', () => { describe('when called with a promise that rejects', () => { it('then evalAsync should be called on $scope', async () => { - const $scope: IScope = { $evalAsync: jest.fn() } as any as IScope; + const $scope = { $evalAsync: jest.fn() } as jest.MockedObject; try { await promiseToDigest($scope)(Promise.reject(123)); diff --git a/public/app/core/TableModel.ts b/public/app/core/TableModel.ts index 901345ce562..1ca95fce1fb 100644 --- a/public/app/core/TableModel.ts +++ b/public/app/core/TableModel.ts @@ -107,10 +107,10 @@ export function mergeTablesIntoModel(dst?: TableModel, ...tables: TableModel[]): const tableDataTables = tables.filter((table) => !!table.columns); // Track column indexes of union: name -> index - const columnNames: { [key: string]: any } = {}; + const columnNames: { [key: string]: number } = {}; // Union of all non-value columns - const columnsUnion = tableDataTables.slice().reduce((acc, series) => { + const columnsUnion = tableDataTables.slice().reduce((acc, series) => { series.columns.forEach((col) => { const { text } = col; if (columnNames[text] === undefined) { @@ -119,7 +119,7 @@ export function mergeTablesIntoModel(dst?: TableModel, ...tables: TableModel[]): } }); return acc; - }, [] as MutableColumn[]); + }, []); // Map old column index to union index per series, e.g., // given columnNames {A: 0, B: 1} and @@ -127,7 +127,7 @@ export function mergeTablesIntoModel(dst?: TableModel, ...tables: TableModel[]): const columnIndexMapper = tableDataTables.map((series) => series.columns.map((col) => columnNames[col.text])); // Flatten rows of all series and adjust new column indexes - const flattenedRows = tableDataTables.reduce((acc, series, seriesIndex) => { + const flattenedRows = tableDataTables.reduce((acc, series, seriesIndex) => { const mapper = columnIndexMapper[seriesIndex]; series.rows.forEach((row) => { const alteredRow: MutableColumn[] = []; @@ -138,12 +138,12 @@ export function mergeTablesIntoModel(dst?: TableModel, ...tables: TableModel[]): acc.push(alteredRow); }); return acc; - }, [] as MutableColumn[][]); + }, []); // Merge rows that have same values for columns const mergedRows: { [key: string]: any } = {}; - const compactedRows = flattenedRows.reduce((acc, row, rowIndex) => { + const compactedRows = flattenedRows.reduce((acc, row, rowIndex) => { if (!mergedRows[rowIndex]) { // Look from current row onwards let offset = rowIndex + 1; @@ -171,7 +171,7 @@ export function mergeTablesIntoModel(dst?: TableModel, ...tables: TableModel[]): acc.push(row); } return acc; - }, [] as MutableColumn[][]); + }, []); model.columns = columnsUnion; model.rows = compactedRows; diff --git a/public/app/core/components/ColorScale/ColorScale.tsx b/public/app/core/components/ColorScale/ColorScale.tsx index d46743207bf..0a689c8addd 100644 --- a/public/app/core/components/ColorScale/ColorScale.tsx +++ b/public/app/core/components/ColorScale/ColorScale.tsx @@ -36,7 +36,7 @@ export const ColorScale = ({ colorPalette, min, max, display, hoverValue, useSto const onScaleMouseMove = (event: React.MouseEvent) => { const divOffset = event.nativeEvent.offsetX; - const offsetWidth = (event.target as any).offsetWidth as number; + const offsetWidth = event.currentTarget.offsetWidth; const normPercentage = Math.floor((divOffset * 100) / offsetWidth + 1); const scaleValue = Math.floor(((max - min) * normPercentage) / 100 + min); diff --git a/public/app/core/components/Layers/LayerName.tsx b/public/app/core/components/Layers/LayerName.tsx index dbf1c42bb1b..c07adc15805 100644 --- a/public/app/core/components/Layers/LayerName.tsx +++ b/public/app/core/components/Layers/LayerName.tsx @@ -55,9 +55,9 @@ export const LayerName = ({ name, onChange, verifyLayerNameUniqueness }: LayerNa onEndEditName(event.currentTarget.value.trim()); }; - const onKeyDown = (event: React.KeyboardEvent) => { + const onKeyDown = (event: React.KeyboardEvent) => { if (event.key === 'Enter') { - onEndEditName((event.target as any).value); + onEndEditName(event.currentTarget.value); } }; diff --git a/public/app/core/components/Login/LoginPage.test.tsx b/public/app/core/components/Login/LoginPage.test.tsx index dbbf6ec4c9e..0cc29232eb0 100644 --- a/public/app/core/components/Login/LoginPage.test.tsx +++ b/public/app/core/components/Login/LoginPage.test.tsx @@ -86,7 +86,7 @@ describe('Login Page', () => { expect(window.location.assign).toHaveBeenCalledWith('/'); }); it('renders social logins correctly', () => { - (runtimeMock as any).config.oauth = { + runtimeMock.config.oauth = { okta: { name: 'Okta Test', icon: 'signin', diff --git a/public/app/core/components/OptionsUI/DashboardPicker.tsx b/public/app/core/components/OptionsUI/DashboardPicker.tsx index b360d68de24..62b2a41e0f0 100644 --- a/public/app/core/components/OptionsUI/DashboardPicker.tsx +++ b/public/app/core/components/OptionsUI/DashboardPicker.tsx @@ -8,7 +8,7 @@ export interface DashboardPickerOptions { isClearable?: boolean; } -type Props = StandardEditorProps; +type Props = StandardEditorProps; /** This will return the item UID */ export const DashboardPicker = ({ value, onChange, item }: Props) => { diff --git a/public/app/core/components/OptionsUI/DashboardPickerByID.tsx b/public/app/core/components/OptionsUI/DashboardPickerByID.tsx index 9d3c942b8d4..085dd1c7e0d 100644 --- a/public/app/core/components/OptionsUI/DashboardPickerByID.tsx +++ b/public/app/core/components/OptionsUI/DashboardPickerByID.tsx @@ -85,7 +85,7 @@ async function getDashboards( }); if (excludedDashboards) { - return dashboards.filter(({ value }) => !excludedDashboards.includes(value.uid as string)); + return dashboards.filter(({ value }) => !excludedDashboards.includes(value.uid)); } return dashboards; diff --git a/public/app/core/components/OptionsUI/fieldColor.tsx b/public/app/core/components/OptionsUI/fieldColor.tsx index 3b6bbdd4cd3..f6e8cad6b5d 100644 --- a/public/app/core/components/OptionsUI/fieldColor.tsx +++ b/public/app/core/components/OptionsUI/fieldColor.tsx @@ -49,7 +49,7 @@ export const FieldColorEditor: React.FC) => { onChange({ ...value, - mode: newMode.value! as FieldColorModeId, + mode: newMode.value!, }); }; diff --git a/public/app/core/history/RichHistoryRemoteStorage.test.ts b/public/app/core/history/RichHistoryRemoteStorage.test.ts index b091d33a621..e01781b9c3a 100644 --- a/public/app/core/history/RichHistoryRemoteStorage.test.ts +++ b/public/app/core/history/RichHistoryRemoteStorage.test.ts @@ -54,14 +54,14 @@ describe('RichHistoryRemoteStorage', () => { }); const setup = (): { richHistoryQuery: RichHistoryQuery; dto: RichHistoryRemoteStorageDTO } => { - const richHistoryQuery: RichHistoryQuery = { + const richHistoryQuery: RichHistoryQuery = { id: '123', createdAt: 200 * 1000, datasourceUid: 'ds1', datasourceName: 'name-of-ds1', starred: true, comment: 'comment', - queries: [{ foo: 'bar ' }], + queries: [{ refId: 'foo' }], }; const dto = { diff --git a/public/app/core/history/RichHistoryRemoteStorage.ts b/public/app/core/history/RichHistoryRemoteStorage.ts index f9467be1cd6..f839c6ad89f 100644 --- a/public/app/core/history/RichHistoryRemoteStorage.ts +++ b/public/app/core/history/RichHistoryRemoteStorage.ts @@ -73,7 +73,7 @@ export default class RichHistoryRemoteStorage implements RichHistoryStorage { const params = buildQueryParams(filters); const queryHistory = await lastValueFrom( - getBackendSrv().fetch({ + getBackendSrv().fetch({ method: 'GET', url: `/api/query-history?${params}`, // to ensure any previous requests are cancelled @@ -81,7 +81,7 @@ export default class RichHistoryRemoteStorage implements RichHistoryStorage { }) ); - const data = queryHistory.data as RichHistoryRemoteStorageResultsPayloadDTO; + const data = queryHistory.data; const richHistory = (data.result.queryHistory || []).map(fromDTO); const total = data.result.totalCount || 0; @@ -127,11 +127,12 @@ export default class RichHistoryRemoteStorage implements RichHistoryStorage { * @internal Used only for migration purposes. Will be removed in future. */ async migrate(richHistory: RichHistoryQuery[]) { + const data: RichHistoryRemoteStorageMigrationPayloadDTO = { queries: richHistory.map(toDTO) }; await lastValueFrom( getBackendSrv().fetch({ url: '/api/query-history/migrate', method: 'POST', - data: { queries: richHistory.map(toDTO) } as RichHistoryRemoteStorageMigrationPayloadDTO, + data, showSuccessAlert: false, }) ); diff --git a/public/app/core/navigation/hooks.ts b/public/app/core/navigation/hooks.ts index 566c5e3f50e..b03333d3fe9 100644 --- a/public/app/core/navigation/hooks.ts +++ b/public/app/core/navigation/hooks.ts @@ -2,14 +2,14 @@ import { useLocation } from 'react-router-dom'; import { locationService } from '@grafana/runtime'; -export type UseUrlParamsResult = [URLSearchParams, (params: Record, replace?: boolean) => void]; +export type UseUrlParamsResult = [URLSearchParams, (params: Record, replace?: boolean) => void]; /** @internal experimental */ export function useUrlParams(): UseUrlParamsResult { const location = useLocation(); const params = new URLSearchParams(location.search); - const updateUrlParams = (params: Record, replace?: boolean) => { + const updateUrlParams = (params: Record, replace?: boolean) => { // Should find a way to use history directly here locationService.partial(params, replace); }; diff --git a/public/app/core/navigation/queryString.ts b/public/app/core/navigation/queryString.ts deleted file mode 100644 index 9035df7894b..00000000000 --- a/public/app/core/navigation/queryString.ts +++ /dev/null @@ -1,10 +0,0 @@ -export const queryString = (params: any) => { - return Object.keys(params) - .filter((k) => { - return !!params[k]; - }) - .map((k) => { - return k + '=' + params[k]; - }) - .join('&'); -}; diff --git a/public/app/core/navigation/testRoutes.tsx b/public/app/core/navigation/testRoutes.tsx index 6a5dc26e442..82e5e5bec79 100644 --- a/public/app/core/navigation/testRoutes.tsx +++ b/public/app/core/navigation/testRoutes.tsx @@ -7,19 +7,16 @@ import { RouteDescriptor } from './types'; export const testRoutes: RouteDescriptor[] = [ { path: '/test1', - // eslint-disable-next-line react/display-name - component: () => - ( - <> -

Test1

- Test2 link - Test2 navlink - - ) as any, + component: () => ( + <> +

Test1

+ Test2 link + Test2 navlink + + ), }, { path: '/test2', - // eslint-disable-next-line react/display-name component: () => ( <>

Test2

@@ -30,7 +27,6 @@ export const testRoutes: RouteDescriptor[] = [ }, { path: '/router-debug', - // eslint-disable-next-line react/display-name - component: () => RouterDebugger, + component: RouterDebugger, }, ]; diff --git a/public/app/core/reducers/appNotification.ts b/public/app/core/reducers/appNotification.ts index f87c8d05712..346fa8a7cb5 100644 --- a/public/app/core/reducers/appNotification.ts +++ b/public/app/core/reducers/appNotification.ts @@ -75,13 +75,8 @@ function isAtLeastWarning(notif: AppNotification) { return notif.severity === AppNotificationSeverity.Warning || notif.severity === AppNotificationSeverity.Error; } -function isStoredNotification(obj: any): obj is StoredNotification { - return ( - typeof obj.id === 'string' && - typeof obj.icon === 'string' && - typeof obj.title === 'string' && - typeof obj.text === 'string' - ); +function isStoredNotification(obj: unknown): obj is StoredNotification { + return typeof obj === 'object' && obj !== null && 'id' in obj && 'icon' in obj && 'title' in obj && 'text' in obj; } // (De)serialization diff --git a/public/app/core/services/FetchQueue.ts b/public/app/core/services/FetchQueue.ts index 3ca6e50a920..d72b98d6143 100644 --- a/public/app/core/services/FetchQueue.ts +++ b/public/app/core/services/FetchQueue.ts @@ -81,11 +81,14 @@ export class FetchQueue { return; } - const entriesWithoutOptions = Object.keys(update.state).reduce((all, key) => { - const entry = { id: key, state: update.state[key].state }; - all.push(entry); - return all; - }, [] as Array<{ id: string; state: FetchStatus }>); + const entriesWithoutOptions = Object.keys(update.state).reduce>( + (all, key) => { + const entry = { id: key, state: update.state[key].state }; + all.push(entry); + return all; + }, + [] + ); console.log('FetchQueue noOfStarted', update.noOfInProgress); console.log('FetchQueue noOfNotStarted', update.noOfPending); diff --git a/public/app/core/services/FetchQueueWorker.ts b/public/app/core/services/FetchQueueWorker.ts index 72c3c210943..5a4c4794c49 100644 --- a/public/app/core/services/FetchQueueWorker.ts +++ b/public/app/core/services/FetchQueueWorker.ts @@ -28,19 +28,19 @@ export class FetchQueueWorker { concatMap(({ state, noOfInProgress }) => { const apiRequests = Object.keys(state) .filter((k) => state[k].state === FetchStatus.Pending && !isDataQuery(state[k].options.url)) - .reduce((all, key) => { + .reduce((all, key) => { const entry = { id: key, options: state[key].options }; all.push(entry); return all; - }, [] as WorkerEntry[]); + }, []); const dataRequests = Object.keys(state) .filter((key) => state[key].state === FetchStatus.Pending && isDataQuery(state[key].options.url)) - .reduce((all, key) => { + .reduce((all, key) => { const entry = { id: key, options: state[key].options }; all.push(entry); return all; - }, [] as WorkerEntry[]); + }, []); // apiRequests have precedence over data requests and should always be called directly // this means we can end up with a negative value. diff --git a/public/app/core/services/context_srv.ts b/public/app/core/services/context_srv.ts index 584be3f699f..490267661f3 100644 --- a/public/app/core/services/context_srv.ts +++ b/public/app/core/services/context_srv.ts @@ -60,9 +60,9 @@ export class ContextSrv { pinned: any; version: any; user: User; - isSignedIn: any; - isGrafanaAdmin: any; - isEditor: any; + isSignedIn: boolean; + isGrafanaAdmin: boolean; + isEditor: boolean; sidemenuSmallBreakpoint = false; hasEditPermissionInFolders: boolean; minRefreshInterval: string; diff --git a/public/app/core/services/echo/backends/analytics/ApplicationInsightsBackend.ts b/public/app/core/services/echo/backends/analytics/ApplicationInsightsBackend.ts index 3fae56b9b13..e822c65d9db 100644 --- a/public/app/core/services/echo/backends/analytics/ApplicationInsightsBackend.ts +++ b/public/app/core/services/echo/backends/analytics/ApplicationInsightsBackend.ts @@ -11,7 +11,7 @@ import { loadScript } from '../../utils'; interface ApplicationInsights { trackPageView: () => void; - trackEvent: (event: { name: string; properties?: Record }) => void; + trackEvent: (event: { name: string; properties?: Record }) => void; } declare global { diff --git a/public/app/core/services/echo/backends/sentry/transports/CustomEndpointTransport.test.ts b/public/app/core/services/echo/backends/sentry/transports/CustomEndpointTransport.test.ts index c38ff48c919..6428907219f 100644 --- a/public/app/core/services/echo/backends/sentry/transports/CustomEndpointTransport.test.ts +++ b/public/app/core/services/echo/backends/sentry/transports/CustomEndpointTransport.test.ts @@ -33,7 +33,7 @@ describe('CustomEndpointTransport', () => { }; it('will send received event to backend using window.fetch', async () => { - fetchSpy.mockResolvedValue({ status: 200 } as Response); + fetchSpy.mockResolvedValue({ status: 200 }); const transport = new CustomEndpointTransport({ endpoint: '/log' }); await transport.sendEvent(event); expect(fetchSpy).toHaveBeenCalledTimes(1); @@ -43,7 +43,7 @@ describe('CustomEndpointTransport', () => { expect(reqInit.headers).toEqual({ 'Content-Type': 'application/json', }); - expect(JSON.parse(reqInit.body as string)).toEqual({ + expect(JSON.parse(reqInit.body!.toString())).toEqual({ ...event, timestamp: now.toISOString(), }); @@ -55,9 +55,9 @@ describe('CustomEndpointTransport', () => { ok: false, headers: new Headers({ 'Retry-After': '1', // 1 second - }) as any as Headers, + }), } as Response; - fetchSpy.mockResolvedValueOnce(rateLimiterResponse).mockResolvedValueOnce({ status: 200 } as Response); + fetchSpy.mockResolvedValueOnce(rateLimiterResponse).mockResolvedValueOnce({ status: 200 }); const transport = new CustomEndpointTransport({ endpoint: '/log' }); // first call - backend is called, rejected because of 429 @@ -80,9 +80,9 @@ describe('CustomEndpointTransport', () => { ok: false, headers: new Headers({ 'Retry-After': '1', // 1 second - }) as any as Headers, + }), } as Response; - fetchSpy.mockResolvedValueOnce(rateLimiterResponse).mockResolvedValueOnce({ status: 200 } as Response); + fetchSpy.mockResolvedValueOnce(rateLimiterResponse).mockResolvedValueOnce({ status: 200 }); const transport = new CustomEndpointTransport({ endpoint: '/log' }); // first call - backend is called, rejected because of 429 diff --git a/public/app/core/services/echo/backends/sentry/transports/CustomEndpointTransport.ts b/public/app/core/services/echo/backends/sentry/transports/CustomEndpointTransport.ts index cf828758a8b..ea15b2622d6 100644 --- a/public/app/core/services/echo/backends/sentry/transports/CustomEndpointTransport.ts +++ b/public/app/core/services/echo/backends/sentry/transports/CustomEndpointTransport.ts @@ -84,7 +84,7 @@ export class CustomEndpointTransport implements BaseTransport { // https://caniuse.com/#feat=referrer-policy // It doesn't. And it throw exception instead of ignoring this parameter... // REF: https://github.com/getsentry/raven-js/issues/1233 - referrerPolicy: (supportsReferrerPolicy() ? 'origin' : '') as ReferrerPolicy, + referrerPolicy: supportsReferrerPolicy() ? 'origin' : '', }; if (this.options.fetchParameters !== undefined) { diff --git a/public/app/core/services/echo/backends/sentry/transports/EchoSrvTransport.ts b/public/app/core/services/echo/backends/sentry/transports/EchoSrvTransport.ts index 4d3db59eca7..a49c3219940 100644 --- a/public/app/core/services/echo/backends/sentry/transports/EchoSrvTransport.ts +++ b/public/app/core/services/echo/backends/sentry/transports/EchoSrvTransport.ts @@ -5,12 +5,15 @@ import { EventStatus, Request, Session, Response } from '@sentry/types'; import { getEchoSrv, EchoEventType } from '@grafana/runtime'; export class EchoSrvTransport extends BaseTransport { - sendEvent(event: Event) { + sendEvent(event: Event): Promise<{ status: EventStatus; event: Event }> { getEchoSrv().addEvent({ type: EchoEventType.Sentry, payload: event, }); - return Promise.resolve({ status: 'success' as EventStatus, event }); + return Promise.resolve({ + status: 'success', + event, + }); } // not recording sessions for now sendSession(session: Session): PromiseLike { diff --git a/public/app/core/specs/TableModel.test.ts b/public/app/core/specs/TableModel.test.ts index c374b1c8742..d6964d351ef 100644 --- a/public/app/core/specs/TableModel.test.ts +++ b/public/app/core/specs/TableModel.test.ts @@ -190,7 +190,7 @@ describe('mergeTables', () => { [12.12, time], [14.44, time + 1], ], - } as any as TableModel, + } as unknown as TableModel, ]; it('should return the single table as is', () => { diff --git a/public/app/core/specs/backend_srv.test.ts b/public/app/core/specs/backend_srv.test.ts index cdae54b0062..eab93722279 100644 --- a/public/app/core/specs/backend_srv.test.ts +++ b/public/app/core/specs/backend_srv.test.ts @@ -40,15 +40,15 @@ const getTestContext = (overides?: object) => { const appEventsMock: EventBusExtended = { emit: jest.fn(), publish: jest.fn(), - } as any as EventBusExtended; + } as jest.MockedObject; const user: User = { isSignedIn: props.isSignedIn, orgId: props.orgId, - } as any as User; + } as jest.MockedObject; const contextSrvMock: ContextSrv = { user, - } as any as ContextSrv; + } as jest.MockedObject; const logoutMock = jest.fn(); const parseRequestOptionsMock = jest.fn().mockImplementation((options) => options); @@ -61,14 +61,14 @@ const getTestContext = (overides?: object) => { backendSrv['parseRequestOptions'] = parseRequestOptionsMock; - const expectCallChain = (options: any) => { + const expectCallChain = () => { expect(fromFetchMock).toHaveBeenCalledTimes(1); }; const expectRequestCallChain = (options: any) => { expect(parseRequestOptionsMock).toHaveBeenCalledTimes(1); expect(parseRequestOptionsMock).toHaveBeenCalledWith(options); - expectCallChain(options); + expectCallChain(); }; return { diff --git a/public/app/core/utils/css_loader.ts b/public/app/core/utils/css_loader.ts deleted file mode 100644 index 31f34b91261..00000000000 --- a/public/app/core/utils/css_loader.ts +++ /dev/null @@ -1,77 +0,0 @@ -const waitSeconds = 100; -const head = document.getElementsByTagName('head')[0]; - -// get all link tags in the page -const links = document.getElementsByTagName('link'); -const linkHrefs: string[] = []; -for (let i = 0; i < links.length; i++) { - linkHrefs.push(links[i].href); -} - -const isWebkit = !!window.navigator.userAgent.match(/AppleWebKit\/([^ ;]*)/); -const webkitLoadCheck = (link: HTMLLinkElement, callback: Function) => { - setTimeout(() => { - for (let i = 0; i < document.styleSheets.length; i++) { - const sheet = document.styleSheets[i]; - if (sheet.href === link.href) { - return callback(); - } - } - webkitLoadCheck(link, callback); - }, 10); -}; - -const noop = () => {}; - -const loadCSS = (url: string) => { - return new Promise((resolve, reject) => { - const link = document.createElement('link'); - const timeout = setTimeout(() => { - reject('Unable to load CSS'); - }, waitSeconds * 1000); - - const _callback = (error: any) => { - clearTimeout(timeout); - link.onload = link.onerror = noop; - setTimeout(() => { - if (error) { - reject(error); - } else { - resolve(''); - } - }, 7); - }; - - link.type = 'text/css'; - link.rel = 'stylesheet'; - link.href = url; - - if (!isWebkit) { - link.onload = () => { - _callback(undefined); - }; - } else { - webkitLoadCheck(link, _callback); - } - - link.onerror = (evt: any) => { - _callback(evt.error || new Error('Error loading CSS file.')); - }; - - head.appendChild(link); - }); -}; - -export function fetch(load: any): any { - if (typeof window === 'undefined') { - return ''; - } - - // don't reload styles loaded in the head - for (let i = 0; i < linkHrefs.length; i++) { - if (load.address === linkHrefs[i]) { - return ''; - } - } - return loadCSS(load.address); -} diff --git a/public/app/core/utils/deferred.ts b/public/app/core/utils/deferred.ts index a9146ef6730..183a41e8309 100644 --- a/public/app/core/utils/deferred.ts +++ b/public/app/core/utils/deferred.ts @@ -1,4 +1,4 @@ -export class Deferred { +export class Deferred { resolve?: (reason: T | PromiseLike) => void; reject?: (reason?: any) => void; promise: Promise; diff --git a/public/app/core/utils/errors.ts b/public/app/core/utils/errors.ts index c9aa302d640..ff68f598021 100644 --- a/public/app/core/utils/errors.ts +++ b/public/app/core/utils/errors.ts @@ -13,5 +13,5 @@ export function getMessageFromError(err: string | (Error & { data?: any; statusT } } - return err as string; + return err; } diff --git a/public/app/core/utils/explore.test.ts b/public/app/core/utils/explore.test.ts index 49bccf92632..63e99705130 100644 --- a/public/app/core/utils/explore.test.ts +++ b/public/app/core/utils/explore.test.ts @@ -235,7 +235,7 @@ describe('hasNonEmptyQuery', () => { describe('hasRefId', () => { describe('when called with a null value', () => { it('then it should return undefined', () => { - const input: any = null; + const input = null; const result = getValueWithRefId(input); expect(result).toBeUndefined(); @@ -328,7 +328,7 @@ describe('getTimeRange', () => { describe('getRefIds', () => { describe('when called with a null value', () => { it('then it should return empty array', () => { - const input: any = null; + const input = null; const result = getRefIds(input); expect(result).toEqual([]); @@ -364,7 +364,7 @@ describe('getRefIds', () => { describe('when called with an object that has refIds somewhere in the object tree', () => { it('then it should return return an array with unique refIds', () => { - const input: any = { + const input = { data: [ 123, null, diff --git a/public/app/core/utils/model_utils.ts b/public/app/core/utils/model_utils.ts index dbcc2d2052d..d0e5a40e479 100644 --- a/public/app/core/utils/model_utils.ts +++ b/public/app/core/utils/model_utils.ts @@ -1,4 +1,9 @@ -export function assignModelProperties(target: any, source: any, defaults: any, removeDefaults?: undefined) { +export function assignModelProperties( + target: Record, + source: Record, + defaults: Record, + removeDefaults?: undefined +) { for (const key in defaults) { if (!defaults.hasOwnProperty(key)) { continue; diff --git a/public/app/features/alerting/getAlertingValidationMessage.test.ts b/public/app/features/alerting/getAlertingValidationMessage.test.ts index 3b62e2ea13f..b97bdb78e63 100644 --- a/public/app/features/alerting/getAlertingValidationMessage.test.ts +++ b/public/app/features/alerting/getAlertingValidationMessage.test.ts @@ -16,7 +16,7 @@ describe('getAlertingValidationMessage', () => { it('then it should return false', async () => { let call = 0; const datasource: DataSourceApi = { - meta: { alerting: true } as any as PluginMeta, + meta: { alerting: true } as unknown as PluginMeta, targetContainsTemplate: () => { if (call === 0) { call++; @@ -26,7 +26,7 @@ describe('getAlertingValidationMessage', () => { }, name: 'some name', uid: 'some uid', - } as any as DataSourceApi; + } as unknown as DataSourceApi; const getMock = jest.fn().mockResolvedValue(datasource); const datasourceSrv: DataSourceSrv = { get: (ref: DataSourceRef) => { @@ -57,15 +57,15 @@ describe('getAlertingValidationMessage', () => { describe('when called with some targets using a datasource that does not support alerting', () => { it('then it should return false', async () => { const alertingDatasource: DataSourceApi = { - meta: { alerting: true } as any as PluginMeta, + meta: { alerting: true } as unknown as PluginMeta, targetContainsTemplate: () => false, name: 'alertingDatasource', - } as any as DataSourceApi; + } as unknown as DataSourceApi; const datasource: DataSourceApi = { - meta: { alerting: false } as any as PluginMeta, + meta: { alerting: false } as unknown as PluginMeta, targetContainsTemplate: () => false, name: 'datasource', - } as any as DataSourceApi; + } as unknown as DataSourceApi; const datasourceSrv: DataSourceSrv = { get: (name: string) => { @@ -98,10 +98,10 @@ describe('getAlertingValidationMessage', () => { describe('when called with all targets containing template variables', () => { it('then it should return false', async () => { const datasource: DataSourceApi = { - meta: { alerting: true } as any as PluginMeta, + meta: { alerting: true } as unknown as PluginMeta, targetContainsTemplate: () => true, name: 'some name', - } as any as DataSourceApi; + } as unknown as DataSourceApi; const getMock = jest.fn().mockResolvedValue(datasource); const datasourceSrv: DataSourceSrv = { get: (ref: DataSourceRef) => { @@ -132,11 +132,11 @@ describe('getAlertingValidationMessage', () => { describe('when called with all targets using a datasource that does not support alerting', () => { it('then it should return false', async () => { const datasource: DataSourceApi = { - meta: { alerting: false } as any as PluginMeta, + meta: { alerting: false } as unknown as PluginMeta, targetContainsTemplate: () => false, name: 'some name', uid: 'theid', - } as any as DataSourceApi; + } as unknown as DataSourceApi; const getMock = jest.fn().mockResolvedValue(datasource); const datasourceSrv: DataSourceSrv = { get: (ref: DataSourceRef) => { @@ -167,10 +167,10 @@ describe('getAlertingValidationMessage', () => { describe('when called with transformations', () => { it('then it should return false', async () => { const datasource: DataSourceApi = { - meta: { alerting: true } as any as PluginMeta, + meta: { alerting: true } as unknown as PluginMeta, targetContainsTemplate: () => false, name: 'some name', - } as any as DataSourceApi; + } as unknown as DataSourceApi; const getMock = jest.fn().mockResolvedValue(datasource); const datasourceSrv: DataSourceSrv = { get: (ref: DataSourceRef) => { diff --git a/public/app/features/alerting/unified/mocks.ts b/public/app/features/alerting/unified/mocks.ts index 3fc57840d11..492a6841313 100644 --- a/public/app/features/alerting/unified/mocks.ts +++ b/public/app/features/alerting/unified/mocks.ts @@ -58,7 +58,7 @@ export function mockDataSource { const state = getState().explore[ExploreId.left]; expect(state.queryResponse.request?.requestId).toBe('explore_left'); - const datasource = state.datasourceInstance as any as DataSourceWithLogsVolumeSupport; + const datasource = state.datasourceInstance as unknown as DataSourceWithLogsVolumeSupport; expect(datasource.getLogsVolumeDataProvider).toBeCalledWith( expect.objectContaining({ requestId: 'explore_left_log_volume', diff --git a/public/app/features/live/data/StreamingDataFrame.test.ts b/public/app/features/live/data/StreamingDataFrame.test.ts index c9eb227df7f..984203ddaf1 100644 --- a/public/app/features/live/data/StreamingDataFrame.test.ts +++ b/public/app/features/live/data/StreamingDataFrame.test.ts @@ -663,7 +663,7 @@ describe('Streaming JSON', () => { expect(val).toEqual(200); expect(stream.length).toEqual(2); - const copy = { ...stream } as any as DataFrame; + const copy = { ...stream } as unknown as DataFrame; expect(copy.length).toEqual(2); }); diff --git a/public/app/features/logs/components/LogRowContextProvider.tsx b/public/app/features/logs/components/LogRowContextProvider.tsx index 89a37b9ce46..814ffb632d4 100644 --- a/public/app/features/logs/components/LogRowContextProvider.tsx +++ b/public/app/features/logs/components/LogRowContextProvider.tsx @@ -149,7 +149,7 @@ export const LogRowContextProvider: React.FunctionComponent(null as any as ResultType); + const [result, setResult] = useState(null as unknown as ResultType); // React Hook that creates an object state value called hasMoreContextRows to component state and a setter function called setHasMoreContextRows // The initial value for hasMoreContextRows is {before: true, after: true} diff --git a/public/app/features/playlist/PlaylistPage.tsx b/public/app/features/playlist/PlaylistPage.tsx index 5d7273b216a..b6c590cde2e 100644 --- a/public/app/features/playlist/PlaylistPage.tsx +++ b/public/app/features/playlist/PlaylistPage.tsx @@ -56,7 +56,7 @@ export const PlaylistPage = () => { {showSearch && ( )} diff --git a/public/app/features/search/components/ManageDashboardsNew.tsx b/public/app/features/search/components/ManageDashboardsNew.tsx index 381a8492c3a..73a19d061c0 100644 --- a/public/app/features/search/components/ManageDashboardsNew.tsx +++ b/public/app/features/search/components/ManageDashboardsNew.tsx @@ -70,7 +70,7 @@ export const ManageDashboardsNew = React.memo(({ folder }: Props) => { { setBackendSrv({ post: mockPost, -} as any as BackendSrv); +} as unknown as BackendSrv); const setup = () => { return render(); diff --git a/public/app/plugins/datasource/cloudwatch/__mocks__/monarch/Monaco.ts b/public/app/plugins/datasource/cloudwatch/__mocks__/monarch/Monaco.ts index 57e3325ea61..400c3303213 100644 --- a/public/app/plugins/datasource/cloudwatch/__mocks__/monarch/Monaco.ts +++ b/public/app/plugins/datasource/cloudwatch/__mocks__/monarch/Monaco.ts @@ -52,7 +52,7 @@ const MonacoMock: Monaco = { ); }, fromPositions: (start: monacoTypes.IPosition, end?: monacoTypes.IPosition) => { - return {} as any as monacoTypes.Range; + return {} as unknown as monacoTypes.Range; }, }, languages: { diff --git a/public/app/plugins/datasource/graphite/datasource_integration.test.ts b/public/app/plugins/datasource/graphite/datasource_integration.test.ts index f962383f441..59bef0fa98c 100644 --- a/public/app/plugins/datasource/graphite/datasource_integration.test.ts +++ b/public/app/plugins/datasource/graphite/datasource_integration.test.ts @@ -130,10 +130,10 @@ function mockBackendSrv(data: string) { const user: User = { isSignedIn: props.isSignedIn, orgId: props.orgId, - } as any as User; + } as unknown as User; const contextSrvMock: ContextSrv = { user, - } as any as ContextSrv; + } as unknown as ContextSrv; const logoutMock = jest.fn(); const mockedBackendSrv = new BackendSrv({ diff --git a/public/app/plugins/datasource/prometheus/datasource.test.ts b/public/app/plugins/datasource/prometheus/datasource.test.ts index a11001cecf0..3e1d0510d03 100644 --- a/public/app/plugins/datasource/prometheus/datasource.test.ts +++ b/public/app/plugins/datasource/prometheus/datasource.test.ts @@ -1784,7 +1784,7 @@ describe('PrometheusDatasource2', () => { targets: [targetA, targetB], interval: '1s', panelId: '', - } as any as DataQueryRequest; + } as unknown as DataQueryRequest; const Aexemplars = ds.shouldRunExemplarQuery(targetA, request); const BExpemplars = ds.shouldRunExemplarQuery(targetB, request); @@ -1938,7 +1938,7 @@ function getPrepareTargetsContext({ panelId, app, ...queryOptions, - } as any as DataQueryRequest; + } as unknown as DataQueryRequest; const ds = new PrometheusDatasource(instanceSettings, templateSrvStub as any, timeSrvStub as any); if (languageProvider) { diff --git a/public/app/plugins/datasource/prometheus/language_provider.test.ts b/public/app/plugins/datasource/prometheus/language_provider.test.ts index 152d05f47de..bdd2d4e4855 100644 --- a/public/app/plugins/datasource/prometheus/language_provider.test.ts +++ b/public/app/plugins/datasource/prometheus/language_provider.test.ts @@ -13,7 +13,7 @@ describe('Language completion provider', () => { metadataRequest: () => ({ data: { data: [] as any[] } }), getTimeRangeParams: () => ({ start: '0', end: '1' }), interpolateString: (string: string) => string, - } as any as PrometheusDatasource; + } as unknown as PrometheusDatasource; describe('cleanText', () => { const cleanText = new LanguageProvider(datasource).cleanText; @@ -304,7 +304,7 @@ describe('Language completion provider', () => { metadataRequest: () => ({ data: { data: [{ __name__: 'metric', bar: 'bazinga' }] as any[] } }), getTimeRangeParams: () => ({ start: '0', end: '1' }), interpolateString: (string: string) => string, - } as any as PrometheusDatasource; + } as unknown as PrometheusDatasource; const instance = new LanguageProvider(datasources); const value = Plain.deserialize('metric{}'); const ed = new SlateEditor({ value }); @@ -338,7 +338,7 @@ describe('Language completion provider', () => { }), getTimeRangeParams: () => ({ start: '0', end: '1' }), interpolateString: (string: string) => string, - } as any as PrometheusDatasource; + } as unknown as PrometheusDatasource; const instance = new LanguageProvider(datasource); const value = Plain.deserialize('{job1="foo",job2!="foo",job3=~"foo",__name__="metric",}'); const ed = new SlateEditor({ value }); @@ -361,7 +361,7 @@ describe('Language completion provider', () => { metadataRequest: () => { return { data: { data: ['value1', 'value2'] } }; }, - } as any as PrometheusDatasource); + } as unknown as PrometheusDatasource); const value = Plain.deserialize('{job!=}'); const ed = new SlateEditor({ value }); const valueWithSelection = ed.moveForward(6).value; @@ -403,7 +403,7 @@ describe('Language completion provider', () => { const instance = new LanguageProvider({ ...datasource, metadataRequest: () => simpleMetricLabelsResponse, - } as any as PrometheusDatasource); + } as unknown as PrometheusDatasource); const value = Plain.deserialize('metric{bar=ba}'); const ed = new SlateEditor({ value }); const valueWithSelection = ed.moveForward(13).value; @@ -424,7 +424,7 @@ describe('Language completion provider', () => { const instance = new LanguageProvider({ ...datasource, metadataRequest: () => simpleMetricLabelsResponse, - } as any as PrometheusDatasource); + } as unknown as PrometheusDatasource); const value = Plain.deserialize('sum(metric{foo="xx"}) by ()'); const ed = new SlateEditor({ value }); const valueWithSelection = ed.moveForward(26).value; @@ -444,7 +444,7 @@ describe('Language completion provider', () => { const instance = new LanguageProvider({ ...datasource, metadataRequest: () => simpleMetricLabelsResponse, - } as any as PrometheusDatasource); + } as unknown as PrometheusDatasource); const value = Plain.deserialize('sum(metric) by ()'); const ed = new SlateEditor({ value }); const valueWithSelection = ed.moveForward(16).value; @@ -464,7 +464,7 @@ describe('Language completion provider', () => { const instance = new LanguageProvider({ ...datasource, metadataRequest: () => simpleMetricLabelsResponse, - } as any as PrometheusDatasource); + } as unknown as PrometheusDatasource); const value = Plain.deserialize('sum(\nmetric\n)\nby ()'); const aggregationTextBlock = value.document.getBlocks().get(3); const ed = new SlateEditor({ value }); @@ -490,7 +490,7 @@ describe('Language completion provider', () => { const instance = new LanguageProvider({ ...datasource, metadataRequest: () => simpleMetricLabelsResponse, - } as any as PrometheusDatasource); + } as unknown as PrometheusDatasource); const value = Plain.deserialize('sum(rate(metric[1h])) by ()'); const ed = new SlateEditor({ value }); const valueWithSelection = ed.moveForward(26).value; @@ -514,7 +514,7 @@ describe('Language completion provider', () => { const instance = new LanguageProvider({ ...datasource, metadataRequest: () => simpleMetricLabelsResponse, - } as any as PrometheusDatasource); + } as unknown as PrometheusDatasource); const value = Plain.deserialize('sum(rate(metric{label1="value"}[1h])) by ()'); const ed = new SlateEditor({ value }); const valueWithSelection = ed.moveForward(42).value; @@ -553,7 +553,7 @@ describe('Language completion provider', () => { const instance = new LanguageProvider({ ...datasource, metadataRequest: () => simpleMetricLabelsResponse, - } as any as PrometheusDatasource); + } as unknown as PrometheusDatasource); const value = Plain.deserialize('sum by () (metric)'); const ed = new SlateEditor({ value }); const valueWithSelection = ed.moveForward(8).value; @@ -578,7 +578,7 @@ describe('Language completion provider', () => { metadataRequest: jest.fn(() => ({ data: { data: [] as any[] } })), getTimeRangeParams: jest.fn(() => ({ start: '0', end: '1' })), interpolateString: (string: string) => string, - } as any as PrometheusDatasource; + } as unknown as PrometheusDatasource; const mockedMetadataRequest = jest.mocked(datasource.metadataRequest); @@ -608,7 +608,7 @@ describe('Language completion provider', () => { metadataRequest: jest.fn(() => ({ data: { data: ['foo', 'bar'] as string[] } })), getTimeRangeParams: jest.fn(() => ({ start: '0', end: '1' })), lookupsDisabled: true, - } as any as PrometheusDatasource; + } as unknown as PrometheusDatasource; const mockedMetadataRequest = jest.mocked(datasource.metadataRequest); const instance = new LanguageProvider(datasource); const value = Plain.deserialize('{}'); @@ -634,7 +634,7 @@ describe('Language completion provider', () => { getTimeRangeParams: jest.fn(() => ({ start: '0', end: '1' })), lookupsDisabled: false, interpolateString: (string: string) => string, - } as any as PrometheusDatasource; + } as unknown as PrometheusDatasource; const mockedMetadataRequest = jest.mocked(datasource.metadataRequest); const instance = new LanguageProvider(datasource); diff --git a/public/app/plugins/datasource/prometheus/query_hints.ts b/public/app/plugins/datasource/prometheus/query_hints.ts index b635d625202..b895a25df64 100644 --- a/public/app/plugins/datasource/prometheus/query_hints.ts +++ b/public/app/plugins/datasource/prometheus/query_hints.ts @@ -110,7 +110,7 @@ export function getQueryHints(query: string, series?: any[], datasource?: Promet query, options: mappingForQuery, }, - } as any as QueryFix, + } as unknown as QueryFix, }); } } diff --git a/public/app/plugins/datasource/prometheus/querybuilder/shared/LabelFilterItem.tsx b/public/app/plugins/datasource/prometheus/querybuilder/shared/LabelFilterItem.tsx index 28ffec9c8dd..3ee215d3a66 100644 --- a/public/app/plugins/datasource/prometheus/querybuilder/shared/LabelFilterItem.tsx +++ b/public/app/plugins/datasource/prometheus/querybuilder/shared/LabelFilterItem.tsx @@ -81,7 +81,7 @@ export function LabelFilterItem({ ...item, op: item.op ?? defaultOp, label: change.label, - } as any as QueryBuilderLabelFilter); + } as unknown as QueryBuilderLabelFilter); } }} invalid={invalidLabel} @@ -94,7 +94,7 @@ export function LabelFilterItem({ width="auto" onChange={(change) => { if (change.value != null) { - onChange({ ...item, op: change.value } as any as QueryBuilderLabelFilter); + onChange({ ...item, op: change.value } as unknown as QueryBuilderLabelFilter); } }} /> @@ -124,14 +124,18 @@ export function LabelFilterItem({ options={getOptions()} onChange={(change) => { if (change.value) { - onChange({ ...item, value: change.value, op: item.op ?? defaultOp } as any as QueryBuilderLabelFilter); + onChange({ + ...item, + value: change.value, + op: item.op ?? defaultOp, + } as unknown as QueryBuilderLabelFilter); } else { const changes = change .map((change: any) => { return change.label; }) .join('|'); - onChange({ ...item, value: changes, op: item.op ?? defaultOp } as any as QueryBuilderLabelFilter); + onChange({ ...item, value: changes, op: item.op ?? defaultOp } as unknown as QueryBuilderLabelFilter); } }} invalid={invalidValue} diff --git a/public/app/plugins/panel/geomap/migrations.test.ts b/public/app/plugins/panel/geomap/migrations.test.ts index 9be13781f04..88d3da0df0a 100644 --- a/public/app/plugins/panel/geomap/migrations.test.ts +++ b/public/app/plugins/panel/geomap/migrations.test.ts @@ -138,7 +138,7 @@ describe('geomap migrations', () => { ], }, pluginVersion: '8.2.0', - } as any as PanelModel; + } as unknown as PanelModel; panel.options = mapMigrationHandler(panel); expect(panel).toMatchInlineSnapshot(` diff --git a/public/test/mocks/getGrafanaContextMock.ts b/public/test/mocks/getGrafanaContextMock.ts index 3dcc57704c7..d84e6c8e305 100644 --- a/public/test/mocks/getGrafanaContextMock.ts +++ b/public/test/mocks/getGrafanaContextMock.ts @@ -19,7 +19,7 @@ export function getGrafanaContextMock(overrides: Partial = { clearAndInitGlobalBindings: jest.fn(), setupDashboardBindings: jest.fn(), setupTimeRangeBindings: jest.fn(), - } as any as KeybindingSrv, + } as unknown as KeybindingSrv, ...overrides, }; }