Skip to content

Commit dd4a4bf

Browse files
authored
Switch to Biome (#6838)
* switch to Biome * do check format first * check only changes * ignore generated codes * dedupe ignore list that already ignored by vcs integration * update Biome ignore list * did `npm run format:all` once * use Biome for gentype tests too * add VSCode extension recommendation * fix more json errors * jsx runtime should be match
1 parent 4ef6668 commit dd4a4bf

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

67 files changed

+692
-1873
lines changed

.github/workflows/get_artifact_dir_name.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,5 @@ const { dirName: artifactDirName } = require("../../cli/bin_path.js");
66
// Pass artifactDirName to subsequent GitHub actions
77
fs.appendFileSync(
88
process.env.GITHUB_ENV,
9-
`artifact_dir_name=${artifactDirName}${os.EOL}`
9+
`artifact_dir_name=${artifactDirName}${os.EOL}`,
1010
);

.github/workflows/prepare_package_upload.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -9,15 +9,15 @@ const commitHashShort = commitHash.substring(0, 7);
99

1010
fs.renameSync(
1111
`rescript-${version}.tgz`,
12-
`rescript-${version}-${commitHashShort}.tgz`
12+
`rescript-${version}-${commitHashShort}.tgz`,
1313
);
1414
fs.renameSync(
1515
`packages/std/rescript-std-${version}.tgz`,
16-
`rescript-std-${version}-${commitHashShort}.tgz`
16+
`rescript-std-${version}-${commitHashShort}.tgz`,
1717
);
1818

1919
// Pass information to subsequent GitHub actions
2020
fs.appendFileSync(
2121
process.env.GITHUB_ENV,
22-
`rescript_version=${version}-${commitHashShort}${os.EOL}`
22+
`rescript_version=${version}-${commitHashShort}${os.EOL}`,
2323
);

.gitignore

+3
Original file line numberDiff line numberDiff line change
@@ -93,3 +93,6 @@ playground/*.cmj
9393
playground/*.cmi
9494
playground/.netrc
9595
playground/compiler.js
96+
97+
rewatch/target/
98+
rewatch/rewatch

.prettierignore

-14
This file was deleted.

.prettierrc.json

-3
This file was deleted.

.vscode/extensions.json

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"recommendations": ["biomejs.biome", "chenglou92.rescript-vscode"],
3+
"unwantedRecommendations": [
4+
"dbaeumer.vscode-eslint",
5+
"esbenp.prettier-vscode"
6+
]
7+
}

biome.json

+49
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
{
2+
"$schema": "https://biomejs.dev/schemas/1.8.3/schema.json",
3+
"vcs": {
4+
"enabled": true,
5+
"clientKind": "git",
6+
"defaultBranch": "master",
7+
"useIgnoreFile": true
8+
},
9+
"linter": {
10+
"enabled": false
11+
},
12+
"organizeImports": {
13+
"enabled": false
14+
},
15+
"formatter": {
16+
"enabled": true,
17+
"formatWithErrors": false,
18+
"indentStyle": "space",
19+
"indentWidth": 2,
20+
"lineEnding": "lf",
21+
"lineWidth": 80,
22+
"attributePosition": "auto",
23+
"ignore": [
24+
"jscomp/build_tests/**/lib/**",
25+
"jscomp/build_tests/**/src/**",
26+
"jscomp/test/**",
27+
"lib/**",
28+
"ninja/**",
29+
"playground/**",
30+
"**/*.bs.js",
31+
"**/*.res.js",
32+
"**/*.gen.ts*",
33+
"package.json"
34+
]
35+
},
36+
"javascript": {
37+
"formatter": {
38+
"jsxQuoteStyle": "double",
39+
"quoteProperties": "asNeeded",
40+
"trailingCommas": "all",
41+
"semicolons": "always",
42+
"arrowParentheses": "asNeeded",
43+
"bracketSpacing": true,
44+
"bracketSameLine": false,
45+
"quoteStyle": "double",
46+
"attributePosition": "auto"
47+
}
48+
}
49+
}

