diff --git a/.betterer.results b/.betterer.results index 14165ffed3a..9648cb3d1e3 100644 --- a/.betterer.results +++ b/.betterer.results @@ -19,10 +19,6 @@ exports[`better eslint`] = { [0, 0, 0, "Do not use any type assertions.", "0"], [0, 0, 0, "Do not use any type assertions.", "1"] ], - "packages/grafana-data/src/dataframe/DataFrameView.test.ts:5381": [ - [0, 0, 0, "Unexpected any. Specify a different type.", "0"], - [0, 0, 0, "Unexpected any. Specify a different type.", "1"] - ], "packages/grafana-data/src/dataframe/DataFrameView.ts:5381": [ [0, 0, 0, "Unexpected any. Specify a different type.", "0"], [0, 0, 0, "Do not use any type assertions.", "1"], @@ -40,14 +36,12 @@ 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, "Do not use any type assertions.", "10"], [0, 0, 0, "Unexpected any. Specify a different type.", "11"], [0, 0, 0, "Do not use any type assertions.", "12"], [0, 0, 0, "Unexpected any. Specify a different type.", "13"], - [0, 0, 0, "Do not use any type assertions.", "14"], - [0, 0, 0, "Unexpected any. Specify a different type.", "15"], - [0, 0, 0, "Unexpected any. Specify a different type.", "16"], - [0, 0, 0, "Do not use any type assertions.", "17"] + [0, 0, 0, "Unexpected any. Specify a different type.", "14"], + [0, 0, 0, "Do not use any type assertions.", "15"] ], "packages/grafana-data/src/dataframe/StreamingDataFrame.ts:5381": [ [0, 0, 0, "Do not use any type assertions.", "0"], @@ -55,8 +49,7 @@ exports[`better eslint`] = { [0, 0, 0, "Do not use any type assertions.", "2"], [0, 0, 0, "Do not use any type assertions.", "3"], [0, 0, 0, "Do not use any type assertions.", "4"], - [0, 0, 0, "Do not use any type assertions.", "5"], - [0, 0, 0, "Do not use any type assertions.", "6"] + [0, 0, 0, "Do not use any type assertions.", "5"] ], "packages/grafana-data/src/dataframe/dimensions.ts:5381": [ [0, 0, 0, "Unexpected any. Specify a different type.", "0"] @@ -129,10 +122,6 @@ exports[`better eslint`] = { [0, 0, 0, "Unexpected any. Specify a different type.", "0"], [0, 0, 0, "Unexpected any. Specify a different type.", "1"] ], - "packages/grafana-data/src/events/common.ts:5381": [ - [0, 0, 0, "Unexpected any. Specify a different type.", "0"], - [0, 0, 0, "Unexpected any. Specify a different type.", "1"] - ], "packages/grafana-data/src/events/types.ts:5381": [ [0, 0, 0, "Unexpected any. Specify a different type.", "0"], [0, 0, 0, "Unexpected any. Specify a different type.", "1"], @@ -148,21 +137,13 @@ exports[`better eslint`] = { "packages/grafana-data/src/field/overrides/processors.ts:5381": [ [0, 0, 0, "Unexpected any. Specify a different type.", "0"], [0, 0, 0, "Unexpected any. Specify a different type.", "1"], - [0, 0, 0, "Unexpected any. Specify a different type.", "2"], - [0, 0, 0, "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.", "2"], + [0, 0, 0, "Unexpected any. Specify a different type.", "3"], + [0, 0, 0, "Do not use any type assertions.", "4"], + [0, 0, 0, "Unexpected any. Specify a different type.", "5"], [0, 0, 0, "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, "Do not use any type assertions.", "10"] - ], - "packages/grafana-data/src/field/scale.ts:5381": [ - [0, 0, 0, "Do not use any type assertions.", "0"], - [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.", "8"] ], "packages/grafana-data/src/field/standardFieldConfigEditorRegistry.ts:5381": [ [0, 0, 0, "Unexpected any. Specify a different type.", "0"], @@ -187,9 +168,6 @@ exports[`better eslint`] = { [0, 0, 0, "Do not use any type assertions.", "6"], [0, 0, 0, "Do not use any type assertions.", "7"] ], - "packages/grafana-data/src/panel/getPanelOptionsWithDefaults.ts:5381": [ - [0, 0, 0, "Unexpected any. Specify a different type.", "0"] - ], "packages/grafana-data/src/panel/registryFactories.ts:5381": [ [0, 0, 0, "Do not use any type assertions.", "0"] ], @@ -211,37 +189,15 @@ exports[`better eslint`] = { "packages/grafana-data/src/transformations/transformDataFrame.ts:5381": [ [0, 0, 0, "Unexpected any. Specify a different type.", "0"] ], - "packages/grafana-data/src/transformations/transformers/groupBy.ts:5381": [ - [0, 0, 0, "Unexpected any. Specify a different type.", "0"], - [0, 0, 0, "Unexpected any. Specify a different type.", "1"] - ], - "packages/grafana-data/src/transformations/transformers/groupingToMatrix.ts:5381": [ - [0, 0, 0, "Unexpected any. Specify a different type.", "0"] - ], - "packages/grafana-data/src/transformations/transformers/histogram.ts:5381": [ - [0, 0, 0, "Unexpected any. Specify a different type.", "0"] - ], "packages/grafana-data/src/transformations/transformers/joinDataFrames.ts:5381": [ [0, 0, 0, "Unexpected any. Specify a different type.", "0"] ], - "packages/grafana-data/src/transformations/transformers/merge.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"] - ], "packages/grafana-data/src/transformations/transformers/nulls/nullInsertThreshold.ts:5381": [ [0, 0, 0, "Do not use any type assertions.", "0"], [0, 0, 0, "Unexpected any. Specify a different type.", "1"], [0, 0, 0, "Unexpected any. Specify a different type.", "2"], [0, 0, 0, "Unexpected any. Specify a different type.", "3"] ], - "packages/grafana-data/src/transformations/transformers/nulls/nullToUndefThreshold.ts:5381": [ - [0, 0, 0, "Unexpected any. Specify a different type.", "0"], - [0, 0, 0, "Unexpected any. Specify a different type.", "1"], - [0, 0, 0, "Do not use any type assertions.", "2"] - ], "packages/grafana-data/src/transformations/transformers/reduce.ts:5381": [ [0, 0, 0, "Unexpected any. Specify a different type.", "0"], [0, 0, 0, "Unexpected any. Specify a different type.", "1"] @@ -398,8 +354,7 @@ exports[`better eslint`] = { ], "packages/grafana-data/src/types/plugin.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, "Do not use any type assertions.", "1"] ], "packages/grafana-data/src/types/select.ts:5381": [ [0, 0, 0, "Unexpected any. Specify a different type.", "0"], @@ -540,34 +495,26 @@ exports[`better eslint`] = { [0, 0, 0, "Unexpected any. Specify a different type.", "0"] ], "packages/grafana-data/src/utils/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, "Unexpected any. Specify a different type.", "2"], - [0, 0, 0, "Do not use any type assertions.", "3"], - [0, 0, 0, "Do not use any type assertions.", "4"] - ], - "packages/grafana-data/src/utils/fieldParser.ts:5381": [ - [0, 0, 0, "Unexpected any. Specify a different type.", "0"] + [0, 0, 0, "Do not use any type assertions.", "0"], + [0, 0, 0, "Do not use any type assertions.", "1"] ], "packages/grafana-data/src/utils/flotPairs.ts:5381": [ [0, 0, 0, "Unexpected any. Specify a different type.", "0"] ], "packages/grafana-data/src/utils/location.ts:5381": [ [0, 0, 0, "Do not use any type assertions.", "0"], - [0, 0, 0, "Unexpected any. Specify a different type.", "1"], - [0, 0, 0, "Unexpected any. Specify a different type.", "2"] + [0, 0, 0, "Unexpected any. Specify a different type.", "1"] ], "packages/grafana-data/src/utils/url.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, "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, "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.", "7"], + [0, 0, 0, "Unexpected any. Specify a different type.", "8"] ], "packages/grafana-data/src/utils/valueMappings.ts:5381": [ [0, 0, 0, "Unexpected any. Specify a different type.", "0"], @@ -587,8 +534,7 @@ exports[`better eslint`] = { [0, 0, 0, "Unexpected any. Specify a different type.", "2"] ], "packages/grafana-data/src/vector/CircularVector.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"] ], "packages/grafana-data/src/vector/ConstantVector.ts:5381": [ [0, 0, 0, "Unexpected any. Specify a different type.", "0"] @@ -606,8 +552,7 @@ exports[`better eslint`] = { [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.", "9"] ], "packages/grafana-data/src/vector/SortedVector.ts:5381": [ [0, 0, 0, "Unexpected any. Specify a different type.", "0"] diff --git a/packages/grafana-data/src/dataframe/DataFrameView.test.ts b/packages/grafana-data/src/dataframe/DataFrameView.test.ts index 8975da7b24f..dca646c3ec0 100644 --- a/packages/grafana-data/src/dataframe/DataFrameView.test.ts +++ b/packages/grafana-data/src/dataframe/DataFrameView.test.ts @@ -46,7 +46,12 @@ describe('dataFrameView', () => { it('Should support array indexes', () => { expect(vector.length).toEqual(3); - const first = vector.get(0) as any; + const first = vector.get(0) as unknown as [ + MySpecialObject['time'], + MySpecialObject['name'], + MySpecialObject['value'], + MySpecialObject['more'], + ]; expect(first[0]).toEqual(100); expect(first[1]).toEqual('a'); expect(first[2]).toEqual(1); @@ -84,7 +89,10 @@ describe('dataFrameView', () => { }); it('Can handle fields with number name', () => { - const view = new DataFrameView( + const view = new DataFrameView<{ + '1': string; + '2': string; + }>( new MutableDataFrame({ fields: [ { name: '1', type: FieldType.string, values: ['a'] }, @@ -93,7 +101,7 @@ describe('dataFrameView', () => { }) ); - const obj = view.get(0) as any; + const obj = view.get(0); expect(obj['1']).toEqual('a'); expect(obj['2']).toEqual('b'); }); diff --git a/packages/grafana-data/src/dataframe/MutableDataFrame.ts b/packages/grafana-data/src/dataframe/MutableDataFrame.ts index 7d96a8f592c..84a02a33679 100644 --- a/packages/grafana-data/src/dataframe/MutableDataFrame.ts +++ b/packages/grafana-data/src/dataframe/MutableDataFrame.ts @@ -162,7 +162,7 @@ export class MutableDataFrame extends FunctionalVector implements Da return parser; } - private parseValue(field: Field, v: any): any { + private parseValue(field: Field, v: string) { let p = this.parsers?.get(field); if (!p) { p = this.setParser(field, makeFieldParser(v, field)); diff --git a/packages/grafana-data/src/dataframe/StreamingDataFrame.ts b/packages/grafana-data/src/dataframe/StreamingDataFrame.ts index d0de4ef1eeb..36fe7a77e22 100644 --- a/packages/grafana-data/src/dataframe/StreamingDataFrame.ts +++ b/packages/grafana-data/src/dataframe/StreamingDataFrame.ts @@ -123,7 +123,7 @@ export class StreamingDataFrame implements DataFrame { dataFrameDTO.fields = dataFrameDTO.fields.map((f) => ({ ...f, - values: (f.values as unknown[]).slice(numberOfItemsToRemove), + values: f.values?.slice(numberOfItemsToRemove), })); const length = dataFrameDTO.fields[0]?.values?.length ?? 0; diff --git a/packages/grafana-data/src/events/common.ts b/packages/grafana-data/src/events/common.ts index 588b6a6d30d..6b480a834f3 100644 --- a/packages/grafana-data/src/events/common.ts +++ b/packages/grafana-data/src/events/common.ts @@ -17,8 +17,8 @@ export interface DataHoverPayload { dataId?: string; // identifying string to correlate data between publishers and subscribers // When dragging, this will capture the point when the mouse was down - point: Record; // { time: 5678, lengthft: 456 } // each axis|scale gets a value - down?: Record; + point: Record; // { time: 5678, lengthft: 456 } // each axis|scale gets a value + down?: Record; } /** @alpha */ diff --git a/packages/grafana-data/src/field/overrides/processors.ts b/packages/grafana-data/src/field/overrides/processors.ts index 409b0bdab68..5394c692cd5 100644 --- a/packages/grafana-data/src/field/overrides/processors.ts +++ b/packages/grafana-data/src/field/overrides/processors.ts @@ -33,7 +33,7 @@ export const numberOverrideProcessor = ( }; export const displayNameOverrideProcessor = ( - value: any, + value: unknown, context: FieldOverrideContext, settings?: StringFieldConfigSettings ) => { @@ -100,14 +100,14 @@ export interface StringFieldConfigSettings { } export const stringOverrideProcessor = ( - value: any, + value: unknown, context: FieldOverrideContext, settings?: StringFieldConfigSettings ) => { if (value === null || value === undefined) { return value; } - if (settings && settings.expandTemplateVars && context.replaceVariables) { + if (settings && settings.expandTemplateVars && context.replaceVariables && typeof value === 'string') { return context.replaceVariables(value, context.field!.state!.scopedVars); } return `${value}`; diff --git a/packages/grafana-data/src/field/scale.ts b/packages/grafana-data/src/field/scale.ts index e97b01faf94..c8624e6086f 100644 --- a/packages/grafana-data/src/field/scale.ts +++ b/packages/grafana-data/src/field/scale.ts @@ -9,7 +9,7 @@ import { getActiveThresholdForValue } from './thresholds'; export interface ColorScaleValue { percent: number; // 0-1 - threshold: Threshold; + threshold: Threshold | undefined; color: string; } @@ -49,13 +49,13 @@ function getBooleanScaleCalculator(field: Field, theme: GrafanaTheme2): ScaleCal const trueValue: ColorScaleValue = { color: theme.visualization.getColorByName('green'), percent: 1, - threshold: undefined as unknown as Threshold, + threshold: undefined, }; const falseValue: ColorScaleValue = { color: theme.visualization.getColorByName('red'), percent: 0, - threshold: undefined as unknown as Threshold, + threshold: undefined, }; const mode = getFieldColorModeForField(field); diff --git a/packages/grafana-data/src/panel/getPanelOptionsWithDefaults.ts b/packages/grafana-data/src/panel/getPanelOptionsWithDefaults.ts index 584ea189989..f3a8d44faf7 100644 --- a/packages/grafana-data/src/panel/getPanelOptionsWithDefaults.ts +++ b/packages/grafana-data/src/panel/getPanelOptionsWithDefaults.ts @@ -111,11 +111,10 @@ export function filterFieldConfigOverrides( .filter((x) => x.properties.length > 0); } -function cleanProperties(obj: any, parentPath: string, fieldConfigRegistry: FieldConfigOptionsRegistry) { +function cleanProperties(obj: object, parentPath: string, fieldConfigRegistry: FieldConfigOptionsRegistry) { let found = false; - for (const propName of Object.keys(obj)) { - const value = obj[propName]; + for (const [propName, value] of Object.entries(obj)) { const fullPath = `${parentPath}${propName}`; const existsInRegistry = !!fieldConfigRegistry.getIfExists(fullPath); diff --git a/packages/grafana-data/src/transformations/transformers/groupBy.ts b/packages/grafana-data/src/transformations/transformers/groupBy.ts index e57d15ed9b3..3fd95db316b 100644 --- a/packages/grafana-data/src/transformations/transformers/groupBy.ts +++ b/packages/grafana-data/src/transformations/transformers/groupBy.ts @@ -117,7 +117,7 @@ export const groupByTransformer: DataTransformerInfo const fields: Field[] = []; for (const field of groupByFields) { - const values: any[] = []; + const values: unknown[] = []; const fieldName = getFieldDisplayName(field); valuesByGroupKey.forEach((value) => { @@ -142,7 +142,7 @@ export const groupByTransformer: DataTransformerInfo const fieldName = getFieldDisplayName(field); const aggregations = options.fields[fieldName].aggregations; - const valuesByAggregation: Record = {}; + const valuesByAggregation: Record = {}; valuesByGroupKey.forEach((value) => { const fieldWithValuesForGroup = value[fieldName]; diff --git a/packages/grafana-data/src/transformations/transformers/groupingToMatrix.ts b/packages/grafana-data/src/transformations/transformers/groupingToMatrix.ts index f600b5ee7ba..bb1dcd445d4 100644 --- a/packages/grafana-data/src/transformations/transformers/groupingToMatrix.ts +++ b/packages/grafana-data/src/transformations/transformers/groupingToMatrix.ts @@ -89,7 +89,7 @@ export const groupingToMatrixTransformer: DataTransformerInfo a - b; export interface HistogramTransformerInputs { @@ -496,7 +496,7 @@ export function incrRoundDn(num: number, incr: number) { function histogram( vals: number[], getBucket: (v: number) => number, - filterOut?: any[] | null, + filterOut?: number[], sort?: ((a: number, b: number) => number) | null ): AlignedData { let hist = new Map(); diff --git a/packages/grafana-data/src/transformations/transformers/merge.ts b/packages/grafana-data/src/transformations/transformers/merge.ts index 5abf270b6e5..4c783acf42c 100644 --- a/packages/grafana-data/src/transformations/transformers/merge.ts +++ b/packages/grafana-data/src/transformations/transformers/merge.ts @@ -73,7 +73,7 @@ export const mergeTransformer: DataTransformerInfo = { return dataFrames; } - const valuesByKey: Record>> = {}; + const valuesByKey: Record>> = {}; const valuesInOrder: ValuePointer[] = []; const keyFactory = createKeyFactory(data, fieldIndexByName, fieldNamesForKey); const valueMapper = createValueMapper(data, fieldNames, fieldIndexByName); @@ -157,7 +157,7 @@ const createValueMapper = ( fieldIndexByName: Record> ) => { return (frameIndex: number, valueIndex: number) => { - const value: Record = {}; + const value: Record = {}; const fieldNames = Array.from(fieldByName); for (const fieldName of fieldNames) { @@ -188,7 +188,7 @@ const createValueMapper = ( }; }; -const isMergable = (existing: Record, value: Record): boolean => { +const isMergable = (existing: Record, value: Record): boolean => { let mergable = true; for (const prop in value) { @@ -217,7 +217,7 @@ const fieldExistsInAllFrames = ( return Object.keys(fieldIndexByName[field.name]).length === data.length; }; -const createPointer = (key: string, valuesByKey: Record>>): ValuePointer => { +const createPointer = (key: string, valuesByKey: Record>>): ValuePointer => { return { key, index: valuesByKey[key].length - 1, diff --git a/packages/grafana-data/src/transformations/transformers/nulls/nullToUndefThreshold.ts b/packages/grafana-data/src/transformations/transformers/nulls/nullToUndefThreshold.ts index dacc82a63fa..7003ede81ab 100644 --- a/packages/grafana-data/src/transformations/transformers/nulls/nullToUndefThreshold.ts +++ b/packages/grafana-data/src/transformations/transformers/nulls/nullToUndefThreshold.ts @@ -1,6 +1,6 @@ // mutates all nulls -> undefineds in the fieldValues array for value-less refValues ranges below maxThreshold // refValues is typically a time array and maxThreshold is the allowable distance between in time -export function nullToUndefThreshold(refValues: number[], fieldValues: any[], maxThreshold: number): any[] { +export function nullToUndefThreshold(refValues: number[], fieldValues: unknown[], maxThreshold: number) { let prevRef; let nullIdx; @@ -12,8 +12,8 @@ export function nullToUndefThreshold(refValues: number[], fieldValues: any[], ma nullIdx = i; } } else { - if (nullIdx != null) { - if (refValues[i] - (prevRef as number) < maxThreshold) { + if (nullIdx != null && prevRef != null) { + if (refValues[i] - prevRef < maxThreshold) { while (nullIdx < i) { fieldValues[nullIdx++] = undefined; } diff --git a/packages/grafana-data/src/types/plugin.ts b/packages/grafana-data/src/types/plugin.ts index b67f1294655..7d07e91f018 100644 --- a/packages/grafana-data/src/types/plugin.ts +++ b/packages/grafana-data/src/types/plugin.ts @@ -203,7 +203,7 @@ export class GrafanaPlugin { /** * @deprecated -- this is no longer necessary and will be removed */ - setChannelSupport(support: any) { + setChannelSupport() { console.warn('[deprecation] plugin is using ignored option: setChannelSupport', this.meta); return this; } diff --git a/packages/grafana-data/src/utils/datasource.ts b/packages/grafana-data/src/utils/datasource.ts index 42f8811cce9..19d7971986a 100644 --- a/packages/grafana-data/src/utils/datasource.ts +++ b/packages/grafana-data/src/utils/datasource.ts @@ -94,7 +94,7 @@ export const onUpdateDatasourceResetOption = export function updateDatasourcePluginOption( props: DataSourcePluginOptionsEditorProps, key: keyof DataSourceSettings, - val: any + val: unknown ) { const config = props.options; @@ -107,7 +107,7 @@ export function updateDatasourcePluginOption( props: DataSourcePluginOptionsEditorProps, key: K, - val: any + val: unknown ) => { const config = props.options; @@ -123,7 +123,7 @@ export const updateDatasourcePluginJsonDataOption = ( props: DataSourcePluginOptionsEditorProps, key: string, - val: any + val: unknown ) => { const config = props.options; diff --git a/packages/grafana-data/src/utils/fieldParser.ts b/packages/grafana-data/src/utils/fieldParser.ts index fd1b07ec519..c6ab0183be1 100644 --- a/packages/grafana-data/src/utils/fieldParser.ts +++ b/packages/grafana-data/src/utils/fieldParser.ts @@ -1,7 +1,7 @@ import { guessFieldTypeFromValue } from '../dataframe/processDataFrame'; import { Field, FieldType } from '../types/dataFrame'; -export function makeFieldParser(value: unknown, field: Field): (value: string) => any { +export function makeFieldParser(value: unknown, field: Field) { if (!field.type) { if (field.name === 'time' || field.name === 'Time') { field.type = FieldType.time; diff --git a/packages/grafana-data/src/utils/location.ts b/packages/grafana-data/src/utils/location.ts index 7897e860c52..44d42f247a5 100644 --- a/packages/grafana-data/src/utils/location.ts +++ b/packages/grafana-data/src/utils/location.ts @@ -69,7 +69,7 @@ const assureBaseUrl = (url: string): string => { * @param searchParamsToUpdate * @returns */ -const getUrlForPartial = (location: Location, searchParamsToUpdate: Record) => { +const getUrlForPartial = (location: Location, searchParamsToUpdate: UrlQueryMap) => { const searchParams = urlUtil.parseKeyValue( location.search.startsWith('?') ? location.search.substring(1) : location.search ); diff --git a/packages/grafana-data/src/utils/url.ts b/packages/grafana-data/src/utils/url.ts index e3a602e0059..2ee35d9f449 100644 --- a/packages/grafana-data/src/utils/url.ts +++ b/packages/grafana-data/src/utils/url.ts @@ -54,7 +54,7 @@ function toUrlParams(a: any, encodeAsAngularJS = true) { encodeURIComponentAsAngularJS(value, pctEncodeSpaces) : (value: EncodeURIComponentParams, _: boolean) => encodeURIComponent(value); - const isArray = (obj: any) => { + const isArray = (obj: unknown) => { return Object.prototype.toString.call(obj) === '[object Array]'; }; diff --git a/packages/grafana-data/src/vector/CircularVector.ts b/packages/grafana-data/src/vector/CircularVector.ts index aa70ae27578..fa3bd2503a8 100644 --- a/packages/grafana-data/src/vector/CircularVector.ts +++ b/packages/grafana-data/src/vector/CircularVector.ts @@ -122,7 +122,7 @@ export class CircularVector extends FunctionalVector { return this.buffer[(index + this.index) % this.buffer.length]; } - set(index: number, value: any) { + set(index: number, value: T) { this.buffer[(index + this.index) % this.buffer.length] = value; } diff --git a/packages/grafana-data/src/vector/FunctionalVector.ts b/packages/grafana-data/src/vector/FunctionalVector.ts index fa6a0420a67..5c2984c4b72 100644 --- a/packages/grafana-data/src/vector/FunctionalVector.ts +++ b/packages/grafana-data/src/vector/FunctionalVector.ts @@ -18,7 +18,7 @@ export abstract class FunctionalVector implements Vector { } } - set(index: number, value: any): void { + set(index: number, value: T): void { throw 'unsupported operation'; } diff --git a/public/app/plugins/panel/geomap/layers/data/dayNightLayer.tsx b/public/app/plugins/panel/geomap/layers/data/dayNightLayer.tsx index fe50748812d..e9ef19af26f 100644 --- a/public/app/plugins/panel/geomap/layers/data/dayNightLayer.tsx +++ b/public/app/plugins/panel/geomap/layers/data/dayNightLayer.tsx @@ -163,7 +163,7 @@ export const dayNightLayer: MapLayerRegistryItem = { if (false) { subscriptions.add( eventBus.subscribe(DataHoverEvent, (event) => { - const time: number = event.payload?.point?.time; + const time = event.payload?.point?.time; if (time) { const lineTime = new Date(time); const nightLinePoints = sourceLine.getCoordinates(lineTime.toString(), 'line'); diff --git a/public/app/plugins/panel/geomap/layers/data/routeLayer.tsx b/public/app/plugins/panel/geomap/layers/data/routeLayer.tsx index 286c07c4fbe..d7f86b10ab0 100644 --- a/public/app/plugins/panel/geomap/layers/data/routeLayer.tsx +++ b/public/app/plugins/panel/geomap/layers/data/routeLayer.tsx @@ -252,7 +252,7 @@ export const routeLayer: MapLayerRegistryItem = { const mapExtents = map.getView().calculateExtent(map.getSize()); const feature = source.getFeatures()[0]; const frame: DataFrame = feature?.get('frame'); - const time: number = event.payload?.point?.time; + const time = event.payload?.point?.time; if (frame && time) { const timeField = frame.fields.find((f) => f.type === FieldType.time); if (timeField) {