From a093250dd522f00db2c6e379821a3145502faec5 Mon Sep 17 00:00:00 2001 From: Ryan McKinley Date: Thu, 23 Jun 2022 11:19:08 -0700 Subject: [PATCH] Chore: avoid implicit any by using inline functions (#51338) --- .betterer.results | 14 ++------------ .../search/page/components/FolderSection.tsx | 12 +++++------- .../page/components/SearchResultsCards.tsx | 17 ++++++----------- 3 files changed, 13 insertions(+), 30 deletions(-) diff --git a/.betterer.results b/.betterer.results index 9d6c94a8e46..2243598cc85 100644 --- a/.betterer.results +++ b/.betterer.results @@ -3194,18 +3194,14 @@ exports[`no type assertions`] = { [26, 25, 60, "Do not use any type assertions.", "1006626118"], [61, 21, 28, "Do not use any type assertions.", "1547636696"] ], - "public/app/features/search/page/components/FolderSection.tsx:2694034564": [ - [139, 27, 22, "Do not use any type assertions.", "3217586069"] - ], "public/app/features/search/page/components/ManageActions.tsx:2913473343": [ [47, 28, 26, "Do not use any type assertions.", "1971436753"] ], "public/app/features/search/page/components/MoveToFolderModal.tsx:739519709": [ [66, 51, 15, "Do not use any type assertions.", "3135191849"] ], - "public/app/features/search/page/components/SearchResultsCards.tsx:4110686088": [ - [54, 21, 56, "Do not use any type assertions.", "1375039711"], - [94, 31, 22, "Do not use any type assertions.", "3217586069"] + "public/app/features/search/page/components/SearchResultsCards.tsx:590892204": [ + [45, 21, 56, "Do not use any type assertions.", "1375039711"] ], "public/app/features/search/page/components/SearchResultsGrid.tsx:994645204": [ [30, 16, 28, "Do not use any type assertions.", "1941050010"] @@ -10059,15 +10055,9 @@ exports[`no explicit any`] = { "public/app/features/search/components/SearchResults.tsx:4264592788": [ [19, 35, 3, "Unexpected any. Specify a different type.", "193409811"] ], - "public/app/features/search/page/components/FolderSection.tsx:2694034564": [ - [139, 46, 3, "Unexpected any. Specify a different type.", "193409811"] - ], "public/app/features/search/page/components/MoveToFolderModal.tsx:739519709": [ [31, 63, 3, "Unexpected any. Specify a different type.", "193409811"] ], - "public/app/features/search/page/components/SearchResultsCards.tsx:4110686088": [ - [94, 50, 3, "Unexpected any. Specify a different type.", "193409811"] - ], "public/app/features/search/page/components/SearchResultsGrid.test.tsx:2090205358": [ [40, 35, 3, "Unexpected any. Specify a different type.", "193409811"] ], diff --git a/public/app/features/search/page/components/FolderSection.tsx b/public/app/features/search/page/components/FolderSection.tsx index c4b5ec5df33..69f8de0be3f 100644 --- a/public/app/features/search/page/components/FolderSection.tsx +++ b/public/app/features/search/page/components/FolderSection.tsx @@ -99,12 +99,6 @@ export const FolderSection: FC = ({ } }; - const onToggleChecked = (item: DashboardSectionItem) => { - if (selectionToggle) { - selectionToggle('dashboard', item.uid!); - } - }; - const id = useUniqueId(); const labelId = `section-header-label-${id}`; @@ -137,7 +131,11 @@ export const FolderSection: FC = ({ key={v.uid} item={v} onTagSelected={onTagSelected} - onToggleChecked={onToggleChecked as any} + onToggleChecked={(item) => { + if (selectionToggle) { + selectionToggle('dashboard', item.uid!); + } + }} editable={Boolean(selection != null)} /> ); diff --git a/public/app/features/search/page/components/SearchResultsCards.tsx b/public/app/features/search/page/components/SearchResultsCards.tsx index 506f3c0d939..b70310e5c34 100644 --- a/public/app/features/search/page/components/SearchResultsCards.tsx +++ b/public/app/features/search/page/components/SearchResultsCards.tsx @@ -41,15 +41,6 @@ export const SearchResultsCards = React.memo( } }, [response, listEl]); - const onToggleChecked = useCallback( - (item: DashboardSectionItem) => { - if (selectionToggle) { - selectionToggle('dashboard', item.uid!); - } - }, - [selectionToggle] - ); - const RenderRow = useCallback( ({ index: rowIndex, style }) => { const meta = response.view.dataFrame.meta?.custom as SearchResultMeta; @@ -92,13 +83,17 @@ export const SearchResultsCards = React.memo( { + if (selectionToggle) { + selectionToggle('dashboard', item.uid!); + } + }} editable={Boolean(selection != null)} /> ); }, - [response.view, highlightIndex, styles, onTagSelected, selection, selectionToggle, onToggleChecked] + [response.view, highlightIndex, styles, onTagSelected, selection, selectionToggle] ); if (!response.totalRows) {