diff --git a/.betterer.results b/.betterer.results index 61633c953c4..b3610ed75af 100644 --- a/.betterer.results +++ b/.betterer.results @@ -6259,8 +6259,7 @@ exports[`better eslint`] = { ], "public/app/plugins/datasource/grafana-testdata-datasource/components/SimulationSchemaForm.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, "Styles should be written using objects.", "2"] + [0, 0, 0, "Styles should be written using objects.", "1"] ], "public/app/plugins/datasource/grafana-testdata-datasource/components/index.ts:5381": [ [0, 0, 0, "Do not re-export imported variable (\`./StreamingClientEditor\`)", "0"], @@ -6270,9 +6269,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/plugins/datasource/grafana-testdata-datasource/runStreams.ts:5381": [ - [0, 0, 0, "Unexpected any. Specify a different type.", "0"] - ], "public/app/plugins/datasource/grafana-testdata-datasource/webpack.config.ts:5381": [ [0, 0, 0, "Do not re-export imported variable (\`config\`)", "0"] ], @@ -6321,7 +6317,7 @@ exports[`better eslint`] = { [0, 0, 0, "Styles should be written using objects.", "2"] ], "public/app/plugins/datasource/graphite/components/MetricTankMetaInspector.tsx:5381": [ - [0, 0, 0, "Do not use any type assertions.", "0"], + [0, 0, 0, "Styles should be written using objects.", "0"], [0, 0, 0, "Styles should be written using objects.", "1"], [0, 0, 0, "Styles should be written using objects.", "2"], [0, 0, 0, "Styles should be written using objects.", "3"], @@ -6330,8 +6326,7 @@ exports[`better eslint`] = { [0, 0, 0, "Styles should be written using objects.", "6"], [0, 0, 0, "Styles should be written using objects.", "7"], [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.", "9"] ], "public/app/plugins/datasource/graphite/components/TagsSection.tsx:5381": [ [0, 0, 0, "Styles should be written using objects.", "0"] @@ -6374,8 +6369,7 @@ exports[`better eslint`] = { [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.", "29"], - [0, 0, 0, "Unexpected any. Specify a different type.", "30"] + [0, 0, 0, "Unexpected any. Specify a different type.", "29"] ], "public/app/plugins/datasource/graphite/gfunc.ts:5381": [ [0, 0, 0, "Do not use any type assertions.", "0"], @@ -6398,14 +6392,11 @@ 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, "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, "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, "Unexpected any. Specify a different type.", "19"] + [0, 0, 0, "Unexpected any. Specify a different type.", "15"], + [0, 0, 0, "Unexpected any. Specify a different type.", "16"] ], "public/app/plugins/datasource/graphite/lexer.ts:5381": [ [0, 0, 0, "Unexpected any. Specify a different type.", "0"], @@ -6474,10 +6465,7 @@ exports[`better eslint`] = { ], "public/app/plugins/datasource/influxdb/influx_query_model.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.", "1"] ], "public/app/plugins/datasource/influxdb/influx_series.ts:5381": [ [0, 0, 0, "Unexpected any. Specify a different type.", "0"], @@ -6491,17 +6479,7 @@ exports[`better eslint`] = { [0, 0, 0, "Unexpected any. Specify a different type.", "8"], [0, 0, 0, "Unexpected any. Specify a different type.", "9"], [0, 0, 0, "Unexpected any. Specify a different type.", "10"], - [0, 0, 0, "Unexpected any. Specify a different type.", "11"], - [0, 0, 0, "Unexpected any. Specify a different type.", "12"], - [0, 0, 0, "Unexpected any. Specify a different type.", "13"], - [0, 0, 0, "Unexpected any. Specify a different type.", "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"] - ], - "public/app/plugins/datasource/influxdb/migrations.ts:5381": [ - [0, 0, 0, "Unexpected any. Specify a different type.", "0"] + [0, 0, 0, "Unexpected any. Specify a different type.", "11"] ], "public/app/plugins/datasource/influxdb/query_part.ts:5381": [ [0, 0, 0, "Unexpected any. Specify a different type.", "0"], @@ -6517,8 +6495,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.", "13"] ], "public/app/plugins/datasource/influxdb/response_parser.ts:5381": [ [0, 0, 0, "Unexpected any. Specify a different type.", "0"] @@ -6631,9 +6608,6 @@ exports[`better eslint`] = { [0, 0, 0, "Styles should be written using objects.", "1"], [0, 0, 0, "Styles should be written using objects.", "2"] ], - "public/app/plugins/datasource/loki/streaming.ts:5381": [ - [0, 0, 0, "Unexpected any. Specify a different type.", "0"] - ], "public/app/plugins/datasource/loki/types.ts:5381": [ [0, 0, 0, "Do not re-export imported variable (\`LokiQueryDirection\`)", "0"], [0, 0, 0, "Do not re-export imported variable (\`LokiQueryType\`)", "1"], @@ -6670,9 +6644,6 @@ exports[`better eslint`] = { [0, 0, 0, "Unexpected any. Specify a different type.", "16"], [0, 0, 0, "Unexpected any. Specify a different type.", "17"] ], - "public/app/plugins/datasource/opentsdb/migrations.ts:5381": [ - [0, 0, 0, "Unexpected any. Specify a different type.", "0"] - ], "public/app/plugins/datasource/parca/QueryEditor/LabelsEditor.tsx:5381": [ [0, 0, 0, "Styles should be written using objects.", "0"], [0, 0, 0, "Styles should be written using objects.", "1"] @@ -6744,12 +6715,8 @@ exports[`better eslint`] = { "public/app/plugins/datasource/tempo/resultTransformer.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.", "5"], - [0, 0, 0, "Do not use any type assertions.", "6"], - [0, 0, 0, "Unexpected any. Specify a different type.", "7"] + [0, 0, 0, "Do not use any type assertions.", "2"], + [0, 0, 0, "Unexpected any. Specify a different type.", "3"] ], "public/app/plugins/datasource/tempo/webpack.config.ts:5381": [ [0, 0, 0, "Do not re-export imported variable (\`config\`)", "0"] @@ -6813,9 +6780,6 @@ exports[`better eslint`] = { "public/app/plugins/panel/barchart/quadtree.ts:5381": [ [0, 0, 0, "Unexpected any. Specify a different type.", "0"] ], - "public/app/plugins/panel/barchart/utils.ts:5381": [ - [0, 0, 0, "Unexpected any. Specify a different type.", "0"] - ], "public/app/plugins/panel/candlestick/CandlestickPanel.tsx:5381": [ [0, 0, 0, "Do not use any type assertions.", "0"], [0, 0, 0, "Unexpected any. Specify a different type.", "1"] @@ -6953,12 +6917,8 @@ exports[`better eslint`] = { [0, 0, 0, "Do not use any type assertions.", "15"], [0, 0, 0, "Do not use any type assertions.", "16"] ], - "public/app/plugins/panel/histogram/migrations.ts:5381": [ - [0, 0, 0, "Unexpected any. Specify a different type.", "0"] - ], "public/app/plugins/panel/live/LiveChannelEditor.tsx:5381": [ - [0, 0, 0, "Unexpected any. Specify a different type.", "0"], - [0, 0, 0, "Styles should be written using objects.", "1"] + [0, 0, 0, "Styles should be written using objects.", "0"] ], "public/app/plugins/panel/live/LivePanel.tsx:5381": [ [0, 0, 0, "Do not use any type assertions.", "0"], @@ -7072,17 +7032,14 @@ exports[`better eslint`] = { [0, 0, 0, "Unexpected any. Specify a different type.", "0"], [0, 0, 0, "Unexpected any. Specify a different type.", "1"], [0, 0, 0, "Unexpected any. Specify a different type.", "2"], - [0, 0, 0, "Unexpected any. Specify a different type.", "3"], - [0, 0, 0, "Unexpected any. Specify a different type.", "4"], - [0, 0, 0, "Unexpected any. Specify a different type.", "5"] + [0, 0, 0, "Unexpected any. Specify a different type.", "3"] ], "public/app/plugins/panel/text/TextPanel.tsx:5381": [ [0, 0, 0, "Styles should be written using objects.", "0"], [0, 0, 0, "Styles should be written using objects.", "1"] ], "public/app/plugins/panel/text/TextPanelEditor.tsx:5381": [ - [0, 0, 0, "Unexpected any. Specify a different type.", "0"], - [0, 0, 0, "Styles should be written using objects.", "1"] + [0, 0, 0, "Styles should be written using objects.", "0"] ], "public/app/plugins/panel/text/textPanelMigrationHandler.ts:5381": [ [0, 0, 0, "Unexpected any. Specify a different type.", "0"] @@ -7146,9 +7103,8 @@ exports[`better eslint`] = { [0, 0, 0, "Styles should be written using objects.", "5"] ], "public/app/plugins/panel/xychart/AutoEditor.tsx:5381": [ - [0, 0, 0, "Unexpected any. Specify a different type.", "0"], - [0, 0, 0, "Styles should be written using objects.", "1"], - [0, 0, 0, "Styles should be written using objects.", "2"] + [0, 0, 0, "Styles should be written using objects.", "0"], + [0, 0, 0, "Styles should be written using objects.", "1"] ], "public/app/plugins/panel/xychart/ManualEditor.tsx:5381": [ [0, 0, 0, "Do not use any type assertions.", "0"] @@ -7173,12 +7129,10 @@ 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, "Do not use any type assertions.", "4"] + [0, 0, 0, "Do not use any type assertions.", "3"] ], "public/app/plugins/panel/xychart/v2/migrations.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/plugins/panel/xychart/v2/scatter.ts:5381": [ [0, 0, 0, "Do not use any type assertions.", "0"], @@ -7200,9 +7154,6 @@ exports[`better eslint`] = { [0, 0, 0, "Do not use any type assertions.", "16"], [0, 0, 0, "Do not use any type assertions.", "17"] ], - "public/app/plugins/panel/xychart/v2/utils.ts:5381": [ - [0, 0, 0, "Unexpected any. Specify a different type.", "0"] - ], "public/app/plugins/sdk.ts:5381": [ [0, 0, 0, "Do not re-export imported variable (\`loadPluginCss\`)", "0"] ], @@ -7228,9 +7179,7 @@ exports[`better eslint`] = { [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.", "4"] ], "public/app/types/dashboard.ts:5381": [ [0, 0, 0, "Unexpected any. Specify a different type.", "0"] @@ -7244,11 +7193,7 @@ exports[`better eslint`] = { [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.", "8"] ], "public/app/types/index.ts:5381": [ [0, 0, 0, "Do not use export all (\`export * from ...\`)", "0"], @@ -7292,18 +7237,13 @@ exports[`better eslint`] = { "public/app/types/unified-alerting-dto.ts:5381": [ [0, 0, 0, "Do not use any type assertions.", "0"] ], - "public/swagger/K8sNameLookup.tsx:5381": [ - [0, 0, 0, "Unexpected any. Specify a different type.", "0"] - ], "public/swagger/SwaggerPage.tsx:5381": [ [0, 0, 0, "Unexpected any. Specify a different type.", "0"], [0, 0, 0, "No untranslated strings. Wrap text with ", "1"] ], "public/swagger/index.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, "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/swagger/plugins.tsx:5381": [ [0, 0, 0, "Unexpected any. Specify a different type.", "0"], @@ -7313,8 +7253,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.", "3"] ], "public/test/core/thunk/thunkTester.ts:5381": [ [0, 0, 0, "Unexpected any. Specify a different type.", "0"], @@ -7322,9 +7261,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.", "5"] ], "public/test/global-jquery-shim.ts:5381": [ [0, 0, 0, "Unexpected any. Specify a different type.", "0"] @@ -7338,21 +7275,12 @@ exports[`better eslint`] = { "public/test/jest-setup.ts:5381": [ [0, 0, 0, "Unexpected any. Specify a different type.", "0"] ], - "public/test/lib/common.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"], [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.", "4"] ] }` }; diff --git a/public/app/plugins/datasource/grafana-testdata-datasource/components/SimulationSchemaForm.tsx b/public/app/plugins/datasource/grafana-testdata-datasource/components/SimulationSchemaForm.tsx index fc9a9cec505..04f8df747d0 100644 --- a/public/app/plugins/datasource/grafana-testdata-datasource/components/SimulationSchemaForm.tsx +++ b/public/app/plugins/datasource/grafana-testdata-datasource/components/SimulationSchemaForm.tsx @@ -4,10 +4,12 @@ import { FormEvent, useState, ChangeEvent } from 'react'; import { DataFrameSchema, FieldSchema, GrafanaTheme2 } from '@grafana/data'; import { useStyles2, TextArea, InlineField, Input, FieldSet, InlineSwitch } from '@grafana/ui'; +type Config = Record; + interface SchemaFormProps { - config: Record; + config: Config; schema: DataFrameSchema; - onChange: (config: Record) => void; + onChange: (config: Config) => void; } const renderInput = (field: FieldSchema, onChange: SchemaFormProps['onChange'], config: SchemaFormProps['config']) => { diff --git a/public/app/plugins/datasource/grafana-testdata-datasource/runStreams.ts b/public/app/plugins/datasource/grafana-testdata-datasource/runStreams.ts index 6e052c38df1..49a2522d997 100644 --- a/public/app/plugins/datasource/grafana-testdata-datasource/runStreams.ts +++ b/public/app/plugins/datasource/grafana-testdata-datasource/runStreams.ts @@ -215,7 +215,9 @@ export function runFetchStream( }, }); - const processChunk = (value: ReadableStreamReadResult): any => { + const processChunk = async ( + value: ReadableStreamReadResult + ): Promise | undefined> => { if (value.value) { const text = new TextDecoder().decode(value.value); csv.readCSV(text); diff --git a/public/app/plugins/datasource/graphite/components/MetricTankMetaInspector.tsx b/public/app/plugins/datasource/graphite/components/MetricTankMetaInspector.tsx index 1b45fc14593..32de948b67b 100644 --- a/public/app/plugins/datasource/graphite/components/MetricTankMetaInspector.tsx +++ b/public/app/plugins/datasource/graphite/components/MetricTankMetaInspector.tsx @@ -96,8 +96,9 @@ export class MetricTankMetaInspector extends PureComponent { const seriesMetas: Record = {}; for (const series of data) { - if (series?.meta?.custom?.seriesMetaList) { - for (const metaItem of series.meta.custom.seriesMetaList as MetricTankSeriesMeta[]) { + const seriesMetaList: MetricTankSeriesMeta[] | undefined = series?.meta?.custom?.seriesMetaList; + if (seriesMetaList) { + for (const metaItem of seriesMetaList) { // key is to dedupe as many series will have identitical meta const key = `${JSON.stringify(metaItem)}`; diff --git a/public/app/plugins/datasource/graphite/datasource.ts b/public/app/plugins/datasource/graphite/datasource.ts index e69055df474..c3215567a12 100644 --- a/public/app/plugins/datasource/graphite/datasource.ts +++ b/public/app/plugins/datasource/graphite/datasource.ts @@ -494,7 +494,7 @@ export class GraphiteDatasource } metricFindQuery(findQuery: string | GraphiteQuery, optionalOptions?: any): Promise { - const options: any = optionalOptions || {}; + const options = optionalOptions || {}; const queryObject = convertToGraphiteQueryObject(findQuery); if (queryObject.queryType === GraphiteQueryType.Value || queryObject.queryType === GraphiteQueryType.MetricName) { diff --git a/public/app/plugins/datasource/graphite/graphite_query.ts b/public/app/plugins/datasource/graphite/graphite_query.ts index d9202c335a5..9d2b8960b07 100644 --- a/public/app/plugins/datasource/graphite/graphite_query.ts +++ b/public/app/plugins/datasource/graphite/graphite_query.ts @@ -39,9 +39,9 @@ export default class GraphiteQuery { checkOtherSegmentsIndex = 0; removeTagValue: string; templateSrv: any; - scopedVars: any; + scopedVars?: ScopedVars; - constructor(datasource: any, target: any, templateSrv?: TemplateSrv, scopedVars?: ScopedVars) { + constructor(datasource: GraphiteDatasource, target: any, templateSrv?: TemplateSrv, scopedVars?: ScopedVars) { this.datasource = datasource; this.target = target; this.templateSrv = templateSrv; @@ -153,7 +153,7 @@ export default class GraphiteQuery { } } - updateSegmentValue(segment: any, index: number) { + updateSegmentValue(segment: GraphiteSegment, index: number) { this.segments[index].value = segment.value; } diff --git a/public/app/plugins/datasource/influxdb/influx_query_model.ts b/public/app/plugins/datasource/influxdb/influx_query_model.ts index 3a61a60a2a7..2035ea876a4 100644 --- a/public/app/plugins/datasource/influxdb/influx_query_model.ts +++ b/public/app/plugins/datasource/influxdb/influx_query_model.ts @@ -122,7 +122,7 @@ export default class InfluxQueryModel { this.updateProjection(); } - removeSelectPart(selectParts: any[], part: any) { + removeSelectPart(selectParts: QueryPart[], part: QueryPart) { // if we remove the field remove the whole statement if (part.def.type === 'field') { if (this.selectModels.length > 1) { @@ -137,7 +137,7 @@ export default class InfluxQueryModel { this.updatePersistedParts(); } - addSelectPart(selectParts: any[], type: string) { + addSelectPart(selectParts: QueryPart[], type: string) { const partModel = queryPart.create({ type: type }); partModel.def.addStrategy(selectParts, partModel, this); this.updatePersistedParts(); diff --git a/public/app/plugins/datasource/influxdb/influx_series.test.ts b/public/app/plugins/datasource/influxdb/influx_series.test.ts index eb603946520..1e9b9cd4584 100644 --- a/public/app/plugins/datasource/influxdb/influx_series.test.ts +++ b/public/app/plugins/datasource/influxdb/influx_series.test.ts @@ -266,7 +266,9 @@ describe('when generating timeseries from influxdb response', () => { describe('with empty tagsColumn', () => { const options = { alias: '', - annotation: {}, + annotation: { + refId: '', + }, series: [ { name: 'logins.count', @@ -290,6 +292,7 @@ describe('when generating timeseries from influxdb response', () => { alias: '', annotation: { tagsColumn: 'datacenter, source', + refId: '', }, series: [ { diff --git a/public/app/plugins/datasource/influxdb/influx_series.ts b/public/app/plugins/datasource/influxdb/influx_series.ts index fa4b0cd41ee..6addecb190a 100644 --- a/public/app/plugins/datasource/influxdb/influx_series.ts +++ b/public/app/plugins/datasource/influxdb/influx_series.ts @@ -3,14 +3,22 @@ import { each, map, includes, flatten, keys } from 'lodash'; import { FieldType, QueryResultMeta, TimeSeries, TableData } from '@grafana/data'; import TableModel from 'app/core/TableModel'; +import { InfluxQuery } from './types'; + export default class InfluxSeries { refId?: string; series: any; - alias: any; - annotation: any; + alias?: string; + annotation?: InfluxQuery; meta?: QueryResultMeta; - constructor(options: { series: any; alias?: any; annotation?: any; meta?: QueryResultMeta; refId?: string }) { + constructor(options: { + series: any; + alias?: string; + annotation?: InfluxQuery; + meta?: QueryResultMeta; + refId?: string; + }) { this.series = options.series; this.alias = options.alias; this.annotation = options.annotation; @@ -70,7 +78,7 @@ export default class InfluxSeries { const regex = /\$(\w+)|\[\[([\s\S]+?)\]\]/g; const segments = series.name.split('.'); - return this.alias.replace(regex, (match: any, g1: any, g2: any) => { + return this.alias?.replace(regex, (match, g1, g2) => { const group = g1 || g2; const segIndex = parseInt(group, 10); @@ -113,19 +121,19 @@ export default class InfluxSeries { if (column === 'sequence_number') { return; } - if (column === this.annotation.titleColumn) { + if (column === this.annotation?.titleColumn) { titleCol = index; return; } - if (includes((this.annotation.tagsColumn || '').replace(' ', '').split(','), column)) { + if (includes((this.annotation?.tagsColumn || '').replace(' ', '').split(','), column)) { tagsCol.push(index); return; } - if (column === this.annotation.textColumn) { + if (column === this.annotation?.textColumn) { textCol = index; return; } - if (column === this.annotation.timeEndColumn) { + if (column === this.annotation?.timeEndColumn) { timeEndCol = index; return; } diff --git a/public/app/plugins/datasource/influxdb/migrations.ts b/public/app/plugins/datasource/influxdb/migrations.ts index e0ebecf0169..60ccf5f7d88 100644 --- a/public/app/plugins/datasource/influxdb/migrations.ts +++ b/public/app/plugins/datasource/influxdb/migrations.ts @@ -1,3 +1,5 @@ +import { AnnotationQuery, AnnotationSupport } from '@grafana/data'; + import { InfluxQuery, InfluxQueryTag } from './types'; type LegacyAnnotation = { @@ -52,8 +54,9 @@ const migrateLegacyAnnotation = (json: LegacyAnnotation) => { return target; }; -// eslint-ignore-next-line -export const prepareAnnotation = (json: any) => { +export const prepareAnnotation: AnnotationSupport>['prepareAnnotation'] = ( + json +) => { // make sure that any additional target fields are migrated json.target = json.target && !json.target?.query ? migrateLegacyAnnotation(json) : json.target; diff --git a/public/app/plugins/datasource/influxdb/query_part.ts b/public/app/plugins/datasource/influxdb/query_part.ts index 50fb0053369..03a07bc1e1e 100644 --- a/public/app/plugins/datasource/influxdb/query_part.ts +++ b/public/app/plugins/datasource/influxdb/query_part.ts @@ -3,7 +3,7 @@ import { clone, map } from 'lodash'; import { functionRenderer, QueryPart, QueryPartDef, suffixRenderer } from 'app/features/alerting/state/query_part'; const index: any[] = []; -const categories: any = { +const categories = { Aggregations: [], Selectors: [], Transformations: [], diff --git a/public/app/plugins/datasource/loki/streaming.ts b/public/app/plugins/datasource/loki/streaming.ts index 57a515ee723..1c3f9f77927 100644 --- a/public/app/plugins/datasource/loki/streaming.ts +++ b/public/app/plugins/datasource/loki/streaming.ts @@ -4,6 +4,7 @@ import { DataFrameJSON, DataQueryRequest, DataQueryResponse, + LiveChannelEvent, LiveChannelScope, LoadingState, StreamingDataFrame, @@ -43,8 +44,8 @@ export function doLokiChannelStream( } let frame: StreamingDataFrame | undefined = undefined; - const updateFrame = (msg: any) => { - if (msg?.message) { + const updateFrame = (msg: LiveChannelEvent) => { + if ('message' in msg && msg.message) { const p: DataFrameJSON = msg.message; if (!frame) { frame = StreamingDataFrame.fromDataFrameJSON(p, { diff --git a/public/app/plugins/datasource/opentsdb/migrations.ts b/public/app/plugins/datasource/opentsdb/migrations.ts index 90e5795c4ef..03a470c6226 100644 --- a/public/app/plugins/datasource/opentsdb/migrations.ts +++ b/public/app/plugins/datasource/opentsdb/migrations.ts @@ -1,4 +1,6 @@ -import { LegacyAnnotation } from './types'; +import { AnnotationQuery, AnnotationSupport } from '@grafana/data'; + +import { LegacyAnnotation, OpenTsdbQuery } from './types'; // this becomes the target in the migrated annotations const migrateLegacyAnnotation = (json: LegacyAnnotation) => { @@ -13,8 +15,10 @@ const migrateLegacyAnnotation = (json: LegacyAnnotation) => { return annotation; }; -// eslint-ignore-next-line -export const prepareAnnotation = (json: any) => { +export const prepareAnnotation: AnnotationSupport< + OpenTsdbQuery, + AnnotationQuery +>['prepareAnnotation'] = (json) => { const resultingTarget = json.target && typeof json.target !== 'string' ? json.target : migrateLegacyAnnotation(json); json.target = resultingTarget; diff --git a/public/app/plugins/datasource/tempo/resultTransformer.ts b/public/app/plugins/datasource/tempo/resultTransformer.ts index b41458590d1..4557b1137f7 100644 --- a/public/app/plugins/datasource/tempo/resultTransformer.ts +++ b/public/app/plugins/datasource/tempo/resultTransformer.ts @@ -48,11 +48,11 @@ function getAttributeValue(value: collectorTypes.opentelemetryProto.common.v1.An } if (value.intValue !== undefined) { - return Number.parseInt(value.intValue as any, 10); + return Number.parseInt(String(value.intValue), 10); } if (value.doubleValue) { - return Number.parseFloat(value.doubleValue as any); + return Number.parseFloat(String(value.doubleValue)); } if (value.arrayValue) { diff --git a/public/app/plugins/panel/barchart/utils.ts b/public/app/plugins/panel/barchart/utils.ts index 117d43e327a..0e85a09c27b 100644 --- a/public/app/plugins/panel/barchart/utils.ts +++ b/public/app/plugins/panel/barchart/utils.ts @@ -52,7 +52,7 @@ interface BarSeries { export function prepSeries( frames: DataFrame[], - fieldConfig: FieldConfigSource, + fieldConfig: FieldConfigSource, stacking: StackingMode, theme: GrafanaTheme2, xFieldName?: string, diff --git a/public/app/plugins/panel/histogram/migrations.ts b/public/app/plugins/panel/histogram/migrations.ts index 983aaedc8a6..319c2082d38 100644 --- a/public/app/plugins/panel/histogram/migrations.ts +++ b/public/app/plugins/panel/histogram/migrations.ts @@ -38,11 +38,10 @@ export const changeToHistogramPanelMigrationHandler: PanelTypeChangedHandler = ( return {}; }; -function graphToHistogramOptions(angular: any): { +function graphToHistogramOptions(graphOptions: GraphOptions): { fieldConfig: FieldConfigSource; options: Options; } { - const graphOptions: GraphOptions = angular; let histogramFieldConfig: HistogramFieldConfig = {}; const options: Options = { legend: { diff --git a/public/app/plugins/panel/live/LiveChannelEditor.tsx b/public/app/plugins/panel/live/LiveChannelEditor.tsx index 08bb3d63766..138bea0bfd4 100644 --- a/public/app/plugins/panel/live/LiveChannelEditor.tsx +++ b/public/app/plugins/panel/live/LiveChannelEditor.tsx @@ -15,7 +15,7 @@ import { getManagedChannelInfo } from 'app/features/live/info'; import { LivePanelOptions } from './types'; -type Props = StandardEditorProps, any, LivePanelOptions>; +type Props = StandardEditorProps, {}, LivePanelOptions>; const scopes: Array> = [ { label: 'Grafana', value: LiveChannelScope.Grafana, description: 'Core grafana live features' }, diff --git a/public/app/plugins/panel/table/migrations.ts b/public/app/plugins/panel/table/migrations.ts index f92d5b60836..734376e18be 100644 --- a/public/app/plugins/panel/table/migrations.ts +++ b/public/app/plugins/panel/table/migrations.ts @@ -75,7 +75,7 @@ const generateThresholds = (thresholds: string[], colors: string[]) => { }; const migrateTransformations = ( - panel: PanelModel> | any, + panel: PanelModel>, oldOpts: { columns: any; transform: Transformations } ) => { const transformations: Transformation[] = panel.transformations ?? []; @@ -237,7 +237,7 @@ const migrateDefaults = (prevDefaults: Style) => { * This is called when the panel changes from another panel */ export const tablePanelChangedHandler = ( - panel: PanelModel> | any, + panel: PanelModel>, prevPluginId: string, prevOptions: any ) => { diff --git a/public/app/plugins/panel/text/TextPanelEditor.tsx b/public/app/plugins/panel/text/TextPanelEditor.tsx index 29fb1d3687f..dd37e638042 100644 --- a/public/app/plugins/panel/text/TextPanelEditor.tsx +++ b/public/app/plugins/panel/text/TextPanelEditor.tsx @@ -12,7 +12,7 @@ import { import { Options, TextMode } from './panelcfg.gen'; -export const TextPanelEditor = ({ value, onChange, context }: StandardEditorProps) => { +export const TextPanelEditor = ({ value, onChange, context }: StandardEditorProps) => { const language = useMemo(() => context.options?.mode ?? TextMode.Markdown, [context]); const styles = useStyles2(getStyles); diff --git a/public/app/plugins/panel/xychart/AutoEditor.tsx b/public/app/plugins/panel/xychart/AutoEditor.tsx index 3ceb607b321..bf4b7773a88 100644 --- a/public/app/plugins/panel/xychart/AutoEditor.tsx +++ b/public/app/plugins/panel/xychart/AutoEditor.tsx @@ -19,7 +19,7 @@ interface XYInfo { yFields: Array>; } -export const AutoEditor = ({ value, onChange, context }: StandardEditorProps) => { +export const AutoEditor = ({ value, onChange, context }: StandardEditorProps) => { const frameNames = useMemo(() => { if (context?.data?.length) { return context.data.map((f, idx) => ({ diff --git a/public/app/plugins/panel/xychart/v2/SeriesEditor.tsx b/public/app/plugins/panel/xychart/v2/SeriesEditor.tsx index 7fe1f777b45..4d9e1ebcf51 100644 --- a/public/app/plugins/panel/xychart/v2/SeriesEditor.tsx +++ b/public/app/plugins/panel/xychart/v2/SeriesEditor.tsx @@ -26,7 +26,7 @@ export const SeriesEditor = ({ const style = useStyles2(getStyles); // reset opts when mapping changes (no way to do this in panel opts builder?) - const mapping = context.options?.mapping as SeriesMapping; + const mapping = context.options?.mapping; const prevMapping = usePrevious(mapping); const mappingChanged = prevMapping != null && mapping !== prevMapping; diff --git a/public/app/plugins/panel/xychart/v2/migrations.ts b/public/app/plugins/panel/xychart/v2/migrations.ts index 7fe76f5290e..0b3c5db64a9 100644 --- a/public/app/plugins/panel/xychart/v2/migrations.ts +++ b/public/app/plugins/panel/xychart/v2/migrations.ts @@ -11,7 +11,7 @@ export const xyChartMigrationHandler = (panel: PanelModel): Options => { return migrateOptions(panel); } - return panel.options as Options; + return panel.options; }; function migrateOptions(panel: PanelModel): Options { diff --git a/public/app/plugins/panel/xychart/v2/utils.ts b/public/app/plugins/panel/xychart/v2/utils.ts index a4e86800cbc..2df8612b398 100644 --- a/public/app/plugins/panel/xychart/v2/utils.ts +++ b/public/app/plugins/panel/xychart/v2/utils.ts @@ -40,7 +40,7 @@ export function prepSeries( mapping: SeriesMapping, mappedSeries: XYSeriesConfig[], frames: DataFrame[], - fieldConfig: FieldConfigSource + fieldConfig: FieldConfigSource ) { cacheFieldDisplayNames(frames); decoupleHideFromState(frames, fieldConfig); diff --git a/public/app/types/appEvent.ts b/public/app/types/appEvent.ts index b5ee46d553d..999248e12e2 100644 --- a/public/app/types/appEvent.ts +++ b/public/app/types/appEvent.ts @@ -17,6 +17,10 @@ export interface AppEventEmitter { } export interface AppEventConsumer { - onAppEvent(name: string, callback: (event: IAngularEvent, ...args: any[]) => void, localScope?: any): void; - onAppEvent(event: AppEvent, callback: (event: IAngularEvent, ...args: any[]) => void, localScope?: any): void; + onAppEvent(name: string, callback: (event: IAngularEvent, ...args: unknown[]) => void, localScope?: any): void; + onAppEvent( + event: AppEvent, + callback: (event: IAngularEvent, ...args: unknown[]) => void, + localScope?: any + ): void; } diff --git a/public/app/types/events.ts b/public/app/types/events.ts index 9d742e99e8a..0b03e21b20d 100644 --- a/public/app/types/events.ts +++ b/public/app/types/events.ts @@ -44,20 +44,6 @@ export interface ShowConfirmModalPayload { onAltAction?: () => void; } -export interface DataSourceResponse { - data: T; - readonly status: number; - readonly statusText: string; - readonly ok: boolean; - readonly headers: Headers; - readonly redirected: boolean; - readonly type: ResponseType; - readonly url: string; - readonly config: any; -} - -type DataSourceResponsePayload = DataSourceResponse; - export interface ToggleKioskModePayload { exit?: boolean; } @@ -70,7 +56,7 @@ export interface GraphClickedPayload { export interface ThresholdChangedPayload { threshold: any; - handleIndex: any; + handleIndex: number; } export interface DashScrollPayload { @@ -85,8 +71,6 @@ export interface PanelChangeViewPayload {} * Events */ -export const dsRequestResponse = eventFactory('ds-request-response'); -export const dsRequestError = eventFactory('ds-request-error'); export const templateVariableValueUpdated = eventFactory('template-variable-value-updated'); export const graphClicked = eventFactory('graph-click'); diff --git a/public/swagger/K8sNameLookup.tsx b/public/swagger/K8sNameLookup.tsx index 032b89e819f..568a53c40db 100644 --- a/public/swagger/K8sNameLookup.tsx +++ b/public/swagger/K8sNameLookup.tsx @@ -49,12 +49,12 @@ export function K8sNameLookup(props: Props) { console.log('LIST', url, table); const options: Array> = []; if (table.rows?.length) { - table.rows.forEach((row: any) => { + for (const row of table.rows) { const n = row.object?.metadata?.name; if (n) { options.push({ label: n, value: n }); } - }); + } } else { setPlaceholder('No items found'); } diff --git a/public/swagger/index.tsx b/public/swagger/index.tsx index 9a2e3bbacf5..85a458ca02d 100644 --- a/public/swagger/index.tsx +++ b/public/swagger/index.tsx @@ -29,7 +29,7 @@ const tt = window.trustedTypes; if (tt?.createPolicy) { tt.createPolicy('default', { createHTML: (string, sink) => DOMPurify.sanitize(string, { RETURN_TRUSTED_TYPE: true }) as unknown as string, - createScriptURL: (url, sink) => textUtil.sanitizeUrl(url) as unknown as string, + createScriptURL: (url, sink) => textUtil.sanitizeUrl(url), createScript: (script, sink) => script, }); } diff --git a/public/test/core/redux/reduxTester.ts b/public/test/core/redux/reduxTester.ts index 8149ed89ccd..787ce13b59b 100644 --- a/public/test/core/redux/reduxTester.ts +++ b/public/test/core/redux/reduxTester.ts @@ -1,5 +1,5 @@ import { AnyAction, configureStore, EnhancedStore, Reducer, Tuple } from '@reduxjs/toolkit'; -import { Middleware, StoreEnhancer, UnknownAction } from 'redux'; +import { Middleware, Store, StoreEnhancer, UnknownAction } from 'redux'; import { thunk, ThunkDispatch, ThunkMiddleware } from 'redux-thunk'; import { setStore } from '../../../app/store/store'; @@ -79,7 +79,7 @@ export const reduxTester = (args?: ReduxTesterArguments): ReduxTes preloadedState, }); - setStore(store as any); + setStore(store as Store); return instance; }; diff --git a/public/test/core/thunk/thunkTester.ts b/public/test/core/thunk/thunkTester.ts index 5e8d5c5f3b9..1fb1d0cee3c 100644 --- a/public/test/core/thunk/thunkTester.ts +++ b/public/test/core/thunk/thunkTester.ts @@ -9,7 +9,7 @@ export interface ThunkGiven { } export interface ThunkWhen { - whenThunkIsDispatched: (...args: any) => Promise>>; + whenThunkIsDispatched: (...args: unknown[]) => Promise>>; } export const thunkTester = (initialState: unknown, debug?: boolean): ThunkGiven => { @@ -23,7 +23,7 @@ export const thunkTester = (initialState: unknown, debug?: boolean): ThunkGiven return instance; }; - const whenThunkIsDispatched = async (...args: any): Promise>> => { + const whenThunkIsDispatched = async (...args: unknown[]): Promise>> => { await store.dispatch(thunkUnderTest(...args)); dispatchedActions = store.getActions(); diff --git a/public/test/lib/common.ts b/public/test/lib/common.ts deleted file mode 100644 index 8495158b6a6..00000000000 --- a/public/test/lib/common.ts +++ /dev/null @@ -1,7 +0,0 @@ -const _global = window as any; -const angularMocks = { - module: _global.module, - inject: _global.inject, -}; - -export { angularMocks }; diff --git a/public/test/specs/helpers.ts b/public/test/specs/helpers.ts index ad14ee1d4f2..cfacbb9f46e 100644 --- a/public/test/specs/helpers.ts +++ b/public/test/specs/helpers.ts @@ -1,13 +1,10 @@ -import { each, template } from 'lodash'; +import { template } from 'lodash'; import { RawTimeRange, PanelPluginMeta, dateMath } from '@grafana/data'; -import { GrafanaRootScope } from 'app/angular/GrafanaCtrl'; import config from 'app/core/config'; import { ContextSrv } from 'app/core/services/context_srv'; import { PanelModel } from 'app/features/dashboard/state/PanelModel'; -import { angularMocks } from '../lib/common'; - export function ControllerTestContext(this: any) { const self = this; @@ -30,75 +27,16 @@ export function ControllerTestContext(this: any) { }; this.isUtc = false; - this.providePhase = (mocks: any) => { - return angularMocks.module(($provide: any) => { - $provide.value('contextSrv', self.contextSrv); - $provide.value('datasourceSrv', self.datasourceSrv); - $provide.value('annotationsSrv', self.annotationsSrv); - $provide.value('timeSrv', self.timeSrv); - $provide.value('templateSrv', self.templateSrv); - $provide.value('$element', self.$element); - $provide.value('$sanitize', self.$sanitize); - each(mocks, (value, key) => { - $provide.value(key, value); - }); - }); - }; - this.createPanelController = (Ctrl: any) => { - return angularMocks.inject(($controller: any, $rootScope: GrafanaRootScope, $browser: any) => { - self.scope = $rootScope.$new(); - self.$browser = $browser; + return () => { self.panel = new PanelModel({ type: 'test' }); self.dashboard = { meta: {} }; self.isUtc = false; self.dashboard.getTimezone = () => { return self.isUtc ? 'utc' : 'browser'; }; - - $rootScope.appEvent = jest.fn(); - $rootScope.onAppEvent = jest.fn(); - $rootScope.colors = []; - - for (let i = 0; i < 50; i++) { - $rootScope.colors.push('#' + i); - } - config.panels['test'] = { info: {} } as PanelPluginMeta; - self.ctrl = $controller( - Ctrl, - { $scope: self.scope }, - { - panel: self.panel, - dashboard: self.dashboard, - } - ); - }); - }; - - this.createControllerPhase = (controllerName: string) => { - return angularMocks.inject(($controller: any, $rootScope: GrafanaRootScope, $browser: any) => { - self.scope = $rootScope.$new(); - self.$browser = $browser; - self.scope.contextSrv = {}; - self.scope.panel = {}; - self.scope.dashboard = { meta: {} }; - self.scope.dashboardMeta = {}; - self.scope.dashboardViewState = DashboardViewStateStub(); - self.scope.appEvent = jest.fn(); - self.scope.onAppEvent = jest.fn(); - - $rootScope.colors = []; - for (let i = 0; i < 50; i++) { - $rootScope.colors.push('#' + i); - } - - self.scope.skipDataOnInit = true; - self.scope.skipAutoInit = true; - self.controller = $controller(controllerName, { - $scope: self.scope, - }); - }); + }; }; this.setIsUtc = (isUtc = false) => {