From 89236cf418372fb04db73aaec3d755563b87a7f5 Mon Sep 17 00:00:00 2001 From: Adela Almasan <88068998+adela-almasan@users.noreply.github.com> Date: Mon, 29 Aug 2022 16:34:42 -0500 Subject: [PATCH] Geomap: Cleanup (#54415) --- .betterer.results | 36 ++++--------------- .../components/Layers/LayerDragDropList.tsx | 8 ++--- .../app/plugins/panel/geomap/GeomapPanel.tsx | 2 +- .../geomap/editor/GeomapStyleRulesEditor.tsx | 2 +- .../panel/geomap/editor/StyleEditor.tsx | 34 +++++++++--------- .../panel/geomap/editor/StyleRuleEditor.tsx | 4 +-- 6 files changed, 32 insertions(+), 54 deletions(-) diff --git a/.betterer.results b/.betterer.results index 7c4b2921cd5..4ad4b85002c 100644 --- a/.betterer.results +++ b/.betterer.results @@ -2723,12 +2723,6 @@ exports[`better eslint`] = { "public/app/core/components/DynamicImports/SafeDynamicImport.tsx:5381": [ [0, 0, 0, "Unexpected any. Specify a different type.", "0"] ], - "public/app/core/components/Layers/LayerDragDropList.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"] - ], "public/app/core/components/Layers/LayerName.tsx:5381": [ [0, 0, 0, "Do not use any type assertions.", "0"], [0, 0, 0, "Unexpected any. Specify a different type.", "1"] @@ -8323,42 +8317,26 @@ exports[`better eslint`] = { ], "public/app/plugins/panel/geomap/editor/GeomapStyleRulesEditor.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, "Do not use any type assertions.", "1"] ], "public/app/plugins/panel/geomap/editor/StyleEditor.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, "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.", "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.", "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.", "8"], [0, 0, 0, "Do not use any type assertions.", "9"], - [0, 0, 0, "Unexpected any. Specify a different type.", "10"], + [0, 0, 0, "Do not use any type assertions.", "10"], [0, 0, 0, "Do not use any type assertions.", "11"], - [0, 0, 0, "Unexpected any. Specify a different type.", "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, "Unexpected any. Specify a different type.", "16"], - [0, 0, 0, "Do not use any type assertions.", "17"], - [0, 0, 0, "Unexpected any. Specify a different type.", "18"], - [0, 0, 0, "Do not use any type assertions.", "19"], - [0, 0, 0, "Unexpected any. Specify a different type.", "20"], - [0, 0, 0, "Do not use any type assertions.", "21"], - [0, 0, 0, "Unexpected any. Specify a different type.", "22"], - [0, 0, 0, "Do not use any type assertions.", "23"], - [0, 0, 0, "Unexpected any. Specify a different type.", "24"], - [0, 0, 0, "Do not use any type assertions.", "25"], - [0, 0, 0, "Unexpected any. Specify a different type.", "26"] + [0, 0, 0, "Do not use any type assertions.", "12"] ], "public/app/plugins/panel/geomap/editor/StyleRuleEditor.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, "Do not use any type assertions.", "1"] ], "public/app/plugins/panel/geomap/layers/basemaps/carto.ts:5381": [ [0, 0, 0, "Do not use any type assertions.", "0"] diff --git a/public/app/core/components/Layers/LayerDragDropList.tsx b/public/app/core/components/Layers/LayerDragDropList.tsx index dcf6323486f..009fd6e065a 100644 --- a/public/app/core/components/Layers/LayerDragDropList.tsx +++ b/public/app/core/components/Layers/LayerDragDropList.tsx @@ -15,13 +15,13 @@ export type LayerDragDropListProps = { layers: T[]; getLayerInfo: (element: T) => string; onDragEnd: (result: DropResult) => void; - onSelect: (element: T) => any; - onDelete: (element: T) => any; - onDuplicate?: (element: T) => any; + onSelect: (element: T) => void; + onDelete: (element: T) => void; + onDuplicate?: (element: T) => void; showActions: (element: T) => boolean; selection?: string[]; // list of unique ids (names) excludeBaseLayer?: boolean; - onNameChange: (element: T, newName: string) => any; + onNameChange: (element: T, newName: string) => void; verifyLayerNameUniqueness?: (nameToCheck: string) => boolean; }; diff --git a/public/app/plugins/panel/geomap/GeomapPanel.tsx b/public/app/plugins/panel/geomap/GeomapPanel.tsx index e9980ae084d..362e5c6d0a2 100644 --- a/public/app/plugins/panel/geomap/GeomapPanel.tsx +++ b/public/app/plugins/panel/geomap/GeomapPanel.tsx @@ -436,7 +436,7 @@ export class GeomapPanel extends Component { }); } - const found = layers.length ? true : false; + const found = Boolean(layers.length); this.mapDiv!.style.cursor = found ? 'pointer' : 'auto'; return found; }; diff --git a/public/app/plugins/panel/geomap/editor/GeomapStyleRulesEditor.tsx b/public/app/plugins/panel/geomap/editor/GeomapStyleRulesEditor.tsx index 87ec1843468..87647544d6f 100644 --- a/public/app/plugins/panel/geomap/editor/GeomapStyleRulesEditor.tsx +++ b/public/app/plugins/panel/geomap/editor/GeomapStyleRulesEditor.tsx @@ -44,7 +44,7 @@ export const GeomapStyleRulesEditor: FC { const itemSettings: StandardEditorsRegistryItem = { settings, - } as any; + } as StandardEditorsRegistryItem; return ( { - onChange({ ...value, textConfig: { ...value.textConfig, textAlign: textAlign as TextAlignment } }); + const onTextAlignChange = (textAlign: TextAlignment) => { + onChange({ ...value, textConfig: { ...value.textConfig, textAlign: textAlign } }); }; - const onTextBaselineChange = (textBaseline: unknown) => { - onChange({ ...value, textConfig: { ...value.textConfig, textBaseline: textBaseline as TextBaseline } }); + const onTextBaselineChange = (textBaseline: TextBaseline) => { + onChange({ ...value, textConfig: { ...value.textConfig, textBaseline: textBaseline } }); }; const propertyOptions = useObservable(settings?.layerInfo ?? of()); @@ -119,7 +119,7 @@ export const StyleEditor: FC @@ -135,7 +135,7 @@ export const StyleEditor: FC @@ -166,7 +166,7 @@ export const StyleEditor: FC @@ -188,7 +188,7 @@ export const StyleEditor: FC @@ -206,7 +206,7 @@ export const StyleEditor: FC @@ -215,7 +215,7 @@ export const StyleEditor: FC @@ -230,7 +230,7 @@ export const StyleEditor: FC @@ -246,7 +246,7 @@ export const StyleEditor: FC @@ -256,7 +256,7 @@ export const StyleEditor: FC @@ -268,7 +268,7 @@ export const StyleEditor: FC @@ -276,7 +276,7 @@ export const StyleEditor: FC @@ -284,7 +284,7 @@ export const StyleEditor: FC diff --git a/public/app/plugins/panel/geomap/editor/StyleRuleEditor.tsx b/public/app/plugins/panel/geomap/editor/StyleRuleEditor.tsx index 20dbd03a2af..8aab89c820b 100644 --- a/public/app/plugins/panel/geomap/editor/StyleRuleEditor.tsx +++ b/public/app/plugins/panel/geomap/editor/StyleRuleEditor.tsx @@ -4,7 +4,7 @@ import React, { FC, useCallback, useMemo } from 'react'; import { useObservable } from 'react-use'; import { Observable } from 'rxjs'; -import { GrafanaTheme2, SelectableValue, StandardEditorProps } from '@grafana/data'; +import { GrafanaTheme2, SelectableValue, StandardEditorProps, StandardEditorsRegistryItem } from '@grafana/data'; import { Button, InlineField, InlineFieldRow, Select, useStyles2 } from '@grafana/ui'; import { NumberInput } from 'app/core/components/OptionsUI/NumberInput'; @@ -199,7 +199,7 @@ export const StyleRuleEditor: FC