fix: code quality nitpicks for some issues spotted (#357)

This commit is contained in:
Liran Tal
2023-08-18 08:48:48 +03:00
committed by GitHub
parent 83bcefe10c
commit 57514f8771
2 changed files with 8 additions and 11 deletions
+5 -8
View File
@@ -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);
}
+3 -3
View File
@@ -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);
}