diff --git a/.betterer.results b/.betterer.results index 4d292507ed6..8ab2c279de6 100644 --- a/.betterer.results +++ b/.betterer.results @@ -1356,21 +1356,9 @@ exports[`better eslint`] = { "packages/grafana-ui/src/components/Layout/Layout.story.tsx:5381": [ [0, 0, 0, "Do not use any type assertions.", "0"] ], - "packages/grafana-ui/src/components/Link/Link.tsx:5381": [ - [0, 0, 0, "Do not use any type assertions.", "0"] - ], - "packages/grafana-ui/src/components/List/List.story.internal.tsx:5381": [ - [0, 0, 0, "Do not use any type assertions.", "0"] - ], - "packages/grafana-ui/src/components/Logs/LogRowContext.tsx:5381": [ - [0, 0, 0, "Do not use any type assertions.", "0"] - ], "packages/grafana-ui/src/components/Logs/LogRowContextProvider.tsx:5381": [ [0, 0, 0, "Do not use any type assertions.", "0"], - [0, 0, 0, "Do not use any type assertions.", "1"], - [0, 0, 0, "Do not use any type assertions.", "2"], - [0, 0, 0, "Do not use any type assertions.", "3"], - [0, 0, 0, "Unexpected any. Specify a different type.", "4"] + [0, 0, 0, "Do not use any type assertions.", "1"] ], "packages/grafana-ui/src/components/Logs/LogRows.tsx:5381": [ [0, 0, 0, "Unexpected any. Specify a different type.", "0"] @@ -1387,12 +1375,6 @@ exports[`better eslint`] = { "packages/grafana-ui/src/components/Menu/MenuItem.tsx:5381": [ [0, 0, 0, "Unexpected any. Specify a different type.", "0"] ], - "packages/grafana-ui/src/components/Menu/hooks.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"] - ], "packages/grafana-ui/src/components/Modal/ModalsContext.tsx:5381": [ [0, 0, 0, "Unexpected any. Specify a different type.", "0"], [0, 0, 0, "Unexpected any. Specify a different type.", "1"], @@ -1419,14 +1401,7 @@ exports[`better eslint`] = { [0, 0, 0, "Unexpected any. Specify a different type.", "3"] ], "packages/grafana-ui/src/components/QueryField/QueryField.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"] - ], - "packages/grafana-ui/src/components/RefreshPicker/RefreshPicker.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.", "0"] ], "packages/grafana-ui/src/components/Segment/Segment.story.tsx:5381": [ [0, 0, 0, "Unexpected any. Specify a different type.", "0"], @@ -1513,9 +1488,6 @@ exports[`better eslint`] = { [0, 0, 0, "Unexpected any. Specify a different type.", "4"], [0, 0, 0, "Unexpected any. Specify a different type.", "5"] ], - "packages/grafana-ui/src/components/Select/utils.ts:5381": [ - [0, 0, 0, "Unexpected any. Specify a different type.", "0"] - ], "packages/grafana-ui/src/components/SetInterval/SetInterval.tsx:5381": [ [0, 0, 0, "Unexpected any. Specify a different type.", "0"] ], @@ -1553,21 +1525,13 @@ exports[`better eslint`] = { [0, 0, 0, "Unexpected any. Specify a different type.", "19"], [0, 0, 0, "Unexpected any. Specify a different type.", "20"] ], - "packages/grafana-ui/src/components/Sparkline/Sparkline.tsx:5381": [ - [0, 0, 0, "Do not use any type assertions.", "0"] - ], "packages/grafana-ui/src/components/StatsPicker/StatsPicker.story.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"] ], - "packages/grafana-ui/src/components/Table/BarGaugeCell.tsx:5381": [ - [0, 0, 0, "Do not use any type assertions.", "0"] - ], "packages/grafana-ui/src/components/Table/CellActions.tsx:5381": [ - [0, 0, 0, "Do not use any type assertions.", "0"], - [0, 0, 0, "Do not use any type assertions.", "1"], - [0, 0, 0, "Do not use any type assertions.", "2"] + [0, 0, 0, "Do not use any type assertions.", "0"] ], "packages/grafana-ui/src/components/Table/DefaultCell.tsx:5381": [ [0, 0, 0, "Do not use any type assertions.", "0"] @@ -1583,9 +1547,7 @@ exports[`better eslint`] = { [0, 0, 0, "Unexpected any. Specify a different type.", "1"] ], "packages/grafana-ui/src/components/Table/HeaderRow.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.", "0"] ], "packages/grafana-ui/src/components/Table/JSONViewCell.tsx:5381": [ [0, 0, 0, "Do not use any type assertions.", "0"] @@ -1607,11 +1569,10 @@ exports[`better eslint`] = { "packages/grafana-ui/src/components/Table/TableCell.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.", "3"], - [0, 0, 0, "Unexpected any. Specify a different type.", "4"], - [0, 0, 0, "Do not use any type assertions.", "5"], - [0, 0, 0, "Do not use any type assertions.", "6"] + [0, 0, 0, "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, "Do not use any type assertions.", "5"] ], "packages/grafana-ui/src/components/Table/TableCellInspectModal.tsx:5381": [ [0, 0, 0, "Unexpected any. Specify a different type.", "0"] @@ -1649,21 +1610,15 @@ 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, "Do not use any type assertions.", "7"], + [0, 0, 0, "Do not use any type assertions.", "6"], + [0, 0, 0, "Unexpected any. Specify a different type.", "7"], [0, 0, 0, "Unexpected any. Specify a different type.", "8"], [0, 0, 0, "Unexpected any. Specify a different type.", "9"], [0, 0, 0, "Unexpected any. Specify a different type.", "10"], - [0, 0, 0, "Unexpected any. Specify a different type.", "11"], - [0, 0, 0, "Unexpected any. Specify a different type.", "12"] + [0, 0, 0, "Unexpected any. Specify a different type.", "11"] ], "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"] - ], - "packages/grafana-ui/src/components/ThemeDemos/EmotionPerfTest.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.", "0"] ], "packages/grafana-ui/src/components/ThemeDemos/ThemeDemo.tsx:5381": [ [0, 0, 0, "Do not use any type assertions.", "0"], @@ -1671,28 +1626,12 @@ exports[`better eslint`] = { ], "packages/grafana-ui/src/components/TimeSeries/TimeSeries.tsx:5381": [ [0, 0, 0, "Do not use any type assertions.", "0"], - [0, 0, 0, "Do not use any type assertions.", "1"], - [0, 0, 0, "Do not use any type assertions.", "2"], - [0, 0, 0, "Unexpected any. Specify a different type.", "3"] + [0, 0, 0, "Do not use any type assertions.", "1"] ], "packages/grafana-ui/src/components/TimeSeries/utils.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.", "2"], - [0, 0, 0, "Unexpected any. Specify a different type.", "3"] - ], - "packages/grafana-ui/src/components/Tooltip/Tooltip.tsx:5381": [ - [0, 0, 0, "Do not use any type assertions.", "0"], - [0, 0, 0, "Unexpected any. Specify a different type.", "1"] - ], - "packages/grafana-ui/src/components/Tooltip/types.ts: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"] - ], - "packages/grafana-ui/src/components/VizLegend/VizLegendListItem.tsx:5381": [ - [0, 0, 0, "Unexpected any. Specify a different type.", "0"] + [0, 0, 0, "Unexpected any. Specify a different type.", "2"] ], "packages/grafana-ui/src/components/VizLegend/types.ts:5381": [ [0, 0, 0, "Unexpected any. Specify a different type.", "0"], @@ -1707,8 +1646,7 @@ exports[`better eslint`] = { ], "packages/grafana-ui/src/components/VizTooltip/VizTooltip.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"] ], "packages/grafana-ui/src/components/uPlot/Plot.tsx:5381": [ [0, 0, 0, "Do not use any type assertions.", "0"], @@ -1770,10 +1708,6 @@ exports[`better eslint`] = { "packages/grafana-ui/src/options/builder/hideSeries.tsx:5381": [ [0, 0, 0, "Do not use any type assertions.", "0"] ], - "packages/grafana-ui/src/options/builder/legend.tsx:5381": [ - [0, 0, 0, "Do not use any type assertions.", "0"], - [0, 0, 0, "Unexpected any. Specify a different type.", "1"] - ], "packages/grafana-ui/src/options/builder/stacking.tsx:5381": [ [0, 0, 0, "Unexpected any. Specify a different type.", "0"] ], diff --git a/packages/grafana-ui/src/components/Link/Link.tsx b/packages/grafana-ui/src/components/Link/Link.tsx index 0b9e9c80dd1..c9040f5231a 100644 --- a/packages/grafana-ui/src/components/Link/Link.tsx +++ b/packages/grafana-ui/src/components/Link/Link.tsx @@ -12,8 +12,7 @@ export const Link = forwardRef(({ href, children, ...r const validUrl = locationUtil.stripBaseFromUrl(textUtil.sanitizeUrl(href ?? '')); return ( - // @ts-ignore - } to={validUrl} {...rest}> + {children} ); diff --git a/packages/grafana-ui/src/components/List/List.story.internal.tsx b/packages/grafana-ui/src/components/List/List.story.internal.tsx index dd39646024c..c113c34bc5d 100644 --- a/packages/grafana-ui/src/components/List/List.story.internal.tsx +++ b/packages/grafana-ui/src/components/List/List.story.internal.tsx @@ -6,7 +6,7 @@ import tinycolor from 'tinycolor2'; import { InlineList } from './InlineList'; import { List } from './List'; -export default { +const meta: Meta = { title: 'Layout/List', component: List, parameters: { @@ -26,7 +26,9 @@ export default { }, }, }, -} as Meta; +}; + +export default meta; const generateListItems = (numberOfItems: number) => { return [...new Array(numberOfItems)].map((item, i) => { diff --git a/packages/grafana-ui/src/components/Logs/LogRowContext.tsx b/packages/grafana-ui/src/components/Logs/LogRowContext.tsx index 73d52fe01d1..4e8fc2ec47b 100644 --- a/packages/grafana-ui/src/components/Logs/LogRowContext.tsx +++ b/packages/grafana-ui/src/components/Logs/LogRowContext.tsx @@ -135,7 +135,7 @@ export const LogRowContextGroup: React.FunctionComponent { const { commonStyles, logs } = useStyles2(getLogRowContextStyles); const [scrollTop, setScrollTop] = useState(0); - const listContainerRef = useRef() as React.RefObject; + const listContainerRef = useRef(null); useLayoutEffect(() => { // We want to scroll to bottom only when we receive first 10 log lines diff --git a/packages/grafana-ui/src/components/Logs/LogRowContextProvider.tsx b/packages/grafana-ui/src/components/Logs/LogRowContextProvider.tsx index c70216f9db9..f1fab4e1eba 100644 --- a/packages/grafana-ui/src/components/Logs/LogRowContextProvider.tsx +++ b/packages/grafana-ui/src/components/Logs/LogRowContextProvider.tsx @@ -151,7 +151,7 @@ export const LogRowContextProvider: React.FunctionComponent(null as any as ResultType); + const [result, setResult] = useState(null); // React Hook that creates an object state value called hasMoreContextRows to component state and a setter function called setHasMoreContextRows // The initial value for hasMoreContextRows is {before: true, after: true} @@ -177,20 +177,22 @@ export const LogRowContextProvider: React.FunctionComponent ((a % n) + n) % n; const UNFOCUSED = -1; @@ -42,15 +40,19 @@ export const useMenuFocus = ({ }, [isMenuOpen, openedWithArrow, setOpenedWithArrow]); useEffect(() => { - const menuItems = localRef?.current?.querySelectorAll(`[data-role="menuitem"]`); - (menuItems?.[focusedItem] as MenuItemElement)?.focus(); + const menuItems = localRef?.current?.querySelectorAll( + `[data-role="menuitem"]` + ); + menuItems?.[focusedItem]?.focus(); menuItems?.forEach((menuItem, i) => { - (menuItem as MenuItemElement).tabIndex = i === focusedItem ? 0 : -1; + menuItem.tabIndex = i === focusedItem ? 0 : -1; }); }, [localRef, focusedItem]); useEffectOnce(() => { - const firstMenuItem = localRef?.current?.querySelector(`[data-role="menuitem"]`) as MenuItemElement | null; + const firstMenuItem = localRef?.current?.querySelector( + `[data-role="menuitem"]` + ); if (firstMenuItem) { firstMenuItem.tabIndex = 0; } @@ -58,7 +60,9 @@ export const useMenuFocus = ({ }); const handleKeys = (event: React.KeyboardEvent) => { - const menuItems = localRef?.current?.querySelectorAll(`[data-role="menuitem"]`); + const menuItems = localRef?.current?.querySelectorAll( + `[data-role="menuitem"]` + ); const menuItemsCount = menuItems?.length ?? 0; switch (event.key) { @@ -91,7 +95,7 @@ export const useMenuFocus = ({ case 'Enter': event.preventDefault(); event.stopPropagation(); - (menuItems?.[focusedItem] as MenuItemElement)?.click(); + menuItems?.[focusedItem]?.click(); break; case 'Escape': event.preventDefault(); diff --git a/packages/grafana-ui/src/components/QueryField/QueryField.tsx b/packages/grafana-ui/src/components/QueryField/QueryField.tsx index f543d3597f3..210e35bfbdf 100644 --- a/packages/grafana-ui/src/components/QueryField/QueryField.tsx +++ b/packages/grafana-ui/src/components/QueryField/QueryField.tsx @@ -4,7 +4,7 @@ import { debounce } from 'lodash'; import React, { Context, PureComponent } from 'react'; import { Value } from 'slate'; import Plain from 'slate-plain-serializer'; -import { Editor, Plugin } from 'slate-react'; +import { Editor, EventHook, Plugin } from 'slate-react'; import { GrafanaTheme2 } from '@grafana/data'; import { selectors } from '@grafana/e2e-selectors'; @@ -42,7 +42,7 @@ export interface QueryFieldProps extends Themeable2 { onBlur?: () => void; onChange?: (value: string) => void; onRichValueChange?: (value: Value) => void; - onClick?: (event: Event | React.MouseEvent, editor: Editor, next: () => any) => any; + onClick?: EventHook>; onTypeahead?: (typeahead: TypeaheadInput) => Promise; onWillApplySuggestion?: (suggestion: string, state: SuggestionsState) => string; placeholder?: string; diff --git a/packages/grafana-ui/src/components/RefreshPicker/RefreshPicker.tsx b/packages/grafana-ui/src/components/RefreshPicker/RefreshPicker.tsx index c2704534503..387175c223a 100644 --- a/packages/grafana-ui/src/components/RefreshPicker/RefreshPicker.tsx +++ b/packages/grafana-ui/src/components/RefreshPicker/RefreshPicker.tsx @@ -13,7 +13,7 @@ export const defaultIntervals = ['5s', '10s', '30s', '1m', '5m', '15m', '30m', ' export interface Props { intervals?: string[]; - onRefresh?: () => any; + onRefresh?: () => void; onIntervalChanged: (interval: string) => void; value?: string; tooltip?: string; @@ -50,8 +50,7 @@ export class RefreshPicker extends PureComponent { onChangeSelect = (item: SelectableValue) => { const { onIntervalChanged } = this.props; - if (onIntervalChanged) { - // @ts-ignore + if (onIntervalChanged && item.value) { onIntervalChanged(item.value); } }; @@ -127,7 +126,7 @@ export class RefreshPicker extends PureComponent { ) => { +export const cleanValue = ( + value: unknown, + options: Array +) => { if (Array.isArray(value)) { const filtered = value.filter(Boolean); return filtered?.length ? filtered : undefined; diff --git a/packages/grafana-ui/src/components/Sparkline/Sparkline.tsx b/packages/grafana-ui/src/components/Sparkline/Sparkline.tsx index ba02f8db302..cea10de0722 100644 --- a/packages/grafana-ui/src/components/Sparkline/Sparkline.tsx +++ b/packages/grafana-ui/src/components/Sparkline/Sparkline.tsx @@ -148,7 +148,7 @@ export class Sparkline extends PureComponent { for (let i = 0; i < data.fields.length; i++) { const field = data.fields[i]; - const config = field.config as FieldConfig; + const config: FieldConfig = field.config; const customConfig: GraphFieldConfig = { ...defaultConfig, ...config.custom, diff --git a/packages/grafana-ui/src/components/Table/BarGaugeCell.tsx b/packages/grafana-ui/src/components/Table/BarGaugeCell.tsx index 4e1c61f858e..a140a7e6840 100644 --- a/packages/grafana-ui/src/components/Table/BarGaugeCell.tsx +++ b/packages/grafana-ui/src/components/Table/BarGaugeCell.tsx @@ -1,7 +1,7 @@ import { isFunction } from 'lodash'; import React, { FC } from 'react'; -import { ThresholdsConfig, ThresholdsMode, VizOrientation, getFieldConfigWithMinMax, LinkModel } from '@grafana/data'; +import { ThresholdsConfig, ThresholdsMode, VizOrientation, getFieldConfigWithMinMax } from '@grafana/data'; import { BarGauge, BarGaugeDisplayMode } from '../BarGauge/BarGauge'; import { DataLinksContextMenu, DataLinksContextMenuApi } from '../DataLinks/DataLinksContextMenu'; @@ -44,7 +44,7 @@ export const BarGaugeCell: FC = (props) => { const getLinks = () => { if (!isFunction(field.getLinks)) { - return [] as LinkModel[]; + return []; } return field.getLinks({ valueRowIndex: row.index }); diff --git a/packages/grafana-ui/src/components/Table/CellActions.tsx b/packages/grafana-ui/src/components/Table/CellActions.tsx index 568d2f1ca5a..b6a4326e22e 100644 --- a/packages/grafana-ui/src/components/Table/CellActions.tsx +++ b/packages/grafana-ui/src/components/Table/CellActions.tsx @@ -13,15 +13,20 @@ interface CellActionProps extends TableCellProps { previewMode: 'text' | 'code'; } +interface CommonButtonProps { + size: IconSize; + tooltipPlacement: TooltipPlacement; +} + export function CellActions({ field, cell, previewMode, onCellFilterAdded }: CellActionProps) { const [isInspecting, setIsInspecting] = useState(false); const isRightAligned = getTextAlign(field) === 'flex-end'; const showFilters = Boolean(field.config.filterable) && cell.value !== undefined; const inspectEnabled = Boolean((field.config.custom as TableFieldOptions)?.inspect); - const commonButtonProps = { - size: 'sm' as IconSize, - tooltipPlacement: 'top' as TooltipPlacement, + const commonButtonProps: CommonButtonProps = { + size: 'sm', + tooltipPlacement: 'top', }; const onFilterFor = useCallback( diff --git a/packages/grafana-ui/src/components/Table/HeaderRow.tsx b/packages/grafana-ui/src/components/Table/HeaderRow.tsx index e6389620b5c..7d9147e4a41 100644 --- a/packages/grafana-ui/src/components/Table/HeaderRow.tsx +++ b/packages/grafana-ui/src/components/Table/HeaderRow.tsx @@ -51,7 +51,7 @@ function renderHeaderCell(column: any, tableStyles: TableStyles, showTypeIcons?: } headerProps.style.position = 'absolute'; - headerProps.style.justifyContent = (column as any).justifyContent; + headerProps.style.justifyContent = column.justifyContent; return (
diff --git a/packages/grafana-ui/src/components/Table/TableCell.tsx b/packages/grafana-ui/src/components/Table/TableCell.tsx index 2ebb78e89f5..7177142c122 100644 --- a/packages/grafana-ui/src/components/Table/TableCell.tsx +++ b/packages/grafana-ui/src/components/Table/TableCell.tsx @@ -15,7 +15,7 @@ export interface Props { export const TableCell: FC = ({ cell, tableStyles, onCellFilterAdded, columnIndex, columnCount, userProps }) => { const cellProps = cell.getCellProps(); - const field = (cell.column as any as GrafanaTableColumn).field; + const field = (cell.column as unknown as GrafanaTableColumn).field; if (!field?.display) { return null; diff --git a/packages/grafana-ui/src/components/Table/utils.ts b/packages/grafana-ui/src/components/Table/utils.ts index 5b6e13c740f..36221ea96fa 100644 --- a/packages/grafana-ui/src/components/Table/utils.ts +++ b/packages/grafana-ui/src/components/Table/utils.ts @@ -174,7 +174,7 @@ export function calculateUniqueFieldValues(rows: any[], field?: Field) { return {}; } - const set: Record = {}; + const set: Record = {}; for (let index = 0; index < rows.length; index++) { const value = rowToFieldValue(rows[index], field); diff --git a/packages/grafana-ui/src/components/Tags/Tag.tsx b/packages/grafana-ui/src/components/Tags/Tag.tsx index eee65fa0cd8..d9a08461184 100644 --- a/packages/grafana-ui/src/components/Tags/Tag.tsx +++ b/packages/grafana-ui/src/components/Tags/Tag.tsx @@ -11,7 +11,7 @@ import { Icon } from '../Icon/Icon'; /** * @public */ -export type OnTagClick = (name: string, event: React.MouseEvent) => any; +export type OnTagClick = (name: string, event: React.MouseEvent) => void; export interface Props extends Omit, 'onClick'> { /** Name of the tag to display */ diff --git a/packages/grafana-ui/src/components/ThemeDemos/EmotionPerfTest.tsx b/packages/grafana-ui/src/components/ThemeDemos/EmotionPerfTest.tsx index e2bfc382258..468f91dd50e 100644 --- a/packages/grafana-ui/src/components/ThemeDemos/EmotionPerfTest.tsx +++ b/packages/grafana-ui/src/components/ThemeDemos/EmotionPerfTest.tsx @@ -1,6 +1,6 @@ /** @jsxRuntime classic */ /** @jsx jsx */ -import { css, cx } from '@emotion/css'; +import { css, CSSInterpolation, cx } from '@emotion/css'; import { jsx } from '@emotion/react'; import classnames from 'classnames'; import { Profiler, ProfilerOnRenderCallback, useState, FC } from 'react'; @@ -174,7 +174,7 @@ const getStylesObjects = (theme: GrafanaTheme2) => { }; }; -function getStylesObjectMain(theme: GrafanaTheme2): any { +function getStylesObjectMain(theme: GrafanaTheme2): CSSInterpolation { return { background: 'blue', border: '1px solid red', @@ -187,7 +187,7 @@ function getStylesObjectMain(theme: GrafanaTheme2): any { }; } -function getStylesObjectChild(theme: GrafanaTheme2): any { +function getStylesObjectChild(theme: GrafanaTheme2): CSSInterpolation { return { padding: '2px', fontSize: '10px', diff --git a/packages/grafana-ui/src/components/TimeSeries/TimeSeries.tsx b/packages/grafana-ui/src/components/TimeSeries/TimeSeries.tsx index 9dd4a7c385d..499d01297be 100644 --- a/packages/grafana-ui/src/components/TimeSeries/TimeSeries.tsx +++ b/packages/grafana-ui/src/components/TimeSeries/TimeSeries.tsx @@ -53,7 +53,7 @@ export class UnthemedTimeSeries extends Component { {...this.props} prepConfig={this.prepConfig} propsToDiff={propsToDiff} - renderLegend={this.renderLegend as any} + renderLegend={this.renderLegend} /> ); } diff --git a/packages/grafana-ui/src/components/TimeSeries/utils.ts b/packages/grafana-ui/src/components/TimeSeries/utils.ts index 9f5b4fd59e3..f986ad9e83c 100644 --- a/packages/grafana-ui/src/components/TimeSeries/utils.ts +++ b/packages/grafana-ui/src/components/TimeSeries/utils.ts @@ -173,13 +173,13 @@ export const preparePlotConfigBuilder: UPlotConfigPrepFn<{ for (let i = 1; i < frame.fields.length; i++) { const field = frame.fields[i]; - const config = { + const config: FieldConfig = { ...field.config, custom: { ...defaultConfig, ...field.config.custom, }, - } as FieldConfig; + }; const customConfig: GraphFieldConfig = config.custom!; diff --git a/packages/grafana-ui/src/components/Tooltip/Tooltip.tsx b/packages/grafana-ui/src/components/Tooltip/Tooltip.tsx index 2ef3cd36933..239002b718b 100644 --- a/packages/grafana-ui/src/components/Tooltip/Tooltip.tsx +++ b/packages/grafana-ui/src/components/Tooltip/Tooltip.tsx @@ -66,8 +66,9 @@ export const Tooltip = React.memo(({ children, theme, interactive, show, placeme {typeof content === 'string' && content} {React.isValidElement(content) && React.cloneElement(content)} {typeof content === 'function' && + update && content({ - updatePopperPosition: update as any, + updatePopperPosition: update, })}
diff --git a/packages/grafana-ui/src/components/Tooltip/types.ts b/packages/grafana-ui/src/components/Tooltip/types.ts index 5c4aedeb9da..cec0b6dd8a0 100644 --- a/packages/grafana-ui/src/components/Tooltip/types.ts +++ b/packages/grafana-ui/src/components/Tooltip/types.ts @@ -7,7 +7,7 @@ export interface PopoverContentProps { updatePopperPosition?: () => void; } -export type PopoverContent = string | React.ReactElement | ((props: PopoverContentProps) => JSX.Element); +export type PopoverContent = string | React.ReactElement | ((props: PopoverContentProps) => JSX.Element); export type TooltipPlacement = | 'auto-start' diff --git a/packages/grafana-ui/src/components/UnitPicker/UnitPicker.tsx b/packages/grafana-ui/src/components/UnitPicker/UnitPicker.tsx index 1718ae5b128..983aded2a6c 100644 --- a/packages/grafana-ui/src/components/UnitPicker/UnitPicker.tsx +++ b/packages/grafana-ui/src/components/UnitPicker/UnitPicker.tsx @@ -29,7 +29,7 @@ export class UnitPicker extends PureComponent { const unitGroups = getValueFormats(); // Need to transform the data structure to work well with Select - const groupOptions = unitGroups.map((group) => { + const groupOptions: CascaderOption[] = unitGroups.map((group) => { const options = group.submenu.map((unit) => { const sel = { label: unit.text, @@ -60,7 +60,7 @@ export class UnitPicker extends PureComponent { allowCustomValue changeOnSelect={false} formatCreateLabel={formatCreateLabel} - options={groupOptions as CascaderOption[]} + options={groupOptions} placeholder="Choose" onSelect={this.props.onChange} /> diff --git a/packages/grafana-ui/src/components/VizLegend/VizLegendListItem.tsx b/packages/grafana-ui/src/components/VizLegend/VizLegendListItem.tsx index 1861e99fe83..01ad17d39c8 100644 --- a/packages/grafana-ui/src/components/VizLegend/VizLegendListItem.tsx +++ b/packages/grafana-ui/src/components/VizLegend/VizLegendListItem.tsx @@ -22,7 +22,7 @@ export interface Props { /** * @internal */ -export const VizLegendListItem = ({ +export const VizLegendListItem = ({ item, onLabelClick, onLabelMouseEnter, diff --git a/packages/grafana-ui/src/components/VizTooltip/VizTooltip.tsx b/packages/grafana-ui/src/components/VizTooltip/VizTooltip.tsx index dd3a1a6012c..c1319ab31a2 100644 --- a/packages/grafana-ui/src/components/VizTooltip/VizTooltip.tsx +++ b/packages/grafana-ui/src/components/VizTooltip/VizTooltip.tsx @@ -31,7 +31,7 @@ export interface VizTooltipContentProps { export interface VizTooltipProps { /** Element used as tooltips content */ - content?: React.ReactElement; + content?: React.ReactElement; /** Optional component to be used as a tooltip content */ tooltipComponent?: React.ComponentType; diff --git a/packages/grafana-ui/src/options/builder/legend.tsx b/packages/grafana-ui/src/options/builder/legend.tsx index 5fdbfd992ae..dea6b45a2c0 100644 --- a/packages/grafana-ui/src/options/builder/legend.tsx +++ b/packages/grafana-ui/src/options/builder/legend.tsx @@ -61,7 +61,7 @@ export function addLegendOptions( name: 'Values', category: ['Legend'], description: 'Select values or calculations to show in legend', - editor: standardEditorsRegistry.get('stats-picker').editor as any, + editor: standardEditorsRegistry.get('stats-picker').editor, defaultValue: [], settings: { allowMultiple: true,