diff --git a/.eslintrc.js b/.eslintrc.js index a154d00794ab4d..660cedd2cca5c4 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -133,11 +133,7 @@ module.exports = { // https://eslint.org/docs/rules/ 'accessor-pairs': 'error', 'array-callback-return': 'error', - 'arrow-parens': 'error', - 'arrow-spacing': 'error', 'block-scoped-var': 'error', - 'block-spacing': 'error', - 'brace-style': ['error', '1tbs', { allowSingleLine: true }], 'capitalized-comments': ['error', 'always', { line: { // Ignore all lines that have less characters than 20 and all lines that @@ -150,49 +146,20 @@ module.exports = { ignorePattern: '.*', }, }], - 'comma-dangle': ['error', 'always-multiline'], - 'comma-spacing': 'error', - 'comma-style': 'error', - 'computed-property-spacing': 'error', 'default-case-last': 'error', - 'dot-location': ['error', 'property'], 'dot-notation': 'error', 'eol-last': 'error', 'eqeqeq': ['error', 'smart'], 'func-call-spacing': 'error', 'func-name-matching': 'error', 'func-style': ['error', 'declaration', { allowArrowFunctions: true }], - 'indent': ['error', 2, { - ArrayExpression: 'first', - CallExpression: { arguments: 'first' }, - FunctionDeclaration: { parameters: 'first' }, - FunctionExpression: { parameters: 'first' }, - MemberExpression: 'off', - ObjectExpression: 'first', - SwitchCase: 1, - }], - 'key-spacing': 'error', - 'keyword-spacing': 'error', 'linebreak-style': 'error', - 'max-len': ['error', { - code: 120, - ignorePattern: '^// Flags:', - ignoreRegExpLiterals: true, - ignoreTemplateLiterals: true, - ignoreUrls: true, - tabWidth: 2, - }], - 'new-parens': 'error', - 'no-confusing-arrow': 'error', 'no-constant-condition': ['error', { checkLoops: false }], 'no-constructor-return': 'error', 'no-duplicate-imports': 'error', 'no-else-return': 'error', - 'no-extra-parens': ['error', 'functions'], 'no-lonely-if': 'error', 'no-mixed-requires': 'error', - 'no-multi-spaces': ['error', { ignoreEOLComments: true }], - 'no-multiple-empty-lines': ['error', { max: 2, maxEOF: 0, maxBOF: 0 }], 'no-new-require': 'error', 'no-path-concat': 'error', 'no-proto': 'error', @@ -257,10 +224,8 @@ module.exports = { }, ], 'no-self-compare': 'error', - 'no-tabs': 'error', 'no-template-curly-in-string': 'error', 'no-throw-literal': 'error', - 'no-trailing-spaces': 'error', 'no-undef': ['error', { typeof: true }], 'no-undef-init': 'error', 'no-unused-expressions': ['error', { allowShortCircuit: true }], @@ -276,39 +241,11 @@ module.exports = { 'no-useless-return': 'error', 'no-var': 'error', 'no-void': 'error', - 'no-whitespace-before-property': 'error', - 'object-curly-newline': 'error', - 'object-curly-spacing': ['error', 'always'], 'one-var': ['error', { initialized: 'never' }], - 'one-var-declaration-per-line': 'error', - 'operator-linebreak': ['error', 'after'], - 'padding-line-between-statements': [ - 'error', - { blankLine: 'always', prev: 'function', next: 'function' }, - ], 'prefer-const': ['error', { ignoreReadBeforeAssign: true }], 'prefer-object-has-own': 'error', - 'quotes': ['error', 'single', { avoidEscape: true }], - 'quote-props': ['error', 'consistent'], - 'rest-spread-spacing': 'error', - 'semi': 'error', - 'semi-spacing': 'error', - 'space-before-blocks': ['error', 'always'], - 'space-before-function-paren': ['error', { - anonymous: 'never', - named: 'never', - asyncArrow: 'always', - }], - 'space-in-parens': 'error', - 'space-infix-ops': 'error', - 'space-unary-ops': 'error', - 'spaced-comment': ['error', 'always', { - 'block': { 'balanced': true }, - 'exceptions': ['-'], - }], 'strict': ['error', 'global'], 'symbol-description': 'error', - 'template-curly-spacing': 'error', 'unicode-bom': 'error', 'valid-typeof': ['error', { requireStringLiterals: true }], diff --git a/.github/workflows/linters.yml b/.github/workflows/linters.yml index 90518237732827..d9ff3dfa8e913c 100644 --- a/.github/workflows/linters.yml +++ b/.github/workflows/linters.yml @@ -114,6 +114,30 @@ jobs: NODE=$(command -v node) make lint-md env: NODE_RELEASED_VERSIONS: ${{ steps.get-released-versions.outputs.NODE_RELEASED_VERSIONS }} + format-js: + if: github.event.pull_request.draft == false + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1 + with: + persist-credentials: false + - name: Use Node.js ${{ env.NODE_VERSION }} + uses: actions/setup-node@8f152de45cc393bb48ce5d89d36b731f54556e65 # v4.0.0 + with: + node-version: ${{ env.NODE_VERSION }} + - name: Environment Information + run: npx envinfo + - name: Format JavaScript files + run: | + make format-js-build + + BIOME_FORMAT_START="$(git merge-base HEAD refs/remotes/origin/$GITHUB_BASE_REF)" + + tools/biome/node_modules/.bin/biome \ + check . \ + --changed \ + --no-errors-on-unmatched \ + --since="$BIOME_FORMAT_START" lint-py: if: github.event.pull_request.draft == false runs-on: ubuntu-latest diff --git a/.github/workflows/tools.yml b/.github/workflows/tools.yml index 225b7b107ef39e..45300770313886 100644 --- a/.github/workflows/tools.yml +++ b/.github/workflows/tools.yml @@ -17,6 +17,7 @@ on: - acorn-walk - ada - base64 + - biome - brotli - c-ares - cjs-module-lexer @@ -88,6 +89,14 @@ jobs: cat temp-output tail -n1 temp-output | grep "NEW_VERSION=" >> "$GITHUB_ENV" || true rm temp-output + - id: biome + subsystem: tools + label: tools + run: | + ./tools/dep_updaters/update-biome.sh > temp-output + cat temp-output + tail -n1 temp-output | grep "NEW_VERSION=" >> "$GITHUB_ENV" || true + rm temp-output - id: brotli subsystem: deps label: dependencies diff --git a/.gitignore b/.gitignore index 34c26e3a81e051..ff0a6ea8c81d87 100644 --- a/.gitignore +++ b/.gitignore @@ -115,6 +115,7 @@ tools/*/*.i.tmp /node_modules /tools/doc/node_modules /tools/clang-format/node_modules +/tools/biome/node_modules # === Rules for test artifacts === /*.tap diff --git a/LICENSE b/LICENSE index fb7c9d3abe9215..4b5365f13c2405 100644 --- a/LICENSE +++ b/LICENSE @@ -2024,6 +2024,31 @@ The externally maintained libraries used by Node.js are: THE SOFTWARE. """ +- biome, located at tools/biome/node_modules/@biomejs/biome, is licensed as follows: + """ + MIT License + + Copyright (c) 2023 Biome Developers and Contributors. + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. + """ + - gtest, located at deps/googletest, is licensed as follows: """ Copyright 2008, Google Inc. diff --git a/Makefile b/Makefile index 1113873a21a298..571404d694e443 100644 --- a/Makefile +++ b/Makefile @@ -1450,6 +1450,40 @@ FORMAT_CPP_FILES += $(wildcard \ # and the actual filename is generated so it won't match header guards ADDON_DOC_LINT_FLAGS=-whitespace/ending_newline,-build/header_guard +.PHONY: format-js-build +format-js-build: + cd tools/biome && $(call available-node,$(run-npm-ci)) + +.PHONY: format-js-clean +.NOTPARALLEL: format-js-clean +format-js-clean: + $(RM) -r tools/biome/node_modules + +.PHONY: format-js +format-js: ## Format JS files +ifneq ("","$(wildcard tools/biome/node_modules/)") + tools/biome/node_modules/.bin/biome \ + check . \ + --apply \ + --changed \ + --no-errors-on-unmatched +else + $(info Required tooling for JavaScript code formatting is not installed.) + $(info To install (requires internet access) run: $$ make format-js-build) +endif + +.PHONY: format-js-check +format-js-check: ## Format JS files +ifneq ("","$(wildcard tools/biome/node_modules/)") + tools/biome/node_modules/.bin/biome \ + check . \ + --changed \ + --no-errors-on-unmatched +else + $(info Required tooling for JavaScript code formatting is not installed.) + $(info To install (requires internet access) run: $$ make format-js-build) +endif + .PHONY: format-cpp-build format-cpp-build: cd tools/clang-format && $(call available-node,$(run-npm-ci)) diff --git a/biome.json b/biome.json new file mode 100644 index 00000000000000..88ae4fc6ba3a47 --- /dev/null +++ b/biome.json @@ -0,0 +1,45 @@ +{ + "$schema": "./tools/biome/node_modules/@biomejs/biome/configuration_schema.json", + "vcs": { + "enabled": true, + "defaultBranch": "main", + "clientKind": "git", + "useIgnoreFile": true + }, + "files": { + "ignoreUnknown": true, + "include": [], + "ignore": ["doc", "out", "benchmark", "typings", "test", "tools", "deps", ".eslintrc.js", "src"] + }, + "formatter": { + "enabled": true, + "indentStyle": "space", + "indentWidth": 2, + "lineWidth": 120, + "formatWithErrors": true, + "lineEnding": "lf" + }, + "linter": { + "enabled": false + }, + "organizeImports": { + "enabled": false + }, + "javascript": { + "formatter": { + "enabled": true, + "arrowParentheses": "always", + "trailingComma": "all", + "quoteStyle": "single", + "semicolons": "always" + } + }, + "json": { + "formatter": { + "enabled": true, + "indentWidth": 2, + "indentStyle": "space", + "lineEnding": "lf" + } + } +} diff --git a/test/common/dns.js b/test/common/dns.js index 578f823684bbf9..f522e1d9d4c04c 100644 --- a/test/common/dns.js +++ b/test/common/dns.js @@ -40,7 +40,6 @@ function readDomainFromPacket(buffer, offset) { } // Pointer to another part of the packet. assert.strictEqual(length & 0xC0, 0xC0); - // eslint-disable-next-line space-infix-ops, space-unary-ops const pointeeOffset = buffer.readUInt16BE(offset) &~ 0xC000; return { nread: 2, diff --git a/test/parallel/test-assert.js b/test/parallel/test-assert.js index 3132c52504421d..b7b1910efeeecb 100644 --- a/test/parallel/test-assert.js +++ b/test/parallel/test-assert.js @@ -730,7 +730,7 @@ assert.throws( // before the assertion causes any wrong assertion message. // Therefore, don't reformat the following code. // Refs: https://github.com/nodejs/node/issues/30872 - try { assert.ok(0); // eslint-disable-line no-useless-catch, brace-style + try { assert.ok(0); // eslint-disable-line no-useless-catch } catch (err) { throw err; } @@ -767,7 +767,7 @@ assert.throws( // before the assertion causes any wrong assertion message. // Therefore, don't reformat the following code. // Refs: https://github.com/nodejs/node/issues/30872 - function test() { assert.ok(0); // eslint-disable-line brace-style + function test() { assert.ok(0); } test(); }, @@ -804,7 +804,6 @@ assert.throws( () => { a( (() => 'string')() - // eslint-disable-next-line operator-linebreak === 123 instanceof Buffer @@ -828,7 +827,6 @@ assert.throws( () => { a( (() => 'string')() - // eslint-disable-next-line operator-linebreak === 123 instanceof Buffer @@ -848,7 +846,6 @@ assert.throws( } ); -/* eslint-disable indent */ assert.throws(() => { a(( () => 'string')() === @@ -866,7 +863,6 @@ Buffer ' )\n' } ); -/* eslint-enable indent */ assert.throws( () => { @@ -894,7 +890,7 @@ assert.throws( ); assert.throws( - // eslint-disable-next-line dot-notation, quotes + // eslint-disable-next-line dot-notation () => assert['ok']["apply"](null, [0]), { code: 'ERR_ASSERTION', diff --git a/test/parallel/test-internal-validators-validateoneof.js b/test/parallel/test-internal-validators-validateoneof.js index 5c5a62ef893726..3bcb6b7088097d 100644 --- a/test/parallel/test-internal-validators-validateoneof.js +++ b/test/parallel/test-internal-validators-validateoneof.js @@ -10,7 +10,6 @@ const { validateOneOf } = require('internal/validators'); const allowed = [2, 3]; assert.throws(() => validateOneOf(1, 'name', allowed), { code: 'ERR_INVALID_ARG_VALUE', - // eslint-disable-next-line quotes message: `The argument 'name' must be one of: 2, 3. Received 1` }); } @@ -25,7 +24,6 @@ const { validateOneOf } = require('internal/validators'); const allowed = ['b', 'c']; assert.throws(() => validateOneOf('a', 'name', allowed), { code: 'ERR_INVALID_ARG_VALUE', - // eslint-disable-next-line quotes message: `The argument 'name' must be one of: 'b', 'c'. Received 'a'` }); } @@ -40,7 +38,6 @@ const { validateOneOf } = require('internal/validators'); const allowed = [Symbol.for('b'), Symbol.for('c')]; assert.throws(() => validateOneOf(Symbol.for('a'), 'name', allowed), { code: 'ERR_INVALID_ARG_VALUE', - // eslint-disable-next-line quotes message: `The argument 'name' must be one of: Symbol(b), Symbol(c). ` + 'Received Symbol(a)' }); diff --git a/test/parallel/test-policy-integrity-flag.js b/test/parallel/test-policy-integrity-flag.js index ddcd02236d27c0..d9b3b3524bdcab 100644 --- a/test/parallel/test-policy-integrity-flag.js +++ b/test/parallel/test-policy-integrity-flag.js @@ -21,12 +21,10 @@ const emptySRI = `sha512-${emptyHash.digest('base64')}`; const policyHash = crypto.createHash('sha512'); policyHash.update(fs.readFileSync(depPolicy)); -/* eslint-disable max-len */ // When using \n only const nixPolicySRI = 'sha512-u/nXI6UacK5fKDC2bopcgnuQY4JXJKlK3dESO3GIKKxwogVHjJqpF9rgk7Zw+TJXIc96xBUWKHuUgOzic8/4tQ=='; // When \n is turned into \r\n const windowsPolicySRI = 'sha512-OeyCPRo4OZMosHyquZXDHpuU1F4KzG9UHFnn12FMaHsvqFUt3TFZ+7wmZE7ThZ5rsQWkUjc9ZH0knGZ2e8BYPQ=='; -/* eslint-enable max-len */ const depPolicySRI = `${nixPolicySRI} ${windowsPolicySRI}`; { diff --git a/test/parallel/test-repl-colors.js b/test/parallel/test-repl-colors.js index dd1bdb1a08ee9e..cdbca5790ad5aa 100644 --- a/test/parallel/test-repl-colors.js +++ b/test/parallel/test-repl-colors.js @@ -1,4 +1,3 @@ -/* eslint-disable quotes */ 'use strict'; require('../common'); const { Duplex } = require('stream'); diff --git a/test/parallel/test-runner-coverage.js b/test/parallel/test-runner-coverage.js index d8181417205b46..d64e4c6cc38427 100644 --- a/test/parallel/test-runner-coverage.js +++ b/test/parallel/test-runner-coverage.js @@ -22,7 +22,6 @@ function findCoverageFileForPid(pid) { } function getTapCoverageFixtureReport() { - /* eslint-disable max-len */ const report = [ '# start of coverage report', '# -------------------------------------------------------------------------------------------------------------------', @@ -36,7 +35,6 @@ function getTapCoverageFixtureReport() { '# -------------------------------------------------------------------------------------------------------------------', '# end of coverage report', ].join('\n'); - /* eslint-enable max-len */ if (common.isWindows) { return report.replaceAll('/', '\\'); @@ -46,7 +44,6 @@ function getTapCoverageFixtureReport() { } function getSpecCoverageFixtureReport() { - /* eslint-disable max-len */ const report = [ '\u2139 start of coverage report', '\u2139 -------------------------------------------------------------------------------------------------------------------', @@ -60,7 +57,6 @@ function getSpecCoverageFixtureReport() { '\u2139 -------------------------------------------------------------------------------------------------------------------', '\u2139 end of coverage report', ].join('\n'); - /* eslint-enable max-len */ if (common.isWindows) { return report.replaceAll('/', '\\'); diff --git a/test/parallel/test-runner-run.mjs b/test/parallel/test-runner-run.mjs index 8f95de4db16296..718225c652aa62 100644 --- a/test/parallel/test-runner-run.mjs +++ b/test/parallel/test-runner-run.mjs @@ -335,7 +335,6 @@ describe('require(\'node:test\').run', { concurrency: true }, () => { }), { name: 'RangeError', code: 'ERR_OUT_OF_RANGE', - // eslint-disable-next-line max-len message: 'The value of "options.shard.index" is out of range. It must be >= 1 && <= 6 ("options.shard.total"). Received 0' }); }); @@ -350,7 +349,6 @@ describe('require(\'node:test\').run', { concurrency: true }, () => { }), { name: 'RangeError', code: 'ERR_OUT_OF_RANGE', - // eslint-disable-next-line max-len message: 'The value of "options.shard.index" is out of range. It must be >= 1 && <= 6 ("options.shard.total"). Received 7' }); }); diff --git a/test/parallel/test-util-inspect.js b/test/parallel/test-util-inspect.js index ba5b6f9fe84bb3..3955e252486d16 100644 --- a/test/parallel/test-util-inspect.js +++ b/test/parallel/test-util-inspect.js @@ -1462,7 +1462,7 @@ if (typeof Symbol !== 'undefined') { } { - const x = new function() {}; // eslint-disable-line new-parens + const x = new function() {}; assert.strictEqual(util.inspect(x), '{}'); } @@ -2056,7 +2056,6 @@ assert.strictEqual(util.inspect('"\'${a}'), "'\"\\'${a}'"); // Verify that classes are properly inspected. [ - /* eslint-disable spaced-comment, no-multi-spaces, brace-style */ // The whitespace is intentional. [class { }, '[class (anonymous)]'], [class extends Error { log() {} }, '[class (anonymous) extends Error]'], @@ -2064,14 +2063,12 @@ assert.strictEqual(util.inspect('"\'${a}'), "'\"\\'${a}'"); '[class A]'], [class // Random { // comments /* */ are part of the toString() result - /* eslint-disable-next-line space-before-blocks */ äß/**/extends/*{*/TypeError{}, '[class äß extends TypeError]'], /* The whitespace and new line is intended! */ // Foobar !!! [class X extends /****/ Error // More comments {}, '[class X extends Error]'], - /* eslint-enable spaced-comment, no-multi-spaces, brace-style */ ].forEach(([clazz, string]) => { const inspected = util.inspect(clazz); assert.strictEqual(inspected, string); @@ -2111,7 +2108,6 @@ assert.strictEqual(util.inspect('"\'${a}'), "'\"\\'${a}'"); // "class" properties should not be detected as "class". { - // eslint-disable-next-line space-before-function-paren let obj = { class () {} }; assert.strictEqual( util.inspect(obj), @@ -3215,7 +3211,7 @@ assert.strictEqual( '[GeneratorFunction: generator] {\n' + ' [length]: 0,\n' + " [name]: 'generator',\n" + - " [prototype]: Object [Generator] { [Symbol(Symbol.toStringTag)]: 'Generator' },\n" + // eslint-disable-line max-len + " [prototype]: Object [Generator] { [Symbol(Symbol.toStringTag)]: 'Generator' },\n" + " [Symbol(Symbol.toStringTag)]: 'GeneratorFunction'\n" + '}' ); diff --git a/test/parallel/test-webcrypto-export-import-ec.js b/test/parallel/test-webcrypto-export-import-ec.js index d0548f56662f94..8b6f9b09ff0a95 100644 --- a/test/parallel/test-webcrypto-export-import-ec.js +++ b/test/parallel/test-webcrypto-export-import-ec.js @@ -380,8 +380,8 @@ async function testImportRaw({ name, publicUsages }, namedCurve) { // https://github.com/nodejs/node/issues/45859 (async function() { - const compressed = Buffer.from([48, 57, 48, 19, 6, 7, 42, 134, 72, 206, 61, 2, 1, 6, 8, 42, 134, 72, 206, 61, 3, 1, 7, 3, 34, 0, 2, 210, 16, 176, 166, 249, 217, 240, 18, 134, 128, 88, 180, 63, 164, 244, 113, 1, 133, 67, 187, 160, 12, 146, 80, 223, 146, 87, 194, 172, 174, 93, 209]); // eslint-disable-line max-len - const uncompressed = Buffer.from([48, 89, 48, 19, 6, 7, 42, 134, 72, 206, 61, 2, 1, 6, 8, 42, 134, 72, 206, 61, 3, 1, 7, 3, 66, 0, 4, 210, 16, 176, 166, 249, 217, 240, 18, 134, 128, 88, 180, 63, 164, 244, 113, 1, 133, 67, 187, 160, 12, 146, 80, 223, 146, 87, 194, 172, 174, 93, 209, 206, 3, 117, 82, 212, 129, 69, 12, 227, 155, 77, 16, 149, 112, 27, 23, 91, 250, 179, 75, 142, 108, 9, 158, 24, 241, 193, 152, 53, 131, 97, 232]); // eslint-disable-line max-len + const compressed = Buffer.from([48, 57, 48, 19, 6, 7, 42, 134, 72, 206, 61, 2, 1, 6, 8, 42, 134, 72, 206, 61, 3, 1, 7, 3, 34, 0, 2, 210, 16, 176, 166, 249, 217, 240, 18, 134, 128, 88, 180, 63, 164, 244, 113, 1, 133, 67, 187, 160, 12, 146, 80, 223, 146, 87, 194, 172, 174, 93, 209]); + const uncompressed = Buffer.from([48, 89, 48, 19, 6, 7, 42, 134, 72, 206, 61, 2, 1, 6, 8, 42, 134, 72, 206, 61, 3, 1, 7, 3, 66, 0, 4, 210, 16, 176, 166, 249, 217, 240, 18, 134, 128, 88, 180, 63, 164, 244, 113, 1, 133, 67, 187, 160, 12, 146, 80, 223, 146, 87, 194, 172, 174, 93, 209, 206, 3, 117, 82, 212, 129, 69, 12, 227, 155, 77, 16, 149, 112, 27, 23, 91, 250, 179, 75, 142, 108, 9, 158, 24, 241, 193, 152, 53, 131, 97, 232]); for (const name of ['ECDH', 'ECDSA']) { const options = { name, namedCurve: 'P-256' }; const key = await subtle.importKey('spki', compressed, options, true, []); diff --git a/tools/biome/package-lock.json b/tools/biome/package-lock.json new file mode 100644 index 00000000000000..c41fe6c6b5e98f --- /dev/null +++ b/tools/biome/package-lock.json @@ -0,0 +1,162 @@ +{ + "name": "node-biome", + "version": "1.0.0", + "lockfileVersion": 3, + "requires": true, + "packages": { + "": { + "name": "node-biome", + "version": "1.0.0", + "license": "MIT", + "dependencies": { + "@biomejs/biome": "^1.5.3" + } + }, + "node_modules/@biomejs/biome": { + "version": "1.5.3", + "resolved": "https://registry.npmjs.org/@biomejs/biome/-/biome-1.5.3.tgz", + "integrity": "sha512-yvZCa/g3akwTaAQ7PCwPWDCkZs3Qa5ONg/fgOUT9e6wAWsPftCjLQFPXBeGxPK30yZSSpgEmRCfpGTmVbUjGgg==", + "hasInstallScript": true, + "bin": { + "biome": "bin/biome" + }, + "engines": { + "node": ">=14.*" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/biome" + }, + "optionalDependencies": { + "@biomejs/cli-darwin-arm64": "1.5.3", + "@biomejs/cli-darwin-x64": "1.5.3", + "@biomejs/cli-linux-arm64": "1.5.3", + "@biomejs/cli-linux-arm64-musl": "1.5.3", + "@biomejs/cli-linux-x64": "1.5.3", + "@biomejs/cli-linux-x64-musl": "1.5.3", + "@biomejs/cli-win32-arm64": "1.5.3", + "@biomejs/cli-win32-x64": "1.5.3" + } + }, + "node_modules/@biomejs/cli-darwin-arm64": { + "version": "1.5.3", + "resolved": "https://registry.npmjs.org/@biomejs/cli-darwin-arm64/-/cli-darwin-arm64-1.5.3.tgz", + "integrity": "sha512-ImU7mh1HghEDyqNmxEZBoMPr8SxekkZuYcs+gynKlNW+TALQs7swkERiBLkG9NR0K1B3/2uVzlvYowXrmlW8hw==", + "cpu": [ + "arm64" + ], + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": ">=14.*" + } + }, + "node_modules/@biomejs/cli-darwin-x64": { + "version": "1.5.3", + "resolved": "https://registry.npmjs.org/@biomejs/cli-darwin-x64/-/cli-darwin-x64-1.5.3.tgz", + "integrity": "sha512-vCdASqYnlpq/swErH7FD6nrFz0czFtK4k/iLgj0/+VmZVjineFPgevOb+Sr9vz0tk0GfdQO60bSpI74zU8M9Dw==", + "cpu": [ + "x64" + ], + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": ">=14.*" + } + }, + "node_modules/@biomejs/cli-linux-arm64": { + "version": "1.5.3", + "resolved": "https://registry.npmjs.org/@biomejs/cli-linux-arm64/-/cli-linux-arm64-1.5.3.tgz", + "integrity": "sha512-cupBQv0sNF1OKqBfx7EDWMSsKwRrBUZfjXawT4s6hKV6ALq7p0QzWlxr/sDmbKMLOaLQtw2Qgu/77N9rm+f9Rg==", + "cpu": [ + "arm64" + ], + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=14.*" + } + }, + "node_modules/@biomejs/cli-linux-arm64-musl": { + "version": "1.5.3", + "resolved": "https://registry.npmjs.org/@biomejs/cli-linux-arm64-musl/-/cli-linux-arm64-musl-1.5.3.tgz", + "integrity": "sha512-DYuMizUYUBYfS0IHGjDrOP1RGipqWfMGEvNEJ398zdtmCKLXaUvTimiox5dvx4X15mBK5M2m8wgWUgOP1giUpQ==", + "cpu": [ + "arm64" + ], + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=14.*" + } + }, + "node_modules/@biomejs/cli-linux-x64": { + "version": "1.5.3", + "resolved": "https://registry.npmjs.org/@biomejs/cli-linux-x64/-/cli-linux-x64-1.5.3.tgz", + "integrity": "sha512-YQrSArQvcv4FYsk7Q91Yv4uuu5F8hJyORVcv3zsjCLGkjIjx2RhjYLpTL733SNL7v33GmOlZY0eFR1ko38tuUw==", + "cpu": [ + "x64" + ], + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=14.*" + } + }, + "node_modules/@biomejs/cli-linux-x64-musl": { + "version": "1.5.3", + "resolved": "https://registry.npmjs.org/@biomejs/cli-linux-x64-musl/-/cli-linux-x64-musl-1.5.3.tgz", + "integrity": "sha512-UUHiAnlDqr2Y/LpvshBFhUYMWkl2/Jn+bi3U6jKuav0qWbbBKU/ByHgR4+NBxpKBYoCtWxhnmatfH1bpPIuZMw==", + "cpu": [ + "x64" + ], + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=14.*" + } + }, + "node_modules/@biomejs/cli-win32-arm64": { + "version": "1.5.3", + "resolved": "https://registry.npmjs.org/@biomejs/cli-win32-arm64/-/cli-win32-arm64-1.5.3.tgz", + "integrity": "sha512-HxatYH7vf/kX9nrD+pDYuV2GI9GV8EFo6cfKkahAecTuZLPxryHx1WEfJthp5eNsE0+09STGkKIKjirP0ufaZA==", + "cpu": [ + "arm64" + ], + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": ">=14.*" + } + }, + "node_modules/@biomejs/cli-win32-x64": { + "version": "1.5.3", + "resolved": "https://registry.npmjs.org/@biomejs/cli-win32-x64/-/cli-win32-x64-1.5.3.tgz", + "integrity": "sha512-fMvbSouZEASU7mZH8SIJSANDm5OqsjgtVXlbUqxwed6BP7uuHRSs396Aqwh2+VoW8fwTpp6ybIUoC9FrzB0kyA==", + "cpu": [ + "x64" + ], + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": ">=14.*" + } + } + } +} diff --git a/tools/biome/package.json b/tools/biome/package.json new file mode 100644 index 00000000000000..e50de7db9a08cd --- /dev/null +++ b/tools/biome/package.json @@ -0,0 +1,9 @@ +{ + "name": "node-biome", + "version": "1.0.0", + "description": "Formatting JavaScript and JSON files for Node.js core", + "license": "MIT", + "dependencies": { + "@biomejs/biome": "^1.5.3" + } +} diff --git a/tools/dep_updaters/update-biome.sh b/tools/dep_updaters/update-biome.sh new file mode 100755 index 00000000000000..a74ce0b1ddd2ec --- /dev/null +++ b/tools/dep_updaters/update-biome.sh @@ -0,0 +1,30 @@ +#!/bin/sh + +# Shell script to update @biomejs/biome in the source tree to the latest release. + +# This script must be in the tools directory when it runs because it uses the +# script source file path to determine directories to work in. + +set -ex + +ROOT=$(cd "$(dirname "$0")/../.." && pwd) + +[ -z "$NODE" ] && NODE="$ROOT/out/Release/node" +[ -x "$NODE" ] || NODE=$(command -v node) +NPM="$ROOT/deps/npm/bin/npm-cli.js" + +# shellcheck disable=SC1091 +. "$ROOT/tools/dep_updaters/utils.sh" + +NEW_VERSION=$("$NODE" "$NPM" view @biomejs/biome dist-tags.latest) +CURRENT_VERSION=$("$NODE" -p "require('./tools/biome/package.json').dependencies['@biomejs/biome']") + +# This function exit with 0 if new version and current version are the same +compare_dependency_version "@biomejs/biome" "$NEW_VERSION" "$CURRENT_VERSION" + +cd tools/biome || exit +"$NODE" "$NPM" install "@biomejs/biome@$NEW_VERSION" + +# The last line of the script should always print the new version, +# as we need to add it to $GITHUB_ENV variable. +echo "NEW_VERSION=$NEW_VERSION" diff --git a/tools/license-builder.sh b/tools/license-builder.sh index 0a3f8fbe636b55..8dd6bdb107b6d0 100755 --- a/tools/license-builder.sh +++ b/tools/license-builder.sh @@ -109,6 +109,8 @@ licenseText="$(sed -e '/^$/,$d' -e 's/^#$//' -e 's/^# //' "${rootdir}/tools/gypi addlicense "gypi_to_gn.py" "tools/gypi_to_gn.py" "$licenseText" licenseText="$(cat "${rootdir}/tools/node_modules/eslint/LICENSE")" addlicense "ESLint" "tools/node_modules/eslint" "$licenseText" +licenseText="$(curl -sL https://raw.githubusercontent.com/biomejs/biome/HEAD/LICENSE-MIT)" +addlicense "biome" "tools/biome/node_modules/@biomejs/biome" "$licenseText" licenseText="$(cat "${rootdir}/deps/googletest/LICENSE")" addlicense "gtest" "deps/googletest" "$licenseText"