From 57514f8771cd5bd21bdb71b430eb45092ff355ea Mon Sep 17 00:00:00 2001 From: Liran Tal Date: Fri, 18 Aug 2023 08:48:48 +0300 Subject: [PATCH] fix: code quality nitpicks for some issues spotted (#357) --- apps/webapp/app/utils.ts | 13 +++++-------- packages/cli/src/utils/fileSystem.ts | 6 +++--- 2 files changed, 8 insertions(+), 11 deletions(-) diff --git a/apps/webapp/app/utils.ts b/apps/webapp/app/utils.ts index dbb7aa718..cde12d89c 100644 --- a/apps/webapp/app/utils.ts +++ b/apps/webapp/app/utils.ts @@ -45,13 +45,10 @@ export function useMatchesData( const paths = Array.isArray(id) ? id : [id]; // Get the first matching route - const route = paths.reduce( - (acc, path) => { - if (acc) return acc; - return matchingRoutes.find((route) => route.id === path); - }, - undefined as RouteMatch | undefined - ); + const route = paths.reduce((acc, path) => { + if (acc) return acc; + return matchingRoutes.find((route) => route.id === path); + }, undefined as RouteMatch | undefined); return route; } @@ -76,7 +73,7 @@ export function hydrateDates(object: any): any { if ( typeof object === "string" && object.match(/\d{4}-\d{2}-\d{2}/) && - !isNaN(Date.parse(object)) + !Number.isNaN(Date.parse(object)) ) { return new Date(object); } diff --git a/packages/cli/src/utils/fileSystem.ts b/packages/cli/src/utils/fileSystem.ts index 89fb9b5fe..76c350eb9 100644 --- a/packages/cli/src/utils/fileSystem.ts +++ b/packages/cli/src/utils/fileSystem.ts @@ -25,11 +25,11 @@ export async function removeFile(path: string) { } export async function readFile(path: string) { - return await fsModule.readFile(path, "utf-8"); + return await fsModule.readFile(path, "utf8"); } export async function readJSONFile(path: string) { - const fileContents = await fsModule.readFile(path, "utf-8"); + const fileContents = await fsModule.readFile(path, "utf8"); return JSON.parse(fileContents); } @@ -39,7 +39,7 @@ export async function writeJSONFile(path: string, json: any) { } export function readJSONFileSync(path: string) { - const fileContents = fsSync.readFileSync(path, "utf-8"); + const fileContents = fsSync.readFileSync(path, "utf8"); return JSON.parse(fileContents); }