diff --git a/.betterer.results b/.betterer.results index 140a1f0af24..0f0c8c76b2b 100644 --- a/.betterer.results +++ b/.betterer.results @@ -5958,16 +5958,16 @@ 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, "Do not use any type assertions.", "3"], [0, 0, 0, "Do not use any type assertions.", "4"], - [0, 0, 0, "Do not use any type assertions.", "5"], + [0, 0, 0, "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, "Do not use any type assertions.", "10"], [0, 0, 0, "Do not use any type assertions.", "11"], - [0, 0, 0, "Do not use any type assertions.", "12"], + [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"], @@ -6009,15 +6009,7 @@ exports[`better eslint`] = { [0, 0, 0, "Unexpected any. Specify a different type.", "51"], [0, 0, 0, "Unexpected any. Specify a different type.", "52"], [0, 0, 0, "Unexpected any. Specify a different type.", "53"], - [0, 0, 0, "Unexpected any. Specify a different type.", "54"], - [0, 0, 0, "Unexpected any. Specify a different type.", "55"], - [0, 0, 0, "Unexpected any. Specify a different type.", "56"], - [0, 0, 0, "Unexpected any. Specify a different type.", "57"], - [0, 0, 0, "Unexpected any. Specify a different type.", "58"], - [0, 0, 0, "Unexpected any. Specify a different type.", "59"], - [0, 0, 0, "Unexpected any. Specify a different type.", "60"], - [0, 0, 0, "Unexpected any. Specify a different type.", "61"], - [0, 0, 0, "Unexpected any. Specify a different type.", "62"] + [0, 0, 0, "Unexpected any. Specify a different type.", "54"] ], "public/app/plugins/datasource/graphite/gfunc.ts:5381": [ [0, 0, 0, "Unexpected any. Specify a different type.", "0"], @@ -6030,11 +6022,7 @@ exports[`better eslint`] = { [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.", "10"] ], "public/app/plugins/datasource/graphite/graphite_query.ts:5381": [ [0, 0, 0, "Unexpected any. Specify a different type.", "0"], @@ -6052,15 +6040,11 @@ exports[`better eslint`] = { [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, "Do not use any type assertions.", "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.", "18"], - [0, 0, 0, "Do not use any type assertions.", "19"], - [0, 0, 0, "Unexpected any. Specify a different type.", "20"], - [0, 0, 0, "Unexpected any. Specify a different type.", "21"], - [0, 0, 0, "Unexpected any. Specify a different type.", "22"], - [0, 0, 0, "Unexpected any. Specify a different type.", "23"] + [0, 0, 0, "Unexpected any. Specify a different type.", "19"] ], "public/app/plugins/datasource/graphite/lexer.ts:5381": [ [0, 0, 0, "Unexpected any. Specify a different type.", "0"], @@ -6074,11 +6058,6 @@ exports[`better eslint`] = { "public/app/plugins/datasource/graphite/migrations.ts:5381": [ [0, 0, 0, "Unexpected any. Specify a different type.", "0"] ], - "public/app/plugins/datasource/graphite/parser.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/plugins/datasource/graphite/specs/graphite_query.test.ts:5381": [ [0, 0, 0, "Unexpected any. Specify a different type.", "0"] ], @@ -6095,17 +6074,14 @@ exports[`better eslint`] = { ], "public/app/plugins/datasource/graphite/state/store.ts:5381": [ [0, 0, 0, "Do not use any type assertions.", "0"], - [0, 0, 0, "Do not use any type assertions.", "1"], - [0, 0, 0, "Do not use any type assertions.", "2"], - [0, 0, 0, "Do not use any type assertions.", "3"] + [0, 0, 0, "Do not use any type assertions.", "1"] ], "public/app/plugins/datasource/graphite/types.ts:5381": [ [0, 0, 0, "Unexpected any. Specify a different type.", "0"], [0, 0, 0, "Unexpected any. Specify a different type.", "1"] ], "public/app/plugins/datasource/graphite/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.", "0"] ], "public/app/plugins/datasource/influxdb/components/editor/config/ConfigEditor.tsx:5381": [ [0, 0, 0, "Do not use any type assertions.", "0"] @@ -6138,9 +6114,7 @@ exports[`better eslint`] = { [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, "Do not use any type assertions.", "17"] + [0, 0, 0, "Do not use any type assertions.", "15"] ], "public/app/plugins/datasource/influxdb/influx_query_model.ts:5381": [ [0, 0, 0, "Unexpected any. Specify a different type.", "0"], @@ -6155,14 +6129,7 @@ exports[`better eslint`] = { [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.", "18"], - [0, 0, 0, "Unexpected any. Specify a different type.", "19"] + [0, 0, 0, "Unexpected any. Specify a different type.", "12"] ], "public/app/plugins/datasource/influxdb/influx_series.ts:5381": [ [0, 0, 0, "Unexpected any. Specify a different type.", "0"], @@ -6210,8 +6177,7 @@ exports[`better eslint`] = { [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.", "15"] ], "public/app/plugins/datasource/influxdb/response_parser.ts:5381": [ [0, 0, 0, "Unexpected any. Specify a different type.", "0"], @@ -6232,14 +6198,8 @@ exports[`better eslint`] = { [0, 0, 0, "Styles should be written using objects.", "1"] ], "public/app/plugins/datasource/jaeger/datasource.ts:5381": [ - [0, 0, 0, "Unexpected any. Specify a different type.", "0"], - [0, 0, 0, "Unexpected any. Specify a different type.", "1"], - [0, 0, 0, "Do not use any type assertions.", "2"], - [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, "Do not use any type assertions.", "0"], + [0, 0, 0, "Unexpected any. Specify a different type.", "1"] ], "public/app/plugins/datasource/jaeger/testResponse.ts:5381": [ [0, 0, 0, "Unexpected any. Specify a different type.", "0"], @@ -6248,13 +6208,9 @@ exports[`better eslint`] = { "public/app/plugins/datasource/jaeger/types.ts:5381": [ [0, 0, 0, "Unexpected any. Specify a different type.", "0"] ], - "public/app/plugins/datasource/jaeger/util.ts:5381": [ - [0, 0, 0, "Unexpected any. Specify a different type.", "0"] - ], "public/app/plugins/datasource/loki/LanguageProvider.ts:5381": [ [0, 0, 0, "Unexpected any. Specify a different type.", "0"], - [0, 0, 0, "Unexpected any. Specify a different type.", "1"], - [0, 0, 0, "Unexpected any. Specify a different type.", "2"] + [0, 0, 0, "Unexpected any. Specify a different type.", "1"] ], "public/app/plugins/datasource/loki/LiveStreams.ts:5381": [ [0, 0, 0, "Unexpected any. Specify a different type.", "0"] @@ -6364,8 +6320,7 @@ exports[`better eslint`] = { ], "public/app/plugins/datasource/loki/streaming.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, "Unexpected any. Specify a different type.", "1"] ], "public/app/plugins/datasource/opentsdb/components/OpenTsdbQueryEditor.tsx:5381": [ [0, 0, 0, "Styles should be written using objects.", "0"], @@ -6458,8 +6413,7 @@ exports[`better eslint`] = { [0, 0, 0, "Unexpected any. Specify a different type.", "0"] ], "public/app/plugins/datasource/prometheus/components/PromQueryField.tsx:5381": [ - [0, 0, 0, "Unexpected any. Specify a different type.", "0"], - [0, 0, 0, "Unexpected any. Specify a different type.", "1"] + [0, 0, 0, "Unexpected any. Specify a different type.", "0"] ], "public/app/plugins/datasource/prometheus/components/PrometheusMetricsBrowser.tsx:5381": [ [0, 0, 0, "Styles should be written using objects.", "0"], @@ -6473,9 +6427,7 @@ exports[`better eslint`] = { [0, 0, 0, "Styles should be written using objects.", "8"], [0, 0, 0, "Styles should be written using objects.", "9"], [0, 0, 0, "Styles should be written using objects.", "10"], - [0, 0, 0, "Styles should be written using objects.", "11"], - [0, 0, 0, "Do not use any type assertions.", "12"], - [0, 0, 0, "Do not use any type assertions.", "13"] + [0, 0, 0, "Styles should be written using objects.", "11"] ], "public/app/plugins/datasource/prometheus/components/monaco-query-field/MonacoQueryField.tsx:5381": [ [0, 0, 0, "Styles should be written using objects.", "0"], @@ -6532,9 +6484,6 @@ exports[`better eslint`] = { [0, 0, 0, "Use data-testid for E2E selectors instead of aria-label", "0"], [0, 0, 0, "Styles should be written using objects.", "1"] ], - "public/app/plugins/datasource/prometheus/configuration/PromSettings.tsx:5381": [ - [0, 0, 0, "Do not use any type assertions.", "0"] - ], "public/app/plugins/datasource/prometheus/datasource.test.ts:5381": [ [0, 0, 0, "Unexpected any. Specify a different type.", "0"], [0, 0, 0, "Unexpected any. Specify a different type.", "1"], @@ -6561,7 +6510,7 @@ exports[`better eslint`] = { [0, 0, 0, "Unexpected any. Specify a different type.", "8"], [0, 0, 0, "Unexpected any. Specify a different type.", "9"], [0, 0, 0, "Unexpected any. Specify a different type.", "10"], - [0, 0, 0, "Do not use any type assertions.", "11"], + [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"], @@ -6569,16 +6518,7 @@ exports[`better eslint`] = { [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.", "18"], - [0, 0, 0, "Unexpected any. Specify a different type.", "19"], - [0, 0, 0, "Unexpected any. Specify a different type.", "20"], - [0, 0, 0, "Unexpected any. Specify a different type.", "21"], - [0, 0, 0, "Unexpected any. Specify a different type.", "22"], - [0, 0, 0, "Unexpected any. Specify a different type.", "23"], - [0, 0, 0, "Unexpected any. Specify a different type.", "24"], - [0, 0, 0, "Unexpected any. Specify a different type.", "25"], - [0, 0, 0, "Unexpected any. Specify a different type.", "26"], - [0, 0, 0, "Unexpected any. Specify a different type.", "27"], - [0, 0, 0, "Unexpected any. Specify a different type.", "28"] + [0, 0, 0, "Unexpected any. Specify a different type.", "19"] ], "public/app/plugins/datasource/prometheus/language_provider.ts:5381": [ [0, 0, 0, "Unexpected any. Specify a different type.", "0"], @@ -6855,17 +6795,13 @@ exports[`better eslint`] = { [0, 0, 0, "Do not use any type assertions.", "3"], [0, 0, 0, "Do not use any type assertions.", "4"], [0, 0, 0, "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, "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, "Do not use any type assertions.", "9"], - [0, 0, 0, "Do not use any type assertions.", "10"], - [0, 0, 0, "Do not use any type assertions.", "11"], - [0, 0, 0, "Do not use any type assertions.", "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.", "10"], + [0, 0, 0, "Unexpected any. Specify a different type.", "11"], + [0, 0, 0, "Unexpected any. Specify a different type.", "12"] ], "public/app/plugins/datasource/tempo/language_provider.ts:5381": [ [0, 0, 0, "Unexpected any. Specify a different type.", "0"] @@ -7111,9 +7047,6 @@ exports[`better eslint`] = { [0, 0, 0, "Unexpected any. Specify a different type.", "0"], [0, 0, 0, "Do not use any type assertions.", "1"] ], - "public/app/plugins/panel/geomap/utils/selection.ts:5381": [ - [0, 0, 0, "Unexpected any. Specify a different type.", "0"] - ], "public/app/plugins/panel/geomap/utils/tooltip.ts:5381": [ [0, 0, 0, "Do not use any type assertions.", "0"] ], @@ -7196,11 +7129,9 @@ exports[`better eslint`] = { [0, 0, 0, "Do not use any type assertions.", "16"] ], "public/app/plugins/panel/histogram/Histogram.tsx:5381": [ - [0, 0, 0, "Unexpected any. Specify a different type.", "0"], - [0, 0, 0, "Unexpected any. Specify a different type.", "1"], - [0, 0, 0, "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.", "0"], + [0, 0, 0, "Do not use any type assertions.", "1"], + [0, 0, 0, "Unexpected any. Specify a different type.", "2"] ], "public/app/plugins/panel/live/LiveChannelEditor.tsx:5381": [ [0, 0, 0, "Unexpected any. Specify a different type.", "0"], @@ -7296,9 +7227,7 @@ exports[`better eslint`] = { ], "public/app/plugins/panel/nodeGraph/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"], - [0, 0, 0, "Unexpected any. Specify a different type.", "3"] + [0, 0, 0, "Unexpected any. Specify a different type.", "1"] ], "public/app/plugins/panel/piechart/PieChart.tsx:5381": [ [0, 0, 0, "Use data-testid for E2E selectors instead of aria-label", "0"], @@ -7644,20 +7573,10 @@ exports[`better eslint`] = { [0, 0, 0, "Unexpected any. Specify a different type.", "0"], [0, 0, 0, "Do not use any type assertions.", "1"] ], - "public/app/types/templates.ts:5381": [ - [0, 0, 0, "Unexpected any. Specify a different type.", "0"] - ], "public/app/types/unified-alerting-dto.ts:5381": [ [0, 0, 0, "Do not use any type assertions.", "0"], [0, 0, 0, "Do not use any type assertions.", "1"] ], - "public/test/core/redux/mocks.ts:5381": [ - [0, 0, 0, "Unexpected any. Specify a different type.", "0"] - ], - "public/test/core/redux/reducerTester.ts:5381": [ - [0, 0, 0, "Unexpected any. Specify a different type.", "0"], - [0, 0, 0, "Unexpected any. Specify a different type.", "1"] - ], "public/test/core/redux/reduxTester.ts:5381": [ [0, 0, 0, "Unexpected any. Specify a different type.", "0"], [0, 0, 0, "Unexpected any. Specify a different type.", "1"], @@ -7674,15 +7593,11 @@ 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/test/global-jquery-shim.ts:5381": [ [0, 0, 0, "Unexpected any. Specify a different type.", "0"] ], - "public/test/helpers/convertToStoreState.ts:5381": [ - [0, 0, 0, "Unexpected any. Specify a different type.", "0"] - ], "public/test/helpers/getDashboardModel.ts:5381": [ [0, 0, 0, "Unexpected any. Specify a different type.", "0"] ], @@ -7695,20 +7610,11 @@ exports[`better eslint`] = { "public/test/lib/common.ts:5381": [ [0, 0, 0, "Unexpected any. Specify a different type.", "0"] ], - "public/test/matchers/index.ts:5381": [ - [0, 0, 0, "Unexpected any. Specify a different type.", "0"] - ], "public/test/matchers/toEmitValuesWith.ts:5381": [ [0, 0, 0, "Unexpected any. Specify a different type.", "0"], [0, 0, 0, "Unexpected any. Specify a different type.", "1"], [0, 0, 0, "Unexpected any. Specify a different type.", "2"] ], - "public/test/matchers/utils.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"] - ], "public/test/specs/helpers.ts:5381": [ [0, 0, 0, "Unexpected any. Specify a different type.", "0"], [0, 0, 0, "Unexpected any. Specify a different type.", "1"], @@ -7723,9 +7629,7 @@ exports[`better eslint`] = { [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.", "13"] ] }` }; diff --git a/public/app/plugins/datasource/graphite/datasource.ts b/public/app/plugins/datasource/graphite/datasource.ts index 2577d402e2f..e99e02b85d5 100644 --- a/public/app/plugins/datasource/graphite/datasource.ts +++ b/public/app/plugins/datasource/graphite/datasource.ts @@ -28,7 +28,7 @@ import { getRollupNotice, getRuntimeConsolidationNotice } from 'app/plugins/data import { AnnotationEditor } from './components/AnnotationsEditor'; import { convertToGraphiteQueryObject } from './components/helpers'; -import gfunc, { FuncDefs, FuncInstance } from './gfunc'; +import gfunc, { FuncDef, FuncDefs, FuncInstance } from './gfunc'; import GraphiteQueryModel from './graphite_query'; import { prepareAnnotation } from './migrations'; // Types @@ -78,7 +78,7 @@ export class GraphiteDatasource cacheTimeout: any; withCredentials: boolean; funcDefs: FuncDefs | null = null; - funcDefsPromise: Promise | null = null; + funcDefsPromise: Promise | null = null; _seriesRefLetters: string; requestCounter = 100; private readonly metricMappings: GraphiteLokiMapping[]; @@ -371,7 +371,7 @@ export class GraphiteDatasource return lastValueFrom( this.query(graphiteQuery).pipe( - map((result: any) => { + map((result) => { const list = []; for (let i = 0; i < result.data.length; i++) { @@ -400,7 +400,7 @@ export class GraphiteDatasource } else { // Graphite event/tag as annotation const tags = this.templateSrv.replace(target.tags?.join(' ')); - return this.events({ range: range, tags: tags }).then((results: any) => { + return this.events({ range: range, tags: tags }).then((results) => { const list = []; if (!isArray(results.data)) { console.error(`Unable to get annotations from ${results.url}.`); @@ -827,7 +827,7 @@ export class GraphiteDatasource ); } - createFuncInstance(funcDef: any, options?: any): FuncInstance { + createFuncInstance(funcDef: string | FuncDef, options?: any): FuncInstance { return gfunc.createFuncInstance(funcDef, options, this.funcDefs); } @@ -870,7 +870,7 @@ export class GraphiteDatasource this.funcDefs = gfunc.parseFuncDefs(fixedData); return this.funcDefs; }), - catchError((error: any) => { + catchError((error) => { console.error('Fetching graphite functions error', error); this.funcDefs = gfunc.getFuncDefs(this.graphiteVersion); return of(this.funcDefs); @@ -924,7 +924,7 @@ export class GraphiteDatasource return getBackendSrv() .fetch(options) .pipe( - catchError((err: any) => { + catchError((err) => { return throwError(reduceError(err)); }) ); @@ -941,7 +941,7 @@ export class GraphiteDatasource options['format'] = 'json'; - function fixIntervalFormat(match: any) { + function fixIntervalFormat(match: string) { return match.replace('m', 'min').replace('M', 'mon'); } @@ -1007,7 +1007,7 @@ function supportsFunctionIndex(version: string): boolean { function mapToTags(): OperatorFunction> { return pipe( - map((results: any) => { + map((results) => { if (results.data) { return _map(results.data, (value) => { return { text: value }; diff --git a/public/app/plugins/datasource/graphite/gfunc.ts b/public/app/plugins/datasource/graphite/gfunc.ts index ffec5cfa703..a8bc886e3e4 100644 --- a/public/app/plugins/datasource/graphite/gfunc.ts +++ b/public/app/plugins/datasource/graphite/gfunc.ts @@ -1061,7 +1061,7 @@ export class FuncInstance { return str + parameters.join(', ') + ')'; } - _hasMultipleParamsInString(strValue: any, index: number) { + _hasMultipleParamsInString(strValue: string, index: number) { if (strValue.indexOf(',') === -1) { return false; } @@ -1077,7 +1077,7 @@ export class FuncInstance { return false; } - updateParam(strValue: any, index: any) { + updateParam(strValue: string, index: number) { // handle optional parameters // if string contains ',' and next param is optional, split and update both if (this._hasMultipleParamsInString(strValue, index)) { @@ -1109,7 +1109,7 @@ export class FuncInstance { } } -function createFuncInstance(funcDef: any, options?: { withDefaultParams: any }, idx?: any): FuncInstance { +function createFuncInstance(funcDef: FuncDef | string, options?: { withDefaultParams: any }, idx?: any): FuncInstance { if (isString(funcDef)) { funcDef = getFuncDef(funcDef, idx); } diff --git a/public/app/plugins/datasource/graphite/graphite_query.ts b/public/app/plugins/datasource/graphite/graphite_query.ts index c8e7254b78c..fbf5f9bf32f 100644 --- a/public/app/plugins/datasource/graphite/graphite_query.ts +++ b/public/app/plugins/datasource/graphite/graphite_query.ts @@ -159,11 +159,11 @@ export default class GraphiteQuery { this.segments.push({ value: 'select metric' }); } - addFunction(newFunc: any) { + addFunction(newFunc: FuncInstance) { this.functions.push(newFunc); } - addFunctionParameter(func: any, value: string) { + addFunctionParameter(func: FuncInstance, value: string) { if (func.params.length >= func.def.params.length && !get(last(func.def.params), 'multiple', false)) { throw { message: 'too many parameters for function ' + func.def.name }; } @@ -174,13 +174,13 @@ export default class GraphiteQuery { this.functions = without(this.functions, func); } - moveFunction(func: any, offset: number) { + moveFunction(func: FuncInstance, offset: number) { const index = this.functions.indexOf(func); arrayMove(this.functions, index, index + offset); } updateModelTarget(targets: any) { - const wrapFunction = (target: string, func: any) => { + const wrapFunction = (target: string, func: FuncInstance) => { return func.render(target, (value: string) => { return this.templateSrv.replace(value, this.scopedVars); }); diff --git a/public/app/plugins/datasource/graphite/parser.ts b/public/app/plugins/datasource/graphite/parser.ts index 5ee0e44332b..315d4509c08 100644 --- a/public/app/plugins/datasource/graphite/parser.ts +++ b/public/app/plugins/datasource/graphite/parser.ts @@ -276,12 +276,12 @@ export class Parser { return this.tokens[this.index - 1]; } - matchToken(type: any, index: number) { + matchToken(type: string, index: number) { const token = this.tokens[this.index + index]; return (token === undefined && type === '') || (token && token.type === type); } - match(token1: any, token2?: any) { + match(token1: string, token2?: string) { return this.matchToken(token1, 0) && (!token2 || this.matchToken(token2, 1)); } } diff --git a/public/app/plugins/datasource/graphite/state/store.ts b/public/app/plugins/datasource/graphite/state/store.ts index 2bd3842df78..0081c2bd0ea 100644 --- a/public/app/plugins/datasource/graphite/state/store.ts +++ b/public/app/plugins/datasource/graphite/state/store.ts @@ -8,7 +8,7 @@ import { TemplateSrv } from '../../../../features/templating/template_srv'; import { GraphiteDatasource } from '../datasource'; import { FuncDefs } from '../gfunc'; import GraphiteQuery, { GraphiteTarget } from '../graphite_query'; -import { GraphiteSegment, GraphiteTagOperator } from '../types'; +import { GraphiteSegment } from '../types'; import { actions } from './actions'; import { @@ -91,7 +91,7 @@ const reducer = async (action: Action, state: GraphiteQueryEditorState): Promise fake: false, }; } else { - segment = segmentOrString as GraphiteSegment; + segment = segmentOrString; } state.error = null; @@ -131,7 +131,7 @@ const reducer = async (action: Action, state: GraphiteQueryEditorState): Promise if (actions.addNewTag.match(action)) { const segment = action.payload.segment; const newTagKey = segment.value; - const newTag = { key: newTagKey, operator: '=' as GraphiteTagOperator, value: '' }; + const newTag = { key: newTagKey, operator: '=' as const, value: '' }; state.queryModel.addTag(newTag); handleTargetChanged(state); } diff --git a/public/app/plugins/datasource/graphite/utils.ts b/public/app/plugins/datasource/graphite/utils.ts index 88f0a5332cd..c8de42fac29 100644 --- a/public/app/plugins/datasource/graphite/utils.ts +++ b/public/app/plugins/datasource/graphite/utils.ts @@ -8,7 +8,7 @@ import { GraphiteParserError } from './types'; * This function removes all HTML tags and keeps only the last line from the stack * trace which should be the most meaningful. */ -export function reduceError(error: any): any { +export function reduceError(error: any) { if (error && error.status === 500 && error.data?.message?.startsWith('( diff --git a/public/app/plugins/datasource/influxdb/datasource.ts b/public/app/plugins/datasource/influxdb/datasource.ts index 78467ba3a0f..91bd95a0382 100644 --- a/public/app/plugins/datasource/influxdb/datasource.ts +++ b/public/app/plugins/datasource/influxdb/datasource.ts @@ -590,7 +590,7 @@ export default class InfluxDatasource extends DataSourceWithBackend { + map((data) => { if (!data || !data.results) { return { data: [] }; } @@ -690,7 +690,7 @@ export default class InfluxDatasource extends DataSourceWithBackend { + return lastValueFrom(this._seriesQuery(query, options)).then((data) => { if (!data || !data.results || !data.results[0]) { throw { message: 'No results in response from InfluxDB' }; } diff --git a/public/app/plugins/datasource/influxdb/influx_query_model.ts b/public/app/plugins/datasource/influxdb/influx_query_model.ts index 676fa04eccd..3356e2d40ed 100644 --- a/public/app/plugins/datasource/influxdb/influx_query_model.ts +++ b/public/app/plugins/datasource/influxdb/influx_query_model.ts @@ -39,7 +39,7 @@ export default class InfluxQueryModel { } updateProjection() { - this.selectModels = map(this.target.select, (parts: any) => { + this.selectModels = map(this.target.select, (parts) => { return map(parts, queryPart.create); }); this.groupByParts = map(this.target.groupBy, queryPart.create); @@ -47,18 +47,18 @@ export default class InfluxQueryModel { updatePersistedParts() { this.target.select = map(this.selectModels, (selectParts) => { - return map(selectParts, (part: any) => { + return map(selectParts, (part) => { return { type: part.def.type, params: part.params }; }); }); } hasGroupByTime() { - return find(this.target.groupBy, (g: any) => g.type === 'time'); + return find(this.target.groupBy, (g) => g.type === 'time'); } hasFill() { - return find(this.target.groupBy, (g: any) => g.type === 'fill'); + return find(this.target.groupBy, (g) => g.type === 'fill'); } addGroupBy(value: string) { @@ -95,10 +95,10 @@ export default class InfluxQueryModel { if (part.def.type === 'time') { // remove fill - this.target.groupBy = filter(this.target.groupBy, (g: any) => g.type !== 'fill'); + this.target.groupBy = filter(this.target.groupBy, (g) => g.type !== 'fill'); // remove aggregations - this.target.select = map(this.target.select, (s: any) => { - return filter(s, (part: any) => { + this.target.select = map(this.target.select, (s) => { + return filter(s, (part) => { const partModel = queryPart.create(part); if (partModel.def.category === categories.Aggregations) { return false; diff --git a/public/app/plugins/datasource/influxdb/query_part.ts b/public/app/plugins/datasource/influxdb/query_part.ts index d37adbafa7f..a2bb8f2cd10 100644 --- a/public/app/plugins/datasource/influxdb/query_part.ts +++ b/public/app/plugins/datasource/influxdb/query_part.ts @@ -140,7 +140,7 @@ function addAliasStrategy(selectParts: any[], partModel: any) { function addFieldStrategy(selectParts: any, partModel: any, query: { selectModels: any[][] }) { // copy all parts - const parts = map(selectParts, (part: any) => { + const parts = map(selectParts, (part) => { return createPart({ type: part.def.type, params: clone(part.params) }); }); diff --git a/public/app/plugins/datasource/jaeger/datasource.ts b/public/app/plugins/datasource/jaeger/datasource.ts index a2d10cc0f8d..5333b60f0c5 100644 --- a/public/app/plugins/datasource/jaeger/datasource.ts +++ b/public/app/plugins/datasource/jaeger/datasource.ts @@ -47,7 +47,7 @@ export class JaegerDatasource extends DataSourceApi this.traceIdTimeParams = instanceSettings.jsonData.traceIdTimeParams; } - async metadataRequest(url: string, params?: Record): Promise { + async metadataRequest(url: string, params?: Record) { const res = await lastValueFrom(this._request(url, params, { hideFromInspector: true })); return res.data.data; } @@ -180,11 +180,11 @@ export class JaegerDatasource extends DataSourceApi }; } - async testDatasource(): Promise { + async testDatasource() { return lastValueFrom( this._request('/api/services').pipe( map((res) => { - const values: any[] = res?.data?.data || []; + const values = res?.data?.data || []; const testResult = values.length > 0 ? { status: 'success', message: 'Data source connected and services found.' } @@ -195,7 +195,7 @@ export class JaegerDatasource extends DataSourceApi }; return testResult; }), - catchError((err: any) => { + catchError((err) => { let message = 'Jaeger: '; if (err.statusText) { message += err.statusText; @@ -230,7 +230,11 @@ export class JaegerDatasource extends DataSourceApi return query.query || ''; } - private _request(apiUrl: string, data?: any, options?: Partial): Observable> { + private _request( + apiUrl: string, + data?: Record, + options?: Partial + ): Observable> { const params = data ? serializeParams(data) : ''; const url = `${this.instanceSettings.url}${apiUrl}${params.length ? `?${params}` : ''}`; const req = { diff --git a/public/app/plugins/datasource/jaeger/util.ts b/public/app/plugins/datasource/jaeger/util.ts index 51f01fa929a..f025ed9df55 100644 --- a/public/app/plugins/datasource/jaeger/util.ts +++ b/public/app/plugins/datasource/jaeger/util.ts @@ -4,7 +4,7 @@ export function convertTagsLogfmt(tags: string | undefined) { if (!tags) { return ''; } - const data: any = logfmt.parse(tags); + const data = logfmt.parse(tags); Object.keys(data).forEach((key) => { const value = data[key]; if (typeof value !== 'string') { diff --git a/public/app/plugins/datasource/loki/LanguageProvider.ts b/public/app/plugins/datasource/loki/LanguageProvider.ts index 960dfcbfa89..7cf74f98113 100644 --- a/public/app/plugins/datasource/loki/LanguageProvider.ts +++ b/public/app/plugins/datasource/loki/LanguageProvider.ts @@ -37,7 +37,7 @@ export default class LokiLanguageProvider extends LanguageProvider { Object.assign(this, initialValues); } - request = async (url: string, params?: any): Promise => { + request = async (url: string, params?: any) => { try { return await this.datasource.metadataRequest(url, params); } catch (error) { diff --git a/public/app/plugins/datasource/loki/streaming.ts b/public/app/plugins/datasource/loki/streaming.ts index edd28783118..953e74337df 100644 --- a/public/app/plugins/datasource/loki/streaming.ts +++ b/public/app/plugins/datasource/loki/streaming.ts @@ -45,7 +45,7 @@ export function doLokiChannelStream( let frame: StreamingDataFrame | undefined = undefined; const updateFrame = (msg: any) => { if (msg?.message) { - const p = msg.message as DataFrameJSON; + const p: DataFrameJSON = msg.message; if (!frame) { frame = StreamingDataFrame.fromDataFrameJSON(p, { maxLength, diff --git a/public/app/plugins/datasource/prometheus/components/PromQueryField.tsx b/public/app/plugins/datasource/prometheus/components/PromQueryField.tsx index 97e010b0b5f..1986901cca3 100644 --- a/public/app/plugins/datasource/prometheus/components/PromQueryField.tsx +++ b/public/app/plugins/datasource/prometheus/components/PromQueryField.tsx @@ -50,8 +50,8 @@ interface PromQueryFieldState { class PromQueryField extends React.PureComponent { declare languageProviderInitializationPromise: CancelablePromise; - constructor(props: PromQueryFieldProps, context: React.Context) { - super(props, context); + constructor(props: PromQueryFieldProps) { + super(props); this.state = { labelBrowserVisible: false, diff --git a/public/app/plugins/datasource/prometheus/components/PrometheusMetricsBrowser.tsx b/public/app/plugins/datasource/prometheus/components/PrometheusMetricsBrowser.tsx index becc8b401f2..2ef3b2694ee 100644 --- a/public/app/plugins/datasource/prometheus/components/PrometheusMetricsBrowser.tsx +++ b/public/app/plugins/datasource/prometheus/components/PrometheusMetricsBrowser.tsx @@ -500,7 +500,7 @@ export class UnthemedPrometheusMetricsBrowser extends React.Component (metrics!.values as FacettableValue[])[i].name} + itemKey={(i) => metrics!.values![i].name} width={300} className={styles.valueList} > @@ -589,7 +589,7 @@ export class UnthemedPrometheusMetricsBrowser extends React.Component (label.values as FacettableValue[])[i].name} + itemKey={(i) => label.values![i].name} width={200} className={styles.valueList} > diff --git a/public/app/plugins/datasource/prometheus/configuration/PromSettings.tsx b/public/app/plugins/datasource/prometheus/configuration/PromSettings.tsx index d310c804418..2eb17508cfc 100644 --- a/public/app/plugins/datasource/prometheus/configuration/PromSettings.tsx +++ b/public/app/plugins/datasource/prometheus/configuration/PromSettings.tsx @@ -549,11 +549,11 @@ export const getValueFromEventItem = (eventItem: SyntheticEvent).value; + return eventItem.value; }; const onChangeHandler = diff --git a/public/app/plugins/datasource/prometheus/datasource.ts b/public/app/plugins/datasource/prometheus/datasource.ts index ccecbe67f29..02218a579e0 100644 --- a/public/app/plugins/datasource/prometheus/datasource.ts +++ b/public/app/plugins/datasource/prometheus/datasource.ts @@ -227,7 +227,7 @@ export class PrometheusDatasource * request. Any processing done here needs to be also copied on the backend as this goes through data source proxy * but not through the same code as alerting. */ - _request( + _request( url: string, data: Record | null, overrides: Partial = {} @@ -369,7 +369,7 @@ export class PrometheusDatasource delete instantTarget.maxDataPoints; // Create range target - const rangeTarget: any = cloneDeep(target); + const rangeTarget = cloneDeep(target); rangeTarget.format = 'time_series'; rangeTarget.instant = false; instantTarget.range = true; @@ -398,7 +398,7 @@ export class PrometheusDatasource ); // If running only instant query in Explore, format as table } else if (target.instant && options.app === CoreApp.Explore) { - const instantTarget: any = cloneDeep(target); + const instantTarget = cloneDeep(target); instantTarget.format = 'table'; queries.push(this.createQuery(instantTarget, options, start, end)); activeTargets.push(instantTarget); @@ -536,18 +536,19 @@ export class PrometheusDatasource // (should hold until there is some streaming requests involved). tap(() => runningQueriesCount--), filter((response: any) => (response.cancelled ? false : true)), - map((response: any) => { + map((response) => { const data = transform(response, { query, target, responseListLength: queries.length, exemplarTraceIdDestinations: this.exemplarTraceIdDestinations, }); - return { + const result: DataQueryResponse = { data, key: query.requestId, state: runningQueriesCount === 0 ? LoadingState.Done : LoadingState.Loading, - } as DataQueryResponse; + }; + return result; }) ); @@ -569,7 +570,7 @@ export class PrometheusDatasource const filterAndMapResponse = pipe( filter((response: any) => (response.cancelled ? false : true)), - map((response: any) => { + map((response) => { const data = transform(response, { query, target, @@ -1174,11 +1175,7 @@ export class PrometheusDatasource } // Used when running queries through backend - applyTemplateVariables( - target: PromQuery, - scopedVars: ScopedVars, - filters?: AdHocVariableFilter[] - ): Record { + applyTemplateVariables(target: PromQuery, scopedVars: ScopedVars, filters?: AdHocVariableFilter[]) { const variables = cloneDeep(scopedVars); // We want to interpolate these variables on backend @@ -1302,10 +1299,10 @@ export function extractRuleMappingFromGroups(groups: any[]) { // NOTE: these two functions are very similar to the escapeLabelValueIn* functions // in language_utils.ts, but they are not exactly the same algorithm, and we found // no way to reuse one in the another or vice versa. -export function prometheusRegularEscape(value: any) { +export function prometheusRegularEscape(value: unknown) { return typeof value === 'string' ? value.replace(/\\/g, '\\\\').replace(/'/g, "\\\\'") : value; } -export function prometheusSpecialRegexEscape(value: any) { +export function prometheusSpecialRegexEscape(value: unknown) { return typeof value === 'string' ? value.replace(/\\/g, '\\\\\\\\').replace(/[$^*{}\[\]\'+?.()|]/g, '\\\\$&') : value; } diff --git a/public/app/plugins/datasource/tempo/datasource.ts b/public/app/plugins/datasource/tempo/datasource.ts index 476d2d46a58..73898ceb31b 100644 --- a/public/app/plugins/datasource/tempo/datasource.ts +++ b/public/app/plugins/datasource/tempo/datasource.ts @@ -18,6 +18,7 @@ import { LoadingState, rangeUtil, ScopedVars, + TestDataSourceResponse, } from '@grafana/data'; import { BackendSrvRequest, @@ -496,7 +497,7 @@ export class TempoDatasource extends DataSourceWithBackend { + applyTemplateVariables(query: TempoQuery, scopedVars: ScopedVars) { return this.applyVariables(query, scopedVars); } @@ -685,7 +686,11 @@ export class TempoDatasource extends DataSourceWithBackend): Observable> { + private _request( + apiUrl: string, + data?: unknown, + options?: Partial + ): Observable> { const params = data ? serializeParams(data) : ''; const url = `${this.instanceSettings.url}${apiUrl}${params.length ? `?${params}` : ''}`; const req = { ...options, url }; @@ -693,7 +698,7 @@ export class TempoDatasource extends DataSourceWithBackend { + async testDatasource(): Promise { const options: BackendSrvRequest = { headers: {}, method: 'GET', @@ -1297,7 +1302,7 @@ export function getRateAlignedValues( return values; } -export function makeServiceGraphViewRequest(metrics: any[]) { +export function makeServiceGraphViewRequest(metrics: string[]): PromQuery[] { return metrics.map((metric) => { return { refId: metric, diff --git a/public/app/plugins/panel/geomap/utils/selection.ts b/public/app/plugins/panel/geomap/utils/selection.ts index b164c7fe9bf..a666ef0049e 100644 --- a/public/app/plugins/panel/geomap/utils/selection.ts +++ b/public/app/plugins/panel/geomap/utils/selection.ts @@ -1,6 +1,6 @@ import { SelectableValue } from '@grafana/data'; -export interface SelectionInfo { +export interface SelectionInfo { options: Array>; current?: SelectableValue; } diff --git a/public/app/plugins/panel/histogram/Histogram.tsx b/public/app/plugins/panel/histogram/Histogram.tsx index 77d3c3127bd..29852eb5728 100644 --- a/public/app/plugins/panel/histogram/Histogram.tsx +++ b/public/app/plugins/panel/histogram/Histogram.tsx @@ -157,8 +157,8 @@ const prepConfig = (frame: DataFrame, theme: GrafanaTheme2) => { incrs: isOrdinalX ? [1] : useLogScale ? undefined : histogramBucketSizes, splits: useLogScale || isOrdinalX ? undefined : xSplits, values: isOrdinalX - ? (u: uPlot, splits: any[]) => splits - : (u: uPlot, splits: any[]) => { + ? (u, splits) => splits + : (u, splits) => { const tickLabels = splits.map(xAxisFormatter); const maxWidth = tickLabels.reduce( diff --git a/public/app/plugins/panel/nodeGraph/utils.ts b/public/app/plugins/panel/nodeGraph/utils.ts index 97fb11e3061..728026b95d0 100644 --- a/public/app/plugins/panel/nodeGraph/utils.ts +++ b/public/app/plugins/panel/nodeGraph/utils.ts @@ -251,8 +251,8 @@ function computableField(field?: Field) { * @param edgeFields */ function normalizeStatsForNodes(nodesMap: { [id: string]: NodeDatumFromEdge }, edgeFields: EdgeFields): NodeDatum[] { - const secondaryStatValues: any[] = []; - const mainStatValues: any[] = []; + const secondaryStatValues: Array = []; + const mainStatValues: Array = []; const secondaryStatField = computableField(edgeFields.secondaryStat) ? { ...edgeFields.secondaryStat!, diff --git a/public/app/types/templates.ts b/public/app/types/templates.ts index 897044a93fe..17bb0edb3fb 100644 --- a/public/app/types/templates.ts +++ b/public/app/types/templates.ts @@ -1,5 +1,5 @@ export interface Variable { name: string; type: string; - current: any; + current: unknown; } diff --git a/public/test/core/redux/mocks.ts b/public/test/core/redux/mocks.ts index a65bf971c7f..e6ad9c835ec 100644 --- a/public/test/core/redux/mocks.ts +++ b/public/test/core/redux/mocks.ts @@ -1,6 +1,6 @@ import { ActionCreatorWithoutPayload, PayloadActionCreator } from '@reduxjs/toolkit'; -export const mockToolkitActionCreator = (creator: PayloadActionCreator) => { +export const mockToolkitActionCreator =

(creator: PayloadActionCreator) => { return Object.assign(jest.fn(), creator); }; diff --git a/public/test/core/redux/reducerTester.ts b/public/test/core/redux/reducerTester.ts index 145dadb0e9a..55d5378cff1 100644 --- a/public/test/core/redux/reducerTester.ts +++ b/public/test/core/redux/reducerTester.ts @@ -2,7 +2,9 @@ import { AnyAction } from '@reduxjs/toolkit'; import { cloneDeep } from 'lodash'; import { Action } from 'redux'; -type GrafanaReducer = (state: S, action: A) => S; +import { StoreState } from 'app/types'; + +type GrafanaReducer = (state: S, action: A) => S; export interface Given { givenReducer: ( @@ -23,10 +25,6 @@ export interface Then { whenActionIsDispatched: (action: AnyAction) => Then; } -interface ObjectType extends Object { - [key: string]: any; -} - export const deepFreeze = (obj: T): T => { Object.freeze(obj); @@ -37,7 +35,7 @@ export const deepFreeze = (obj: T): T => { const hasOwnProp = Object.prototype.hasOwnProperty; if (obj && obj instanceof Object) { - const object: ObjectType = obj; + const object: Record = obj; Object.getOwnPropertyNames(object).forEach((propertyName) => { const objectProperty = object[propertyName]; if ( diff --git a/public/test/core/thunk/thunkTester.ts b/public/test/core/thunk/thunkTester.ts index 8afedcb53bf..9e228630d2e 100644 --- a/public/test/core/thunk/thunkTester.ts +++ b/public/test/core/thunk/thunkTester.ts @@ -1,4 +1,3 @@ -// @ts-ignore import { PayloadAction } from '@reduxjs/toolkit'; import configureMockStore from 'redux-mock-store'; import thunk from 'redux-thunk'; @@ -13,7 +12,7 @@ export interface ThunkWhen { whenThunkIsDispatched: (...args: any) => Promise>>; } -export const thunkTester = (initialState: any, debug?: boolean): ThunkGiven => { +export const thunkTester = (initialState: unknown, debug?: boolean): ThunkGiven => { const store = mockStore(initialState); let thunkUnderTest: any = null; let dispatchedActions: Array> = []; diff --git a/public/test/helpers/convertToStoreState.ts b/public/test/helpers/convertToStoreState.ts index 8a93487ae02..9f696b0e45a 100644 --- a/public/test/helpers/convertToStoreState.ts +++ b/public/test/helpers/convertToStoreState.ts @@ -1,8 +1,11 @@ +import { TypedVariableModel } from '@grafana/data'; + import { getPreloadedState } from '../../app/features/variables/state/helpers'; +import { VariablesState } from '../../app/features/variables/state/types'; import { StoreState } from '../../app/types'; -export const convertToStoreState = (key: string, models: any[]): StoreState => { - const variables = models.reduce((byName, variable) => { +export const convertToStoreState = (key: string, models: TypedVariableModel[]): StoreState => { + const variables = models.reduce((byName, variable) => { byName[variable.name] = variable; return byName; }, {}); diff --git a/public/test/matchers/index.ts b/public/test/matchers/index.ts index b6f8a091aaa..b62de8d6974 100644 --- a/public/test/matchers/index.ts +++ b/public/test/matchers/index.ts @@ -4,7 +4,7 @@ import { toEmitValues } from './toEmitValues'; import { toEmitValuesWith } from './toEmitValuesWith'; import { ObservableMatchers } from './types'; -export const matchers: ObservableMatchers> = { +export const matchers: ObservableMatchers> = { toEmitValues, toEmitValuesWith, }; diff --git a/public/test/matchers/utils.ts b/public/test/matchers/utils.ts index e7758bb9177..08a57f060b8 100644 --- a/public/test/matchers/utils.ts +++ b/public/test/matchers/utils.ts @@ -3,7 +3,10 @@ import { asapScheduler, Subscription, timer, isObservable } from 'rxjs'; import { OBSERVABLE_TEST_TIMEOUT_IN_MS } from './types'; -export function forceObservableCompletion(subscription: Subscription, resolve: (args: any) => void) { +export function forceObservableCompletion( + subscription: Subscription, + resolve: (args: jest.CustomMatcherResult | PromiseLike) => void +) { const timeoutObservable = timer(OBSERVABLE_TEST_TIMEOUT_IN_MS, asapScheduler); subscription.add( diff --git a/public/test/mocks/workers.ts b/public/test/mocks/workers.ts index 2b7802a4a1f..ddba6e1e386 100644 --- a/public/test/mocks/workers.ts +++ b/public/test/mocks/workers.ts @@ -1,9 +1,12 @@ +import { Config } from 'app/plugins/panel/nodeGraph/layout'; +import { EdgeDatum, NodeDatum } from 'app/plugins/panel/nodeGraph/types'; + const { layout } = jest.requireActual('../../app/plugins/panel/nodeGraph/layout.worker.js'); class LayoutMockWorker { timeout: number | undefined; constructor() {} - postMessage(data: any) { + postMessage(data: { nodes: NodeDatum[]; edges: EdgeDatum[]; config: Config }) { const { nodes, edges, config } = data; this.timeout = window.setTimeout(() => { this.timeout = undefined; diff --git a/public/test/specs/helpers.ts b/public/test/specs/helpers.ts index 303421c4584..d094d019b6a 100644 --- a/public/test/specs/helpers.ts +++ b/public/test/specs/helpers.ts @@ -129,7 +129,7 @@ export class TimeSrvStub { }; } - setTime(time: any) { + setTime(time: RawTimeRange) { this.time = time; } } @@ -161,7 +161,7 @@ export function TemplateSrvStub(this: any) { return template(text, this.templateSettings)(this.data); }; this.init = () => {}; - this.getAdhocFilters = (): any => { + this.getAdhocFilters = () => { return []; }; this.fillVariableValuesForUrl = () => {};