From 28c091ee92cb0272c6e65460d84aa790ca33d830 Mon Sep 17 00:00:00 2001 From: Renat Kalimulin Date: Fri, 9 Feb 2024 16:54:59 +0300 Subject: [PATCH] Eslint fixes Resolves Issue #75 --- frontend/src/lib/hooks/useAppParams.tsx | 14 +++++++++----- frontend/src/lib/paths.ts | 7 ++++++- 2 files changed, 15 insertions(+), 6 deletions(-) diff --git a/frontend/src/lib/hooks/useAppParams.tsx b/frontend/src/lib/hooks/useAppParams.tsx index 6c4ab3502..773b6ccb6 100644 --- a/frontend/src/lib/hooks/useAppParams.tsx +++ b/frontend/src/lib/hooks/useAppParams.tsx @@ -5,11 +5,15 @@ export default function useAppParams< T extends { [K in keyof Params]?: string } >() { const params = useParams() as T; - - const hasClusterName = (params: T): params is T & ClusterNameRoute => typeof params.clusterName !== "undefined" + + const hasClusterName = ( + checkingParams: T + ): checkingParams is T & ClusterNameRoute => + typeof checkingParams.clusterName !== 'undefined'; + if (hasClusterName(params)) { - params.clusterName = decodeURIComponent(params.clusterName) + params.clusterName = decodeURIComponent(params.clusterName); } - - return params + + return params; } diff --git a/frontend/src/lib/paths.ts b/frontend/src/lib/paths.ts index a420f212f..62b19568c 100644 --- a/frontend/src/lib/paths.ts +++ b/frontend/src/lib/paths.ts @@ -24,7 +24,12 @@ export const accessErrorPage = '/403'; export const clusterPath = ( clusterName: ClusterName = RouteParams.clusterName -) => `/ui/clusters/${clusterName === RouteParams.clusterName ? clusterName : encodeURIComponent(clusterName)}`; +) => + `/ui/clusters/${ + clusterName === RouteParams.clusterName + ? clusterName + : encodeURIComponent(clusterName) + }`; export type ClusterNameRoute = { clusterName: ClusterName };