Skip to content

Commit aac8f12

Browse files
committed
auto-fix by Biome
1 parent d5f4d38 commit aac8f12

File tree

20 files changed

+72
-75
lines changed

20 files changed

+72
-75
lines changed

cli/rescript_arg.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ class StringBuilder {
1515
}
1616
}
1717

18-
class ArgError extends Error { }
18+
class ArgError extends Error {}
1919

2020
/**
2121
* @param {string} s

cli/rescript_bsb.js

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ function releaseBuild() {
3232
ownerProcess.kill("SIGHUP");
3333
try {
3434
fs.rmSync(lockFileName);
35-
} catch { }
35+
} catch {}
3636
ownerProcess = null;
3737
}
3838
}
@@ -147,7 +147,7 @@ function logFinishCompiling(code) {
147147

148148
function logStartCompiling() {
149149
updateStartTime();
150-
let log = `>>>> Start compiling`;
150+
let log = ">>>> Start compiling";
151151
if (shouldColorize) {
152152
log = `\x1b[36m${log}\x1b[0m`;
153153
}
@@ -210,7 +210,7 @@ function watch(args) {
210210
let watchers = [];
211211

212212
const verbose = args.includes("-verbose");
213-
const dlog = verbose ? console.log : () => { };
213+
const dlog = verbose ? console.log : () => {};
214214

215215
const wsParamIndex = args.indexOf("-ws");
216216
if (wsParamIndex > -1) {
@@ -253,18 +253,18 @@ function watch(args) {
253253
function setUpWebSocket() {
254254
const _id = setInterval(notifyClients, 3000);
255255
createServer()
256-
.on("upgrade", function(req, socket, upgradeHead) {
256+
.on("upgrade", (req, socket, upgradeHead) => {
257257
dlog("connection opened");
258-
var ws = new WebSocket(req, socket, upgradeHead);
259-
socket.on("error", function(err) {
258+
const ws = new WebSocket(req, socket, upgradeHead);
259+
socket.on("error", err => {
260260
dlog(`Socket Error ${err}`);
261261
});
262262
wsClients.push(ws);
263263
})
264-
.on("error", function(err) {
264+
.on("error", err => {
265265
// @ts-ignore
266266
if (err !== undefined && err.code === "EADDRINUSE") {
267-
var error = shouldColorize ? `\x1b[1;31mERROR:\x1b[0m` : `ERROR:`;
267+
const error = shouldColorize ? "\x1b[1;31mERROR:\x1b[0m" : "ERROR:";
268268
console.error(`${error} The websocket port number ${webSocketPort} is in use.
269269
Please pick a different one using the \`-ws [host:]port\` flag from bsb.`);
270270
} else {

cli/rescript_format.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ async function readStdin() {
7070
return Buffer.concat(chunks).toString("utf8");
7171
}
7272

73-
const numThreads = os.cpus().length;
73+
const _numThreads = os.cpus().length;
7474

7575
/**
7676
* Splits an array into smaller chunks of a specified size.

lib/minisocket.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,14 +72,14 @@ function encodeMessage(opcode, payload) {
7272
const upgradeHeader =
7373
"HTTP/1.1 101 Web Socket Protocol Handshake\r\nUpgrade: WebSocket\r\nConnection: Upgrade\r\nsec-websocket-accept: ";
7474
class MiniWebSocket {
75-
constructor(req, socket, upgradeHead) {
75+
constructor(req, socket, _upgradeHead) {
7676
this.socket = socket;
7777
this.closed = false;
7878
const key = hashWebSocketKey(req.headers["sec-websocket-key"]);
7979

8080
// http://tools.ietf.org/html/rfc6455#section-4.2.2
8181
socket.write(`${upgradeHeader + key}\r\n\r\n`);
82-
socket.on("close", hadError => {
82+
socket.on("close", _hadError => {
8383
if (!this.closed) {
8484
this.closed = true;
8585
}

packages/playground-bundling/rollup.config.cjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
const resolve = require("@rollup/plugin-node-resolve");
22

33
const { globSync } = require("glob");
4-
const path = require("path");
4+
const path = require("node:path");
55

66
const RESCRIPT_COMPILER_ROOT_DIR = path.join(__dirname, "..", "..");
77
const LIB_DIR = path.join(RESCRIPT_COMPILER_ROOT_DIR, "lib");

scripts/cppo.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// @ts-check
22

3-
const { execFileSync } = require("child_process");
3+
const { execFileSync } = require("node:child_process");
44

55
[
66
["belt_HashSetString.res", "hashset.res.cppo", "TYPE_STRING"],

scripts/npmPack.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,9 @@
2626
* @typedef {[PackOutputEntry]} PackOutput
2727
*/
2828

