Skip to content

Switch to Biome #6838

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 11 commits into from
Jun 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/get_artifact_dir_name.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,5 @@ const { dirName: artifactDirName } = require("../../cli/bin_path.js");
// Pass artifactDirName to subsequent GitHub actions
fs.appendFileSync(
process.env.GITHUB_ENV,
`artifact_dir_name=${artifactDirName}${os.EOL}`
`artifact_dir_name=${artifactDirName}${os.EOL}`,
);
6 changes: 3 additions & 3 deletions .github/workflows/prepare_package_upload.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,15 @@ const commitHashShort = commitHash.substring(0, 7);

fs.renameSync(
`rescript-${version}.tgz`,
`rescript-${version}-${commitHashShort}.tgz`
`rescript-${version}-${commitHashShort}.tgz`,
);
fs.renameSync(
`packages/std/rescript-std-${version}.tgz`,
`rescript-std-${version}-${commitHashShort}.tgz`
`rescript-std-${version}-${commitHashShort}.tgz`,
);

// Pass information to subsequent GitHub actions
fs.appendFileSync(
process.env.GITHUB_ENV,
`rescript_version=${version}-${commitHashShort}${os.EOL}`
`rescript_version=${version}-${commitHashShort}${os.EOL}`,
);
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -93,3 +93,6 @@ playground/*.cmj
playground/*.cmi
playground/.netrc
playground/compiler.js

rewatch/target/
rewatch/rewatch
14 changes: 0 additions & 14 deletions .prettierignore

This file was deleted.

3 changes: 0 additions & 3 deletions .prettierrc.json

This file was deleted.

7 changes: 7 additions & 0 deletions .vscode/extensions.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"recommendations": ["biomejs.biome", "chenglou92.rescript-vscode"],
"unwantedRecommendations": [
"dbaeumer.vscode-eslint",
"esbenp.prettier-vscode"
]
}
49 changes: 49 additions & 0 deletions biome.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
{
"$schema": "https://biomejs.dev/schemas/1.8.3/schema.json",
"vcs": {
"enabled": true,
"clientKind": "git",
"defaultBranch": "master",
"useIgnoreFile": true
},
"linter": {
"enabled": false
},
"organizeImports": {
"enabled": false
},
"formatter": {
"enabled": true,
"formatWithErrors": false,
"indentStyle": "space",
"indentWidth": 2,
"lineEnding": "lf",
"lineWidth": 80,
"attributePosition": "auto",
"ignore": [
"jscomp/build_tests/**/lib/**",
"jscomp/build_tests/**/src/**",
"jscomp/test/**",
"lib/**",
"ninja/**",
"playground/**",
"**/*.bs.js",
"**/*.res.js",
"**/*.gen.ts*",
"package.json"
]
},
"javascript": {
"formatter": {
"jsxQuoteStyle": "double",
"quoteProperties": "asNeeded",
"trailingCommas": "all",
"semicolons": "always",
"arrowParentheses": "asNeeded",
"bracketSpacing": true,
"bracketSameLine": false,
"quoteStyle": "double",
"attributePosition": "auto"
}
}
}
2 changes: 1 addition & 1 deletion cli/rescript_arg.js
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ function parse_exn(
annofun,
start = 0,
// first 3 are [node, rescript, subcommand]
finish = argv.length
finish = argv.length,
) {
var current = start;
var list = [];
Expand Down
4 changes: 2 additions & 2 deletions cli/rescript_bsb.js
Original file line number Diff line number Diff line change
Expand Up @@ -363,7 +363,7 @@ Please pick a different one using the \`-ws [host:]port\` flag from bsb.`);
function outputError(error, highlight) {
if (isTtyError && highlight) {
process.stderr.write(
error.replace(highlight, "\x1b[1;31m" + highlight + "\x1b[0m")
error.replace(highlight, "\x1b[1;31m" + highlight + "\x1b[0m"),
);
} else {
process.stderr.write(error);
Expand Down Expand Up @@ -408,7 +408,7 @@ Please pick a different one using the \`-ws [host:]port\` flag from bsb.`);
// it could fail due to other issues like .bsb.lock
else {
dlog(
`Acquire lock failed, do the build later ${depth} : ${reasonsToRebuild}`
`Acquire lock failed, do the build later ${depth} : ${reasonsToRebuild}`,
);
const waitTime = Math.pow(2, depth) * 40;
setTimeout(() => {
Expand Down
4 changes: 2 additions & 2 deletions cli/rescript_convert.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ function handleOneFile(file, bsc_exe) {
console.error(`Error when converting ${file}`);
console.log(stderr);
}
}
},
);
}
/**
Expand Down Expand Up @@ -91,7 +91,7 @@ function main(argv, rescript_exe, bsc_exe) {
["info", "-list-files"],
{
encoding: "utf-8",
}
},
);
if (output.status !== 0) {
console.error(output.stdout);
Expand Down
12 changes: 6 additions & 6 deletions cli/rescript_format.js
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ async function formatFiles(files, bsc_exe, isSupportedFile, checkFormatting) {
}
}
return null;
})
}),
);
} catch (err) {
console.error(err);
Expand All @@ -103,7 +103,7 @@ async function formatFiles(files, bsc_exe, isSupportedFile, checkFormatting) {
console.error("The file listed above needs formatting");
} else {
console.error(
`The ${incorrectlyFormattedFiles} files listed above need formatting`
`The ${incorrectlyFormattedFiles} files listed above need formatting`,
);
}
process.exit(3);
Expand Down Expand Up @@ -135,7 +135,7 @@ async function main(argv, rescript_exe, bsc_exe) {
// Require: -all or path to a file
if (check.val && !format_project && files.length == 0) {
console.error(
"format check require path to a file or use `-all` to check the whole project"
"format check require path to a file or use `-all` to check the whole project",
);
process.exit(2);
}
Expand All @@ -152,7 +152,7 @@ async function main(argv, rescript_exe, bsc_exe) {
["info", "-list-files"],
{
encoding: "utf-8",
}
},
);
if (output.status !== 0) {
console.error(output.stdout);
Expand All @@ -173,7 +173,7 @@ async function main(argv, rescript_exe, bsc_exe) {
os.tmpdir(),
"rescript_" +
crypto.randomBytes(8).toString("hex") +
path.parse(use_stdin).base
path.parse(use_stdin).base,
);
(async function () {
var content = await readStdin();
Expand All @@ -191,7 +191,7 @@ async function main(argv, rescript_exe, bsc_exe) {
console.error(stderr);
process.exit(2);
}
}
},
);
})();
} else {
Expand Down
8 changes: 4 additions & 4 deletions cli/rescript_postinstall.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,31 +7,31 @@ const { bsc_exe, ninja_exe } = require("./bin_path");
function checkNinja() {
if (!fs.existsSync(ninja_exe)) {
throw new Error(
`No ninja binary found for this platform. ${ninja_exe} does not exist.`
`No ninja binary found for this platform. ${ninja_exe} does not exist.`,
);
}

try {
return String(child_process.execFileSync(ninja_exe, ["--version"])).trim();
} catch (e) {
throw new Error(
`Error getting ninja version. The ninja binary at ${ninja_exe} may not be compatible with this platform: ${e}`
`Error getting ninja version. The ninja binary at ${ninja_exe} may not be compatible with this platform: ${e}`,
);
}
}

function checkCompiler() {
if (!fs.existsSync(bsc_exe)) {
throw new Error(
`No ReScript compiler binary found for this platform. ${bsc_exe} does not exist.`
`No ReScript compiler binary found for this platform. ${bsc_exe} does not exist.`,
);
}

try {
return String(child_process.execFileSync(bsc_exe, ["-v"])).trim();
} catch (e) {
throw new Error(
`Error getting ReScript compiler version. The compiler binary at ${bsc_exe} may not be compatible with this platform: ${e}`
`Error getting ReScript compiler version. The compiler binary at ${bsc_exe} may not be compatible with this platform: ${e}`,
);
}
}
Expand Down
4 changes: 1 addition & 3 deletions jscomp/build_tests/case/rescript.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,5 @@
"name": "case",
"version": "0.1.0",
"sources": ["src"],
"bs-dependencies": [
// add your bs-dependencies here
]
"bs-dependencies": []
}
4 changes: 1 addition & 3 deletions jscomp/build_tests/case2/rescript.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,5 @@
"name": "case2",
"version": "0.1.0",
"sources": ["src"],
"bs-dependencies": [
// add your bs-dependencies here
]
"bs-dependencies": []
}
8 changes: 4 additions & 4 deletions jscomp/build_tests/cli_compile_status/input.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ assert.match(
out.stdout,
new RegExp(`>>>> Start compiling
Dependency Finished
>>>> Finish compiling \\d+ mseconds`)
>>>> Finish compiling \\d+ mseconds`),
);

// Shows compile time for `rescript` command
Expand All @@ -24,7 +24,7 @@ assert.match(
out.stdout,
new RegExp(`>>>> Start compiling
Dependency Finished
>>>> Finish compiling \\d+ mseconds`)
>>>> Finish compiling \\d+ mseconds`),
);

// Doesn't show compile time for `rescript build -verbose` command
Expand All @@ -38,6 +38,6 @@ out = child_process.spawnSync(`../../../rescript`, ["build", "-verbose"], {
assert.match(
out.stdout,
new RegExp(
`Package stack: test \nDependency Finished\nninja.exe -C lib/bs \n`
)
`Package stack: test \nDependency Finished\nninja.exe -C lib/bs \n`,
),
);
6 changes: 3 additions & 3 deletions jscomp/build_tests/cmd/input.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ function evalCode(code) {
encoding: "utf8",
shell: true,
cwd: __dirname,
}
},
);

return bsc_exe;
Expand All @@ -51,10 +51,10 @@ test(react);

assert.ok(
evalCode(react + foo_react).stdout.match(/require/g).length === 2,
"foo react twice "
"foo react twice ",
);

assert.ok(
evalCode(foo_react).stdout.match(/require/g).length === 1,
"foo react one"
"foo react one",
);
2 changes: 1 addition & 1 deletion jscomp/build_tests/deprecated-package-specs/input.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@ const { rescript_exe } = require("#cli/bin_path");
const out = child_process.spawnSync(rescript_exe, { encoding: "utf8" });
assert.match(
out.stderr,
/deprecated: Option "es6-global" is deprecated\. Use "esmodule" instead\./
/deprecated: Option "es6-global" is deprecated\. Use "esmodule" instead\./,
);
11 changes: 4 additions & 7 deletions jscomp/build_tests/duplicated_symlinked_packages/a/bsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,15 @@
"name": "a",
"version": "0.1.0",
"sources": {
"dir" : "src",
"subdirs" : true
"dir": "src",
"subdirs": true
},
"package-specs": {
"module": "commonjs",
"in-source": true
},
"suffix": ".bs.js",
"bs-dependencies": [
"c",
"z"
],
"warnings": {"error" : "+101"},
"bs-dependencies": ["c", "z"],
"warnings": { "error": "+101" },
"namespace": true
}
10 changes: 4 additions & 6 deletions jscomp/build_tests/duplicated_symlinked_packages/b/bsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,15 @@
"name": "b",
"version": "0.1.0",
"sources": {
"dir" : "src",
"subdirs" : true
"dir": "src",
"subdirs": true
},
"package-specs": {
"module": "commonjs",
"in-source": true
},
"suffix": ".bs.js",
"bs-dependencies": [
"c"
],
"warnings": {"error" : "+101"},
"bs-dependencies": ["c"],
"warnings": { "error": "+101" },
"namespace": true
}
10 changes: 4 additions & 6 deletions jscomp/build_tests/duplicated_symlinked_packages/c/bsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,15 @@
"name": "c",
"version": "0.1.0",
"sources": {
"dir" : "src",
"subdirs" : true
"dir": "src",
"subdirs": true
},
"package-specs": {
"module": "commonjs",
"in-source": true
},
"suffix": ".bs.js",
"bs-dependencies": [

],
"warnings": {"error" : "+101"},
"bs-dependencies": [],
"warnings": { "error": "+101" },
"namespace": true
}
2 changes: 1 addition & 1 deletion jscomp/build_tests/duplicated_symlinked_packages/input.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ child_process.exec(rescript_exe, { cwd: __dirname }, (err, stdout, stderr) => {
fs.writeFileSync(expectedFilePath, actualErrorOutput);
} else {
const expectedErrorOutput = postProcessErrorOutput(
fs.readFileSync(expectedFilePath, { encoding: "utf-8" })
fs.readFileSync(expectedFilePath, { encoding: "utf-8" }),
);
if (expectedErrorOutput !== actualErrorOutput) {
console.error(`The old and new error output aren't the same`);
Expand Down
Loading