From 0ab548a8b5d3855259446f4b9a57b9f2d0437902 Mon Sep 17 00:00:00 2001 From: Ashley Harrison Date: Fri, 2 Sep 2022 17:39:09 +0100 Subject: [PATCH] Chore: fixing some `any`s/type assertions (#54661) * fixing some anys/type assertions * make types consistent --- .betterer.results | 77 ++++--------------- packages/grafana-data/src/types/logs.ts | 2 +- packages/grafana-data/src/types/logsVolume.ts | 2 +- packages/grafana-data/src/types/query.ts | 4 +- packages/grafana-data/src/utils/Registry.ts | 2 +- .../grafana-data/src/utils/anyToNumber.ts | 2 +- packages/grafana-data/src/utils/arrayUtils.ts | 2 +- packages/grafana-data/src/utils/logs.ts | 2 +- packages/grafana-data/src/utils/object.ts | 4 +- packages/grafana-e2e/src/index.ts | 2 +- .../JSONFormatter/json_explorer/helpers.ts | 2 +- .../src/components/Select/MultiValue.tsx | 4 +- .../SingleStatBaseOptions.test.ts | 6 +- .../TableInputCSV/TableInputCSV.tsx | 4 +- .../components/Typeahead/TypeaheadItem.tsx | 2 +- .../uPlot/plugins/TooltipPlugin.tsx | 2 +- .../src/slate-plugins/braces.test.tsx | 6 -- packages/grafana-ui/src/utils/colors.ts | 2 +- .../core/components/TagFilter/TagBadge.tsx | 6 +- .../core/components/TagFilter/TagValue.tsx | 4 +- public/app/core/logsModel.test.ts | 2 +- public/app/core/services/keybindingSrv.ts | 4 +- public/app/core/utils/dag.ts | 2 +- public/app/features/teams/TeamMemberRow.tsx | 2 +- public/app/features/teams/TeamMembers.tsx | 2 +- 25 files changed, 47 insertions(+), 102 deletions(-) diff --git a/.betterer.results b/.betterer.results index d4ebc1c53e5..0f0253e4715 100644 --- a/.betterer.results +++ b/.betterer.results @@ -14,7 +14,7 @@ exports[`no enzyme tests`] = { "packages/grafana-ui/src/components/QueryField/QueryField.test.tsx:375894800": [ [0, 19, 13, "RegExp match", "2409514259"] ], - "packages/grafana-ui/src/slate-plugins/braces.test.tsx:1440546721": [ + "packages/grafana-ui/src/slate-plugins/braces.test.tsx:4104231341": [ [0, 19, 13, "RegExp match", "2409514259"] ], "packages/grafana-ui/src/slate-plugins/clear.test.tsx:1085648664": [ @@ -669,12 +669,10 @@ exports[`better eslint`] = { [0, 0, 0, "Do not use any type assertions.", "8"] ], "packages/grafana-data/src/types/logs.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, "Do not use any type assertions.", "0"] ], "packages/grafana-data/src/types/logsVolume.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, "Do not use any type assertions.", "0"] ], "packages/grafana-data/src/types/options.ts:5381": [ [0, 0, 0, "Unexpected any. Specify a different type.", "0"], @@ -702,10 +700,8 @@ exports[`better eslint`] = { [0, 0, 0, "Do not use any type assertions.", "2"] ], "packages/grafana-data/src/types/query.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, "Do not use any type assertions.", "0"], + [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"], @@ -823,17 +819,11 @@ exports[`better eslint`] = { ], "packages/grafana-data/src/utils/Registry.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"] - ], - "packages/grafana-data/src/utils/anyToNumber.ts:5381": [ - [0, 0, 0, "Unexpected any. Specify a different type.", "0"] + [0, 0, 0, "Do not use any type assertions.", "1"] ], "packages/grafana-data/src/utils/arrayUtils.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"] ], "packages/grafana-data/src/utils/csv.ts:5381": [ [0, 0, 0, "Unexpected any. Specify a different type.", "0"], @@ -904,8 +894,7 @@ exports[`better eslint`] = { [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, "Do not use any type assertions.", "4"], - [0, 0, 0, "Unexpected any. Specify a different type.", "5"] + [0, 0, 0, "Do not use any type assertions.", "4"] ], "packages/grafana-data/src/utils/makeClassES5Compatible.ts:5381": [ [0, 0, 0, "Do not use any type assertions.", "0"], @@ -913,10 +902,6 @@ exports[`better eslint`] = { [0, 0, 0, "Do not use any type assertions.", "2"], [0, 0, 0, "Unexpected any. Specify a different type.", "3"] ], - "packages/grafana-data/src/utils/object.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/utils/testdata/testTheme.ts:5381": [ [0, 0, 0, "Do not use any type assertions.", "0"], [0, 0, 0, "Do not use any type assertions.", "1"] @@ -1034,9 +1019,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-e2e/src/index.ts:5381": [ - [0, 0, 0, "Unexpected any. Specify a different type.", "0"] - ], "packages/grafana-e2e/src/support/localStorage.ts:5381": [ [0, 0, 0, "Unexpected any. Specify a different type.", "0"], [0, 0, 0, "Unexpected any. Specify a different type.", "1"], @@ -1440,9 +1422,6 @@ exports[`better eslint`] = { "packages/grafana-ui/src/components/JSONFormatter/JSONFormatter.tsx:5381": [ [0, 0, 0, "Unexpected any. Specify a different type.", "0"] ], - "packages/grafana-ui/src/components/JSONFormatter/json_explorer/helpers.ts:5381": [ - [0, 0, 0, "Unexpected any. Specify a different type.", "0"] - ], "packages/grafana-ui/src/components/JSONFormatter/json_explorer/json_explorer.ts:5381": [ [0, 0, 0, "Unexpected any. Specify a different type.", "0"], [0, 0, 0, "Unexpected any. Specify a different type.", "1"], @@ -1562,9 +1541,6 @@ exports[`better eslint`] = { "packages/grafana-ui/src/components/Select/IndicatorsContainer.tsx:5381": [ [0, 0, 0, "Unexpected any. Specify a different type.", "0"] ], - "packages/grafana-ui/src/components/Select/MultiValue.tsx:5381": [ - [0, 0, 0, "Unexpected any. Specify a different type.", "0"] - ], "packages/grafana-ui/src/components/Select/Select.story.tsx:5381": [ [0, 0, 0, "Unexpected any. Specify a different type.", "0"], [0, 0, 0, "Unexpected any. Specify a different type.", "1"] @@ -1627,10 +1603,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.", "8"] ], "packages/grafana-ui/src/components/SingleStatShared/SingleStatBaseOptions.ts:5381": [ [0, 0, 0, "Unexpected any. Specify a different type.", "0"], @@ -1754,10 +1727,6 @@ exports[`better eslint`] = { [0, 0, 0, "Unexpected any. Specify a different type.", "11"], [0, 0, 0, "Unexpected any. Specify a different type.", "12"] ], - "packages/grafana-ui/src/components/TableInputCSV/TableInputCSV.tsx:5381": [ - [0, 0, 0, "Unexpected any. Specify a different type.", "0"], - [0, 0, 0, "Unexpected any. Specify a different type.", "1"] - ], "packages/grafana-ui/src/components/Tags/Tag.tsx:5381": [ [0, 0, 0, "Unexpected any. Specify a different type.", "0"], [0, 0, 0, "Do not use any type assertions.", "1"] @@ -1789,9 +1758,6 @@ exports[`better eslint`] = { "packages/grafana-ui/src/components/Tooltip/types.ts:5381": [ [0, 0, 0, "Unexpected any. Specify a different type.", "0"] ], - "packages/grafana-ui/src/components/Typeahead/TypeaheadItem.tsx:5381": [ - [0, 0, 0, "Unexpected any. Specify a different type.", "0"] - ], "packages/grafana-ui/src/components/UnitPicker/UnitPicker.tsx:5381": [ [0, 0, 0, "Do not use any type assertions.", "0"] ], @@ -1854,9 +1820,6 @@ exports[`better eslint`] = { [0, 0, 0, "Do not use any type assertions.", "1"], [0, 0, 0, "Do not use any type assertions.", "2"] ], - "packages/grafana-ui/src/components/uPlot/plugins/TooltipPlugin.tsx:5381": [ - [0, 0, 0, "Unexpected any. Specify a different type.", "0"] - ], "packages/grafana-ui/src/components/uPlot/types.ts:5381": [ [0, 0, 0, "Unexpected any. Specify a different type.", "0"] ], @@ -1891,8 +1854,7 @@ exports[`better eslint`] = { [0, 0, 0, "Unexpected any. Specify a different type.", "3"], [0, 0, 0, "Unexpected any. Specify a different type.", "4"], [0, 0, 0, "Unexpected any. Specify a different type.", "5"], - [0, 0, 0, "Unexpected any. Specify a different type.", "6"], - [0, 0, 0, "Unexpected any. Specify a different type.", "7"] + [0, 0, 0, "Unexpected any. Specify a different type.", "6"] ], "packages/grafana-ui/src/slate-plugins/braces.ts:5381": [ [0, 0, 0, "Unexpected any. Specify a different type.", "0"], @@ -1988,9 +1950,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-ui/src/utils/colors.ts:5381": [ - [0, 0, 0, "Unexpected any. Specify a different type.", "0"] - ], "packages/grafana-ui/src/utils/debug.ts:5381": [ [0, 0, 0, "Unexpected any. Specify a different type.", "0"] ], @@ -2838,8 +2797,7 @@ exports[`better eslint`] = { [0, 0, 0, "Unexpected any. Specify a different type.", "0"] ], "public/app/core/components/TagFilter/TagBadge.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/core/components/TagFilter/TagFilter.tsx:5381": [ [0, 0, 0, "Unexpected any. Specify a different type.", "0"], @@ -2859,8 +2817,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/app/core/components/connectWithCleanUp.tsx:5381": [ [0, 0, 0, "Unexpected any. Specify a different type.", "0"], @@ -2888,8 +2845,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.", "8"] ], "public/app/core/logsModel.ts:5381": [ [0, 0, 0, "Do not use any type assertions.", "0"], @@ -3068,9 +3024,7 @@ exports[`better eslint`] = { ], "public/app/core/services/keybindingSrv.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"] + [0, 0, 0, "Unexpected any. Specify a different type.", "1"] ], "public/app/core/services/search_srv.ts:5381": [ [0, 0, 0, "Unexpected any. Specify a different type.", "0"], @@ -3177,9 +3131,6 @@ exports[`better eslint`] = { [0, 0, 0, "Unexpected any. Specify a different type.", "2"], [0, 0, 0, "Unexpected any. Specify a different type.", "3"] ], - "public/app/core/utils/dag.ts:5381": [ - [0, 0, 0, "Unexpected any. Specify a different type.", "0"] - ], "public/app/core/utils/deferred.ts:5381": [ [0, 0, 0, "Unexpected any. Specify a different type.", "0"], [0, 0, 0, "Unexpected any. Specify a different type.", "1"] diff --git a/packages/grafana-data/src/types/logs.ts b/packages/grafana-data/src/types/logs.ts index 1af4caf3ee0..553be92b9e0 100644 --- a/packages/grafana-data/src/types/logs.ts +++ b/packages/grafana-data/src/types/logs.ts @@ -165,7 +165,7 @@ export interface DataSourceWithLogsContextSupport { +export const hasLogsContextSupport = (datasource: unknown): datasource is DataSourceWithLogsContextSupport => { if (!datasource) { return false; } diff --git a/packages/grafana-data/src/types/logsVolume.ts b/packages/grafana-data/src/types/logsVolume.ts index 925f63d899b..161bb3da1be 100644 --- a/packages/grafana-data/src/types/logsVolume.ts +++ b/packages/grafana-data/src/types/logsVolume.ts @@ -17,7 +17,7 @@ export interface DataSourceWithLogsVolumeSupport { * @internal */ export const hasLogsVolumeSupport = ( - datasource: any + datasource: unknown ): datasource is DataSourceWithLogsVolumeSupport => { return (datasource as DataSourceWithLogsVolumeSupport).getLogsVolumeDataProvider !== undefined; }; diff --git a/packages/grafana-data/src/types/query.ts b/packages/grafana-data/src/types/query.ts index 1f13c56e770..2e1802b8c28 100644 --- a/packages/grafana-data/src/types/query.ts +++ b/packages/grafana-data/src/types/query.ts @@ -98,7 +98,7 @@ export interface DataSourceWithQueryExportSupport { * @internal */ export const hasQueryImportSupport = ( - datasource: any + datasource: unknown ): datasource is DataSourceWithQueryImportSupport => { return (datasource as DataSourceWithQueryImportSupport).importFromAbstractQueries !== undefined; }; @@ -107,7 +107,7 @@ export const hasQueryImportSupport = ( * @internal */ export const hasQueryExportSupport = ( - datasource: any + datasource: unknown ): datasource is DataSourceWithQueryExportSupport => { return (datasource as DataSourceWithQueryExportSupport).exportToAbstractQueries !== undefined; }; diff --git a/packages/grafana-data/src/utils/Registry.ts b/packages/grafana-data/src/utils/Registry.ts index a3ecbc96ed4..f6e9d08df0c 100644 --- a/packages/grafana-data/src/utils/Registry.ts +++ b/packages/grafana-data/src/utils/Registry.ts @@ -132,7 +132,7 @@ export class Registry { /** * Return a list of values by ID, or all values if not specified */ - list(ids?: any[]): T[] { + list(ids?: string[]): T[] { if (!this.initialized) { this.initialize(); } diff --git a/packages/grafana-data/src/utils/anyToNumber.ts b/packages/grafana-data/src/utils/anyToNumber.ts index 7cb69d0920d..cf6f7eead3d 100644 --- a/packages/grafana-data/src/utils/anyToNumber.ts +++ b/packages/grafana-data/src/utils/anyToNumber.ts @@ -5,7 +5,7 @@ import { toNumber } from 'lodash'; * * @internal * */ -export function anyToNumber(value: any): number { +export function anyToNumber(value: unknown): number { if (typeof value === 'number') { return value; } diff --git a/packages/grafana-data/src/utils/arrayUtils.ts b/packages/grafana-data/src/utils/arrayUtils.ts index 147969965ca..fe56786fedc 100644 --- a/packages/grafana-data/src/utils/arrayUtils.ts +++ b/packages/grafana-data/src/utils/arrayUtils.ts @@ -15,7 +15,7 @@ const collator = new Intl.Collator(undefined, { numeric: true, sensitivity: 'bas const numericCompare = (a: number, b: number) => a - b; export function sortValues(sort: SortOrder.Ascending | SortOrder.Descending) { - return (a: any, b: any) => { + return (a: unknown, b: unknown) => { if (a === b) { return 0; } diff --git a/packages/grafana-data/src/utils/logs.ts b/packages/grafana-data/src/utils/logs.ts index 7fa62feb5d2..35bd1430d7e 100644 --- a/packages/grafana-data/src/utils/logs.ts +++ b/packages/grafana-data/src/utils/logs.ts @@ -134,7 +134,7 @@ export function calculateLogsLabelStats(rows: LogRowModel[], label: string): Log return getSortedCounts(countsByValue, rowCount); } -export function calculateStats(values: any[]): LogLabelStatsModel[] { +export function calculateStats(values: unknown[]): LogLabelStatsModel[] { const nonEmptyValues = values.filter((value) => value !== undefined && value !== null); const countsByValue = countBy(nonEmptyValues); return getSortedCounts(countsByValue, nonEmptyValues.length); diff --git a/packages/grafana-data/src/utils/object.ts b/packages/grafana-data/src/utils/object.ts index e5960b22e4f..47c1ee0e629 100644 --- a/packages/grafana-data/src/utils/object.ts +++ b/packages/grafana-data/src/utils/object.ts @@ -1,5 +1,5 @@ -export const objRemoveUndefined = (obj: any) => { - return Object.keys(obj).reduce((acc: any, key) => { +export const objRemoveUndefined = (obj: { [key: string]: unknown }) => { + return Object.keys(obj).reduce((acc: { [key: string]: unknown }, key) => { if (obj[key] !== undefined) { acc[key] = obj[key]; } diff --git a/packages/grafana-e2e/src/index.ts b/packages/grafana-e2e/src/index.ts index 58cacd133cf..a7df2bec40f 100644 --- a/packages/grafana-e2e/src/index.ts +++ b/packages/grafana-e2e/src/index.ts @@ -15,7 +15,7 @@ import * as typings from './typings'; const e2eObject = { env: (args: string) => Cypress.env(args), config: () => Cypress.config(), - blobToBase64String: (blob: any) => Cypress.Blob.blobToBase64String(blob), + blobToBase64String: (blob: Blob) => Cypress.Blob.blobToBase64String(blob), imgSrcToBlob: (url: string) => Cypress.Blob.imgSrcToBlob(url), scenario: (args: ScenarioArguments) => e2eScenario(args), benchmark, diff --git a/packages/grafana-ui/src/components/JSONFormatter/json_explorer/helpers.ts b/packages/grafana-ui/src/components/JSONFormatter/json_explorer/helpers.ts index 72c410a1feb..51935173e4e 100644 --- a/packages/grafana-ui/src/components/JSONFormatter/json_explorer/helpers.ts +++ b/packages/grafana-ui/src/components/JSONFormatter/json_explorer/helpers.ts @@ -11,7 +11,7 @@ export function formatString(str: string): string { /* * Determines if a value is an object */ -export function isObject(value: any): boolean { +export function isObject(value: unknown): boolean { const type = typeof value; return !!value && type === 'object'; } diff --git a/packages/grafana-ui/src/components/Select/MultiValue.tsx b/packages/grafana-ui/src/components/Select/MultiValue.tsx index 9e660ffb3da..df7c65028f6 100644 --- a/packages/grafana-ui/src/components/Select/MultiValue.tsx +++ b/packages/grafana-ui/src/components/Select/MultiValue.tsx @@ -1,7 +1,7 @@ import React from 'react'; import { useTheme2 } from '../../themes'; -import { IconButton } from '../IconButton/IconButton'; +import { IconButton, Props as IconButtonProps } from '../IconButton/IconButton'; import { getSelectStyles } from './getSelectStyles'; @@ -21,7 +21,7 @@ export const MultiValueContainer: React.FC = ({ innerP }; export type MultiValueRemoveProps = { - innerProps: any; + innerProps: IconButtonProps; }; export const MultiValueRemove: React.FC = ({ children, innerProps }) => { diff --git a/packages/grafana-ui/src/components/SingleStatShared/SingleStatBaseOptions.test.ts b/packages/grafana-ui/src/components/SingleStatShared/SingleStatBaseOptions.test.ts index f4ca88af522..fadc4db2ece 100644 --- a/packages/grafana-ui/src/components/SingleStatShared/SingleStatBaseOptions.test.ts +++ b/packages/grafana-ui/src/components/SingleStatShared/SingleStatBaseOptions.test.ts @@ -181,7 +181,7 @@ describe('sharedSingleStatMigrationHandler', () => { }); it('change from angular singlestat with no enabled gauge', () => { - const old: any = { + const old = { angular: { format: 'ms', decimals: 7, @@ -200,7 +200,7 @@ describe('sharedSingleStatMigrationHandler', () => { }); it('change from angular singlestat with tableColumn set', () => { - const old: any = { + const old = { angular: { tableColumn: 'info', }, @@ -212,7 +212,7 @@ describe('sharedSingleStatMigrationHandler', () => { }); it('change from angular singlestat with no enabled gauge', () => { - const old: any = { + const old = { angular: { format: 'ms', decimals: 7, diff --git a/packages/grafana-ui/src/components/TableInputCSV/TableInputCSV.tsx b/packages/grafana-ui/src/components/TableInputCSV/TableInputCSV.tsx index f0b3a1bccdd..eba01366cc2 100644 --- a/packages/grafana-ui/src/components/TableInputCSV/TableInputCSV.tsx +++ b/packages/grafana-ui/src/components/TableInputCSV/TableInputCSV.tsx @@ -36,7 +36,7 @@ export class UnThemedTableInputCSV extends PureComponent { }; } - readCSV: any = debounce(() => { + readCSV = debounce(() => { const { config } = this.props; const { text } = this.state; @@ -60,7 +60,7 @@ export class UnThemedTableInputCSV extends PureComponent { } } - onTextChange = (event: any) => { + onTextChange = (event: React.ChangeEvent) => { this.setState({ text: event.target.value }); }; diff --git a/packages/grafana-ui/src/components/Typeahead/TypeaheadItem.tsx b/packages/grafana-ui/src/components/Typeahead/TypeaheadItem.tsx index 71db99ebf2b..30c0e7c59bd 100644 --- a/packages/grafana-ui/src/components/Typeahead/TypeaheadItem.tsx +++ b/packages/grafana-ui/src/components/Typeahead/TypeaheadItem.tsx @@ -12,7 +12,7 @@ import { PartialHighlighter } from './PartialHighlighter'; interface Props { isSelected: boolean; item: CompletionItem; - style: any; + style: React.CSSProperties; prefix?: string; onClickItem?: (event: React.MouseEvent) => void; diff --git a/packages/grafana-ui/src/components/uPlot/plugins/TooltipPlugin.tsx b/packages/grafana-ui/src/components/uPlot/plugins/TooltipPlugin.tsx index 73e7371476e..dac9f0f775d 100644 --- a/packages/grafana-ui/src/components/uPlot/plugins/TooltipPlugin.tsx +++ b/packages/grafana-ui/src/components/uPlot/plugins/TooltipPlugin.tsx @@ -217,7 +217,7 @@ export const TooltipPlugin: React.FC = ({ let series: SeriesTableRowProps[] = []; const frame = otherProps.data; const fields = frame.fields; - const sortIdx: any[] = []; + const sortIdx: unknown[] = []; for (let i = 0; i < fields.length; i++) { const field = frame.fields[i]; diff --git a/packages/grafana-ui/src/slate-plugins/braces.test.tsx b/packages/grafana-ui/src/slate-plugins/braces.test.tsx index 680e26f3a32..212d6e462dc 100644 --- a/packages/grafana-ui/src/slate-plugins/braces.test.tsx +++ b/packages/grafana-ui/src/slate-plugins/braces.test.tsx @@ -6,12 +6,6 @@ import { Editor } from '@grafana/slate-react'; import { BracesPlugin } from './braces'; -declare global { - interface Window { - KeyboardEvent: any; - } -} - describe('braces', () => { const handler = BracesPlugin().onKeyDown!; const nextMock = () => {}; diff --git a/packages/grafana-ui/src/utils/colors.ts b/packages/grafana-ui/src/utils/colors.ts index 9afba47c91c..101d8810fce 100644 --- a/packages/grafana-ui/src/utils/colors.ts +++ b/packages/grafana-ui/src/utils/colors.ts @@ -108,7 +108,7 @@ function hexToHsl(color: string) { return tinycolor(color).toHsl(); } -function hslToHex(color: any) { +function hslToHex(color: tinycolor.ColorFormats.HSLA) { return tinycolor(color).toHexString(); } diff --git a/public/app/core/components/TagFilter/TagBadge.tsx b/public/app/core/components/TagFilter/TagBadge.tsx index fa184f0b9f3..8d9c0bcadb7 100644 --- a/public/app/core/components/TagFilter/TagBadge.tsx +++ b/public/app/core/components/TagFilter/TagBadge.tsx @@ -6,7 +6,7 @@ export interface Props { label: string; removeIcon: boolean; count: number; - onClick?: any; + onClick?: React.MouseEventHandler; } export class TagBadge extends React.Component { @@ -15,7 +15,7 @@ export class TagBadge extends React.Component { } render() { - const { label, removeIcon, count } = this.props; + const { label, removeIcon, count, onClick } = this.props; const { color } = getTagColorsFromName(label); const tagStyle = { @@ -26,7 +26,7 @@ export class TagBadge extends React.Component { return ( - {removeIcon && } + {removeIcon && } {label} {countLabel} ); diff --git a/public/app/core/components/TagFilter/TagValue.tsx b/public/app/core/components/TagFilter/TagValue.tsx index 530e43dcc12..a7e2bc9ae5c 100644 --- a/public/app/core/components/TagFilter/TagValue.tsx +++ b/public/app/core/components/TagFilter/TagValue.tsx @@ -5,7 +5,7 @@ import { TagBadge } from './TagBadge'; export interface Props { value: any; className: any; - onClick: any; + onClick: React.MouseEventHandler; onRemove: any; } @@ -15,7 +15,7 @@ export class TagValue extends React.Component { this.onClick = this.onClick.bind(this); } - onClick(event: React.SyntheticEvent) { + onClick(event: React.MouseEvent) { this.props.onRemove(this.props.value, event); } diff --git a/public/app/core/logsModel.test.ts b/public/app/core/logsModel.test.ts index 93b5405b3d0..fed2c6be67d 100644 --- a/public/app/core/logsModel.test.ts +++ b/public/app/core/logsModel.test.ts @@ -212,7 +212,7 @@ describe('filterLogLevels()', () => { }); }); -const emptyLogsModel: any = { +const emptyLogsModel = { hasUniqueLabels: false, rows: [], meta: [], diff --git a/public/app/core/services/keybindingSrv.ts b/public/app/core/services/keybindingSrv.ts index 61222b6bbaa..5ece429b47f 100644 --- a/public/app/core/services/keybindingSrv.ts +++ b/public/app/core/services/keybindingSrv.ts @@ -154,7 +154,7 @@ export class KeybindingSrv { bind(keyArg: string | string[], fn: () => void) { Mousetrap.bind( keyArg, - (evt: any) => { + (evt) => { evt.preventDefault(); evt.stopPropagation(); evt.returnValue = false; @@ -167,7 +167,7 @@ export class KeybindingSrv { bindGlobal(keyArg: string, fn: () => void) { Mousetrap.bindGlobal( keyArg, - (evt: any) => { + (evt) => { evt.preventDefault(); evt.stopPropagation(); evt.returnValue = false; diff --git a/public/app/core/utils/dag.ts b/public/app/core/utils/dag.ts index edfc698c91a..3997442ffa1 100644 --- a/public/app/core/utils/dag.ts +++ b/public/app/core/utils/dag.ts @@ -101,7 +101,7 @@ export class Node { } getOptimizedInputEdges(): Edge[] { - const toBeRemoved: any[] = []; + const toBeRemoved: Edge[] = []; this.inputEdges.forEach((e) => { const inputEdgesNodes = e.inputNode?.inputEdges.map((e) => e.inputNode); diff --git a/public/app/features/teams/TeamMemberRow.tsx b/public/app/features/teams/TeamMemberRow.tsx index 86fb06f39b8..e3c0c58b201 100644 --- a/public/app/features/teams/TeamMemberRow.tsx +++ b/public/app/features/teams/TeamMemberRow.tsx @@ -77,7 +77,7 @@ export class TeamMemberRow extends PureComponent { return ( {labels.map((label) => ( - {}} /> + ))} ); diff --git a/public/app/features/teams/TeamMembers.tsx b/public/app/features/teams/TeamMembers.tsx index afa843d8b94..2f27d35b416 100644 --- a/public/app/features/teams/TeamMembers.tsx +++ b/public/app/features/teams/TeamMembers.tsx @@ -75,7 +75,7 @@ export class TeamMembers extends PureComponent { return ( {labels.map((label) => ( - {}} /> + ))} );