fix: code quality nitpicks for some issues spotted (#357)
This commit is contained in:
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user