diff --git a/.betterer.results b/.betterer.results index 24e6321e7e2..e2d8f86b1dd 100644 --- a/.betterer.results +++ b/.betterer.results @@ -4374,12 +4374,9 @@ exports[`better eslint`] = { [0, 0, 0, "Unexpected any. Specify a different type.", "7"], [0, 0, 0, "Unexpected any. Specify a different type.", "8"], [0, 0, 0, "Unexpected any. Specify a different type.", "9"], - [0, 0, 0, "Unexpected any. Specify a different type.", "10"], - [0, 0, 0, "Unexpected any. Specify a different type.", "11"], - [0, 0, 0, "Do not use any type assertions.", "12"], - [0, 0, 0, "Do not use any type assertions.", "13"], - [0, 0, 0, "Unexpected any. Specify a different type.", "14"], - [0, 0, 0, "Do not use any type assertions.", "15"] + [0, 0, 0, "Do not use any type assertions.", "10"], + [0, 0, 0, "Do not use any type assertions.", "11"], + [0, 0, 0, "Do not use any type assertions.", "12"] ], "public/app/features/trails/SelectMetricTrailView.tsx:5381": [ [0, 0, 0, "Do not use any type assertions.", "0"], @@ -5947,24 +5944,16 @@ exports[`better eslint`] = { [0, 0, 0, "Styles should be written using objects.", "0"], [0, 0, 0, "Styles should be written using objects.", "1"] ], - "public/app/plugins/datasource/tempo/traceql/autocomplete.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/plugins/datasource/zipkin/ConfigEditor.tsx:5381": [ [0, 0, 0, "Styles should be written using objects.", "0"] ], "public/app/plugins/datasource/zipkin/QueryField.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, "Unexpected any. Specify a different type.", "2"] + [0, 0, 0, "Unexpected any. Specify a different type.", "1"] ], "public/app/plugins/datasource/zipkin/datasource.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.", "4"] + [0, 0, 0, "Unexpected any. Specify a different type.", "1"] ], "public/app/plugins/datasource/zipkin/utils/testResponse.ts:5381": [ [0, 0, 0, "Unexpected any. Specify a different type.", "0"], @@ -6003,8 +5992,7 @@ exports[`better eslint`] = { ], "public/app/plugins/panel/alertlist/AlertListMigrationHandler.ts:5381": [ [0, 0, 0, "Unexpected any. Specify a different type.", "0"], - [0, 0, 0, "Unexpected any. Specify a different type.", "1"], - [0, 0, 0, "Unexpected any. Specify a different type.", "2"] + [0, 0, 0, "Unexpected any. Specify a different type.", "1"] ], "public/app/plugins/panel/alertlist/UnifiedAlertList.tsx:5381": [ [0, 0, 0, "Styles should be written using objects.", "0"], @@ -6036,18 +6024,11 @@ exports[`better eslint`] = { ], "public/app/plugins/panel/annolist/AnnoListPanel.test.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.", "1"] ], "public/app/plugins/panel/annolist/AnnoListPanel.tsx:5381": [ - [0, 0, 0, "Unexpected any. Specify a different type.", "0"], - [0, 0, 0, "Unexpected any. Specify a different type.", "1"], - [0, 0, 0, "Do not use any type assertions.", "2"], - [0, 0, 0, "Styles should be written using objects.", "3"] - ], - "public/app/plugins/panel/annolist/module.tsx:5381": [ - [0, 0, 0, "Do not use any type assertions.", "0"] + [0, 0, 0, "Do not use any type assertions.", "0"], + [0, 0, 0, "Styles should be written using objects.", "1"] ], "public/app/plugins/panel/barchart/BarChartPanel.tsx:5381": [ [0, 0, 0, "Do not use any type assertions.", "0"], @@ -6094,9 +6075,6 @@ exports[`better eslint`] = { "public/app/plugins/panel/canvas/globalStyles.ts:5381": [ [0, 0, 0, "Styles should be written using objects.", "0"] ], - "public/app/plugins/panel/dashlist/migrations.test.ts:5381": [ - [0, 0, 0, "Unexpected any. Specify a different type.", "0"] - ], "public/app/plugins/panel/dashlist/styles.ts:5381": [ [0, 0, 0, "Styles should be written using objects.", "0"], [0, 0, 0, "Styles should be written using objects.", "1"], @@ -6117,8 +6095,7 @@ exports[`better eslint`] = { ], "public/app/plugins/panel/debug/EventBusLogger.tsx:5381": [ [0, 0, 0, "Unexpected any. Specify a different type.", "0"], - [0, 0, 0, "Do not use any type assertions.", "1"], - [0, 0, 0, "Unexpected any. Specify a different type.", "2"] + [0, 0, 0, "Unexpected any. Specify a different type.", "1"] ], "public/app/plugins/panel/gauge/GaugeMigrations.ts:5381": [ [0, 0, 0, "Unexpected any. Specify a different type.", "0"] @@ -6168,8 +6145,7 @@ exports[`better eslint`] = { [0, 0, 0, "Unexpected any. Specify a different type.", "1"] ], "public/app/plugins/panel/geomap/utils/layers.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.", "0"] ], "public/app/plugins/panel/geomap/utils/tooltip.ts:5381": [ [0, 0, 0, "Do not use any type assertions.", "0"] @@ -6246,9 +6222,7 @@ exports[`better eslint`] = { [0, 0, 0, "Do not use any type assertions.", "16"] ], "public/app/plugins/panel/histogram/Histogram.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, "Unexpected any. Specify a different type.", "2"] + [0, 0, 0, "Do not use any type assertions.", "0"] ], "public/app/plugins/panel/live/LiveChannelEditor.tsx:5381": [ [0, 0, 0, "Unexpected any. Specify a different type.", "0"], @@ -6330,13 +6304,6 @@ exports[`better eslint`] = { [0, 0, 0, "Styles should be written using objects.", "0"], [0, 0, 0, "Styles should be written using objects.", "1"] ], - "public/app/plugins/panel/nodeGraph/usePanning.ts:5381": [ - [0, 0, 0, "Do not use any type assertions.", "0"] - ], - "public/app/plugins/panel/nodeGraph/utils.ts:5381": [ - [0, 0, 0, "Unexpected any. Specify a different type.", "0"], - [0, 0, 0, "Unexpected any. Specify a different type.", "1"] - ], "public/app/plugins/panel/piechart/PieChart.tsx:5381": [ [0, 0, 0, "Styles should be written using objects.", "0"], [0, 0, 0, "Styles should be written using objects.", "1"], @@ -6349,8 +6316,7 @@ exports[`better eslint`] = { [0, 0, 0, "Unexpected any. Specify a different type.", "1"] ], "public/app/plugins/panel/stat/StatMigrations.ts:5381": [ - [0, 0, 0, "Unexpected any. Specify a different type.", "0"], - [0, 0, 0, "Unexpected any. Specify a different type.", "1"] + [0, 0, 0, "Unexpected any. Specify a different type.", "0"] ], "public/app/plugins/panel/state-timeline/migrations.ts:5381": [ [0, 0, 0, "Unexpected any. Specify a different type.", "0"], @@ -6403,14 +6369,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"] + [0, 0, 0, "Unexpected any. Specify a different type.", "11"] ], "public/app/plugins/panel/table-old/renderer.ts:5381": [ [0, 0, 0, "Unexpected any. Specify a different type.", "0"], @@ -6485,17 +6444,15 @@ exports[`better eslint`] = { ], "public/app/plugins/panel/timeseries/migrations.ts:5381": [ [0, 0, 0, "Unexpected any. Specify a different type.", "0"], - [0, 0, 0, "Unexpected any. Specify a different type.", "1"], - [0, 0, 0, "Do not use any type assertions.", "2"], - [0, 0, 0, "Unexpected any. Specify a different type.", "3"], - [0, 0, 0, "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.", "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, "Unexpected any. Specify a different type.", "10"], - [0, 0, 0, "Unexpected any. Specify a different type.", "11"] + [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, "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, "Unexpected any. Specify a different type.", "9"] ], "public/app/plugins/panel/timeseries/plugins/ThresholdDragHandle.tsx:5381": [ [0, 0, 0, "Styles should be written using objects.", "0"], @@ -6569,14 +6526,6 @@ exports[`better eslint`] = { [0, 0, 0, "Unexpected any. Specify a different type.", "0"], [0, 0, 0, "Do not use any type assertions.", "1"] ], - "public/app/plugins/panel/xychart/dims.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, "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"] - ], "public/app/plugins/panel/xychart/scatter.ts:5381": [ [0, 0, 0, "Do not use any type assertions.", "0"], [0, 0, 0, "Do not use any type assertions.", "1"], @@ -6693,8 +6642,7 @@ exports[`better eslint`] = { [0, 0, 0, "Unexpected any. Specify a different type.", "7"], [0, 0, 0, "Unexpected any. Specify a different type.", "8"], [0, 0, 0, "Unexpected any. Specify a different type.", "9"], - [0, 0, 0, "Unexpected any. Specify a different type.", "10"], - [0, 0, 0, "Unexpected any. Specify a different type.", "11"] + [0, 0, 0, "Unexpected any. Specify a different type.", "10"] ] }` }; diff --git a/public/app/features/templating/template_srv.ts b/public/app/features/templating/template_srv.ts index a255e9384ae..9aa3133080c 100644 --- a/public/app/features/templating/template_srv.ts +++ b/public/app/features/templating/template_srv.ts @@ -69,7 +69,7 @@ export class TemplateSrv implements BaseTemplateSrv { * * Use getVariables function instead */ - get variables(): any[] { + get variables(): TypedVariableModel[] { deprecationWarning('template_srv.ts', 'variables', 'getVariables'); return this.getVariables(); } @@ -84,7 +84,7 @@ export class TemplateSrv implements BaseTemplateSrv { } updateIndex() { - const existsOrEmpty = (value: any) => value || value === ''; + const existsOrEmpty = (value: unknown) => value || value === ''; this.index = this._variables.reduce((acc, currentValue) => { if (currentValue.current && (currentValue.current.isNone || existsOrEmpty(currentValue.current.value))) { @@ -360,7 +360,7 @@ export class TemplateSrv implements BaseTemplateSrv { }); } - isAllValue(value: any) { + isAllValue(value: unknown) { return value === ALL_VARIABLE_VALUE || (Array.isArray(value) && value[0] === ALL_VARIABLE_VALUE); } diff --git a/public/app/plugins/datasource/tempo/traceql/autocomplete.test.ts b/public/app/plugins/datasource/tempo/traceql/autocomplete.test.ts index ad15cc0c95b..4b2e6b0d5f5 100644 --- a/public/app/plugins/datasource/tempo/traceql/autocomplete.test.ts +++ b/public/app/plugins/datasource/tempo/traceql/autocomplete.test.ts @@ -409,12 +409,12 @@ function setup(value: string, offset: number, tagsV1?: string[], tagsV2?: Scope[ EnumMember: 2, }, }, - } as any; + } as unknown as typeof monacoTypes; provider.editor = { getModel() { return model; }, - } as any; + } as unknown as monacoTypes.editor.IStandaloneCodeEditor; return { provider, model } as unknown as { provider: CompletionProvider; model: monacoTypes.editor.ITextModel }; } diff --git a/public/app/plugins/datasource/zipkin/QueryField.tsx b/public/app/plugins/datasource/zipkin/QueryField.tsx index df9a83970e8..3a809b72453 100644 --- a/public/app/plugins/datasource/zipkin/QueryField.tsx +++ b/public/app/plugins/datasource/zipkin/QueryField.tsx @@ -183,7 +183,7 @@ type OptionsState = { // Exported for tests export function useLoadOptions(datasource: ZipkinDatasource) { const isMounted = useMountedState(); - const [allOptions, setAllOptions] = useState({} as OptionsState); + const [allOptions, setAllOptions] = useState({}); const [, fetchSpans] = useAsyncFn( async function findSpans(service: string): Promise { diff --git a/public/app/plugins/datasource/zipkin/datasource.ts b/public/app/plugins/datasource/zipkin/datasource.ts index 6fa69c83834..4a7657335d4 100644 --- a/public/app/plugins/datasource/zipkin/datasource.ts +++ b/public/app/plugins/datasource/zipkin/datasource.ts @@ -61,7 +61,7 @@ export class ZipkinDatasource extends DataSourceApi return of(emptyDataQueryResponse); } - async metadataRequest(url: string, params?: Record): Promise { + async metadataRequest(url: string, params?: Record) { const res = await lastValueFrom(this.request(url, params, { hideFromInspector: true })); return res.data; } @@ -100,7 +100,7 @@ export class ZipkinDatasource extends DataSourceApi private request( apiUrl: string, - data?: any, + data?: unknown, options?: Partial ): Observable> { const params = data ? urlUtil.serializeParams(data) : ''; diff --git a/public/app/plugins/panel/alertlist/AlertListMigrationHandler.ts b/public/app/plugins/panel/alertlist/AlertListMigrationHandler.ts index 2fccfa8ddb5..c36cd742e89 100644 --- a/public/app/plugins/panel/alertlist/AlertListMigrationHandler.ts +++ b/public/app/plugins/panel/alertlist/AlertListMigrationHandler.ts @@ -16,7 +16,7 @@ export const alertListPanelMigrationHandler = ( tags: panel.options.tags ?? panel.dashboardTags ?? [], stateFilter: panel.options.stateFilter ?? - panel.stateFilter?.reduce((filterObj: any, curFilter: any) => ({ ...filterObj, [curFilter]: true }), {}) ?? + panel.stateFilter?.reduce((filterObj: object, curFilter: any) => ({ ...filterObj, [curFilter]: true }), {}) ?? {}, }; diff --git a/public/app/plugins/panel/annolist/AnnoListPanel.test.tsx b/public/app/plugins/panel/annolist/AnnoListPanel.test.tsx index f42c57ff7b7..d231be044a5 100644 --- a/public/app/plugins/panel/annolist/AnnoListPanel.test.tsx +++ b/public/app/plugins/panel/annolist/AnnoListPanel.test.tsx @@ -30,7 +30,7 @@ const defaultOptions: Options = { tags: ['tag A', 'tag B'], }; -const defaultResult: any = { +const defaultResult = { text: 'Result text', userId: 1, login: 'Result login', @@ -40,7 +40,7 @@ const defaultResult: any = { time: Date.UTC(2021, 0, 1, 0, 0, 0, 0), panelId: 13, dashboardId: 14, // deliberately different from panelId - id: 14, + id: '14', uid: '7MeksYbmk', dashboardUID: '7MeksYbmk', url: '/d/asdkjhajksd/some-dash', @@ -55,7 +55,7 @@ async function setupTestContext({ const getMock = jest.spyOn(backendSrv, 'get'); getMock.mockResolvedValue(results); - const dash: any = { uid: 'srx16xR4z', formatDate: (time: number) => new Date(time).toISOString() }; + const dash = { uid: 'srx16xR4z', formatDate: (time: number) => new Date(time).toISOString() }; const dashSrv: any = { getCurrent: () => dash }; setDashboardSrv(dashSrv); const pushSpy = jest.spyOn(locationService, 'push'); diff --git a/public/app/plugins/panel/annolist/AnnoListPanel.tsx b/public/app/plugins/panel/annolist/AnnoListPanel.tsx index 252e353dccc..2e637d7c3bf 100644 --- a/public/app/plugins/panel/annolist/AnnoListPanel.tsx +++ b/public/app/plugins/panel/annolist/AnnoListPanel.tsx @@ -90,7 +90,11 @@ export class AnnoListPanel extends PureComponent { const { options } = this.props; const { queryUser, queryTags } = this.state; - const params: any = { + const params: { + tags: typeof options.tags; + limit: typeof options.limit; + type: string; + } & Record = { tags: options.tags, limit: options.limit, type: 'annotation', // Skip the Annotations that are really alerts. (Use the alerts panel!) @@ -139,15 +143,12 @@ export class AnnoListPanel extends PureComponent { const dashboardSrv = getDashboardSrv(); const current = dashboardSrv.getCurrent(); - const params: any = { + const params = { from: this._timeOffset(anno.time, options.navigateBefore, true), to: this._timeOffset(anno.timeEnd ?? anno.time, options.navigateAfter, false), + viewPanel: options.navigateToPanel ? anno.panelId : undefined, }; - if (options.navigateToPanel) { - params.viewPanel = anno.panelId; - } - if (current?.uid === anno.dashboardUID) { locationService.partial(params); return; @@ -157,8 +158,8 @@ export class AnnoListPanel extends PureComponent { if (result && result.length && result[0].uid === anno.dashboardUID) { const dash = result[0]; const url = new URL(dash.url, window.location.origin); - url.searchParams.set('from', params.from); - url.searchParams.set('to', params.to); + url.searchParams.set('from', String(params.from)); + url.searchParams.set('to', String(params.to)); locationService.push(locationUtil.stripBaseFromUrl(url.toString())); return; } diff --git a/public/app/plugins/panel/annolist/module.tsx b/public/app/plugins/panel/annolist/module.tsx index d719e221fb6..e914b3fad98 100644 --- a/public/app/plugins/panel/annolist/module.tsx +++ b/public/app/plugins/panel/annolist/module.tsx @@ -95,9 +95,9 @@ export const plugin = new PanelPlugin(AnnoListPanel) }); }) // TODO, we should support this directly in the plugin infrastructure - .setPanelChangeHandler((panel: PanelModel, prevPluginId: string, prevOptions: unknown) => { + .setPanelChangeHandler((panel: PanelModel, prevPluginId, prevOptions) => { if (prevPluginId === 'ryantxu-annolist-panel') { - return prevOptions as Options; + return prevOptions; } return panel.options; diff --git a/public/app/plugins/panel/dashlist/migrations.test.ts b/public/app/plugins/panel/dashlist/migrations.test.ts index 62f1f51172a..607c5b9c7a6 100644 --- a/public/app/plugins/panel/dashlist/migrations.test.ts +++ b/public/app/plugins/panel/dashlist/migrations.test.ts @@ -19,7 +19,7 @@ describe('dashlist migrations', () => { const basePanelModel = wellFormedPanelModel({}); basePanelModel.pluginVersion = '5.1'; - const angularPanel: PanelModel & AngularModel = { + const angularPanel: PanelModel & AngularModel = { ...basePanelModel, // pluginVersion: '5.1', starred: true, diff --git a/public/app/plugins/panel/debug/EventBusLogger.tsx b/public/app/plugins/panel/debug/EventBusLogger.tsx index c13501abd61..32bedcf6bd9 100644 --- a/public/app/plugins/panel/debug/EventBusLogger.tsx +++ b/public/app/plugins/panel/debug/EventBusLogger.tsx @@ -52,7 +52,7 @@ export class EventBusLoggerPanel extends PureComponent { eventObserver: PartialObserver = { next: (event: BusEvent) => { - const origin = event.origin as any; + const origin: any = event.origin; this.history.add({ key: counter++, type: event.type, diff --git a/public/app/plugins/panel/geomap/utils/layers.ts b/public/app/plugins/panel/geomap/utils/layers.ts index 75a2357c388..834517fa7df 100644 --- a/public/app/plugins/panel/geomap/utils/layers.ts +++ b/public/app/plugins/panel/geomap/utils/layers.ts @@ -154,6 +154,6 @@ export async function initLayer( return state; } -export const getMapLayerState = (l: any) => { - return l?.__state as MapLayerState; +export const getMapLayerState = (l: any): MapLayerState => { + return l?.__state; }; diff --git a/public/app/plugins/panel/geomap/utils/tooltip.ts b/public/app/plugins/panel/geomap/utils/tooltip.ts index aeb3722a008..9ce1696fb01 100644 --- a/public/app/plugins/panel/geomap/utils/tooltip.ts +++ b/public/app/plugins/panel/geomap/utils/tooltip.ts @@ -62,7 +62,7 @@ export const pointerMoveListener = (evt: MapBrowserEvent, panel: Geo panel.map.forEachFeatureAtPixel( pixel, (feature, layer, geo) => { - const s: MapLayerState = getMapLayerState(layer); + const s = getMapLayerState(layer); //match hover layer to layer in layers //check if the layer show tooltip is enabled //then also pass the list of tooltip fields if exists diff --git a/public/app/plugins/panel/histogram/Histogram.tsx b/public/app/plugins/panel/histogram/Histogram.tsx index 29852eb5728..922d19433f9 100644 --- a/public/app/plugins/panel/histogram/Histogram.tsx +++ b/public/app/plugins/panel/histogram/Histogram.tsx @@ -287,7 +287,9 @@ export class Histogram extends React.Component { } prepState(props: HistogramProps, withConfig = true) { - let state: State = null as any; + let state: State = { + alignedData: [], + }; const { alignedFrame } = props; if (alignedFrame) { diff --git a/public/app/plugins/panel/nodeGraph/usePanning.ts b/public/app/plugins/panel/nodeGraph/usePanning.ts index 995646b15b4..41daf7daf12 100644 --- a/public/app/plugins/panel/nodeGraph/usePanning.ts +++ b/public/app/plugins/panel/nodeGraph/usePanning.ts @@ -184,10 +184,10 @@ function inBounds(value: number, min: number | undefined, max: number | undefine } // The issue here is that TouchEvent is undefined while using instanceof in Firefox and Safari -// which will throw an exception but if it's (event as TouchEvent).changedTouches it will be undefined +// which will throw an exception but if it's event.changedTouches it will be undefined // and the if check will fail so it will go to the else but will not throw an exception function getEventXY(event: Event): { x: number; y: number } { - if ((event as TouchEvent).changedTouches && event instanceof TouchEvent) { + if ('changedTouches' in event && event instanceof TouchEvent) { return { x: event.changedTouches[0].clientX, y: event.changedTouches[0].clientY }; } else if (event instanceof MouseEvent) { return { x: event.clientX, y: event.clientY }; diff --git a/public/app/plugins/panel/nodeGraph/utils.test.ts b/public/app/plugins/panel/nodeGraph/utils.test.ts index b920dfe59c8..00fcf3be24c 100644 --- a/public/app/plugins/panel/nodeGraph/utils.test.ts +++ b/public/app/plugins/panel/nodeGraph/utils.test.ts @@ -275,6 +275,7 @@ function makeNodeDatum(options: Partial = {}) { config: { color: { fixedColor: 'green', + mode: 'fixed', }, }, name: 'arc__success', @@ -285,6 +286,7 @@ function makeNodeDatum(options: Partial = {}) { config: { color: { fixedColor: 'red', + mode: 'fixed', }, }, name: 'arc__errors', diff --git a/public/app/plugins/panel/nodeGraph/utils.ts b/public/app/plugins/panel/nodeGraph/utils.ts index 728026b95d0..e634ea2581d 100644 --- a/public/app/plugins/panel/nodeGraph/utils.ts +++ b/public/app/plugins/panel/nodeGraph/utils.ts @@ -370,7 +370,7 @@ function makeNode(index: number) { } function nodesFrame() { - const fields: any = { + const fields = { [NodeGraphDataFrameFieldNames.id]: { values: [], type: FieldType.string, @@ -394,17 +394,17 @@ function nodesFrame() { [NodeGraphDataFrameFieldNames.arc + 'success']: { values: [], type: FieldType.number, - config: { color: { fixedColor: 'green' } }, + config: { color: { mode: FieldColorModeId.Fixed, fixedColor: 'green' } }, }, [NodeGraphDataFrameFieldNames.arc + 'errors']: { values: [], type: FieldType.number, - config: { color: { fixedColor: 'red' } }, + config: { color: { mode: FieldColorModeId.Fixed, fixedColor: 'red' } }, }, [NodeGraphDataFrameFieldNames.color]: { values: [], type: FieldType.number, - config: { color: { mode: 'continuous-GrYlRd' } }, + config: { color: { mode: FieldColorModeId.ContinuousGrYlRd } }, }, [NodeGraphDataFrameFieldNames.icon]: { values: [], @@ -418,8 +418,8 @@ function nodesFrame() { return new MutableDataFrame({ name: 'nodes', - fields: Object.keys(fields).map((key) => ({ - ...fields[key], + fields: Object.entries(fields).map(([key, value]) => ({ + ...value, name: key, })), }); @@ -440,7 +440,7 @@ export function makeEdgesDataFrame( } function edgesFrame() { - const fields: any = { + const fields = { [NodeGraphDataFrameFieldNames.id]: { values: [], type: FieldType.string, @@ -465,8 +465,8 @@ function edgesFrame() { return new MutableDataFrame({ name: 'edges', - fields: Object.keys(fields).map((key) => ({ - ...fields[key], + fields: Object.entries(fields).map(([key, value]) => ({ + ...value, name: key, })), }); diff --git a/public/app/plugins/panel/stat/StatMigrations.ts b/public/app/plugins/panel/stat/StatMigrations.ts index 4eb5bbdb6c8..2708ef74412 100644 --- a/public/app/plugins/panel/stat/StatMigrations.ts +++ b/public/app/plugins/panel/stat/StatMigrations.ts @@ -6,7 +6,7 @@ import { Options } from './panelcfg.gen'; // This is called when the panel changes from another panel export const statPanelChangedHandler = ( - panel: PanelModel> | any, + panel: PanelModel>, prevPluginId: string, prevOptions: any ) => { diff --git a/public/app/plugins/panel/table-old/module.ts b/public/app/plugins/panel/table-old/module.ts index e6fa9c8ca75..82d6903929e 100644 --- a/public/app/plugins/panel/table-old/module.ts +++ b/public/app/plugins/panel/table-old/module.ts @@ -1,7 +1,9 @@ +import { IScope, IAngularStatic } from 'angular'; import $ from 'jquery'; import { defaults } from 'lodash'; import { isTableData, PanelEvents, PanelPlugin } from '@grafana/data'; +import { AnnotationsSrv } from 'app/angular/services/annotations_srv'; import config from 'app/core/config'; import { applyFilterFromTable } from 'app/features/variables/adhoc/actions'; import { MetricsPanelCtrl } from 'app/plugins/sdk'; @@ -56,9 +58,9 @@ export class TablePanelCtrl extends MetricsPanelCtrl { static $inject = ['$scope', '$injector', 'annotationsSrv', '$sanitize']; constructor( - $scope: any, - $injector: any, - private annotationsSrv: any, + $scope: IScope, + $injector: IAngularStatic['injector'], + private annotationsSrv: AnnotationsSrv, private $sanitize: any ) { super($scope, $injector); @@ -101,12 +103,11 @@ export class TablePanelCtrl extends MetricsPanelCtrl { panel: this.panel, range: this.range, }) - .then((anno: any) => { + .then((anno) => { this.loading = false; this.dataRaw = anno; this.pageIndex = 0; this.render(); - return { data: this.dataRaw }; // Not used }); } @@ -170,7 +171,7 @@ export class TablePanelCtrl extends MetricsPanelCtrl { this.render(); } - link(scope: any, elem: JQuery, attrs: any, ctrl: TablePanelCtrl) { + link(scope: IScope, elem: JQuery, attrs: any, ctrl: TablePanelCtrl) { let data: any; const panel = ctrl.panel; let pageCount = 0; @@ -191,7 +192,7 @@ export class TablePanelCtrl extends MetricsPanelCtrl { tbodyElem.html(ctrl.renderer.render(ctrl.pageIndex)); } - function switchPage(e: any) { + function switchPage(e: JQueryEventObject) { const el = $(e.currentTarget); ctrl.pageIndex = parseInt(el.text(), 10) - 1; renderPanel(); @@ -263,7 +264,7 @@ export class TablePanelCtrl extends MetricsPanelCtrl { unbindDestroy(); }); - ctrl.events.on(PanelEvents.render, (renderData: any) => { + ctrl.events.on(PanelEvents.render, (renderData: unknown) => { data = renderData || data; if (data) { renderPanel(); diff --git a/public/app/plugins/panel/timeseries/migrations.ts b/public/app/plugins/panel/timeseries/migrations.ts index fa138cd89a7..eecf50a36e3 100644 --- a/public/app/plugins/panel/timeseries/migrations.ts +++ b/public/app/plugins/panel/timeseries/migrations.ts @@ -399,7 +399,7 @@ export function graphToTimeseriesOptions(angular: any): { // timeRegions migration if (angular.timeRegions?.length) { - let regions: any[] = angular.timeRegions.map((old: GraphTimeRegionConfig, idx: number) => ({ + let regions = angular.timeRegions.map((old: GraphTimeRegionConfig, idx: number) => ({ name: `T${idx + 1}`, color: old.colorMode !== 'custom' ? old.colorMode : old.fillColor, line: old.line, @@ -684,7 +684,7 @@ function validNumber(val: unknown): number | undefined { return undefined; } -function getReducersFromLegend(obj: Record): string[] { +function getReducersFromLegend(obj: Record): string[] { const ids: string[] = []; for (const key of Object.keys(obj)) { const r = fieldReducers.getIfExists(key); diff --git a/public/app/plugins/panel/xychart/AutoEditor.tsx b/public/app/plugins/panel/xychart/AutoEditor.tsx index 9048cbf9ca1..66dcd0f3209 100644 --- a/public/app/plugins/panel/xychart/AutoEditor.tsx +++ b/public/app/plugins/panel/xychart/AutoEditor.tsx @@ -45,7 +45,7 @@ export const AutoEditor = ({ value, onChange, context }: StandardEditorProps false; } const m = getSimpleFieldMatcher(f); - return (field) => !m(field, undefined as any, undefined as any); + return (field) => !m(field, { fields: [], length: 0 }, []); } diff --git a/public/test/specs/helpers.ts b/public/test/specs/helpers.ts index ebce099682d..ad14ee1d4f2 100644 --- a/public/test/specs/helpers.ts +++ b/public/test/specs/helpers.ts @@ -101,7 +101,7 @@ export function ControllerTestContext(this: any) { }); }; - this.setIsUtc = (isUtc: any = false) => { + this.setIsUtc = (isUtc = false) => { self.isUtc = isUtc; }; }