Skip to content

Commit 10d37b1

Browse files
bukinoshitagabrielmfern
authored andcommitted
fix(all): Remove if/else usage (#1823)
1 parent 3feaed3 commit 10d37b1

File tree

2 files changed

+22
-7
lines changed

2 files changed

+22
-7
lines changed

packages/react-email/src/cli/utils/preview/hot-reloading/create-dependency-graph.ts

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -44,15 +44,25 @@ const checkFileExtensionsUntilItExists = (
4444
): string | undefined => {
4545
if (existsSync(`${pathWithoutExtension}.ts`)) {
4646
return `${pathWithoutExtension}.ts`;
47-
} else if (existsSync(`${pathWithoutExtension}.tsx`)) {
47+
}
48+
49+
if (existsSync(`${pathWithoutExtension}.tsx`)) {
4850
return `${pathWithoutExtension}.tsx`;
49-
} else if (existsSync(`${pathWithoutExtension}.js`)) {
51+
}
52+
53+
if (existsSync(`${pathWithoutExtension}.js`)) {
5054
return `${pathWithoutExtension}.js`;
51-
} else if (existsSync(`${pathWithoutExtension}.jsx`)) {
55+
}
56+
57+
if (existsSync(`${pathWithoutExtension}.jsx`)) {
5258
return `${pathWithoutExtension}.jsx`;
53-
} else if (existsSync(`${pathWithoutExtension}.mjs`)) {
59+
}
60+
61+
if (existsSync(`${pathWithoutExtension}.mjs`)) {
5462
return `${pathWithoutExtension}.mjs`;
55-
} else if (existsSync(`${pathWithoutExtension}.cjs`)) {
63+
}
64+
65+
if (existsSync(`${pathWithoutExtension}.cjs`)) {
5666
return `${pathWithoutExtension}.cjs`;
5767
}
5868
};
@@ -133,9 +143,12 @@ export const createDependencyGraph = async (directory: string) => {
133143
const pathWithExtension = checkFileExtensionsUntilItExists(
134144
pathToDependencyFromDirectory,
135145
);
146+
136147
if (pathWithExtension) {
137148
pathToDependencyFromDirectory = pathWithExtension;
138-
} else if (isDev) {
149+
}
150+
151+
if (isDev) {
139152
// only warn about this on development as it is probably going to be irrelevant otherwise
140153
console.warn(
141154
`Could not determine the file extension for the file at ${pathWithExtension}`,

packages/react-email/src/cli/utils/tree.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,9 @@ const getTreeLines = async (
2828
// orders directories before files
2929
if (a.isDirectory() && b.isFile()) {
3030
return -1;
31-
} else if (a.isFile() && b.isDirectory()) {
31+
}
32+
33+
if (a.isFile() && b.isDirectory()) {
3234
return 1;
3335
}
3436

0 commit comments

Comments
 (0)