29-
const { spawnSync, execSync } = require("child_process");
30-
const path = require("path");
31-
const fs = require("fs");
29+
const { spawnSync, execSync } = require("node:child_process");
30+
const path = require("node:path");
31+
const fs = require("node:fs");
3232

3333
const mode = process.argv.includes("-updateArtifactList")
3434
? "updateArtifactList"
@@ -38,7 +38,7 @@ const rootPath = path.join(__dirname, "..");
3838
const fileListPath = path.join(rootPath, "packages", "artifacts.txt");
3939

4040
const output = spawnSync(
41-
"npm pack --json" + (mode === "updateArtifactList" ? " --dry-run" : ""),
41+
`npm pack --json${mode === "updateArtifactList" ? " --dry-run" : ""}`,
4242
{
4343
cwd: rootPath,
4444
encoding: "utf8",
@@ -75,8 +75,8 @@ function getFilesAddedByCI() {
7575

7676
const files = ["ninja.COPYING"];
7777

78-
for (let platform of platforms) {
79-
for (let exe of exes) {
78+
for (const platform of platforms) {
79+
for (const exe of exes) {
8080
files.push(`${platform}/${exe}`);
8181
}
8282
}

tests/build_tests/build_warn_as_error/input.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ if (!third_message) {
4747
assert.fail(o3.stdout);
4848
}
4949

50-
var cleanup = p.spawnSync(rescript_exe, ["clean"], {
50+
const _cleanup = p.spawnSync(rescript_exe, ["clean"], {
5151
encoding: "utf8",
5252
cwd: __dirname,
5353
});

tests/build_tests/cli_compile_status/input.js

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,7 @@ let out = child_process.spawnSync("node", [rescriptPath, "build"], {
1414
});
1515
assert.match(
1616
normalizeNewlines(out.stdout),
17-
new RegExp(`>>>> Start compiling
18-
Dependency Finished
19-
>>>> Finish compiling \\d+ mseconds`),
17+
/>>>> Start compiling\nDependency Finished\n>>>> Finish compiling \d+ mseconds/,
2018
);
2119

2220
// Shows compile time for `rescript` command
@@ -26,9 +24,7 @@ out = child_process.spawnSync("node", [rescriptPath], {
2624
});
2725
assert.match(
2826
normalizeNewlines(out.stdout),
29-
new RegExp(`>>>> Start compiling
30-
Dependency Finished
31-
>>>> Finish compiling \\d+ mseconds`),
27+
/>>>> Start compiling\nDependency Finished\n>>>> Finish compiling \d+ mseconds/,
3228
);
3329

3430
// Doesn't show compile time for `rescript build -verbose` command
@@ -42,6 +38,6 @@ out = child_process.spawnSync("node", [rescriptPath, "build", "-verbose"], {
4238

4339
assert.match(
4440
normalizeNewlines(out.stdout),
45-
/Package stack: test \nDependency Finished\n/,
41+
/Package stack: test {2}\nDependency Finished\n/,
4642
);
4743
assert.match(normalizeNewlines(out.stdout), /ninja.exe"? -C lib[\\/]bs ?\n/);

tests/build_tests/cli_help/input.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// @ts-check
22

3-
const assert = require("assert");
4-
const path = require("path");
3+
const assert = require("node:assert");
4+
const path = require("node:path");
55
const { exec, normalizeNewlines } = require("../utils.js");
66

77
const rescriptPath = path.join(__dirname, "..", "..", "..", "cli", "rescript");
@@ -103,7 +103,7 @@ async function test() {
103103
// Exits with build help with unknown arg
104104
await runTest(["build", "-foo"], {
105105
stdout: "",
106-
stderr: 'Error: Unknown option "-foo".\n' + buildHelp,
106+
stderr: `Error: Unknown option "-foo".\n${buildHelp}`,
107107
status: 2,
108108
});
109109

@@ -119,14 +119,14 @@ async function test() {
119119
// Exits with cli help with unknown command
120120
await runTest(["built"], {
121121
stdout: "",
122-
stderr: `Error: Unknown command "built".\n` + cliHelp,
122+
stderr: `Error: Unknown command "built".\n${cliHelp}`,
123123
status: 2,
124124
});
125125

126126
// Exits with build help with unknown args
127127
await runTest(["-foo"], {
128128
stdout: "",
129-
stderr: 'Error: Unknown option "-foo".\n' + buildHelp,
129+
stderr: `Error: Unknown option "-foo".\n${buildHelp}`,
130130
status: 2,
131131
});
132132

@@ -143,7 +143,7 @@ async function test() {
143143
// Exits with clean help with unknown arg
144144
await runTest(["clean", "-foo"], {
145145
stdout: "",
146-
stderr: 'Error: Unknown option "-foo".\n' + cleanHelp,
146+
stderr: `Error: Unknown option "-foo".\n${cleanHelp}`,
147147
status: 2,
148148
});
149149

0 commit comments

Comments
 (0)