From 500cf16142375ba155df9afaae9a6414658ae021 Mon Sep 17 00:00:00 2001 From: Ashley Harrison Date: Fri, 11 Nov 2022 16:29:49 +0000 Subject: [PATCH] Chore: fix some types (#58662) chore: fix some types --- .betterer.results | 89 +++---------------- public/app/features/admin/UserProfile.tsx | 2 +- .../StandardAnnotationQueryEditor.tsx | 2 +- public/app/features/comments/CommentView.tsx | 2 +- .../dashboard/components/DashNav/DashNav.tsx | 2 +- .../DashboardPrompt/DashboardPrompt.tsx | 4 +- .../components/DashboardRow/DashboardRow.tsx | 2 +- .../DashboardSettings.test.tsx | 4 +- .../GeneralSettings.test.tsx | 4 +- .../DashboardSettings/GeneralSettings.tsx | 4 +- .../DashboardSettings/VersionsSettings.tsx | 2 +- .../LinksSettings/LinkSettingsEdit.tsx | 4 +- .../PanelEditor/AngularPanelOptions.tsx | 2 +- .../PanelEditor/getFieldOverrideElements.tsx | 2 +- .../PanelEditor/getVisualizationOptions.tsx | 2 +- .../components/PanelEditor/utils.test.ts | 15 +++- .../SaveDashboard/SaveDashboardDiff.tsx | 4 +- .../SharePublicDashboard.test.tsx | 2 +- .../TransformationEditor.tsx | 2 +- .../VersionHistory/HistorySrv.test.ts | 8 +- .../VersionHistoryComparison.tsx | 2 +- .../containers/DashboardPage.test.tsx | 4 +- .../dashboard/dashgrid/DashboardGrid.tsx | 6 +- .../PanelHeader/PanelHeaderMenuItem.tsx | 2 +- .../dashboard/services/DashboardSrv.ts | 2 +- .../services/PublicDashboardDataSource.ts | 4 +- 26 files changed, 61 insertions(+), 117 deletions(-) diff --git a/.betterer.results b/.betterer.results index 34cafb51e18..090f63ed372 100644 --- a/.betterer.results +++ b/.betterer.results @@ -2780,9 +2780,6 @@ exports[`better eslint`] = { "public/app/features/admin/OrgRolePicker.tsx:5381": [ [0, 0, 0, "Do not use any type assertions.", "0"] ], - "public/app/features/admin/UserProfile.tsx:5381": [ - [0, 0, 0, "Unexpected any. Specify a different type.", "0"] - ], "public/app/features/admin/ldap/LdapPage.tsx:5381": [ [0, 0, 0, "Unexpected any. Specify a different type.", "0"] ], @@ -3106,9 +3103,6 @@ exports[`better eslint`] = { "public/app/features/annotations/components/AnnotationResultMapper.tsx:5381": [ [0, 0, 0, "Do not use any type assertions.", "0"] ], - "public/app/features/annotations/components/StandardAnnotationQueryEditor.tsx:5381": [ - [0, 0, 0, "Do not use any type assertions.", "0"] - ], "public/app/features/annotations/events_processing.ts:5381": [ [0, 0, 0, "Unexpected any. Specify a different type.", "0"] ], @@ -3177,9 +3171,6 @@ exports[`better eslint`] = { [0, 0, 0, "Do not use any type assertions.", "0"], [0, 0, 0, "Do not use any type assertions.", "1"] ], - "public/app/features/comments/CommentView.tsx:5381": [ - [0, 0, 0, "Do not use any type assertions.", "0"] - ], "public/app/features/dashboard/components/AddPanelWidget/AddPanelWidget.test.tsx:5381": [ [0, 0, 0, "Unexpected any. Specify a different type.", "0"] ], @@ -3238,32 +3229,14 @@ exports[`better eslint`] = { [0, 0, 0, "Do not use any type assertions.", "0"], [0, 0, 0, "Do not use any type assertions.", "1"], [0, 0, 0, "Unexpected any. Specify a different type.", "2"], - [0, 0, 0, "Unexpected any. Specify a different type.", "3"], - [0, 0, 0, "Do not use any type assertions.", "4"], - [0, 0, 0, "Unexpected any. Specify a different type.", "5"], - [0, 0, 0, "Unexpected any. Specify a different type.", "6"], - [0, 0, 0, "Do not use any type assertions.", "7"], - [0, 0, 0, "Unexpected any. Specify a different type.", "8"] + [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, "Unexpected any. Specify a different type.", "6"] ], "public/app/features/dashboard/components/DashboardRow/DashboardRow.test.tsx:5381": [ [0, 0, 0, "Unexpected any. Specify a different type.", "0"] ], - "public/app/features/dashboard/components/DashboardRow/DashboardRow.tsx:5381": [ - [0, 0, 0, "Unexpected any. Specify a different type.", "0"] - ], - "public/app/features/dashboard/components/DashboardSettings/DashboardSettings.test.tsx:5381": [ - [0, 0, 0, "Unexpected any. Specify a different type.", "0"] - ], - "public/app/features/dashboard/components/DashboardSettings/GeneralSettings.test.tsx:5381": [ - [0, 0, 0, "Unexpected any. Specify a different type.", "0"] - ], - "public/app/features/dashboard/components/DashboardSettings/GeneralSettings.tsx:5381": [ - [0, 0, 0, "Do not use any type assertions.", "0"] - ], - "public/app/features/dashboard/components/DashboardSettings/VersionsSettings.tsx:5381": [ - [0, 0, 0, "Unexpected any. Specify a different type.", "0"], - [0, 0, 0, "Unexpected any. Specify a different type.", "1"] - ], "public/app/features/dashboard/components/HelpWizard/randomizer.ts:5381": [ [0, 0, 0, "Do not use any type assertions.", "0"] ], @@ -3280,12 +3253,6 @@ exports[`better eslint`] = { [0, 0, 0, "Do not use any type assertions.", "1"], [0, 0, 0, "Unexpected any. Specify a different type.", "2"] ], - "public/app/features/dashboard/components/LinksSettings/LinkSettingsEdit.tsx:5381": [ - [0, 0, 0, "Do not use any type assertions.", "0"] - ], - "public/app/features/dashboard/components/PanelEditor/AngularPanelOptions.tsx:5381": [ - [0, 0, 0, "Do not use any type assertions.", "0"] - ], "public/app/features/dashboard/components/PanelEditor/OptionsPaneItemDescriptor.tsx:5381": [ [0, 0, 0, "Unexpected any. Specify a different type.", "0"], [0, 0, 0, "Do not use any type assertions.", "1"] @@ -3304,8 +3271,7 @@ exports[`better eslint`] = { ], "public/app/features/dashboard/components/PanelEditor/getFieldOverrideElements.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.", "2"] + [0, 0, 0, "Unexpected any. Specify a different type.", "1"] ], "public/app/features/dashboard/components/PanelEditor/getVisualizationOptions.tsx:5381": [ [0, 0, 0, "Unexpected any. Specify a different type.", "0"], @@ -3313,8 +3279,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.", "5"] ], "public/app/features/dashboard/components/PanelEditor/state/actions.test.ts:5381": [ [0, 0, 0, "Unexpected any. Specify a different type.", "0"], @@ -3336,10 +3301,6 @@ exports[`better eslint`] = { [0, 0, 0, "Unexpected any. Specify a different type.", "1"], [0, 0, 0, "Unexpected any. Specify a different type.", "2"] ], - "public/app/features/dashboard/components/PanelEditor/utils.test.ts:5381": [ - [0, 0, 0, "Unexpected any. Specify a different type.", "0"], - [0, 0, 0, "Unexpected any. Specify a different type.", "1"] - ], "public/app/features/dashboard/components/PanelEditor/utils.ts:5381": [ [0, 0, 0, "Unexpected any. Specify a different type.", "0"], [0, 0, 0, "Unexpected any. Specify a different type.", "1"], @@ -3351,10 +3312,6 @@ exports[`better eslint`] = { "public/app/features/dashboard/components/RepeatRowSelect/RepeatRowSelect.tsx:5381": [ [0, 0, 0, "Unexpected any. Specify a different type.", "0"] ], - "public/app/features/dashboard/components/SaveDashboard/SaveDashboardDiff.tsx:5381": [ - [0, 0, 0, "Unexpected any. Specify a different type.", "0"], - [0, 0, 0, "Unexpected any. Specify a different type.", "1"] - ], "public/app/features/dashboard/components/SaveDashboard/SaveDashboardErrorProxy.tsx:5381": [ [0, 0, 0, "Unexpected any. Specify a different type.", "0"] ], @@ -3391,9 +3348,6 @@ exports[`better eslint`] = { "public/app/features/dashboard/components/ShareModal/ShareModal.tsx:5381": [ [0, 0, 0, "Unexpected any. Specify a different type.", "0"] ], - "public/app/features/dashboard/components/ShareModal/SharePublicDashboard/SharePublicDashboard.test.tsx:5381": [ - [0, 0, 0, "Unexpected any. Specify a different type.", "0"] - ], "public/app/features/dashboard/components/ShareModal/ShareSnapshot.tsx:5381": [ [0, 0, 0, "Unexpected any. Specify a different type.", "0"] ], @@ -3408,8 +3362,7 @@ exports[`better eslint`] = { [0, 0, 0, "Unexpected any. Specify a different type.", "1"] ], "public/app/features/dashboard/components/TransformationsEditor/TransformationEditor.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/features/dashboard/components/TransformationsEditor/TransformationOperationRow.tsx:5381": [ [0, 0, 0, "Unexpected any. Specify a different type.", "0"], @@ -3419,16 +3372,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/features/dashboard/components/VersionHistory/HistorySrv.test.ts:5381": [ - [0, 0, 0, "Unexpected any. Specify a different type.", "0"], - [0, 0, 0, "Unexpected any. Specify a different type.", "1"], - [0, 0, 0, "Unexpected any. Specify a different type.", "2"], - [0, 0, 0, "Unexpected any. Specify a different type.", "3"] - ], - "public/app/features/dashboard/components/VersionHistory/VersionHistoryComparison.tsx:5381": [ - [0, 0, 0, "Unexpected any. Specify a different type.", "0"], - [0, 0, 0, "Unexpected any. Specify a different type.", "1"] - ], "public/app/features/dashboard/components/VersionHistory/__mocks__/dashboardHistoryMocks.ts:5381": [ [0, 0, 0, "Unexpected any. Specify a different type.", "0"], [0, 0, 0, "Unexpected any. Specify a different type.", "1"], @@ -3450,8 +3393,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/features/dashboard/containers/DashboardPage.tsx:5381": [ [0, 0, 0, "Do not use any type assertions.", "0"], @@ -3473,10 +3415,7 @@ exports[`better eslint`] = { ], "public/app/features/dashboard/dashgrid/DashboardGrid.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.", "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/features/dashboard/dashgrid/DashboardPanel.tsx:5381": [ [0, 0, 0, "Unexpected any. Specify a different type.", "0"] @@ -3484,9 +3423,6 @@ exports[`better eslint`] = { "public/app/features/dashboard/dashgrid/LazyLoader.tsx:5381": [ [0, 0, 0, "Do not use any type assertions.", "0"] ], - "public/app/features/dashboard/dashgrid/PanelHeader/PanelHeaderMenuItem.tsx:5381": [ - [0, 0, 0, "Unexpected any. Specify a different type.", "0"] - ], "public/app/features/dashboard/dashgrid/PanelStateWrapper.tsx:5381": [ [0, 0, 0, "Unexpected any. Specify a different type.", "0"], [0, 0, 0, "Unexpected any. Specify a different type.", "1"], @@ -3507,13 +3443,10 @@ exports[`better eslint`] = { [0, 0, 0, "Unexpected any. Specify a different type.", "8"] ], "public/app/features/dashboard/services/DashboardSrv.ts:5381": [ - [0, 0, 0, "Unexpected any. Specify a different type.", "0"], - [0, 0, 0, "Unexpected any. Specify a different type.", "1"] + [0, 0, 0, "Unexpected any. Specify a different type.", "0"] ], "public/app/features/dashboard/services/PublicDashboardDataSource.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, "Do not use any type assertions.", "0"] ], "public/app/features/dashboard/services/TimeSrv.test.ts:5381": [ [0, 0, 0, "Unexpected any. Specify a different type.", "0"], diff --git a/public/app/features/admin/UserProfile.tsx b/public/app/features/admin/UserProfile.tsx index 1d1e3f6d43b..11e5d5e6e63 100644 --- a/public/app/features/admin/UserProfile.tsx +++ b/public/app/features/admin/UserProfile.tsx @@ -295,7 +295,7 @@ export class UserProfileRow extends PureComponent { - state = {} as State; + state: State = {}; componentDidMount() { this.verifyDataSource(); diff --git a/public/app/features/comments/CommentView.tsx b/public/app/features/comments/CommentView.tsx index a041050ae1b..e3f6defac89 100644 --- a/public/app/features/comments/CommentView.tsx +++ b/public/app/features/comments/CommentView.tsx @@ -29,7 +29,7 @@ export const CommentView = ({ comments, packetCounter, addComment }: Props) => { }, [packetCounter]); const onUpdateComment = (event: FormEvent) => { - const element = event.target as HTMLInputElement; + const element = event.currentTarget; setComment(element.value); }; diff --git a/public/app/features/dashboard/components/DashNav/DashNav.tsx b/public/app/features/dashboard/components/DashNav/DashNav.tsx index 6363840274d..2ada1fcc28d 100644 --- a/public/app/features/dashboard/components/DashNav/DashNav.tsx +++ b/public/app/features/dashboard/components/DashNav/DashNav.tsx @@ -87,7 +87,7 @@ export const DashNav = React.memo((props) => { const dashboardSrv = getDashboardSrv(); const { dashboard, setStarred } = props; - dashboardSrv.starDashboard(dashboard.id, dashboard.meta.isStarred).then((newState) => { + dashboardSrv.starDashboard(dashboard.id, Boolean(dashboard.meta.isStarred)).then((newState) => { setStarred({ id: dashboard.uid, title: dashboard.title, url: dashboard.meta.url ?? '', isStarred: newState }); dashboard.meta.isStarred = newState; forceUpdate(); diff --git a/public/app/features/dashboard/components/DashboardPrompt/DashboardPrompt.tsx b/public/app/features/dashboard/components/DashboardPrompt/DashboardPrompt.tsx index ad51ced0477..ab14b47bc27 100644 --- a/public/app/features/dashboard/components/DashboardPrompt/DashboardPrompt.tsx +++ b/public/app/features/dashboard/components/DashboardPrompt/DashboardPrompt.tsx @@ -201,8 +201,8 @@ export function hasChanges(current: DashboardModel, original: unknown) { const currentClean = cleanDashboardFromIgnoredChanges(current.getSaveModelClone()); const originalClean = cleanDashboardFromIgnoredChanges(original); - const currentTimepicker: any = find((currentClean as any).nav, { type: 'timepicker' }); - const originalTimepicker: any = find((originalClean as any).nav, { type: 'timepicker' }); + const currentTimepicker = find((currentClean as any).nav, { type: 'timepicker' }); + const originalTimepicker = find((originalClean as any).nav, { type: 'timepicker' }); if (currentTimepicker && originalTimepicker) { currentTimepicker.now = originalTimepicker.now; diff --git a/public/app/features/dashboard/components/DashboardRow/DashboardRow.tsx b/public/app/features/dashboard/components/DashboardRow/DashboardRow.tsx index de1e29cc8ed..0467ae662d7 100644 --- a/public/app/features/dashboard/components/DashboardRow/DashboardRow.tsx +++ b/public/app/features/dashboard/components/DashboardRow/DashboardRow.tsx @@ -17,7 +17,7 @@ export interface DashboardRowProps { dashboard: DashboardModel; } -export class DashboardRow extends React.Component { +export class DashboardRow extends React.Component { sub?: Unsubscribable; componentDidMount() { diff --git a/public/app/features/dashboard/components/DashboardSettings/DashboardSettings.test.tsx b/public/app/features/dashboard/components/DashboardSettings/DashboardSettings.test.tsx index a7cb7cf6b9e..81558d8374f 100644 --- a/public/app/features/dashboard/components/DashboardSettings/DashboardSettings.test.tsx +++ b/public/app/features/dashboard/components/DashboardSettings/DashboardSettings.test.tsx @@ -5,7 +5,7 @@ import { BrowserRouter } from 'react-router-dom'; import { getGrafanaContextMock } from 'test/mocks/getGrafanaContextMock'; import { NavModel, NavModelItem } from '@grafana/data'; -import { setBackendSrv } from '@grafana/runtime'; +import { BackendSrv, setBackendSrv } from '@grafana/runtime'; import { GrafanaContext } from 'app/core/context/GrafanaContext'; import { configureStore } from 'app/store/configureStore'; @@ -23,7 +23,7 @@ jest.mock('@grafana/runtime', () => ({ setBackendSrv({ get: jest.fn().mockResolvedValue([]), -} as any); +} as unknown as BackendSrv); describe('DashboardSettings', () => { it('pressing escape navigates away correctly', async () => { diff --git a/public/app/features/dashboard/components/DashboardSettings/GeneralSettings.test.tsx b/public/app/features/dashboard/components/DashboardSettings/GeneralSettings.test.tsx index b13be0bdf34..e8c4aba49d1 100644 --- a/public/app/features/dashboard/components/DashboardSettings/GeneralSettings.test.tsx +++ b/public/app/features/dashboard/components/DashboardSettings/GeneralSettings.test.tsx @@ -7,7 +7,7 @@ import { getGrafanaContextMock } from 'test/mocks/getGrafanaContextMock'; import { byRole } from 'testing-library-selector'; import { selectors } from '@grafana/e2e-selectors'; -import { setBackendSrv } from '@grafana/runtime'; +import { BackendSrv, setBackendSrv } from '@grafana/runtime'; import { GrafanaContext } from 'app/core/context/GrafanaContext'; import { DashboardModel } from '../../state'; @@ -16,7 +16,7 @@ import { GeneralSettingsUnconnected as GeneralSettings, Props } from './GeneralS setBackendSrv({ get: jest.fn().mockResolvedValue([]), -} as any); +} as unknown as BackendSrv); const setupTestContext = (options: Partial) => { const defaults: Props = { diff --git a/public/app/features/dashboard/components/DashboardSettings/GeneralSettings.tsx b/public/app/features/dashboard/components/DashboardSettings/GeneralSettings.tsx index da28d446b72..789b60b2ffc 100644 --- a/public/app/features/dashboard/components/DashboardSettings/GeneralSettings.tsx +++ b/public/app/features/dashboard/components/DashboardSettings/GeneralSettings.tsx @@ -37,7 +37,9 @@ export function GeneralSettingsUnconnected({ }; const onBlur = (event: React.FocusEvent) => { - dashboard[event.currentTarget.name as 'title' | 'description'] = event.currentTarget.value; + if (event.currentTarget.name === 'title' || event.currentTarget.name === 'description') { + dashboard[event.currentTarget.name] = event.currentTarget.value; + } }; const onTooltipChange = (graphTooltip: number) => { diff --git a/public/app/features/dashboard/components/DashboardSettings/VersionsSettings.tsx b/public/app/features/dashboard/components/DashboardSettings/VersionsSettings.tsx index 0db6b274558..5068bc95b77 100644 --- a/public/app/features/dashboard/components/DashboardSettings/VersionsSettings.tsx +++ b/public/app/features/dashboard/components/DashboardSettings/VersionsSettings.tsx @@ -21,7 +21,7 @@ type State = { isAppending: boolean; versions: DecoratedRevisionModel[]; viewMode: 'list' | 'compare'; - diffData: { lhs: any; rhs: any }; + diffData: { lhs: unknown; rhs: unknown }; newInfo?: DecoratedRevisionModel; baseInfo?: DecoratedRevisionModel; isNewLatest: boolean; diff --git a/public/app/features/dashboard/components/LinksSettings/LinkSettingsEdit.tsx b/public/app/features/dashboard/components/LinksSettings/LinkSettingsEdit.tsx index c58fbc7d679..046395e134b 100644 --- a/public/app/features/dashboard/components/LinksSettings/LinkSettingsEdit.tsx +++ b/public/app/features/dashboard/components/LinksSettings/LinkSettingsEdit.tsx @@ -5,7 +5,7 @@ import { CollapsableSection, TagsInput, Select, Field, Input, Checkbox, Button, import { DashboardLink, DashboardModel } from '../../state/DashboardModel'; -export const newLink = { +export const newLink: DashboardLink = { icon: 'external link', title: 'New link', tooltip: '', @@ -16,7 +16,7 @@ export const newLink = { targetBlank: false, keepTime: false, includeVars: false, -} as DashboardLink; +}; const linkTypeOptions = [ { value: 'dashboards', label: 'Dashboards' }, diff --git a/public/app/features/dashboard/components/PanelEditor/AngularPanelOptions.tsx b/public/app/features/dashboard/components/PanelEditor/AngularPanelOptions.tsx index b625700c025..df62f2fcb04 100644 --- a/public/app/features/dashboard/components/PanelEditor/AngularPanelOptions.tsx +++ b/public/app/features/dashboard/components/PanelEditor/AngularPanelOptions.tsx @@ -110,7 +110,7 @@ export class AngularPanelOptionsUnconnected extends PureComponent { toggleOptionGroup: (index: number) => { const tab = panelCtrl.editorTabs[index]; tab.isOpen = !tab.isOpen; - saveSectionOpenState(tab.title, tab.isOpen as boolean); + saveSectionOpenState(tab.title, Boolean(tab.isOpen)); }, }; diff --git a/public/app/features/dashboard/components/PanelEditor/getFieldOverrideElements.tsx b/public/app/features/dashboard/components/PanelEditor/getFieldOverrideElements.tsx index 9ca84fdf48a..0da94a6fafd 100644 --- a/public/app/features/dashboard/components/PanelEditor/getFieldOverrideElements.tsx +++ b/public/app/features/dashboard/components/PanelEditor/getFieldOverrideElements.tsx @@ -33,7 +33,7 @@ export function getFieldOverrideCategories( return []; } - const onOverrideChange = (index: number, override: any) => { + const onOverrideChange = (index: number, override: ConfigOverrideRule) => { let overrides = cloneDeep(currentFieldConfig.overrides); overrides[index] = override; props.onFieldConfigsChange({ ...currentFieldConfig, overrides }); diff --git a/public/app/features/dashboard/components/PanelEditor/getVisualizationOptions.tsx b/public/app/features/dashboard/components/PanelEditor/getVisualizationOptions.tsx index a3fa3263e73..5301e05c07f 100644 --- a/public/app/features/dashboard/components/PanelEditor/getVisualizationOptions.tsx +++ b/public/app/features/dashboard/components/PanelEditor/getVisualizationOptions.tsx @@ -196,7 +196,7 @@ export function fillOptionsPaneItems( return ( { + onChange={(value) => { access.onChange(pluginOption.path, value); }} item={pluginOption} diff --git a/public/app/features/dashboard/components/PanelEditor/utils.test.ts b/public/app/features/dashboard/components/PanelEditor/utils.test.ts index b2efaa7aa7f..42c9485c3d6 100644 --- a/public/app/features/dashboard/components/PanelEditor/utils.test.ts +++ b/public/app/features/dashboard/components/PanelEditor/utils.test.ts @@ -1,4 +1,10 @@ -import { FieldConfig, FieldConfigSource, PanelPlugin, standardFieldConfigEditorRegistry } from '@grafana/data'; +import { + FieldConfig, + FieldConfigSource, + PanelPlugin, + standardFieldConfigEditorRegistry, + ThresholdsMode, +} from '@grafana/data'; import { setOptionImmutably, supportsDataQuery, updateDefaultFieldConfigValue } from './utils'; @@ -8,10 +14,13 @@ describe('standardFieldConfigEditorRegistry', () => { min: 10, max: 10, decimals: 10, - thresholds: {} as any, + thresholds: { + mode: ThresholdsMode.Absolute, + steps: [], + }, noValue: 'no value', unit: 'km/s', - links: {} as any, + links: [], }; it('make sure all fields have a valid name', () => { diff --git a/public/app/features/dashboard/components/SaveDashboard/SaveDashboardDiff.tsx b/public/app/features/dashboard/components/SaveDashboard/SaveDashboardDiff.tsx index d1b997f8882..1b3746d87c5 100644 --- a/public/app/features/dashboard/components/SaveDashboard/SaveDashboardDiff.tsx +++ b/public/app/features/dashboard/components/SaveDashboard/SaveDashboardDiff.tsx @@ -10,8 +10,8 @@ import { DiffViewer } from '../VersionHistory/DiffViewer'; import { Diffs } from '../VersionHistory/utils'; interface SaveDashboardDiffProps { - oldValue?: any; - newValue?: any; + oldValue?: unknown; + newValue?: unknown; // calculated by parent so we can see summary in tabs diff?: Diffs; diff --git a/public/app/features/dashboard/components/ShareModal/SharePublicDashboard/SharePublicDashboard.test.tsx b/public/app/features/dashboard/components/ShareModal/SharePublicDashboard/SharePublicDashboard.test.tsx index 454e52b6f29..f26c0a30e93 100644 --- a/public/app/features/dashboard/components/ShareModal/SharePublicDashboard/SharePublicDashboard.test.tsx +++ b/public/app/features/dashboard/components/ShareModal/SharePublicDashboard/SharePublicDashboard.test.tsx @@ -62,7 +62,7 @@ beforeAll(() => { ], }, ], - } as any; + } as BootData; server.listen({ onUnhandledRequest: 'bypass' }); }); diff --git a/public/app/features/dashboard/components/TransformationsEditor/TransformationEditor.tsx b/public/app/features/dashboard/components/TransformationsEditor/TransformationEditor.tsx index f1cb7042a7f..c6644031ade 100644 --- a/public/app/features/dashboard/components/TransformationsEditor/TransformationEditor.tsx +++ b/public/app/features/dashboard/components/TransformationsEditor/TransformationEditor.tsx @@ -55,7 +55,7 @@ export const TransformationEditor = ({ React.createElement(uiConfig.editor, { options: { ...uiConfig.transformation.defaultOptions, ...config.transformation.options }, input, - onChange: (opts: any) => { + onChange: (opts) => { onChange(index, { id: config.transformation.id, options: opts }); }, }), diff --git a/public/app/features/dashboard/components/VersionHistory/HistorySrv.test.ts b/public/app/features/dashboard/components/VersionHistory/HistorySrv.test.ts index be6d274abbd..ced192487d8 100644 --- a/public/app/features/dashboard/components/VersionHistory/HistorySrv.test.ts +++ b/public/app/features/dashboard/components/VersionHistory/HistorySrv.test.ts @@ -38,19 +38,19 @@ describe('historySrv', () => { getMock.mockImplementation(() => Promise.resolve(versionsResponse)); historySrv = new HistorySrv(); - return historySrv.getHistoryList(dash, historyListOpts).then((versions: any) => { + return historySrv.getHistoryList(dash, historyListOpts).then((versions) => { expect(versions).toEqual(versionsResponse); }); }); it('should return an empty array when not given an id', () => { - return historySrv.getHistoryList(emptyDash, historyListOpts).then((versions: any) => { + return historySrv.getHistoryList(emptyDash, historyListOpts).then((versions) => { expect(versions).toEqual([]); }); }); it('should return an empty array when not given a dashboard', () => { - return historySrv.getHistoryList(null as unknown as DashboardModel, historyListOpts).then((versions: any) => { + return historySrv.getHistoryList(null as unknown as DashboardModel, historyListOpts).then((versions) => { expect(versions).toEqual([]); }); }); @@ -61,7 +61,7 @@ describe('historySrv', () => { const version = 6; postMock.mockImplementation(() => Promise.resolve(restoreResponse(version))); historySrv = new HistorySrv(); - return historySrv.restoreDashboard(dash, version).then((response: any) => { + return historySrv.restoreDashboard(dash, version).then((response) => { expect(response).toEqual(restoreResponse(version)); }); }); diff --git a/public/app/features/dashboard/components/VersionHistory/VersionHistoryComparison.tsx b/public/app/features/dashboard/components/VersionHistory/VersionHistoryComparison.tsx index 2a106e45b3e..db85c1bf1fe 100644 --- a/public/app/features/dashboard/components/VersionHistory/VersionHistoryComparison.tsx +++ b/public/app/features/dashboard/components/VersionHistory/VersionHistoryComparison.tsx @@ -15,7 +15,7 @@ type DiffViewProps = { isNewLatest: boolean; newInfo: DecoratedRevisionModel; baseInfo: DecoratedRevisionModel; - diffData: { lhs: any; rhs: any }; + diffData: { lhs: unknown; rhs: unknown }; }; export const VersionHistoryComparison: React.FC = ({ baseInfo, newInfo, diffData, isNewLatest }) => { diff --git a/public/app/features/dashboard/containers/DashboardPage.test.tsx b/public/app/features/dashboard/containers/DashboardPage.test.tsx index 07cdfb4dca9..be37870e6a3 100644 --- a/public/app/features/dashboard/containers/DashboardPage.test.tsx +++ b/public/app/features/dashboard/containers/DashboardPage.test.tsx @@ -17,7 +17,7 @@ import { DashboardInitPhase, DashboardMeta, DashboardRoutes } from 'app/types'; import { configureStore } from '../../../store/configureStore'; import { Props as LazyLoaderProps } from '../dashgrid/LazyLoader'; -import { setDashboardSrv } from '../services/DashboardSrv'; +import { DashboardSrv, setDashboardSrv } from '../services/DashboardSrv'; import { DashboardModel } from '../state'; import { Props, UnthemedDashboardPage } from './DashboardPage'; @@ -217,7 +217,7 @@ describe('DashboardPage', () => { }); setDashboardSrv({ getCurrent: () => getTestDashboard(), - } as any); + } as DashboardSrv); ctx.mount({ dashboard: getTestDashboard(), queryParams: { viewPanel: '1' }, diff --git a/public/app/features/dashboard/dashgrid/DashboardGrid.tsx b/public/app/features/dashboard/dashgrid/DashboardGrid.tsx index b24841fe679..74f11cfea55 100644 --- a/public/app/features/dashboard/dashgrid/DashboardGrid.tsx +++ b/public/app/features/dashboard/dashgrid/DashboardGrid.tsx @@ -52,7 +52,7 @@ export class DashboardGrid extends PureComponent { } buildLayout() { - const layout = []; + const layout: ReactGridLayout.Layout[] = []; this.panelMap = {}; for (const panel of this.props.dashboard.panels) { @@ -66,7 +66,7 @@ export class DashboardGrid extends PureComponent { continue; } - const panelPos: any = { + const panelPos: ReactGridLayout.Layout = { i: panel.key, x: panel.gridPos.x, y: panel.gridPos.y, @@ -176,7 +176,7 @@ export class DashboardGrid extends PureComponent { return panelElements; } - renderPanel(panel: PanelModel, width: any, height: any) { + renderPanel(panel: PanelModel, width: number, height: number) { if (panel.type === 'row') { return ; } diff --git a/public/app/features/dashboard/dashgrid/PanelHeader/PanelHeaderMenuItem.tsx b/public/app/features/dashboard/dashgrid/PanelHeader/PanelHeaderMenuItem.tsx index 23e82c1cc88..05cf46d3510 100644 --- a/public/app/features/dashboard/dashgrid/PanelHeader/PanelHeaderMenuItem.tsx +++ b/public/app/features/dashboard/dashgrid/PanelHeader/PanelHeaderMenuItem.tsx @@ -6,7 +6,7 @@ import { selectors } from '@grafana/e2e-selectors'; import { Icon, toIconName, useStyles2 } from '@grafana/ui'; interface Props { - children?: any; + children?: React.ReactNode; } export const PanelHeaderMenuItem: FC = (props) => { diff --git a/public/app/features/dashboard/services/DashboardSrv.ts b/public/app/features/dashboard/services/DashboardSrv.ts index 0a0ae013172..0b4eb8d0f07 100644 --- a/public/app/features/dashboard/services/DashboardSrv.ts +++ b/public/app/features/dashboard/services/DashboardSrv.ts @@ -90,7 +90,7 @@ export class DashboardSrv { ); } - starDashboard(dashboardId: string, isStarred: any) { + starDashboard(dashboardId: string, isStarred: boolean) { const backendSrv = getBackendSrv(); let promise; diff --git a/public/app/features/dashboard/services/PublicDashboardDataSource.ts b/public/app/features/dashboard/services/PublicDashboardDataSource.ts index c57d8b7effe..f9a09e89515 100644 --- a/public/app/features/dashboard/services/PublicDashboardDataSource.ts +++ b/public/app/features/dashboard/services/PublicDashboardDataSource.ts @@ -100,7 +100,7 @@ export class PublicDashboardDataSource extends DataSourceApi({ @@ -135,7 +135,7 @@ export class PublicDashboardDataSource extends DataSourceApi { + testDatasource(): Promise { return Promise.resolve(null); } }