Chore: more any/type assertion improvements (#57450)

* more friday any/type assertion improvements

* Apply suggestions from code review

Co-authored-by: Marcus Andersson <marcus.andersson@grafana.com>

* Update public/app/angular/promiseToDigest.test.ts

Co-authored-by: Marcus Andersson <marcus.andersson@grafana.com>

Co-authored-by: Marcus Andersson <marcus.andersson@grafana.com>
This commit is contained in:
Ashley Harrison 2022-10-25 10:04:35 +01:00 committed by GitHub
parent 8adbacb18e
commit d2a70bc42d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
47 changed files with 164 additions and 389 deletions

View File

@ -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"],

View File

@ -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];

View File

@ -47,7 +47,7 @@ const resp = {
},
},
},
} as any as FetchResponse<BackendDataSourceResponse>;
} as unknown as FetchResponse<BackendDataSourceResponse>;
const resWithError = {
data: {
@ -75,7 +75,7 @@ const resWithError = {
},
},
},
} as any as FetchResponse<BackendDataSourceResponse>;
} as unknown as FetchResponse<BackendDataSourceResponse>;
const emptyResults = {
data: { results: { '': { refId: '' } } },

View File

@ -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<IScope>;
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<IScope>;
try {
await promiseToDigest($scope)(Promise.reject(123));

View File

@ -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<MutableColumn[]>((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<MutableColumn[][]>((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<MutableColumn[][]>((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;

View File

@ -36,7 +36,7 @@ export const ColorScale = ({ colorPalette, min, max, display, hoverValue, useSto
const onScaleMouseMove = (event: React.MouseEvent<HTMLDivElement>) => {
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);

View File

@ -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<HTMLInputElement>) => {
if (event.key === 'Enter') {
onEndEditName((event.target as any).value);
onEndEditName(event.currentTarget.value);
}
};

View File

@ -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',

View File

@ -8,7 +8,7 @@ export interface DashboardPickerOptions {
isClearable?: boolean;
}
type Props = StandardEditorProps<string, DashboardPickerOptions, any>;
type Props = StandardEditorProps<string, DashboardPickerOptions>;
/** This will return the item UID */
export const DashboardPicker = ({ value, onChange, item }: Props) => {

View File

@ -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;

View File

@ -49,7 +49,7 @@ export const FieldColorEditor: React.FC<FieldConfigEditorProps<FieldColor | unde
const onModeChange = (newMode: SelectableValue<string>) => {
onChange({
...value,
mode: newMode.value! as FieldColorModeId,
mode: newMode.value!,
});
};

View File

@ -54,14 +54,14 @@ describe('RichHistoryRemoteStorage', () => {
});
const setup = (): { richHistoryQuery: RichHistoryQuery; dto: RichHistoryRemoteStorageDTO } => {
const richHistoryQuery: RichHistoryQuery<any> = {
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 = {

View File

@ -73,7 +73,7 @@ export default class RichHistoryRemoteStorage implements RichHistoryStorage {
const params = buildQueryParams(filters);
const queryHistory = await lastValueFrom(
getBackendSrv().fetch({
getBackendSrv().fetch<RichHistoryRemoteStorageResultsPayloadDTO>({
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,
})
);

View File

@ -2,14 +2,14 @@ import { useLocation } from 'react-router-dom';
import { locationService } from '@grafana/runtime';
export type UseUrlParamsResult = [URLSearchParams, (params: Record<string, any>, replace?: boolean) => void];
export type UseUrlParamsResult = [URLSearchParams, (params: Record<string, unknown>, replace?: boolean) => void];
/** @internal experimental */
export function useUrlParams(): UseUrlParamsResult {
const location = useLocation();
const params = new URLSearchParams(location.search);
const updateUrlParams = (params: Record<string, any>, replace?: boolean) => {
const updateUrlParams = (params: Record<string, unknown>, replace?: boolean) => {
// Should find a way to use history directly here
locationService.partial(params, replace);
};

View File

@ -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('&');
};

View File

@ -7,19 +7,16 @@ import { RouteDescriptor } from './types';
export const testRoutes: RouteDescriptor[] = [
{
path: '/test1',
// eslint-disable-next-line react/display-name
component: () =>
(
<>
<h1>Test1</h1>
<Link to={'/test2'}>Test2 link</Link>
<NavLink to={'/test2'}>Test2 navlink</NavLink>
</>
) as any,
component: () => (
<>
<h1>Test1</h1>
<Link to={'/test2'}>Test2 link</Link>
<NavLink to={'/test2'}>Test2 navlink</NavLink>
</>
),
},
{
path: '/test2',
// eslint-disable-next-line react/display-name
component: () => (
<>
<h1>Test2 </h1>
@ -30,7 +27,6 @@ export const testRoutes: RouteDescriptor[] = [
},
{
path: '/router-debug',
// eslint-disable-next-line react/display-name
component: () => RouterDebugger,
component: RouterDebugger,
},
];

View File

@ -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

View File

@ -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<Array<{ id: string; state: FetchStatus }>>(
(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);

View File

@ -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<WorkerEntry[]>((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<WorkerEntry[]>((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.

View File

@ -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;

View File

@ -11,7 +11,7 @@ import { loadScript } from '../../utils';
interface ApplicationInsights {
trackPageView: () => void;
trackEvent: (event: { name: string; properties?: Record<string, any> }) => void;
trackEvent: (event: { name: string; properties?: Record<string, unknown> }) => void;
}
declare global {

View File

@ -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

View File

@ -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) {

View File

@ -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<Response> {

View File

@ -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', () => {

View File

@ -40,15 +40,15 @@ const getTestContext = (overides?: object) => {
const appEventsMock: EventBusExtended = {
emit: jest.fn(),
publish: jest.fn(),
} as any as EventBusExtended;
} as jest.MockedObject<EventBusExtended>;
const user: User = {
isSignedIn: props.isSignedIn,
orgId: props.orgId,
} as any as User;
} as jest.MockedObject<User>;
const contextSrvMock: ContextSrv = {
user,
} as any as ContextSrv;
} as jest.MockedObject<ContextSrv>;
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 {

View File

@ -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);
}

View File

@ -1,4 +1,4 @@
export class Deferred<T = any> {
export class Deferred<T = unknown> {
resolve?: (reason: T | PromiseLike<T>) => void;
reject?: (reason?: any) => void;
promise: Promise<T>;

View File

@ -13,5 +13,5 @@ export function getMessageFromError(err: string | (Error & { data?: any; statusT
}
}
return err as string;
return err;
}

View File

@ -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,

View File

@ -1,4 +1,9 @@
export function assignModelProperties(target: any, source: any, defaults: any, removeDefaults?: undefined) {
export function assignModelProperties(
target: Record<string, unknown>,
source: Record<string, unknown>,
defaults: Record<string, unknown>,
removeDefaults?: undefined
) {
for (const key in defaults) {
if (!defaults.hasOwnProperty(key)) {
continue;

View File

@ -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) => {

View File

@ -58,7 +58,7 @@ export function mockDataSource<T extends DataSourceJsonData = DataSourceJsonData
},
},
...meta,
} as any as DataSourcePluginMeta,
} as unknown as DataSourcePluginMeta,
readOnly: false,
...partial,
};

View File

@ -124,7 +124,7 @@ describe('runQueries', () => {
const state = getState().explore[ExploreId.left];
expect(state.queryResponse.request?.requestId).toBe('explore_left');
const datasource = state.datasourceInstance as any as DataSourceWithLogsVolumeSupport<DataQuery>;
const datasource = state.datasourceInstance as unknown as DataSourceWithLogsVolumeSupport<DataQuery>;
expect(datasource.getLogsVolumeDataProvider).toBeCalledWith(
expect.objectContaining({
requestId: 'explore_left_log_volume',

View File

@ -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);
});

View File

@ -149,7 +149,7 @@ export const LogRowContextProvider: React.FunctionComponent<LogRowContextProvide
// React Hook that creates an object state value called result to component state and a setter function called setResult
// The initial value for result is null
// Used for sorting the response from backend
const [result, setResult] = useState<ResultType>(null as any as ResultType);
const [result, setResult] = useState<ResultType>(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}

View File

@ -56,7 +56,7 @@ export const PlaylistPage = () => {
{showSearch && (
<PageActionBar
searchQuery={searchQuery}
linkButton={contextSrv.isEditor && { title: 'New playlist', href: '/playlists/new' }}
linkButton={contextSrv.isEditor ? { title: 'New playlist', href: '/playlists/new' } : undefined}
setSearchQuery={setSearchQuery}
/>
)}

View File

@ -70,7 +70,7 @@ export const ManageDashboardsNew = React.memo(({ folder }: Props) => {
</div>
<SearchView
showManage={isEditor || hasEditPermissionInFolders || canSave}
showManage={Boolean(isEditor || hasEditPermissionInFolders || canSave)}
folderDTO={folder}
hidePseudoFolders={true}
includePanels={includePanels!}

View File

@ -29,7 +29,7 @@ const mockPost = jest.fn(() => {
setBackendSrv({
post: mockPost,
} as any as BackendSrv);
} as unknown as BackendSrv);
const setup = () => {
return render(<CreateTeam />);

View File

@ -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: {

View File

@ -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({

View File

@ -1784,7 +1784,7 @@ describe('PrometheusDatasource2', () => {
targets: [targetA, targetB],
interval: '1s',
panelId: '',
} as any as DataQueryRequest<PromQuery>;
} as unknown as DataQueryRequest<PromQuery>;
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<PromQuery>;
} as unknown as DataQueryRequest<PromQuery>;
const ds = new PrometheusDatasource(instanceSettings, templateSrvStub as any, timeSrvStub as any);
if (languageProvider) {

View File

@ -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);

View File

@ -110,7 +110,7 @@ export function getQueryHints(query: string, series?: any[], datasource?: Promet
query,
options: mappingForQuery,
},
} as any as QueryFix,
} as unknown as QueryFix,
});
}
}

View File

@ -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}

View File

@ -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(`

View File

@ -19,7 +19,7 @@ export function getGrafanaContextMock(overrides: Partial<GrafanaContextType> = {
clearAndInitGlobalBindings: jest.fn(),
setupDashboardBindings: jest.fn(),
setupTimeRangeBindings: jest.fn(),
} as any as KeybindingSrv,
} as unknown as KeybindingSrv,
...overrides,
};
}