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

tests/build_tests/duplicated_symlinked_packages/input.js

Lines changed: 21 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -22,21 +22,25 @@ if (process.platform === "win32") {
2222

2323
child_process.execSync(`${rescript_exe} clean`, { cwd: __dirname });
2424

25-
child_process.exec(rescript_exe, { cwd: __dirname }, (err, stdout, stderr) => {
26-
const actualErrorOutput = postProcessErrorOutput(stderr.toString());
27-
if (updateTests) {
28-
fs.writeFileSync(expectedFilePath, actualErrorOutput);
29-
} else {
30-
const expectedErrorOutput = postProcessErrorOutput(
31-
fs.readFileSync(expectedFilePath, { encoding: "utf-8" }),
32-
);
33-
if (expectedErrorOutput !== actualErrorOutput) {
34-
console.error(`The old and new error output aren't the same`);
35-
console.error("\n=== Old:");
36-
console.error(expectedErrorOutput);
37-
console.error("\n=== New:");
38-
console.error(actualErrorOutput);
39-
process.exit(1);
25+
child_process.exec(
26+
rescript_exe,
27+
{ cwd: __dirname },
28+
(_err, _stdout, stderr) => {
29+
const actualErrorOutput = postProcessErrorOutput(stderr.toString());
30+
if (updateTests) {
31+
fs.writeFileSync(expectedFilePath, actualErrorOutput);
32+
} else {
33+
const expectedErrorOutput = postProcessErrorOutput(
34+
fs.readFileSync(expectedFilePath, { encoding: "utf-8" }),
35+
);
36+
if (expectedErrorOutput !== actualErrorOutput) {
37+
console.error(`The old and new error output aren't the same`);
38+
console.error("\n=== Old:");
39+
console.error(expectedErrorOutput);
40+
console.error("\n=== New:");
41+
console.error(actualErrorOutput);
42+
process.exit(1);
43+
}
4044
}
41-
}
42-
});
45+
},
46+
);

tests/build_tests/gpr_978/input.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
//@ts-check
2-
const cp = require("child_process");
3-
const assert = require("assert");
4-
const fs = require("fs");
5-
const path = require("path");
2+
const cp = require("node:child_process");
3+
const assert = require("node:assert");
4+
const fs = require("node:fs");
5+
const path = require("node:path");
66
const { rescript_exe } = require("#cli/bin_path");
77

88
const output = cp.spawnSync(rescript_exe, { encoding: "utf8", shell: true });

tests/build_tests/in_source/input.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ const { rescript_exe } = require("#cli/bin_path");
55

66
assert.throws(
77
() => {
8-
const output = child_process.execSync(`${rescript_exe} build -regen`, {
8+
const _output = child_process.execSync(`${rescript_exe} build -regen`, {
99
cwd: __dirname,
1010
encoding: "utf8",
1111
});

tests/build_tests/react_ppx/input.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
//@ts-check
2-
var cp = require("child_process");
3-
var { rescript_exe } = require("#cli/bin_path");
2+
const cp = require("node:child_process");
3+
const { rescript_exe } = require("#cli/bin_path");
44

55
cp.execSync(rescript_exe, { cwd: __dirname });

tests/build_tests/super_errors/input.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ let atLeastOneTaskFailed = false;
3535
for (const fileName of fixtures) {
3636
const fullFilePath = path.join(__dirname, "fixtures", fileName);
3737
const command = `${prefix} -color always ${fullFilePath}`;
38-
child_process.exec(command, (err, stdout, stderr) => {
38+
child_process.exec(command, (_err, _stdout, stderr) => {
3939
doneTasksCount++;
4040
// careful of:
4141
// - warning test that actually succeeded in compiling (warning's still in stderr, so the code path is shared here)

tests/build_tests/transitive_pinned_dependency1/a/rescript.json

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,6 @@
1818
"error": true
1919
},
2020
"suffix": ".mjs",
21-
"bs-dependencies": [
22-
"b"
23-
],
24-
"pinned-dependencies": [
25-
"b"
26-
]
21+
"bs-dependencies": ["b"],
22+
"pinned-dependencies": ["b"]
2723
}

tests/gentype_tests/typescript-react-example/src/App.css

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,10 @@
2323
}
2424

2525
@keyframes App-logo-spin {
26-
from { transform: rotate(0deg); }
27-
to { transform: rotate(360deg); }
26+
from {
27+
transform: rotate(0deg);
28+
}
29+
to {
30+
transform: rotate(360deg);
31+
}
2832
}

tests/gentype_tests/typescript-react-example/src/MyMath.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ export class AbsoluteValue {
2121

2222
export type stringFunction = (_: string) => string;
2323

24-
export const useColor = (x: "tomato" | "gray"): number => 0;
24+
export const useColor = (_x: "tomato" | "gray"): number => 0;
2525

2626
export const higherOrder = (foo: (_1: number, _2: number) => number) =>
2727
foo(3, 4);

tests/gentype_tests/typescript-react-example/src/index.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
import type * as React from "react";
22
import * as ReactDOM from "react-dom";
3-
import App from "./App";
3+
import App from "./App.tsx";
44
import * as ImportJsValue from "./ImportJsValue.gen";
55
import * as Uncurried from "./Uncurried.gen";
66
import "./index.css";
77
import * as DocStrings from "./Docstrings.gen";
88
import Hooks from "./Hooks.gen";
9-
import * as MyMath from "./MyMath";
9+
import * as MyMath from "./MyMath.tsx";
1010
import { Universe_Nested2_Nested3_nested3Value } from "./NestedModules.gen";
1111
import * as Records from "./Records.gen";
1212
import * as TestPromise from "./TestPromise.gen";
@@ -126,7 +126,7 @@ type Props = {
126126
readonly method?: "push" | "replace";
127127
};
128128

129-
export const make: React.FC<Props> = (x: Props) => {
129+
export const make: React.FC<Props> = (_x: Props) => {
130130
return <div />;
131131
};
132132

tsconfig.json

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,5 @@
1919
"tests/**/input.js",
2020
"package.json"
2121
],
22-
"exclude": [
23-
"*.res.js",
24-
"*.res.mjs",
25-
]
22+
"exclude": ["*.res.js", "*.res.mjs"]
2623
}

0 commit comments

Comments
 (0)