From 3cf8e9c72e6a9228785b69560d3355dc2c2c91cf Mon Sep 17 00:00:00 2001 From: Josh Hunt Date: Fri, 2 Sep 2022 11:31:16 +0100 Subject: [PATCH] Chore: Remove grafana-ui IconName type assertions (#54623) --- .betterer.results | 12 +-------- .../grafana-ui/src/components/Alert/Alert.tsx | 9 ++++--- .../RadioButtonGroup/RadioButtonGroup.tsx | 27 ++++++++++--------- .../src/components/Select/SelectMenu.tsx | 6 ++--- .../ToolbarButton/ToolbarButton.tsx | 8 +++--- 5 files changed, 28 insertions(+), 34 deletions(-) diff --git a/.betterer.results b/.betterer.results index 661a7ff0fde..8cdbeb92f5c 100644 --- a/.betterer.results +++ b/.betterer.results @@ -1294,9 +1294,6 @@ exports[`better eslint`] = { [0, 0, 0, "Do not use any type assertions.", "0"], [0, 0, 0, "Do not use any type assertions.", "1"] ], - "packages/grafana-ui/src/components/Alert/Alert.tsx:5381": [ - [0, 0, 0, "Do not use any type assertions.", "0"] - ], "packages/grafana-ui/src/components/ButtonCascader/ButtonCascader.tsx:5381": [ [0, 0, 0, "Unexpected any. Specify a different type.", "0"] ], @@ -1396,9 +1393,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/components/Forms/RadioButtonGroup/RadioButtonGroup.tsx:5381": [ - [0, 0, 0, "Do not use any type assertions.", "0"] - ], "packages/grafana-ui/src/components/Graph/Graph.test.tsx:5381": [ [0, 0, 0, "Unexpected any. Specify a different type.", "0"] ], @@ -1600,8 +1594,7 @@ exports[`better eslint`] = { [0, 0, 0, "Unexpected any. Specify a different type.", "12"] ], "packages/grafana-ui/src/components/Select/SelectMenu.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.", "0"] ], "packages/grafana-ui/src/components/Select/SelectOptionGroup.tsx:5381": [ [0, 0, 0, "Unexpected any. Specify a different type.", "0"], @@ -1798,9 +1791,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-ui/src/components/ToolbarButton/ToolbarButton.tsx:5381": [ - [0, 0, 0, "Do not use any type assertions.", "0"] - ], "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"] diff --git a/packages/grafana-ui/src/components/Alert/Alert.tsx b/packages/grafana-ui/src/components/Alert/Alert.tsx index f5588c8c09b..957ae9a87cb 100644 --- a/packages/grafana-ui/src/components/Alert/Alert.tsx +++ b/packages/grafana-ui/src/components/Alert/Alert.tsx @@ -25,7 +25,7 @@ export interface Props extends HTMLAttributes { topSpacing?: number; } -export function getIconFromSeverity(severity: AlertVariant): string { +export function getIconFromSeverity(severity: AlertVariant): IconName { switch (severity) { case 'error': case 'warning': @@ -34,8 +34,6 @@ export function getIconFromSeverity(severity: AlertVariant): string { return 'info-circle'; case 'success': return 'check'; - default: - return ''; } } @@ -69,20 +67,23 @@ export const Alert = React.forwardRef( {...restProps} >
- +
+
{title}
{children &&
{children}
}
+ {/* If onRemove is specified, giving preference to onRemove */} {onRemove && !buttonContent && (
)} + {onRemove && buttonContent && (