diff --git a/.github/workflows/ja-translation.yaml b/.github/workflows/ja-translation.yaml index 694f86f1f270..89aaeae18fb5 100644 --- a/.github/workflows/ja-translation.yaml +++ b/.github/workflows/ja-translation.yaml @@ -23,8 +23,6 @@ jobs: ${{ runner.os }}- - uses: pnpm/action-setup@v3 - name: Install libraries - working-directory: website - run: pnpm i + run: pnpm --filter @biomejs/website i - name: Run textlint - working-directory: website - run: pnpm textlint + run: pnpm --filter @biomejs/website run textlint diff --git a/.github/workflows/pull_request.yml b/.github/workflows/pull_request.yml index ea72f245e0b2..3577f9e8a717 100644 --- a/.github/workflows/pull_request.yml +++ b/.github/workflows/pull_request.yml @@ -135,17 +135,17 @@ jobs: - name: Build TypeScript code run: | - pnpm --prefix packages/@biomejs/backend-jsonrpc i - pnpm --prefix packages/@biomejs/backend-jsonrpc run build - pnpm --prefix packages/@biomejs/js-api run build:wasm-bundler - pnpm --prefix packages/@biomejs/js-api run build:wasm-node - pnpm --prefix packages/@biomejs/js-api run build:wasm-web - pnpm --prefix packages/@biomejs/js-api i - pnpm --prefix packages/@biomejs/js-api run build + pnpm --filter @biomejs/backend-jsonrpc i + pnpm --filter @biomejs/backend-jsonrpc run build + pnpm --filter @biomejs/js-api run build:wasm-bundler + pnpm --filter @biomejs/js-api run build:wasm-node + pnpm --filter @biomejs/js-api run build:wasm-web + pnpm --filter @biomejs/js-api i + pnpm --filter @biomejs/js-api run build - name: Run JS tests run: | - pnpm --prefix packages/@biomejs/backend-jsonrpc test:ci - pnpm --prefix packages/@biomejs/js-api test:ci + pnpm --filter @biomejs/backend-jsonrpc run test:ci + pnpm --filter @biomejs/js-api run test:ci documentation: name: Documentation diff --git a/.github/workflows/pull_request_js.yml b/.github/workflows/pull_request_js.yml index 63ba0ac69c3e..b1849b5ce263 100644 --- a/.github/workflows/pull_request_js.yml +++ b/.github/workflows/pull_request_js.yml @@ -40,7 +40,7 @@ jobs: - name: Run Biome Format run: | pnpm i - pnpm run check + pnpm run ci type-check: name: Type-check JS Files @@ -65,8 +65,7 @@ jobs: - name: Build WASM module for the web run: wasm-pack build --out-dir ../../packages/@biomejs/wasm-web --target web --scope biomedev crates/biome_wasm - name: Install libraries - working-directory: website - run: pnpm i + run: pnpm i --filter @biomejs/website - name: Build JS working-directory: website run: pnpm build:js diff --git a/.github/workflows/release_js_api.yml b/.github/workflows/release_js_api.yml index 152cb5557dd0..f6ade9208f2c 100644 --- a/.github/workflows/release_js_api.yml +++ b/.github/workflows/release_js_api.yml @@ -90,17 +90,16 @@ jobs: - name: Compile backends run: | - pnpm --prefix packages/@biomejs/js-api build:wasm-bundler - pnpm --prefix packages/@biomejs/js-api build:wasm-node - pnpm --prefix packages/@biomejs/js-api build:wasm-web - pnpm --prefix packages/@biomejs/backend-jsonrpc i - pnpm --prefix packages/@biomejs/backend-jsonrpc run build + pnpm --filter @biomejs/js-api run build:wasm-bundler + pnpm --filter @biomejs/js-api run build:wasm-node + pnpm --filter @biomejs/js-api run build:wasm-web + pnpm --filter @biomejs/backend-jsonrpc i + pnpm --filter @biomejs/backend-jsonrpc run build - name: Build package - working-directory: packages/@biomejs/js-api run: | - pnpm i - pnpm build + pnpm --filter @biomejs/js-api i + pnpm --filter @biomejs/js-api run build - name: Upload JS API artifact uses: actions/upload-artifact@v3 diff --git a/.github/workflows/runtime.yml b/.github/workflows/runtime.yml index 8fef67a325c5..598c15b2eab8 100644 --- a/.github/workflows/runtime.yml +++ b/.github/workflows/runtime.yml @@ -41,15 +41,14 @@ jobs: - name: Install toolchain uses: moonrepo/setup-rust@v1 - name: Install libraries - working-directory: packages/@biomejs/js-api - run: pnpm i + run: pnpm --filter @biomejs/js-api i - name: Compile backends run: | - pnpm --prefix packages/@biomejs/js-api build:wasm-bundler - pnpm --prefix packages/@biomejs/js-api build:wasm-node - pnpm --prefix packages/@biomejs/js-api build:wasm-web - pnpm --prefix packages/@biomejs/backend-jsonrpc i - pnpm --prefix packages/@biomejs/backend-jsonrpc run build + pnpm --filter @biomejs/js-api run build:wasm-bundler + pnpm --filter @biomejs/js-api run build:wasm-node + pnpm --filter @biomejs/js-api run build:wasm-web + pnpm --filter @biomejs/backend-jsonrpc i + pnpm --filter @biomejs/backend-jsonrpc run build - name: CI checks working-directory: packages/@biomejs/js-api run: pnpm run ci diff --git a/.npmrc b/.npmrc new file mode 100644 index 000000000000..ca0a3a8be9b6 --- /dev/null +++ b/.npmrc @@ -0,0 +1,2 @@ +# workaround until https://github.com/pnpm/pnpm/issues/6300 gets fixed +dedupe-peer-dependents = false diff --git a/benchmark/bench.biome.json b/benchmark/bench.biome.json new file mode 100644 index 000000000000..2d588ebc5d96 --- /dev/null +++ b/benchmark/bench.biome.json @@ -0,0 +1,39 @@ +{ + "$schema": "../packages/@biomejs/biome/configuration_schema.json", + "linter": { + "enabled": true, + "rules": { + "recommended": false, + "complexity": { + "noExtraBooleanCast": "error" + }, + "correctness": { + "noArguments": "error", + "noAsyncPromiseExecutor": "error", + "noCatchAssign": "error", + "noCompareNegZero": "error", + "noDebugger": "error", + "noDelete": "error", + "noDoubleEquals": "error", + "noDuplicateParameters": "error", + "noEmptyPattern": "error", + "noFunctionAssign": "error", + "noImportAssign": "error", + "noLabelVar": "error", + "noMultipleSpacesInRegularExpressionLiterals": "error", + "noNewSymbol": "error", + "noRestrictedGlobals": "error", + "noShadowRestrictedNames": "error", + "noSparseArray": "error", + "noUnreachable": "error", + "noUnsafeNegation": "error", + "noUnusedVariables": "error", + "useValidTypeof": "error" + }, + "nursery": { + "noConstAssign": "warn", + "useValidForDirection": "warn" + } + } + } +} diff --git a/benchmark/bench.rome.json b/benchmark/bench.rome.json deleted file mode 100644 index 205cbf6138a5..000000000000 --- a/benchmark/bench.rome.json +++ /dev/null @@ -1,38 +0,0 @@ -{ - "linter": { - "enabled": true, - "rules": { - "recommended": false, - "complexity": { - "noExtraBooleanCast": "error" - }, - "correctness": { - "noArguments": "error", - "noAsyncPromiseExecutor": "error", - "noCatchAssign": "error", - "noCompareNegZero": "error", - "noDebugger": "error", - "noDelete": "error", - "noDoubleEquals": "error", - "noDuplicateParameters": "error", - "noEmptyPattern": "error", - "noFunctionAssign": "error", - "noImportAssign": "error", - "noLabelVar": "error", - "noMultipleSpacesInRegularExpressionLiterals": "error", - "noNewSymbol": "error", - "noRestrictedGlobals": "error", - "noShadowRestrictedNames": "error", - "noSparseArray": "error", - "noUnreachable": "error", - "noUnsafeNegation": "error", - "noUnusedVariables": "error", - "useValidTypeof": "error" - }, - "nursery": { - "noConstAssign": "warn", - "useValidForDirection": "warn" - } - } - } -} \ No newline at end of file diff --git a/benchmark/dprint.json b/benchmark/dprint.json index ecafd093a680..91ec9208092f 100644 --- a/benchmark/dprint.json +++ b/benchmark/dprint.json @@ -1,12 +1,7 @@ { "incremental": false, - "typescript": { - }, - "includes": ["**/*.{ts,tsx,js,jsx,cjs,mjs}"], - "excludes": [ - "**/node_modules" - ], - "plugins": [ - "https://plugins.dprint.dev/typescript-0.77.0.wasm" - ] + "typescript": {}, + "includes": ["**/*.{ts,tsx,js,jsx,cjs,mjs}"], + "excludes": ["**/node_modules"], + "plugins": ["https://plugins.dprint.dev/typescript-0.77.0.wasm"] } diff --git a/benchmark/package.json b/benchmark/package.json index 45bcf352c083..56ffb0046017 100644 --- a/benchmark/package.json +++ b/benchmark/package.json @@ -1,17 +1,15 @@ { - "name": "benchmark", - "version": "1.0.0", - "description": "", - "main": "run.js", - "scripts": { - "test": "echo \"Error: no test specified\" && exit 1" - }, - "author": "", - "license": "MIT OR Apache-2.0", - "devDependencies": { - "@mixer/parallel-prettier": "^2.0.3", - "dprint": "^0.43.0", - "eslint": "^8.54.0", - "prettier": "^3.1.0" - } + "name": "@biomejs/benchmark", + "version": "1.0.0", + "description": "", + "private": true, + "main": "run.js", + "author": "Biome Developers and Contributors", + "license": "MIT OR Apache-2.0", + "devDependencies": { + "@mixer/parallel-prettier": "^2.0.3", + "dprint": "^0.43.0", + "eslint": "^8.54.0", + "prettier": "^3.1.0" + } } diff --git a/benchmark/run.js b/benchmark/run.js index d459b57ed138..eabaca6fd7ca 100644 --- a/benchmark/run.js +++ b/benchmark/run.js @@ -1,13 +1,12 @@ -const fs = require("fs"); -const child_process = require("child_process"); -const path = require("path"); -const os = require("os"); -const { dir } = require("console"); +const fs = require("node:fs"); +const child_process = require("node:child_process"); +const path = require("node:path"); +const os = require("node:os"); const TMP_DIRECTORY = path.resolve("./target"); -function buildRome() { - console.log("Build Biome..."); +function buildBiome() { + console.log("Building Biome..."); child_process.execSync("cargo build --bin biome --release", { stdio: "inherit", @@ -54,7 +53,7 @@ const BENCHMARKS = { }; function getDirsToClone(sourceDirs) { - if (typeof sourceDirs !== 'object' || sourceDirs === null) { + if (typeof sourceDirs !== "object" || sourceDirs === null) { return; } @@ -65,7 +64,7 @@ function getDirsToClone(sourceDirs) { return Object.keys(sourceDirs); } -function benchmarkFormatter(rome) { +function benchmarkFormatter(biome) { console.log(""); console.log("Benchmark formatter..."); console.log("―".repeat(80)); @@ -77,7 +76,11 @@ function benchmarkFormatter(rome) { for (const [name, configuration] of Object.entries(BENCHMARKS.formatter)) { console.log(`[${name}]`); - let projectDirectory = cloneProject(name, configuration.repository, getDirsToClone(configuration.sourceDirectories)); + const projectDirectory = cloneProject( + name, + configuration.repository, + getDirsToClone(configuration.sourceDirectories), + ); const prettierPaths = Object.entries(configuration.sourceDirectories) .flatMap(([directory, extensions]) => { @@ -88,24 +91,30 @@ function benchmarkFormatter(rome) { .join(" "); const prettierCommand = `node '${resolvePrettier()}' ${prettierPaths} --write --loglevel=error`; - const parallelPrettierCommand = `node '${resolveParallelPrettier()}' ${prettierPaths} --write --concurrency ${os.cpus().length}`; + const parallelPrettierCommand = `node '${resolveParallelPrettier()}' ${prettierPaths} --write --concurrency ${ + os.cpus().length + }`; - const dprintCommand = `${resolveDprint()} fmt --incremental=false --config '${require.resolve("./dprint.json")}' ${Object.keys(configuration.sourceDirectories).map(path => `'${path}/**/*'`).join(" ")}`; + const dprintCommand = `${resolveDprint()} fmt --incremental=false --config '${require.resolve( + "./dprint.json", + )}' ${Object.keys(configuration.sourceDirectories) + .map((path) => `'${path}/**/*'`) + .join(" ")}`; - const romeCommand = `${rome} format --max-diagnostics=0 ${Object.keys( + const biomeCommand = `${biome} format --max-diagnostics=0 ${Object.keys( configuration.sourceDirectories, ) .map((path) => `'${path}'`) .join(" ")} --write`; - const romeSingleCoreCommand = withEnvVariable( + const biomeSingleCoreCommand = withEnvVariable( "RAYON_NUM_THREADS", "1", - romeCommand, + biomeCommand, ); // Run 2 warmups to make sure the files are formatted correctly - const hyperfineCommand = `hyperfine --show-output -w 2 -n Prettier "${prettierCommand}" -n "Parallel-Prettier" "${parallelPrettierCommand}" -n dprint "${dprintCommand}" -n Rome "${romeCommand}" --shell=${shellOption()} -n "Rome (1 thread)" "${romeSingleCoreCommand}"`; + const hyperfineCommand = `hyperfine --show-output -w 2 -n Prettier "${prettierCommand}" -n "Parallel-Prettier" "${parallelPrettierCommand}" -n dprint "${dprintCommand}" -n Biome "${biomeCommand}" --shell=${shellOption()} -n "Biome (1 thread)" "${biomeSingleCoreCommand}"`; console.log(hyperfineCommand); child_process.execSync(hyperfineCommand, { @@ -127,7 +136,7 @@ function resolveDprint() { return path.resolve("node_modules/dprint/dprint"); } -function benchmarkLinter(rome) { +function benchmarkLinter(biome) { console.log(""); console.log("Benchmark linter..."); console.log("―".repeat(80)); @@ -136,17 +145,24 @@ function benchmarkLinter(rome) { for (const [name, configuration] of Object.entries(BENCHMARKS.linter)) { console.log(`[${name}]`); - const projectDirectory = cloneProject(name, configuration.repository, getDirsToClone(configuration.sourceDirectories)); + const projectDirectory = cloneProject( + name, + configuration.repository, + getDirsToClone(configuration.sourceDirectories), + ); deleteFile(path.join(projectDirectory, ".eslintignore")); deleteFile(path.join(projectDirectory, "/eslintrc.js")); // Override eslint config const eslintConfig = fs.readFileSync("./bench.eslint.js"); - fs.writeFileSync(path.join(projectDirectory, "eslint.config.js"), eslintConfig); + fs.writeFileSync( + path.join(projectDirectory, "eslint.config.js"), + eslintConfig, + ); - const romeConfig = fs.readFileSync("./bench.rome.json"); - fs.writeFileSync(path.join(projectDirectory, "rome.json"), romeConfig); + const biomeConfig = fs.readFileSync("./bench.biome.json"); + fs.writeFileSync(path.join(projectDirectory, "biome.json"), biomeConfig); const eslintPaths = configuration.sourceDirectories .map((directory) => `'${directory}/**'`) @@ -154,21 +170,21 @@ function benchmarkLinter(rome) { const eslintCommand = `node '${resolveESlint()}' --no-ignore ${eslintPaths}`; - const romePaths = configuration.sourceDirectories + const biomePaths = configuration.sourceDirectories .map((directory) => `'${directory}'`) .join(" "); // Don't compute the code frames for pulled diagnostics. ESLint doesn't do so as well. - const romeCommand = `${rome} check --max-diagnostics=0 ${romePaths}`; + const biomeCommand = `${biome} check --max-diagnostics=0 ${biomePaths}`; - const romeSingleCoreCommand = withEnvVariable( + const biomeSingleCoreCommand = withEnvVariable( "RAYON_NUM_THREADS", "1", - romeCommand, + biomeCommand, ); // Run 2 warmups to make sure the files are formatted correctly - const hyperfineCommand = `hyperfine -i -w 2 -n ESLint "${eslintCommand}" -n Rome "${romeCommand}" --shell=${shellOption()} -n "Rome (1 thread)" "${romeSingleCoreCommand}"`; + const hyperfineCommand = `hyperfine -i -w 2 -n ESLint "${eslintCommand}" -n Biome "${biomeCommand}" --shell=${shellOption()} -n "Biome (1 thread)" "${biomeSingleCoreCommand}"`; console.log(hyperfineCommand); child_process.execSync(hyperfineCommand, { @@ -220,9 +236,9 @@ function deleteFile(path) { } function cloneProject(name, repository, dirs = []) { - let projectDirectory = path.join(TMP_DIRECTORY, name); + const projectDirectory = path.join(TMP_DIRECTORY, name); - let inProjectDirectory = withDirectory(projectDirectory); + const inProjectDirectory = withDirectory(projectDirectory); if (fs.existsSync(projectDirectory)) { console.log(`Updating git repository in directory ${projectDirectory}`); @@ -232,14 +248,19 @@ function cloneProject(name, repository, dirs = []) { } else { console.log("Clone project..."); - withDirectory(TMP_DIRECTORY).run(`git clone ${dirs.length > 0 ? '--sparse' : ''} --depth=1 ${repository}`, { - stdio: "inherit", - }); + withDirectory(TMP_DIRECTORY).run( + `git clone ${dirs.length > 0 ? "--sparse" : ""} --depth=1 ${repository}`, + { + stdio: "inherit", + }, + ); } if (dirs.length > 0) { - console.log(`Adding directories ${dirs.join()} to sparse checkout in ${projectDirectory}`) - inProjectDirectory.run(`git sparse-checkout add ${dirs.join(' ')}`); + console.log( + `Adding directories ${dirs.join()} to sparse checkout in ${projectDirectory}`, + ); + inProjectDirectory.run(`git sparse-checkout add ${dirs.join(" ")}`); } return projectDirectory; @@ -248,10 +269,10 @@ function cloneProject(name, repository, dirs = []) { function run() { fs.mkdirSync("target", { recursive: true }); - const rome = buildRome(); + const biome = buildBiome(); - benchmarkFormatter(rome); - benchmarkLinter(rome); + benchmarkFormatter(biome); + benchmarkLinter(biome); } run(); diff --git a/biome.json b/biome.json index 5c8e7a046d30..1553c9729465 100644 --- a/biome.json +++ b/biome.json @@ -3,12 +3,13 @@ "extends": ["@biomejs/shared/biome"], "files": { "ignore": [ + "crates/**", "dist/**", ".astro/**", "assets/**", + "packages/@biomejs/backend-jsonrpc/src/workspace.ts", "public/**", "**/__snapshots__", - "**/editors/intellij/**", "**/undefined/**", "_fonts/**" ] diff --git a/netlify.toml b/netlify.toml index c6eb005d02c1..d7ceacdc0c7f 100644 --- a/netlify.toml +++ b/netlify.toml @@ -1,3 +1,3 @@ [build] publish = "website/dist/" -command = "npm i -g wasm-pack && pnpm --filter @biomejs/website build:wasm && pnpm i --filter @biomejs/website --frozen-lockfile && pnpm --filter @biomejs/website build:js" +command = "npm i -g wasm-pack && pnpm --filter @biomejs/website run build:wasm && pnpm i --filter @biomejs/website --frozen-lockfile && pnpm --filter @biomejs/website run build:js" diff --git a/package.json b/package.json index 805b001a72ae..8e29a9b9f6b9 100644 --- a/package.json +++ b/package.json @@ -3,12 +3,13 @@ "version": "0.0.0", "private": true, "scripts": { - "check:apply": "cargo biome-cli-dev check --apply-unsafe website packages/@biomejs/js-api packages/tailwindcss-config-analyzer", - "check": "cargo biome-cli-dev check website packages/@biomejs/js-api packages/tailwindcss-config-analyzer", - "ci": "cargo biome-cli-dev ci website packages/@biomejs/js-api packages/tailwindcss-config-analyzer" + "check:apply": "cargo biome-cli-dev check --apply-unsafe .", + "check": "cargo biome-cli-dev check .", + "ci": "cargo biome-cli-dev ci ." }, "keywords": [], - "author": "", + "author": "Biome Developers and Contributors", + "license": "MIT OR Apache-2.0", "devDependencies": { "@biomejs/shared": "workspace:^" }, diff --git a/packages/@biomejs/backend-jsonrpc/package.json b/packages/@biomejs/backend-jsonrpc/package.json index 4f846ebe16af..8fe5225a7be5 100644 --- a/packages/@biomejs/backend-jsonrpc/package.json +++ b/packages/@biomejs/backend-jsonrpc/package.json @@ -1,44 +1,38 @@ { - "name": "@biomejs/backend-jsonrpc", - "version": "0.0.0", - "main": "dist/index.js", - "scripts": { - "test": "vitest", - "test:ci": "pnpm build && vitest run", - "tsc": "tsc --noEmit", - "build": "tsc" - }, - "files": [ - "dist/", - "README.md", - "LICENSE-APACHE", - "LICENSE-MIT", - "ROME-LICENSE-MIT" - ], - "homepage": "https://biomejs.dev", - "repository": { - "type": "git", - "url": "https://github.com/biomejs/biome.git", - "directory": "npm/backend-jsonrpc" - }, - "author": "Biome Developers and Contributors", - "bugs": "https://github.com/biomejs/biome/issues", - "description": "Bindings to the JSON-RPC Workspace API of the Biome daemon", - "keywords": [ - "JavaScript", - "TypeScript", - "format", - "lint", - "toolchain" - ], - "engines": { - "node": ">=14.*" - }, - "license": "MIT OR Apache-2.0", - "devDependencies": { - "@types/node": "^20.11.27", - "typescript": "^5.4.2", - "vite": "^5.1.6", - "vitest": "^1.3.1" - } + "name": "@biomejs/backend-jsonrpc", + "version": "0.0.0", + "main": "dist/index.js", + "scripts": { + "test": "vitest", + "test:ci": "pnpm build && vitest run", + "tsc": "tsc --noEmit", + "build": "tsc" + }, + "files": [ + "dist/", + "README.md", + "LICENSE-APACHE", + "LICENSE-MIT", + "ROME-LICENSE-MIT" + ], + "homepage": "https://biomejs.dev", + "repository": { + "type": "git", + "url": "https://github.com/biomejs/biome.git", + "directory": "npm/backend-jsonrpc" + }, + "author": "Biome Developers and Contributors", + "bugs": "https://github.com/biomejs/biome/issues", + "description": "Bindings to the JSON-RPC Workspace API of the Biome daemon", + "keywords": ["JavaScript", "TypeScript", "format", "lint", "toolchain"], + "engines": { + "node": ">=14.*" + }, + "license": "MIT OR Apache-2.0", + "devDependencies": { + "@types/node": "^20.11.27", + "typescript": "^5.4.2", + "vite": "^5.1.6", + "vitest": "^1.3.1" + } } diff --git a/packages/@biomejs/backend-jsonrpc/src/socket.ts b/packages/@biomejs/backend-jsonrpc/src/socket.ts index 532aef4b3043..1ef10e73632f 100644 --- a/packages/@biomejs/backend-jsonrpc/src/socket.ts +++ b/packages/@biomejs/backend-jsonrpc/src/socket.ts @@ -1,5 +1,5 @@ -import { spawn } from "child_process"; -import { connect, type Socket } from "net"; +import { spawn } from "node:child_process"; +import { type Socket, connect } from "node:net"; function getSocket(command: string): Promise { return new Promise((resolve, reject) => { diff --git a/packages/@biomejs/backend-jsonrpc/src/transport.ts b/packages/@biomejs/backend-jsonrpc/src/transport.ts index 21686ae62151..f40f25fc44cc 100644 --- a/packages/@biomejs/backend-jsonrpc/src/transport.ts +++ b/packages/@biomejs/backend-jsonrpc/src/transport.ts @@ -5,8 +5,8 @@ interface Socket { } enum ReaderStateKind { - Header, - Body, + Header = 0, + Body = 1, } interface ReaderStateHeader { @@ -27,7 +27,7 @@ interface JsonRpcRequest { jsonrpc: "2.0"; id: number; method: string; - params: any; + params: unknown; } function isJsonRpcRequest(message: JsonRpcMessage): message is JsonRpcRequest { @@ -43,7 +43,7 @@ function isJsonRpcRequest(message: JsonRpcMessage): message is JsonRpcRequest { interface JsonRpcNotification { jsonrpc: "2.0"; method: string; - params: any; + params: unknown; } function isJsonRpcNotification( @@ -61,12 +61,12 @@ type JsonRpcResponse = | { jsonrpc: "2.0"; id: number; - result: any; + result: unknown; } | { jsonrpc: "2.0"; id: number; - error: any; + error: unknown; }; function isJsonRpcResponse( @@ -82,15 +82,18 @@ function isJsonRpcResponse( type JsonRpcMessage = JsonRpcRequest | JsonRpcNotification | JsonRpcResponse; -function isJsonRpcMessage(message: any): message is JsonRpcMessage { +function isJsonRpcMessage(message: unknown): message is JsonRpcMessage { return ( - typeof message === "object" && message !== null && message.jsonrpc === "2.0" + typeof message === "object" && + message !== null && + "jsonrpc" in message && + message.jsonrpc === "2.0" ); } interface PendingRequest { - resolve(result: any): void; - reject(error: any): void; + resolve(result: unknown): void; + reject(error: unknown): void; } const MIME_JSONRPC = "application/vscode-jsonrpc"; @@ -123,7 +126,8 @@ export class Transport { * @param params Parameters object the remote method should be called with * @return Promise resolving with the value returned by the remote method, or rejecting with an RPC error if the remote call failed */ - request(method: string, params: any): Promise { + // biome-ignore lint/suspicious/noExplicitAny: if i change it to Promise typescript breaks + request(method: string, params: unknown): Promise { return new Promise((resolve, reject) => { const id = this.nextRequestId++; this.pendingRequests.set(id, { resolve, reject }); @@ -142,7 +146,7 @@ export class Transport { * @param method Name of the remote method to call * @param params Parameters object the remote method should be called with */ - notify(method: string, params: any) { + notify(method: string, params: unknown) { this.sendMessage({ jsonrpc: "2.0", method, @@ -160,9 +164,7 @@ export class Transport { private sendMessage(message: JsonRpcMessage) { const body = Buffer.from(JSON.stringify(message)); const headers = Buffer.from( - `Content-Length: ${body.length}\r\n` + - `Content-Type: ${MIME_JSONRPC};charset=utf-8\r\n` + - `\r\n`, + `Content-Length: ${body.length}\r\nContent-Type: ${MIME_JSONRPC};charset=utf-8\r\n\r\n`, ); this.socket.write(Buffer.concat([headers, body])); } @@ -209,7 +211,7 @@ export class Transport { const { contentLength, contentType } = readerState; if (typeof contentLength !== "number") { throw new Error( - `incoming message from the remote workspace is missing the Content-Length header`, + "incoming message from the remote workspace is missing the Content-Length header", ); } @@ -231,7 +233,7 @@ export class Transport { switch (headerName) { case "Content-Length": { - const value = parseInt(headerValue); + const value = Number.parseInt(headerValue); readerState.contentLength = value; break; } diff --git a/packages/@biomejs/backend-jsonrpc/tests/transport.test.mjs b/packages/@biomejs/backend-jsonrpc/tests/transport.test.mjs index f20362a0175b..0105f9315039 100644 --- a/packages/@biomejs/backend-jsonrpc/tests/transport.test.mjs +++ b/packages/@biomejs/backend-jsonrpc/tests/transport.test.mjs @@ -1,14 +1,11 @@ -import { describe, it, expect, vi } from "vitest"; +import { describe, expect, it, vi } from "vitest"; import { Transport } from "../dist/transport"; function makeMessage(body) { const content = JSON.stringify(body); return Buffer.from( - `Content-Length: ${content.length}\r\n` + - `Content-Type: application/vscode-jsonrpc;charset=utf-8\r\n` + - `\r\n` + - content, + `Content-Length: ${content.length}\r\nContent-Type: application/vscode-jsonrpc;charset=utf-8\r\n\r\n${content}`, ); } @@ -65,7 +62,7 @@ describe("Transport Layer", () => { const transport = new Transport(socket); - expect(() => onData(Buffer.from(`\r\n`))).toThrowError( + expect(() => onData(Buffer.from("\r\n"))).toThrowError( "incoming message from the remote workspace is missing the Content-Length header", ); @@ -86,7 +83,7 @@ describe("Transport Layer", () => { const transport = new Transport(socket); - expect(() => onData(Buffer.from(`Content-Length\r\n`))).toThrowError( + expect(() => onData(Buffer.from("Content-Length\r\n"))).toThrowError( 'could not find colon token in "Content-Length\r\n"', ); @@ -108,7 +105,7 @@ describe("Transport Layer", () => { const transport = new Transport(socket); expect(() => - onData(Buffer.from(`Content-Type: text/plain\r\n`)), + onData(Buffer.from("Content-Type: text/plain\r\n")), ).toThrowError( 'invalid value for Content-Type expected "application/vscode-jsonrpc", got "text/plain"', ); diff --git a/packages/@biomejs/backend-jsonrpc/tests/workspace.test.mjs b/packages/@biomejs/backend-jsonrpc/tests/workspace.test.mjs index 62c6eec18c27..0b28f79b74e7 100644 --- a/packages/@biomejs/backend-jsonrpc/tests/workspace.test.mjs +++ b/packages/@biomejs/backend-jsonrpc/tests/workspace.test.mjs @@ -1,6 +1,6 @@ -import { fileURLToPath } from "url"; -import { resolve } from "path"; -import { describe, it, expect } from "vitest"; +import { resolve } from "node:path"; +import { fileURLToPath } from "node:url"; +import { describe, expect, it } from "vitest"; import { createWorkspaceWithBinary } from "../dist/index.js"; diff --git a/packages/@biomejs/backend-jsonrpc/tsconfig.json b/packages/@biomejs/backend-jsonrpc/tsconfig.json index 657d64e6a7af..6bea3a21da3c 100644 --- a/packages/@biomejs/backend-jsonrpc/tsconfig.json +++ b/packages/@biomejs/backend-jsonrpc/tsconfig.json @@ -1,103 +1,103 @@ { - "compilerOptions": { - /* Visit https://aka.ms/tsconfig to read more about this file */ + "compilerOptions": { + /* Visit https://aka.ms/tsconfig to read more about this file */ - /* Projects */ - // "incremental": true, /* Save .tsbuildinfo files to allow for incremental compilation of projects. */ - // "composite": true, /* Enable constraints that allow a TypeScript project to be used with project references. */ - // "tsBuildInfoFile": "./.tsbuildinfo", /* Specify the path to .tsbuildinfo incremental compilation file. */ - // "disableSourceOfProjectReferenceRedirect": true, /* Disable preferring source files instead of declaration files when referencing composite projects. */ - // "disableSolutionSearching": true, /* Opt a project out of multi-project reference checking when editing. */ - // "disableReferencedProjectLoad": true, /* Reduce the number of projects loaded automatically by TypeScript. */ + /* Projects */ + // "incremental": true, /* Save .tsbuildinfo files to allow for incremental compilation of projects. */ + // "composite": true, /* Enable constraints that allow a TypeScript project to be used with project references. */ + // "tsBuildInfoFile": "./.tsbuildinfo", /* Specify the path to .tsbuildinfo incremental compilation file. */ + // "disableSourceOfProjectReferenceRedirect": true, /* Disable preferring source files instead of declaration files when referencing composite projects. */ + // "disableSolutionSearching": true, /* Opt a project out of multi-project reference checking when editing. */ + // "disableReferencedProjectLoad": true, /* Reduce the number of projects loaded automatically by TypeScript. */ - /* Language and Environment */ - "target": "es2020", /* Set the JavaScript language version for emitted JavaScript and include compatible library declarations. */ - // "lib": [], /* Specify a set of bundled library declaration files that describe the target runtime environment. */ - // "jsx": "preserve", /* Specify what JSX code is generated. */ - // "experimentalDecorators": true, /* Enable experimental support for TC39 stage 2 draft decorators. */ - // "emitDecoratorMetadata": true, /* Emit design-type metadata for decorated declarations in source files. */ - // "jsxFactory": "", /* Specify the JSX factory function used when targeting React JSX emit, e.g. 'React.createElement' or 'h'. */ - // "jsxFragmentFactory": "", /* Specify the JSX Fragment reference used for fragments when targeting React JSX emit e.g. 'React.Fragment' or 'Fragment'. */ - // "jsxImportSource": "", /* Specify module specifier used to import the JSX factory functions when using 'jsx: react-jsx*'. */ - // "reactNamespace": "", /* Specify the object invoked for 'createElement'. This only applies when targeting 'react' JSX emit. */ - // "noLib": true, /* Disable including any library files, including the default lib.d.ts. */ - // "useDefineForClassFields": true, /* Emit ECMAScript-standard-compliant class fields. */ - // "moduleDetection": "auto", /* Control what method is used to detect module-format JS files. */ + /* Language and Environment */ + "target": "es2020" /* Set the JavaScript language version for emitted JavaScript and include compatible library declarations. */, + // "lib": [], /* Specify a set of bundled library declaration files that describe the target runtime environment. */ + // "jsx": "preserve", /* Specify what JSX code is generated. */ + // "experimentalDecorators": true, /* Enable experimental support for TC39 stage 2 draft decorators. */ + // "emitDecoratorMetadata": true, /* Emit design-type metadata for decorated declarations in source files. */ + // "jsxFactory": "", /* Specify the JSX factory function used when targeting React JSX emit, e.g. 'React.createElement' or 'h'. */ + // "jsxFragmentFactory": "", /* Specify the JSX Fragment reference used for fragments when targeting React JSX emit e.g. 'React.Fragment' or 'Fragment'. */ + // "jsxImportSource": "", /* Specify module specifier used to import the JSX factory functions when using 'jsx: react-jsx*'. */ + // "reactNamespace": "", /* Specify the object invoked for 'createElement'. This only applies when targeting 'react' JSX emit. */ + // "noLib": true, /* Disable including any library files, including the default lib.d.ts. */ + // "useDefineForClassFields": true, /* Emit ECMAScript-standard-compliant class fields. */ + // "moduleDetection": "auto", /* Control what method is used to detect module-format JS files. */ - /* Modules */ - "module": "commonjs", /* Specify what module code is generated. */ - // "rootDir": "./", /* Specify the root folder within your source files. */ - // "moduleResolution": "node", /* Specify how TypeScript looks up a file from a given module specifier. */ - // "baseUrl": "./", /* Specify the base directory to resolve non-relative module names. */ - // "paths": {}, /* Specify a set of entries that re-map imports to additional lookup locations. */ - // "rootDirs": [], /* Allow multiple folders to be treated as one when resolving modules. */ - // "typeRoots": [], /* Specify multiple folders that act like './node_modules/@types'. */ - // "types": [], /* Specify type package names to be included without being referenced in a source file. */ - // "allowUmdGlobalAccess": true, /* Allow accessing UMD globals from modules. */ - // "moduleSuffixes": [], /* List of file name suffixes to search when resolving a module. */ - // "resolveJsonModule": true, /* Enable importing .json files. */ - // "noResolve": true, /* Disallow 'import's, 'require's or ''s from expanding the number of files TypeScript should add to a project. */ + /* Modules */ + "module": "commonjs" /* Specify what module code is generated. */, + // "rootDir": "./", /* Specify the root folder within your source files. */ + // "moduleResolution": "node", /* Specify how TypeScript looks up a file from a given module specifier. */ + // "baseUrl": "./", /* Specify the base directory to resolve non-relative module names. */ + // "paths": {}, /* Specify a set of entries that re-map imports to additional lookup locations. */ + // "rootDirs": [], /* Allow multiple folders to be treated as one when resolving modules. */ + // "typeRoots": [], /* Specify multiple folders that act like './node_modules/@types'. */ + // "types": [], /* Specify type package names to be included without being referenced in a source file. */ + // "allowUmdGlobalAccess": true, /* Allow accessing UMD globals from modules. */ + // "moduleSuffixes": [], /* List of file name suffixes to search when resolving a module. */ + // "resolveJsonModule": true, /* Enable importing .json files. */ + // "noResolve": true, /* Disallow 'import's, 'require's or ''s from expanding the number of files TypeScript should add to a project. */ - /* JavaScript Support */ - // "allowJs": true, /* Allow JavaScript files to be a part of your program. Use the 'checkJS' option to get errors from these files. */ - // "checkJs": true, /* Enable error reporting in type-checked JavaScript files. */ - // "maxNodeModuleJsDepth": 1, /* Specify the maximum folder depth used for checking JavaScript files from 'node_modules'. Only applicable with 'allowJs'. */ + /* JavaScript Support */ + // "allowJs": true, /* Allow JavaScript files to be a part of your program. Use the 'checkJS' option to get errors from these files. */ + // "checkJs": true, /* Enable error reporting in type-checked JavaScript files. */ + // "maxNodeModuleJsDepth": 1, /* Specify the maximum folder depth used for checking JavaScript files from 'node_modules'. Only applicable with 'allowJs'. */ - /* Emit */ - "declaration": true, /* Generate .d.ts files from TypeScript and JavaScript files in your project. */ - // "declarationMap": true, /* Create sourcemaps for d.ts files. */ - // "emitDeclarationOnly": true, /* Only output d.ts files and not JavaScript files. */ - // "sourceMap": true, /* Create source map files for emitted JavaScript files. */ - // "outFile": "./", /* Specify a file that bundles all outputs into one JavaScript file. If 'declaration' is true, also designates a file that bundles all .d.ts output. */ - "outDir": "./dist", /* Specify an output folder for all emitted files. */ - // "removeComments": true, /* Disable emitting comments. */ - // "noEmit": true, /* Disable emitting files from a compilation. */ - // "importHelpers": true, /* Allow importing helper functions from tslib once per project, instead of including them per-file. */ - // "importsNotUsedAsValues": "remove", /* Specify emit/checking behavior for imports that are only used for types. */ - // "downlevelIteration": true, /* Emit more compliant, but verbose and less performant JavaScript for iteration. */ - // "sourceRoot": "", /* Specify the root path for debuggers to find the reference source code. */ - // "mapRoot": "", /* Specify the location where debugger should locate map files instead of generated locations. */ - // "inlineSourceMap": true, /* Include sourcemap files inside the emitted JavaScript. */ - // "inlineSources": true, /* Include source code in the sourcemaps inside the emitted JavaScript. */ - // "emitBOM": true, /* Emit a UTF-8 Byte Order Mark (BOM) in the beginning of output files. */ - // "newLine": "crlf", /* Set the newline character for emitting files. */ - // "stripInternal": true, /* Disable emitting declarations that have '@internal' in their JSDoc comments. */ - // "noEmitHelpers": true, /* Disable generating custom helper functions like '__extends' in compiled output. */ - // "noEmitOnError": true, /* Disable emitting files if any type checking errors are reported. */ - // "preserveConstEnums": true, /* Disable erasing 'const enum' declarations in generated code. */ - // "declarationDir": "./", /* Specify the output directory for generated declaration files. */ - // "preserveValueImports": true, /* Preserve unused imported values in the JavaScript output that would otherwise be removed. */ + /* Emit */ + "declaration": true /* Generate .d.ts files from TypeScript and JavaScript files in your project. */, + // "declarationMap": true, /* Create sourcemaps for d.ts files. */ + // "emitDeclarationOnly": true, /* Only output d.ts files and not JavaScript files. */ + // "sourceMap": true, /* Create source map files for emitted JavaScript files. */ + // "outFile": "./", /* Specify a file that bundles all outputs into one JavaScript file. If 'declaration' is true, also designates a file that bundles all .d.ts output. */ + "outDir": "./dist" /* Specify an output folder for all emitted files. */, + // "removeComments": true, /* Disable emitting comments. */ + // "noEmit": true, /* Disable emitting files from a compilation. */ + // "importHelpers": true, /* Allow importing helper functions from tslib once per project, instead of including them per-file. */ + // "importsNotUsedAsValues": "remove", /* Specify emit/checking behavior for imports that are only used for types. */ + // "downlevelIteration": true, /* Emit more compliant, but verbose and less performant JavaScript for iteration. */ + // "sourceRoot": "", /* Specify the root path for debuggers to find the reference source code. */ + // "mapRoot": "", /* Specify the location where debugger should locate map files instead of generated locations. */ + // "inlineSourceMap": true, /* Include sourcemap files inside the emitted JavaScript. */ + // "inlineSources": true, /* Include source code in the sourcemaps inside the emitted JavaScript. */ + // "emitBOM": true, /* Emit a UTF-8 Byte Order Mark (BOM) in the beginning of output files. */ + // "newLine": "crlf", /* Set the newline character for emitting files. */ + // "stripInternal": true, /* Disable emitting declarations that have '@internal' in their JSDoc comments. */ + // "noEmitHelpers": true, /* Disable generating custom helper functions like '__extends' in compiled output. */ + // "noEmitOnError": true, /* Disable emitting files if any type checking errors are reported. */ + // "preserveConstEnums": true, /* Disable erasing 'const enum' declarations in generated code. */ + // "declarationDir": "./", /* Specify the output directory for generated declaration files. */ + // "preserveValueImports": true, /* Preserve unused imported values in the JavaScript output that would otherwise be removed. */ - /* Interop Constraints */ - // "isolatedModules": true, /* Ensure that each file can be safely transpiled without relying on other imports. */ - // "allowSyntheticDefaultImports": true, /* Allow 'import x from y' when a module doesn't have a default export. */ - "esModuleInterop": true, /* Emit additional JavaScript to ease support for importing CommonJS modules. This enables 'allowSyntheticDefaultImports' for type compatibility. */ - // "preserveSymlinks": true, /* Disable resolving symlinks to their realpath. This correlates to the same flag in node. */ - "forceConsistentCasingInFileNames": true, /* Ensure that casing is correct in imports. */ + /* Interop Constraints */ + // "isolatedModules": true, /* Ensure that each file can be safely transpiled without relying on other imports. */ + // "allowSyntheticDefaultImports": true, /* Allow 'import x from y' when a module doesn't have a default export. */ + "esModuleInterop": true /* Emit additional JavaScript to ease support for importing CommonJS modules. This enables 'allowSyntheticDefaultImports' for type compatibility. */, + // "preserveSymlinks": true, /* Disable resolving symlinks to their realpath. This correlates to the same flag in node. */ + "forceConsistentCasingInFileNames": true /* Ensure that casing is correct in imports. */, - /* Type Checking */ - "strict": true, /* Enable all strict type-checking options. */ - // "noImplicitAny": true, /* Enable error reporting for expressions and declarations with an implied 'any' type. */ - // "strictNullChecks": true, /* When type checking, take into account 'null' and 'undefined'. */ - // "strictFunctionTypes": true, /* When assigning functions, check to ensure parameters and the return values are subtype-compatible. */ - // "strictBindCallApply": true, /* Check that the arguments for 'bind', 'call', and 'apply' methods match the original function. */ - // "strictPropertyInitialization": true, /* Check for class properties that are declared but not set in the constructor. */ - // "noImplicitThis": true, /* Enable error reporting when 'this' is given the type 'any'. */ - // "useUnknownInCatchVariables": true, /* Default catch clause variables as 'unknown' instead of 'any'. */ - // "alwaysStrict": true, /* Ensure 'use strict' is always emitted. */ - // "noUnusedLocals": true, /* Enable error reporting when local variables aren't read. */ - // "noUnusedParameters": true, /* Raise an error when a function parameter isn't read. */ - // "exactOptionalPropertyTypes": true, /* Interpret optional property types as written, rather than adding 'undefined'. */ - // "noImplicitReturns": true, /* Enable error reporting for codepaths that do not explicitly return in a function. */ - // "noFallthroughCasesInSwitch": true, /* Enable error reporting for fallthrough cases in switch statements. */ - // "noUncheckedIndexedAccess": true, /* Add 'undefined' to a type when accessed using an index. */ - // "noImplicitOverride": true, /* Ensure overriding members in derived classes are marked with an override modifier. */ - // "noPropertyAccessFromIndexSignature": true, /* Enforces using indexed accessors for keys declared using an indexed type. */ - // "allowUnusedLabels": true, /* Disable error reporting for unused labels. */ - // "allowUnreachableCode": true, /* Disable error reporting for unreachable code. */ + /* Type Checking */ + "strict": true /* Enable all strict type-checking options. */, + // "noImplicitAny": true, /* Enable error reporting for expressions and declarations with an implied 'any' type. */ + // "strictNullChecks": true, /* When type checking, take into account 'null' and 'undefined'. */ + // "strictFunctionTypes": true, /* When assigning functions, check to ensure parameters and the return values are subtype-compatible. */ + // "strictBindCallApply": true, /* Check that the arguments for 'bind', 'call', and 'apply' methods match the original function. */ + // "strictPropertyInitialization": true, /* Check for class properties that are declared but not set in the constructor. */ + // "noImplicitThis": true, /* Enable error reporting when 'this' is given the type 'any'. */ + // "useUnknownInCatchVariables": true, /* Default catch clause variables as 'unknown' instead of 'any'. */ + // "alwaysStrict": true, /* Ensure 'use strict' is always emitted. */ + // "noUnusedLocals": true, /* Enable error reporting when local variables aren't read. */ + // "noUnusedParameters": true, /* Raise an error when a function parameter isn't read. */ + // "exactOptionalPropertyTypes": true, /* Interpret optional property types as written, rather than adding 'undefined'. */ + // "noImplicitReturns": true, /* Enable error reporting for codepaths that do not explicitly return in a function. */ + // "noFallthroughCasesInSwitch": true, /* Enable error reporting for fallthrough cases in switch statements. */ + // "noUncheckedIndexedAccess": true, /* Add 'undefined' to a type when accessed using an index. */ + // "noImplicitOverride": true, /* Ensure overriding members in derived classes are marked with an override modifier. */ + // "noPropertyAccessFromIndexSignature": true, /* Enforces using indexed accessors for keys declared using an indexed type. */ + // "allowUnusedLabels": true, /* Disable error reporting for unused labels. */ + // "allowUnreachableCode": true, /* Disable error reporting for unreachable code. */ - /* Completeness */ - // "skipDefaultLibCheck": true, /* Skip type checking .d.ts files that are included with TypeScript. */ - "skipLibCheck": true /* Skip type checking all .d.ts files. */ - } + /* Completeness */ + // "skipDefaultLibCheck": true, /* Skip type checking .d.ts files that are included with TypeScript. */ + "skipLibCheck": true /* Skip type checking all .d.ts files. */ + } } diff --git a/packages/@biomejs/biome/package.json b/packages/@biomejs/biome/package.json index 41b3152a4a0c..1be528eb15c3 100644 --- a/packages/@biomejs/biome/package.json +++ b/packages/@biomejs/biome/package.json @@ -1,42 +1,42 @@ { - "name": "@biomejs/biome", - "version": "1.6.1", - "bin": "bin/biome", - "scripts": { - "postinstall": "node scripts/postinstall.js" - }, - "homepage": "https://biomejs.dev", - "repository": { - "type": "git", - "url": "https://github.com/biomejs/biome.git", - "directory": "packages/@biomejs/biome" - }, - "author": "Emanuele Stoppa", - "license": "MIT OR Apache-2.0", - "bugs": "https://github.com/biomejs/biome/issues", - "description": "Biome is a toolchain for the web: formatter, linter and more", - "files": [ - "bin/biome", - "scripts/postinstall.js", - "configuration_schema.json", - "README.md", - "LICENSE-APACHE", - "LICENSE-MIT", - "ROME-LICENSE-MIT" - ], - "keywords": [ - "JavaScript", - "TypeScript", - "format", - "lint", - "toolchain", - "JSON" - ], - "engines": { - "node": ">=14.*" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/biome" - } + "name": "@biomejs/biome", + "version": "1.6.1", + "bin": "bin/biome", + "scripts": { + "postinstall": "node scripts/postinstall.js" + }, + "homepage": "https://biomejs.dev", + "repository": { + "type": "git", + "url": "https://github.com/biomejs/biome.git", + "directory": "packages/@biomejs/biome" + }, + "author": "Emanuele Stoppa", + "license": "MIT OR Apache-2.0", + "bugs": "https://github.com/biomejs/biome/issues", + "description": "Biome is a toolchain for the web: formatter, linter and more", + "files": [ + "bin/biome", + "scripts/postinstall.js", + "configuration_schema.json", + "README.md", + "LICENSE-APACHE", + "LICENSE-MIT", + "ROME-LICENSE-MIT" + ], + "keywords": [ + "JavaScript", + "TypeScript", + "format", + "lint", + "toolchain", + "JSON" + ], + "engines": { + "node": ">=14.*" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/biome" + } } diff --git a/packages/@biomejs/biome/scripts/generate-packages.mjs b/packages/@biomejs/biome/scripts/generate-packages.mjs index dc4d7e452743..03242e9126b3 100644 --- a/packages/@biomejs/biome/scripts/generate-packages.mjs +++ b/packages/@biomejs/biome/scripts/generate-packages.mjs @@ -12,16 +12,16 @@ const rootManifest = JSON.parse( fs.readFileSync(MANIFEST_PATH).toString("utf-8"), ); -function getName(platform, arch, prefix = 'cli') { +function getName(platform, arch, prefix = "cli") { return format(`${prefix}-${platform}`, arch); } function generateNativePackage(platform, arch) { - const os = platform.split('-')[0]; - const buildName = getName(platform, arch) - const packageName = `@biomejs/${buildName}` + const os = platform.split("-")[0]; + const buildName = getName(platform, arch); + const packageName = `@biomejs/${buildName}`; const packageRoot = resolve(PACKAGES_ROOT, buildName); - + // Remove the directory just in case it already exists (it's autogenerated // so there shouldn't be anything important there anyway) fs.rmSync(packageRoot, { recursive: true, force: true }); @@ -31,7 +31,7 @@ function generateNativePackage(platform, arch) { fs.mkdirSync(packageRoot); // Generate the package.json manifest - const { version, license, repository, engines ,homepage } = rootManifest; + const { version, license, repository, engines, homepage } = rootManifest; const manifest = JSON.stringify({ name: packageName, @@ -42,10 +42,12 @@ function generateNativePackage(platform, arch) { homepage, os: [os], cpu: [arch], - libc: os === "linux" - ? packageName.endsWith('musl') - ? ['musl'] : ['glibc'] - : undefined + libc: + os === "linux" + ? packageName.endsWith("musl") + ? ["musl"] + : ["glibc"] + : undefined, }); const manifestPath = resolve(packageRoot, "package.json"); @@ -54,7 +56,10 @@ function generateNativePackage(platform, arch) { // Copy the CLI binary const ext = os === "win32" ? ".exe" : ""; - const binarySource = resolve(REPO_ROOT, `${getName(platform, arch, 'biome')}${ext}`); + const binarySource = resolve( + REPO_ROOT, + `${getName(platform, arch, "biome")}${ext}`, + ); const binaryTarget = resolve(packageRoot, `biome${ext}`); console.log(`Copy binary ${binaryTarget}`); @@ -70,8 +75,8 @@ function updateWasmPackage(target) { const manifest = JSON.parse(fs.readFileSync(manifestPath).toString("utf-8")); const { version, repository } = rootManifest; - manifest["name"] = packageName; - manifest["version"] = version; + manifest.name = packageName; + manifest.version = version; console.log(`Update manifest ${manifestPath}`); fs.writeFileSync(manifestPath, JSON.stringify(manifest)); @@ -91,8 +96,8 @@ function writeManifest(packagePath) { ]), ); - manifestData["version"] = rootManifest.version; - manifestData["optionalDependencies"] = Object.fromEntries(nativePackages); + manifestData.version = rootManifest.version; + manifestData.optionalDependencies = Object.fromEntries(nativePackages); console.log(`Update manifest ${manifestPath}`); const content = JSON.stringify(manifestData); diff --git a/packages/@biomejs/biome/scripts/postinstall.js b/packages/@biomejs/biome/scripts/postinstall.js index 9fd2df7cdfc0..f2a52e4b544f 100644 --- a/packages/@biomejs/biome/scripts/postinstall.js +++ b/packages/@biomejs/biome/scripts/postinstall.js @@ -1,11 +1,12 @@ const { platform, arch } = process; +// biome-ignore lint/style/useNodejsImportProtocol: would be a breaking change, consider bumping node version next major version const { execSync } = require("child_process"); function isMusl() { let stderr; try { stderr = execSync("ldd --version", { - stdio: ['pipe', 'pipe', 'pipe'] + stdio: ["pipe", "pipe", "pipe"], }); } catch (err) { stderr = err.stderr; @@ -46,13 +47,13 @@ if (binName) { binPath = require.resolve(binName); } catch { console.warn( - `The Biome CLI postinstall script failed to resolve the binary file "${binName}". Running Biome from the npm package will probably not work correctly.` + `The Biome CLI postinstall script failed to resolve the binary file "${binName}". Running Biome from the npm package will probably not work correctly.`, ); } } else { console.warn( "The Biome CLI package doesn't ship with prebuilt binaries for your platform yet. " + "You can still use the CLI by cloning the biomejs/biome repo from GitHub, " + - "and follow the instructions there to build the CLI for your platform." + "and follow the instructions there to build the CLI for your platform.", ); } diff --git a/packages/@biomejs/biome/scripts/update-nightly-version.mjs b/packages/@biomejs/biome/scripts/update-nightly-version.mjs index 4eb582ce0dc4..f5535bc841e8 100644 --- a/packages/@biomejs/biome/scripts/update-nightly-version.mjs +++ b/packages/@biomejs/biome/scripts/update-nightly-version.mjs @@ -9,10 +9,12 @@ const rootManifest = JSON.parse( fs.readFileSync(MANIFEST_PATH).toString("utf-8"), ); -let [major, minor, patch] = rootManifest["version"].split('.').map(num => parseInt(num)); +let [major, minor, patch] = rootManifest.version + .split(".") + .map((num) => Number.parseInt(num)); // increment patch version patch += 1; -let version = rootManifest["version"]; +let version = rootManifest.version; if ( typeof process.env.GITHUB_SHA !== "string" || @@ -22,7 +24,7 @@ if ( } version += `-nightly.${process.env.GITHUB_SHA.substring(0, 7)}`; -rootManifest["version"] = version; +rootManifest.version = version; const content = JSON.stringify(rootManifest); fs.writeFileSync(MANIFEST_PATH, content); diff --git a/website/README.md b/website/README.md index cb5979db457d..c9a682a8f303 100644 --- a/website/README.md +++ b/website/README.md @@ -11,13 +11,13 @@ corepack enable Then install the required dependencies: ```shell -pnpm i --filter "@biomejs/website" --frozen-lockfile +pnpm i --filter @biomejs/website --frozen-lockfile ``` ## Local Development ```shell -pnpm --filter "@biomejs/website" start +pnpm --filter @biomejs/website start ``` This command starts a local development server. Most changes are reflected live without having to restart the server. @@ -25,13 +25,13 @@ This command starts a local development server. Most changes are reflected live If you want to work on the playground, additional artifacts are required and the following command must be used instead: ```shell -pnpm --filter "@biomejs/website" start:playground +pnpm --filter @biomejs/website start:playground ``` ## Build ```shell -pnpm --filter "@biomejs/website" build +pnpm --filter @biomejs/website build ``` This command generates static content into the build directory and can be served using any static contents hosting service.