Skip to content

Commit 69f81bd

Browse files
committed
fix: eslint errors
1 parent 7bbafb0 commit 69f81bd

9 files changed

+41
-33
lines changed

cli/check-obsolete.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ function maybeObsolete(packageName) {
6262

6363
const modifiedDate = new Date(timeData.modified);
6464
const isObsolete = modifiedDate < obsoleteDate;
65-
const formattedDate = modifiedDate.toISOString().substring(0, 10);
65+
const formattedDate = modifiedDate.toISOString().slice(0, 10);
6666

6767
return { isObsolete, lastUpdate: formattedDate, packageName };
6868
} catch (error) {
@@ -96,7 +96,7 @@ export function checkObsoleteFrameworks({ debug }) {
9696
continue;
9797
}
9898

99-
const packageJSON = JSON.parse(fs.readFileSync(packageJSONPath, "utf-8"));
99+
const packageJSON = JSON.parse(fs.readFileSync(packageJSONPath, "utf8"));
100100
const mainPackages = packageJSON?.["js-framework-benchmark"]?.frameworkVersionFromPackage;
101101

102102
if (!mainPackages) {
@@ -109,7 +109,7 @@ export function checkObsoleteFrameworks({ debug }) {
109109
}
110110

111111
const packages = mainPackages.split(":");
112-
const isPackageObsolete = packages.map(maybeObsolete);
112+
const isPackageObsolete = packages.map((element) => maybeObsolete(element));
113113

114114
if (DEBUG) {
115115
console.log(`Results for ${type}/${name} ${isPackageObsolete}`);

cli/rebuild-all-frameworks.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
import { execSync } from "node:child_process";
33
import * as fs from "node:fs";
44
import path from "node:path";
5-
import { takeWhile } from "./utils/common/index.js";
5+
import { takeWhile } from "./utils/index.js";
66
import { getFrameworks } from "./helpers/frameworks.js";
77

88
/*
@@ -27,7 +27,7 @@ npm run rebuild-frameworks --restartWith keyed/react
2727
*/
2828
function shouldSkipFramework({ type, name }, restartWithFramework) {
2929
if (!restartWithFramework) return false;
30-
if (restartWithFramework.indexOf("/") > -1) {
30+
if (restartWithFramework.includes("/")) {
3131
return !`${type}/${name}`.startsWith(restartWithFramework);
3232
} else {
3333
return !name.startsWith(restartWithFramework);
@@ -39,7 +39,7 @@ function shouldSkipFramework({ type, name }, restartWithFramework) {
3939
* @param {string} command - The command to run
4040
* @param {string} [cwd] - The current working directory (optional)
4141
*/
42-
function runCommand(command, cwd = undefined) {
42+
function runCommand(command, cwd) {
4343
console.log(command);
4444
execSync(command, { stdio: "inherit", cwd });
4545
}

cli/rebuild-build-single.js

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,10 @@ Pass list of frameworks
2121
* @param {string} command - The command to run
2222
* @param {string|undefined} cwd - The current working directory (optional)
2323
*/
24-
function runCommand(command, cwd = undefined) {
24+
function runCommand(command, cwd) {
2525
console.log(command);
26-
if (cwd) {
27-
if (!fs.existsSync(cwd)) {
28-
throw `working directory ${cwd} doesn't exist.`;
29-
}
26+
if (cwd && !fs.existsSync(cwd)) {
27+
throw `working directory ${cwd} doesn't exist.`;
3028
}
3129

3230
execSync(command, { stdio: "inherit", cwd });

cli/rebuild-check-single.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ Pass list of frameworks
1818
* @param {string} command - The command to run
1919
* @param {string|undefined} cwd - The current working directory (optional)
2020
*/
21-
function runCommand(command, cwd = undefined) {
21+
function runCommand(command, cwd) {
2222
console.log(command);
2323
execSync(command, { stdio: "inherit", cwd });
2424
}
@@ -42,7 +42,7 @@ export function rebuildCheckSingle({ frameworks }) {
4242
console.log("rebuild-check-single.js finished");
4343
console.log("All checks are fine!");
4444
console.log(`======> Please rerun the benchmark: npm run bench ${frameworkNames}`);
45-
} catch (e) {
45+
} catch (error) {
4646
console.log(`rebuild-check-single failed for ${frameworks.join(" ")}`);
4747
process.exit(-1);
4848
}

cli/rebuild-single-framework.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ export function rebuildSingleFramework({ frameworks, useCi }) {
3333
rebuildFrameworks(frameworks, useCi);
3434

3535
rebuildCheckSingle({ frameworks });
36-
} catch (e) {
36+
} catch (error) {
3737
console.log(`ERROR: Rebuilding ${frameworks} was not successful`);
3838
}
3939
}

cli/update-lockfiles.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ function runNpmInstall(frameworkPath) {
3131
*/
3232
function getPackageLockJSONVersion(packageLockJSONPath) {
3333
try {
34-
const packageLockJSON = fs.readFileSync(packageLockJSONPath, "utf-8");
34+
const packageLockJSON = fs.readFileSync(packageLockJSONPath, "utf8");
3535
const parsedPackageLockJSON = JSON.parse(packageLockJSON);
3636
return parsedPackageLockJSON.lockfileVersion;
3737
} catch (error) {
File renamed without changes.
File renamed without changes.

cli/zip.js

Lines changed: 28 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -54,23 +54,33 @@ function addFrameworksToZip(frameworkType, frameworkDir, frameworkName) {
5454
addLocalFolderIfExists(`${frameworkDir}/public`, `${zipFrameworkPath}/public`);
5555
}
5656

57-
if (frameworkName === "halogen") {
58-
addLocalFileIfExists(`${frameworkDir}/output/bundle.js`, `${zipFrameworkPath}/output`);
59-
} else if (frameworkName === "dojo") {
60-
addLocalFolderIfExists(`${frameworkDir}/output/dist`, `${zipFrameworkPath}/output/dist`);
61-
} else if (frameworkName === "s2") {
62-
addLocalFolderIfExists(
63-
`${frameworkDir}/node_modules/s2-engine/dist`,
64-
`${zipFrameworkPath}/node_modules/s2-engine/dist`
65-
);
66-
} else if (frameworkName === "stem") {
67-
addLocalFolderIfExists(
68-
`${frameworkDir}/node_modules/babel-polyfill/dist`,
69-
`${zipFrameworkPath}/node_modules/babel-polyfill/dist`
70-
);
71-
addLocalFileIfExists(`${frameworkDir}/src/bundle.js`, `${zipFrameworkPath}/src`);
72-
} else {
73-
addLocalFolderIfExists(`${frameworkDir}/output`, `${zipFrameworkPath}/output`);
57+
switch (frameworkName) {
58+
case "halogen": {
59+
addLocalFileIfExists(`${frameworkDir}/output/bundle.js`, `${zipFrameworkPath}/output`);
60+
break;
61+
}
62+
case "dojo": {
63+
addLocalFolderIfExists(`${frameworkDir}/output/dist`, `${zipFrameworkPath}/output/dist`);
64+
break;
65+
}
66+
case "s2": {
67+
addLocalFolderIfExists(
68+
`${frameworkDir}/node_modules/s2-engine/dist`,
69+
`${zipFrameworkPath}/node_modules/s2-engine/dist`
70+
);
71+
break;
72+
}
73+
case "stem": {
74+
addLocalFolderIfExists(
75+
`${frameworkDir}/node_modules/babel-polyfill/dist`,
76+
`${zipFrameworkPath}/node_modules/babel-polyfill/dist`
77+
);
78+
addLocalFileIfExists(`${frameworkDir}/src/bundle.js`, `${zipFrameworkPath}/src`);
79+
break;
80+
}
81+
default: {
82+
addLocalFolderIfExists(`${frameworkDir}/output`, `${zipFrameworkPath}/output`);
83+
}
7484
}
7585
}
7686

@@ -83,7 +93,7 @@ export function createFrameworkZipArchive() {
8393

8494
for (const frameworkName of frameworkNames) {
8595
const frameworkPath = path.resolve(frameworkTypeDirPath, frameworkName);
86-
console.log("zipping ", frameworkPath);
96+
console.log("zipping", frameworkPath);
8797

8898
addFrameworksToZip(frameworkType, frameworkPath, frameworkName);
8999
}

0 commit comments

Comments
 (0)