cli/rescript_arg.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ function parse_exn(
112112
annofun,
113113
start = 0,
114114
// first 3 are [node, rescript, subcommand]
115-
finish = argv.length
115+
finish = argv.length,
116116
) {
117117
var current = start;
118118
var list = [];

cli/rescript_bsb.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -363,7 +363,7 @@ Please pick a different one using the \`-ws [host:]port\` flag from bsb.`);
363363
function outputError(error, highlight) {
364364
if (isTtyError && highlight) {
365365
process.stderr.write(
366-
error.replace(highlight, "\x1b[1;31m" + highlight + "\x1b[0m")
366+
error.replace(highlight, "\x1b[1;31m" + highlight + "\x1b[0m"),
367367
);
368368
} else {
369369
process.stderr.write(error);
@@ -408,7 +408,7 @@ Please pick a different one using the \`-ws [host:]port\` flag from bsb.`);
408408
// it could fail due to other issues like .bsb.lock
409409
else {
410410
dlog(
411-
`Acquire lock failed, do the build later ${depth} : ${reasonsToRebuild}`
411+
`Acquire lock failed, do the build later ${depth} : ${reasonsToRebuild}`,
412412
);
413413
const waitTime = Math.pow(2, depth) * 40;
414414
setTimeout(() => {

cli/rescript_convert.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ function handleOneFile(file, bsc_exe) {
5959
console.error(`Error when converting ${file}`);
6060
console.log(stderr);
6161
}
62-
}
62+
},
6363
);
6464
}
6565
/**
@@ -91,7 +91,7 @@ function main(argv, rescript_exe, bsc_exe) {
9191
["info", "-list-files"],
9292
{
9393
encoding: "utf-8",
94-
}
94+
},
9595
);
9696
if (output.status !== 0) {
9797
console.error(output.stdout);

cli/rescript_format.js

+6-6
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ async function formatFiles(files, bsc_exe, isSupportedFile, checkFormatting) {
9292
}
9393
}
9494
return null;
95-
})
95+
}),
9696
);
9797
} catch (err) {
9898
console.error(err);
@@ -103,7 +103,7 @@ async function formatFiles(files, bsc_exe, isSupportedFile, checkFormatting) {
103103
console.error("The file listed above needs formatting");
104104
} else {
105105
console.error(
106-
`The ${incorrectlyFormattedFiles} files listed above need formatting`
106+
`The ${incorrectlyFormattedFiles} files listed above need formatting`,
107107
);
108108
}
109109
process.exit(3);
@@ -135,7 +135,7 @@ async function main(argv, rescript_exe, bsc_exe) {
135135
// Require: -all or path to a file
136136
if (check.val && !format_project && files.length == 0) {
137137
console.error(
138-
"format check require path to a file or use `-all` to check the whole project"
138+
"format check require path to a file or use `-all` to check the whole project",
139139
);
140140
process.exit(2);
141141
}
@@ -152,7 +152,7 @@ async function main(argv, rescript_exe, bsc_exe) {
152152
["info", "-list-files"],
153153
{
154154
encoding: "utf-8",
155-
}
155+
},
156156
);
157157
if (output.status !== 0) {
158158
console.error(output.stdout);
@@ -173,7 +173,7 @@ async function main(argv, rescript_exe, bsc_exe) {
173173
os.tmpdir(),
174174
"rescript_" +
175175
crypto.randomBytes(8).toString("hex") +
176-
path.parse(use_stdin).base
176+
path.parse(use_stdin).base,
177177
);
178178
(async function () {
179179
var content = await readStdin();
@@ -191,7 +191,7 @@ async function main(argv, rescript_exe, bsc_exe) {
191191
console.error(stderr);
192192
process.exit(2);
193193
}
194-
}
194+
},
195195
);
196196
})();
197197
} else {

cli/rescript_postinstall.js

+4-4
Original file line numberDiff line numberDiff line change
@@ -7,31 +7,31 @@ const { bsc_exe, ninja_exe } = require("./bin_path");
77
function checkNinja() {
88
if (!fs.existsSync(ninja_exe)) {
99
throw new Error(
10-
`No ninja binary found for this platform. ${ninja_exe} does not exist.`
10+
`No ninja binary found for this platform. ${ninja_exe} does not exist.`,
1111
);
1212
}
1313

1414
try {
1515
return String(child_process.execFileSync(ninja_exe, ["--version"])).trim();
1616
} catch (e) {
1717
throw new Error(
18-
`Error getting ninja version. The ninja binary at ${ninja_exe} may not be compatible with this platform: ${e}`
18+
`Error getting ninja version. The ninja binary at ${ninja_exe} may not be compatible with this platform: ${e}`,
1919
);
2020
}
2121
}
2222

2323
function checkCompiler() {
2424
if (!fs.existsSync(bsc_exe)) {
2525
throw new Error(
26-
`No ReScript compiler binary found for this platform. ${bsc_exe} does not exist.`
26+
`No ReScript compiler binary found for this platform. ${bsc_exe} does not exist.`,
2727
);
2828
}
2929

3030
try {
3131
return String(child_process.execFileSync(bsc_exe, ["-v"])).trim();
3232
} catch (e) {
3333
throw new Error(
34-
`Error getting ReScript compiler version. The compiler binary at ${bsc_exe} may not be compatible with this platform: ${e}`
34+
`Error getting ReScript compiler version. The compiler binary at ${bsc_exe} may not be compatible with this platform: ${e}`,
3535
);
3636
}
3737
}

jscomp/build_tests/case/rescript.json

+1-3
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,5 @@
22
"name": "case",
33
"version": "0.1.0",
44
"sources": ["src"],
5-
"bs-dependencies": [
6-
// add your bs-dependencies here
7-
]
5+
"bs-dependencies": []
86
}

jscomp/build_tests/case2/rescript.json

+1-3
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,5 @@
22
"name": "case2",
33
"version": "0.1.0",
44
"sources": ["src"],
5-
"bs-dependencies": [
6-
// add your bs-dependencies here
7-
]
5+
"bs-dependencies": []
86
}

jscomp/build_tests/cli_compile_status/input.js

+4-4
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ assert.match(
1212
out.stdout,
1313
new RegExp(`>>>> Start compiling
1414
Dependency Finished
15-
>>>> Finish compiling \\d+ mseconds`)
15+
>>>> Finish compiling \\d+ mseconds`),
1616
);
1717

1818
// Shows compile time for `rescript` command
@@ -24,7 +24,7 @@ assert.match(
2424
out.stdout,
2525
new RegExp(`>>>> Start compiling
2626
Dependency Finished
27-
>>>> Finish compiling \\d+ mseconds`)
27+
>>>> Finish compiling \\d+ mseconds`),
2828
);
2929

3030
// Doesn't show compile time for `rescript build -verbose` command
@@ -38,6 +38,6 @@ out = child_process.spawnSync(`../../../rescript`, ["build", "-verbose"], {
3838
assert.match(
3939
out.stdout,
4040
new RegExp(
41-
`Package stack: test \nDependency Finished\nninja.exe -C lib/bs \n`
42-
)
41+
`Package stack: test \nDependency Finished\nninja.exe -C lib/bs \n`,
42+
),
4343
);

jscomp/build_tests/cmd/input.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ function evalCode(code) {
3535
encoding: "utf8",
3636
shell: true,
3737
cwd: __dirname,
38-
}
38+
},
3939
);
4040

4141
return bsc_exe;
@@ -51,10 +51,10 @@ test(react);
5151

5252
assert.ok(
5353
evalCode(react + foo_react).stdout.match(/require/g).length === 2,
54-
"foo react twice "
54+
"foo react twice ",
5555
);
5656

5757
assert.ok(
5858
evalCode(foo_react).stdout.match(/require/g).length === 1,
59-
"foo react one"
59+
"foo react one",
6060
);

jscomp/build_tests/deprecated-package-specs/input.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,5 @@ const { rescript_exe } = require("#cli/bin_path");
55
const out = child_process.spawnSync(rescript_exe, { encoding: "utf8" });
66
assert.match(
77
out.stderr,
8-
/deprecated: Option "es6-global" is deprecated\. Use "esmodule" instead\./
8+
/deprecated: Option "es6-global" is deprecated\. Use "esmodule" instead\./,
99
);

jscomp/build_tests/duplicated_symlinked_packages/a/bsconfig.json

+4-7
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,15 @@
22
"name": "a",
33
"version": "0.1.0",
44
"sources": {
5-
"dir" : "src",
6-
"subdirs" : true
5+
"dir": "src",
6+
"subdirs": true
77
},
88
"package-specs": {
99
"module": "commonjs",
1010
"in-source": true
1111
},
1212
"suffix": ".bs.js",
13-
"bs-dependencies": [
14-
"c",
15-
"z"
16-
],
17-
"warnings": {"error" : "+101"},
13+
"bs-dependencies": ["c", "z"],
14+
"warnings": { "error": "+101" },
1815
"namespace": true
1916
}

jscomp/build_tests/duplicated_symlinked_packages/b/bsconfig.json

+4-6
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,15 @@
22
"name": "b",
33
"version": "0.1.0",
44
"sources": {
5-
"dir" : "src",
6-
"subdirs" : true
5+
"dir": "src",
6+
"subdirs": true
77
},
88
"package-specs": {
99
"module": "commonjs",
1010
"in-source": true
1111
},
1212
"suffix": ".bs.js",
13-
"bs-dependencies": [
14-
"c"
15-
],
16-
"warnings": {"error" : "+101"},
13+
"bs-dependencies": ["c"],
14+
"warnings": { "error": "+101" },
1715
"namespace": true
1816
}

jscomp/build_tests/duplicated_symlinked_packages/c/bsconfig.json

+4-6
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,15 @@
22
"name": "c",
33
"version": "0.1.0",
44
"sources": {
5-
"dir" : "src",
6-
"subdirs" : true
5+
"dir": "src",
6+
"subdirs": true
77
},
88
"package-specs": {
99
"module": "commonjs",
1010
"in-source": true
1111
},
1212
"suffix": ".bs.js",
13-
"bs-dependencies": [
14-
15-
],
16-
"warnings": {"error" : "+101"},
13+
"bs-dependencies": [],
14+
"warnings": { "error": "+101" },
1715
"namespace": true
1816
}

jscomp/build_tests/duplicated_symlinked_packages/input.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ child_process.exec(rescript_exe, { cwd: __dirname }, (err, stdout, stderr) => {
1919
fs.writeFileSync(expectedFilePath, actualErrorOutput);
2020
} else {
2121
const expectedErrorOutput = postProcessErrorOutput(
22-
fs.readFileSync(expectedFilePath, { encoding: "utf-8" })
22+
fs.readFileSync(expectedFilePath, { encoding: "utf-8" }),
2323
);
2424
if (expectedErrorOutput !== actualErrorOutput) {
2525
console.error(`The old and new error output aren't the same`);

0 commit comments

Comments
 (0)