diff --git a/.github/ISSUE_TEMPLATE/1-bug-report.yml b/.github/ISSUE_TEMPLATE/1-bug-report.yml index 07a8f075ee55c0..820df7bb0952f3 100644 --- a/.github/ISSUE_TEMPLATE/1-bug-report.yml +++ b/.github/ISSUE_TEMPLATE/1-bug-report.yml @@ -1,4 +1,4 @@ -name: "\U0001F41B Bug report" +name: \U0001F41B Bug report description: Create a report to help us improve body: - type: markdown diff --git a/.github/ISSUE_TEMPLATE/2-feature-request.yml b/.github/ISSUE_TEMPLATE/2-feature-request.yml index eca3e6fa48e6fc..ee6c78ee8af9d2 100644 --- a/.github/ISSUE_TEMPLATE/2-feature-request.yml +++ b/.github/ISSUE_TEMPLATE/2-feature-request.yml @@ -1,6 +1,6 @@ -name: "\U0001F680 Feature request" +name: \U0001F680 Feature request description: Suggest an idea for this project -labels: ["feature request"] +labels: [feature request] body: - type: markdown attributes: diff --git a/.github/ISSUE_TEMPLATE/3-api-ref-docs-problem.yml b/.github/ISSUE_TEMPLATE/3-api-ref-docs-problem.yml index 9b3bdc35197f24..bfafc4a23d36b9 100644 --- a/.github/ISSUE_TEMPLATE/3-api-ref-docs-problem.yml +++ b/.github/ISSUE_TEMPLATE/3-api-ref-docs-problem.yml @@ -1,6 +1,6 @@ -name: "\U0001F4D7 Open an issue regarding the Node.js API reference docs" +name: \U0001F4D7 Open an issue regarding the Node.js API reference docs description: Let us know about any problematic API reference documents -labels: ["doc"] +labels: [doc] body: - type: markdown attributes: diff --git a/.github/ISSUE_TEMPLATE/4-report-a-flaky-test.yml b/.github/ISSUE_TEMPLATE/4-report-a-flaky-test.yml index c557accfb15b92..dd6fa5091e3f15 100644 --- a/.github/ISSUE_TEMPLATE/4-report-a-flaky-test.yml +++ b/.github/ISSUE_TEMPLATE/4-report-a-flaky-test.yml @@ -1,6 +1,6 @@ name: Report a flaky test description: Report a flaky test in our CI -labels: ["flaky-test"] +labels: [flaky-test] body: - type: markdown attributes: diff --git a/.github/workflows/authors.yml b/.github/workflows/authors.yml index 0df61e45298201..75fec53a549438 100644 --- a/.github/workflows/authors.yml +++ b/.github/workflows/authors.yml @@ -2,7 +2,7 @@ name: Authors update on: schedule: # Run once a week at 00:05 AM UTC on Sunday. - - cron: '5 0 * * 0' + - cron: 5 0 * * 0 workflow_dispatch: @@ -15,7 +15,7 @@ jobs: with: fetch-depth: '0' # This is required to actually get all the authors persist-credentials: false - - run: "tools/update-authors.js" # Run the AUTHORS tool + - run: tools/update-authors.js # Run the AUTHORS tool - uses: gr2m/create-or-update-pull-request-action@v1 # Create a PR or update the Action's existing PR env: GITHUB_TOKEN: ${{ secrets.GH_USER_TOKEN }} @@ -25,7 +25,7 @@ jobs: Here are some new additions to the AUTHORS file. This is an automatically generated PR by the `authors.yml` GitHub Action, which runs `tools/update-authors.js`. - branch: "actions/authors-update" # Custom branch *just* for this Action. - commit-message: "meta: update AUTHORS" + branch: actions/authors-update # Custom branch *just* for this Action. + commit-message: 'meta: update AUTHORS' labels: meta - title: "meta: update AUTHORS" + title: 'meta: update AUTHORS' diff --git a/.github/workflows/auto-start-ci.yml b/.github/workflows/auto-start-ci.yml index e3399ec3cabb32..3c5ad5948cb11f 100644 --- a/.github/workflows/auto-start-ci.yml +++ b/.github/workflows/auto-start-ci.yml @@ -6,7 +6,7 @@ on: # optimistic, it can take longer to run. # To understand why `schedule` is used instead of other events, refer to # ./doc/contributing/commit-queue.md - - cron: "*/5 * * * *" + - cron: '*/5 * * * *' env: NODE_VERSION: lts/* diff --git a/.github/workflows/build-tarball.yml b/.github/workflows/build-tarball.yml index 0ea3633f0901af..9ae492a7fc1156 100644 --- a/.github/workflows/build-tarball.yml +++ b/.github/workflows/build-tarball.yml @@ -4,10 +4,10 @@ on: pull_request: types: [opened, synchronize, reopened, ready_for_review] paths-ignore: - - '.mailmap' + - .mailmap - '**.md' - - 'AUTHORS' - - 'doc/**' + - AUTHORS + - doc/** - .github/** - '!.github/workflows/build-tarball.yml' push: @@ -17,10 +17,10 @@ on: - v[0-9]+.x-staging - v[0-9]+.x paths-ignore: - - '.mailmap' + - .mailmap - '**.md' - - 'AUTHORS' - - 'doc/**' + - AUTHORS + - doc/** - .github/** - '!.github/workflows/build-tarball.yml' diff --git a/.github/workflows/close-stalled.yml b/.github/workflows/close-stalled.yml index 9a3dad5621b971..347b22bd70caf3 100644 --- a/.github/workflows/close-stalled.yml +++ b/.github/workflows/close-stalled.yml @@ -1,7 +1,7 @@ name: Close stalled issues and PRs on: schedule: - - cron: "0 0 * * *" + - cron: 0 0 * * * env: CLOSE_MESSAGE: > diff --git a/.github/workflows/commit-queue.yml b/.github/workflows/commit-queue.yml index 509be21815bb06..f4aee6dd37a3ee 100644 --- a/.github/workflows/commit-queue.yml +++ b/.github/workflows/commit-queue.yml @@ -11,7 +11,7 @@ on: # be read-only, and the Action won't have access to any other repository # secrets, which it needs to access Jenkins API. schedule: - - cron: "*/5 * * * *" + - cron: '*/5 * * * *' env: NODE_VERSION: lts/* diff --git a/.github/workflows/coverage-linux.yml b/.github/workflows/coverage-linux.yml index 7c1dc8c2d54036..7cd43ea6672a5e 100644 --- a/.github/workflows/coverage-linux.yml +++ b/.github/workflows/coverage-linux.yml @@ -5,18 +5,18 @@ on: types: [opened, synchronize, reopened, ready_for_review] paths-ignore: - '**.md' - - 'benchmark/**' - - 'deps/**' - - 'doc/**' + - benchmark/** + - deps/* + - doc/** - .github/** - '!.github/workflows/coverage-linux.yml' push: branches: [master, main] paths-ignore: - '**.md' - - 'benchmark/**' - - 'deps/**' - - 'doc/**' + - benchmark/** + - deps/** + - doc/** - .github/** - '!.github/workflows/coverage-linux.yml' diff --git a/.github/workflows/coverage-windows.yml b/.github/workflows/coverage-windows.yml index 8dadd868473265..b19a744bab31ec 100644 --- a/.github/workflows/coverage-windows.yml +++ b/.github/workflows/coverage-windows.yml @@ -5,20 +5,20 @@ on: types: [opened, synchronize, reopened, ready_for_review] paths-ignore: - '**.md' - - 'benchmark/**' - - 'deps/**' - - 'doc/**' - - 'tools/**' + - benchmark/** + - deps/** + - doc/** + - tools/** - .github/** - '!.github/workflows/coverage-windows.yml' push: branches: [master, main] paths-ignore: - '**.md' - - 'benchmark/**' - - 'deps/**' - - 'doc/**' - - 'tools/**' + - benchmark/** + - deps/** + - doc/** + - tools/** - .github/** - '!.github/workflows/coverage-windows.yml' diff --git a/.github/workflows/daily.yml b/.github/workflows/daily.yml index 2f2560dd751c1d..79294ca966ddef 100644 --- a/.github/workflows/daily.yml +++ b/.github/workflows/daily.yml @@ -3,7 +3,7 @@ name: Node.js daily job on: workflow_dispatch: schedule: - - cron: "0 0 * * *" + - cron: 0 0 * * * env: NODE_VERSION: lts/* diff --git a/.github/workflows/find-inactive-collaborators.yml b/.github/workflows/find-inactive-collaborators.yml index 643e3ea4a6b4b1..21f0f0297d5f11 100644 --- a/.github/workflows/find-inactive-collaborators.yml +++ b/.github/workflows/find-inactive-collaborators.yml @@ -3,7 +3,7 @@ name: Find inactive collaborators on: schedule: # Run every Monday at 4:05 AM UTC. - - cron: '5 4 * * 1' + - cron: 5 4 * * 1 workflow_dispatch: @@ -37,6 +37,6 @@ jobs: author: Node.js GitHub Bot branch: actions/inactive-collaborators body: This PR was generated by tools/find-inactive-collaborators.yml. - commit-message: "meta: move one or more collaborators to emeritus" + commit-message: 'meta: move one or more collaborators to emeritus' labels: meta - title: "meta: move one or more collaborators to emeritus" + title: 'meta: move one or more collaborators to emeritus' diff --git a/.github/workflows/find-inactive-tsc.yml b/.github/workflows/find-inactive-tsc.yml index 5d834c8cb25d70..9276de8b6a5c3a 100644 --- a/.github/workflows/find-inactive-tsc.yml +++ b/.github/workflows/find-inactive-tsc.yml @@ -3,7 +3,7 @@ name: Find inactive TSC members on: schedule: # Run every Tuesday 12:05 AM UTC. - - cron: '5 0 * * 2' + - cron: 5 0 * * 2 workflow_dispatch: @@ -51,6 +51,6 @@ jobs: @nodejs/tsc ${{ env.INACTIVE_TSC_HANDLES }} ${{ env.DETAILS_FOR_COMMIT_BODY }} - commit-message: "meta: move one or more TSC members to emeritus" + commit-message: 'meta: move one or more TSC members to emeritus' labels: meta - title: "meta: move one or more TSC members to emeritus" + title: 'meta: move one or more TSC members to emeritus' diff --git a/.github/workflows/license-builder.yml b/.github/workflows/license-builder.yml index ff395511019ce6..6ccb3b2f743ed6 100644 --- a/.github/workflows/license-builder.yml +++ b/.github/workflows/license-builder.yml @@ -3,7 +3,7 @@ on: schedule: # 00:00:00 every Monday # https://crontab.guru/#0_0_*_*_1 - - cron: "0 0 * * 1" + - cron: 0 0 * * 1 workflow_dispatch: jobs: @@ -14,14 +14,14 @@ jobs: - uses: actions/checkout@v2 with: persist-credentials: false - - run: "./tools/license-builder.sh" # Run the license builder tool + - run: ./tools/license-builder.sh # Run the license builder tool - uses: gr2m/create-or-update-pull-request-action@v1.x # Create a PR or update the Action's existing PR env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} with: author: Node.js GitHub Bot branch: actions/license-builder - title: "doc: run license-builder" + title: 'doc: run license-builder' body: > License is likely out of date. This is an automatically generated PR by the `license-builder.yml` GitHub Action, which runs `license-builder.sh` diff --git a/.github/workflows/linters.yml b/.github/workflows/linters.yml index 4e8b0e3845895a..a351f6b2a6bdec 100644 --- a/.github/workflows/linters.yml +++ b/.github/workflows/linters.yml @@ -138,7 +138,7 @@ jobs: persist-credentials: false - uses: mszostok/codeowners-validator@v0.6.0 with: - checks: "files,duppatterns" + checks: files,duppatterns lint-pr-url: if: ${{ github.event.pull_request }} runs-on: ubuntu-latest diff --git a/.github/workflows/notify-force-push.yml b/.github/workflows/notify-force-push.yml index e39fefdbda9d93..dac2d50ae266f7 100644 --- a/.github/workflows/notify-force-push.yml +++ b/.github/workflows/notify-force-push.yml @@ -16,7 +16,7 @@ jobs: env: SLACK_COLOR: '#DE512A' SLACK_ICON: https://github.com/nodejs.png?size=48 - SLACK_TITLE: '${{ github.actor }} force-pushed to ${{ github.ref }}' + SLACK_TITLE: ${{ github.actor }} force-pushed to ${{ github.ref }} SLACK_MESSAGE: | A commit was force-pushed to by diff --git a/.github/workflows/test-asan.yml b/.github/workflows/test-asan.yml index ea2c8bf9cee5ef..91fcb0f4e93bdc 100644 --- a/.github/workflows/test-asan.yml +++ b/.github/workflows/test-asan.yml @@ -4,10 +4,10 @@ on: pull_request: types: [opened, synchronize, reopened, ready_for_review] paths-ignore: - - '.mailmap' + - .mailmap - '**.md' - - 'AUTHORS' - - 'doc/**' + - AUTHORS + - doc/** - .github/** - '!.github/workflows/test-asan.yml' push: @@ -18,10 +18,10 @@ on: - v[0-9]+.x-staging - v[0-9]+.x paths-ignore: - - '.mailmap' + - .mailmap - '**.md' - - 'AUTHORS' - - 'doc/**' + - AUTHORS + - doc/** - .github/** - '!.github/workflows/test-asan.yml' diff --git a/.github/workflows/test-macos.yml b/.github/workflows/test-macos.yml index 86a032419a8e09..5d83e786d384ab 100644 --- a/.github/workflows/test-macos.yml +++ b/.github/workflows/test-macos.yml @@ -4,10 +4,10 @@ on: pull_request: types: [opened, synchronize, reopened, ready_for_review] paths-ignore: - - '.mailmap' + - .mailmap - '**.md' - - 'AUTHORS' - - 'doc/**' + - AUTHORS + - doc/** - .github/** - '!.github/workflows/test-macos.yml' push: @@ -18,10 +18,10 @@ on: - v[0-9]+.x-staging - v[0-9]+.x paths-ignore: - - '.mailmap' + - .mailmap - '**.md' - - 'AUTHORS' - - 'doc/**' + - AUTHORS + - doc/** - .github/** - '!.github/workflows/test-macos.yml' diff --git a/.github/workflows/tools.yml b/.github/workflows/tools.yml index 581c8859dad31b..1b97ae96635b00 100644 --- a/.github/workflows/tools.yml +++ b/.github/workflows/tools.yml @@ -2,7 +2,7 @@ name: Tools update on: schedule: # Run once a week at 00:05 AM UTC on Saturday. - - cron: '5 0 * * 6' + - cron: 5 0 * * 6 workflow_dispatch: @@ -23,7 +23,7 @@ jobs: echo "NEW_VERSION=$NEW_VERSION" >> $GITHUB_ENV ./update-eslint.sh fi - - id: "lint-md-dependencies" + - id: lint-md-dependencies run: | cd tools/lint-md npm ci @@ -63,8 +63,8 @@ jobs: GITHUB_TOKEN: ${{ secrets.GH_USER_TOKEN }} with: author: Node.js GitHub Bot - body: "This is an automated update of ${{ matrix.id }} to ${{ env.NEW_VERSION }}." - branch: "actions/tools-update-${{ matrix.id }}" # Custom branch *just* for this Action. - commit-message: "tools: update ${{ matrix.id }} to ${{ env.NEW_VERSION }}" + body: This is an automated update of ${{ matrix.id }} to ${{ env.NEW_VERSION }}. + branch: actions/tools-update-${{ matrix.id }} # Custom branch *just* for this Action. + commit-message: 'tools: update ${{ matrix.id }} to ${{ env.NEW_VERSION }}' labels: tools - title: "tools: update ${{ matrix.id }} to ${{ env.NEW_VERSION }}" + title: 'tools: update ${{ matrix.id }} to ${{ env.NEW_VERSION }}' diff --git a/lib/.eslintrc.yaml b/lib/.eslintrc.yaml index d817b2596b7fec..fee5e730179c3d 100644 --- a/lib/.eslintrc.yaml +++ b/lib/.eslintrc.yaml @@ -6,93 +6,93 @@ rules: no-buffer-constructor: error no-mixed-operators: - error - - groups: [["&&", "||"]] + - groups: [['&&', '||']] no-restricted-syntax: # Config copied from .eslintrc.js - error - - selector: "CallExpression[callee.object.name='assert']:not([callee.property.name='ok']):not([callee.property.name='fail']):not([callee.property.name='ifError'])" - message: "Please only use simple assertions in ./lib" - - selector: "CallExpression[callee.name='setTimeout'][arguments.length<2]" - message: "setTimeout() must be invoked with at least two arguments." - - selector: "CallExpression[callee.name='setInterval'][arguments.length<2]" - message: "setInterval() must be invoked with at least 2 arguments." - - selector: "ThrowStatement > CallExpression[callee.name=/Error$/]" - message: "Use new keyword when throwing an Error." + - selector: CallExpression[callee.object.name='assert']:not([callee.property.name='ok']):not([callee.property.name='fail']):not([callee.property.name='ifError']) + message: Please only use simple assertions in ./lib + - selector: CallExpression[callee.name='setTimeout'][arguments.length<2] + message: setTimeout() must be invoked with at least two arguments. + - selector: CallExpression[callee.name='setInterval'][arguments.length<2] + message: setInterval() must be invoked with at least 2 arguments. + - selector: ThrowStatement > CallExpression[callee.name=/Error$/] + message: Use new keyword when throwing an Error. # Config specific to lib - - selector: "NewExpression[callee.name=/Error$/]:not([callee.name=/^(AssertionError|NghttpError|AbortError)$/])" - message: "Use an error exported by the internal/errors module." - - selector: "CallExpression[callee.object.name='Error'][callee.property.name='captureStackTrace']" - message: "Please use `require('internal/errors').hideStackFrames()` instead." - - selector: "AssignmentExpression:matches([left.name='prepareStackTrace'], [left.property.name='prepareStackTrace'])" - message: "Use 'overrideStackTrace' from 'lib/internal/errors.js' instead of 'Error.prepareStackTrace'." - - selector: "ThrowStatement > NewExpression[callee.name=/^ERR_[A-Z_]+$/] > ObjectExpression:first-child:not(:has([key.name='message']):has([key.name='code']):has([key.name='syscall']))" - message: "The context passed into SystemError constructor must have .code, .syscall and .message." + - selector: NewExpression[callee.name=/Error$/]:not([callee.name=/^(AssertionError|NghttpError|AbortError)$/]) + message: Use an error exported by the internal/errors module. + - selector: CallExpression[callee.object.name='Error'][callee.property.name='captureStackTrace'] + message: Please use `require('internal/errors').hideStackFrames()` instead. + - selector: AssignmentExpression:matches([left.name='prepareStackTrace'], [left.property.name='prepareStackTrace']) + message: Use 'overrideStackTrace' from 'lib/internal/errors.js' instead of 'Error.prepareStackTrace'. + - selector: ThrowStatement > NewExpression[callee.name=/^ERR_[A-Z_]+$/] > ObjectExpression:first-child:not(:has([key.name='message']):has([key.name='code']):has([key.name='syscall'])) + message: The context passed into SystemError constructor must have .code, .syscall and .message. no-restricted-globals: - error - name: AbortController - message: "Use `const { AbortController } = require('internal/abort_controller');` instead of the global." + message: Use `const { AbortController } = require('internal/abort_controller');` instead of the global. - name: AbortSignal - message: "Use `const { AbortSignal } = require('internal/abort_controller');` instead of the global." + message: Use `const { AbortSignal } = require('internal/abort_controller');` instead of the global. # Atomics is not available in primordials because it can be # disabled with --no-harmony-atomics CLI flag. - name: Atomics - message: "Use `const { Atomics } = globalThis;` instead of the global." + message: Use `const { Atomics } = globalThis;` instead of the global. - name: Buffer - message: "Use `const { Buffer } = require('buffer');` instead of the global." + message: Use `const { Buffer } = require('buffer');` instead of the global. - name: Event - message: "Use `const { Event } = require('internal/event_target');` instead of the global." + message: Use `const { Event } = require('internal/event_target');` instead of the global. - name: EventTarget - message: "Use `const { EventTarget } = require('internal/event_target');` instead of the global." + message: Use `const { EventTarget } = require('internal/event_target');` instead of the global. - name: FormData - message: "Use `const { FormData } = require('internal/deps/undici/undici');` instead of the global." + message: Use `const { FormData } = require('internal/deps/undici/undici');` instead of the global. - name: Headers - message: "Use `const { Headers } = require('internal/deps/undici/undici');` instead of the global." + message: Use `const { Headers } = require('internal/deps/undici/undici');` instead of the global. # Intl is not available in primordials because it can be # disabled with --without-intl build flag. - name: Intl - message: "Use `const { Intl } = globalThis;` instead of the global." + message: Use `const { Intl } = globalThis;` instead of the global. - name: MessageChannel - message: "Use `const { MessageChannel } = require('internal/worker/io');` instead of the global." + message: Use `const { MessageChannel } = require('internal/worker/io');` instead of the global. - name: MessageEvent - message: "Use `const { MessageEvent } = require('internal/worker/io');` instead of the global." + message: Use `const { MessageEvent } = require('internal/worker/io');` instead of the global. - name: MessagePort - message: "Use `const { MessagePort } = require('internal/worker/io');` instead of the global." + message: Use `const { MessagePort } = require('internal/worker/io');` instead of the global. # SharedArrayBuffer is not available in primordials because it can be # disabled with --no-harmony-sharedarraybuffer CLI flag. - name: SharedArrayBuffer - message: "Use `const { SharedArrayBuffer } = globalThis;` instead of the global." + message: Use `const { SharedArrayBuffer } = globalThis;` instead of the global. - name: TextDecoder - message: "Use `const { TextDecoder } = require('internal/encoding');` instead of the global." + message: Use `const { TextDecoder } = require('internal/encoding');` instead of the global. - name: TextEncoder - message: "Use `const { TextEncoder } = require('internal/encoding');` instead of the global." + message: Use `const { TextEncoder } = require('internal/encoding');` instead of the global. - name: URL - message: "Use `const { URL } = require('internal/url');` instead of the global." + message: Use `const { URL } = require('internal/url');` instead of the global. - name: URLSearchParams - message: "Use `const { URLSearchParams } = require('internal/url');` instead of the global." + message: Use `const { URLSearchParams } = require('internal/url');` instead of the global. # WebAssembly is not available in primordials because it can be # disabled with --jitless CLI flag. - name: WebAssembly - message: "Use `const { WebAssembly } = globalThis;` instead of the global." + message: Use `const { WebAssembly } = globalThis;` instead of the global. - name: atob - message: "Use `const { atob } = require('buffer');` instead of the global." + message: Use `const { atob } = require('buffer');` instead of the global. - name: btoa - message: "Use `const { btoa } = require('buffer');` instead of the global." + message: Use `const { btoa } = require('buffer');` instead of the global. - name: crypto - message: "Use `const { crypto } = require('internal/crypto/webcrypto');` instead of the global." + message: Use `const { crypto } = require('internal/crypto/webcrypto');` instead of the global. - name: Crypto - message: "Use `const { Crypto } = require('internal/crypto/webcrypto');` instead of the global." + message: Use `const { Crypto } = require('internal/crypto/webcrypto');` instead of the global. - name: CryptoKey - message: "Use `const { CryptoKey } = require('internal/crypto/webcrypto');` instead of the global." + message: Use `const { CryptoKey } = require('internal/crypto/webcrypto');` instead of the global. - name: global - message: "Use `const { globalThis } = primordials;` instead of `global`." + message: Use `const { globalThis } = primordials;` instead of `global`. - name: globalThis - message: "Use `const { globalThis } = primordials;` instead of the global." + message: Use `const { globalThis } = primordials;` instead of the global. - name: performance - message: "Use `const { performance } = require('perf_hooks');` instead of the global." + message: Use `const { performance } = require('perf_hooks');` instead of the global. - name: queueMicrotask - message: "Use `const { queueMicrotask } = require('internal/process/task_queues');` instead of the global." + message: Use `const { queueMicrotask } = require('internal/process/task_queues');` instead of the global. - name: SubtleCrypto - message: "Use `const { SubtleCrypto } = require('internal/crypto/webcrypto');` instead of the global." + message: Use `const { SubtleCrypto } = require('internal/crypto/webcrypto');` instead of the global. # Custom rules in tools/eslint-rules node-core/lowercase-name-for-primitive: error node-core/non-ascii-character: error diff --git a/test/.eslintrc.yaml b/test/.eslintrc.yaml index 2a8ca894c7d688..c89a19bdfeaaae 100644 --- a/test/.eslintrc.yaml +++ b/test/.eslintrc.yaml @@ -5,7 +5,7 @@ env: es6: true rules: - multiline-comment-style: ["error", "separate-lines"] + multiline-comment-style: [error, separate-lines] no-var: error prefer-const: error symbol-description: off @@ -13,40 +13,40 @@ rules: no-restricted-syntax: # Config copied from .eslintrc.js - error - - selector: "CallExpression:matches([callee.name='deepStrictEqual'], [callee.property.name='deepStrictEqual']):matches([arguments.1.type='Literal']:not([arguments.1.regex]), [arguments.1.type='Identifier'][arguments.1.name='undefined'])" - message: "Use strictEqual instead of deepStrictEqual for literals or undefined." - - selector: "CallExpression:matches([callee.name='notDeepStrictEqual'], [callee.property.name='notDeepStrictEqual']):matches([arguments.1.type='Literal']:not([arguments.1.regex]), [arguments.1.type='Identifier'][arguments.1.name='undefined'])" - message: "Use notStrictEqual instead of notDeepStrictEqual for literals or undefined." - - selector: "CallExpression:matches([callee.name='deepStrictEqual'], [callee.property.name='deepStrictEqual'])[arguments.2.type='Literal']" - message: "Do not use a literal for the third argument of assert.deepStrictEqual()" - - selector: "CallExpression:matches([callee.name='doesNotThrow'], [callee.property.name='doesNotThrow'])" - message: "Do not use `assert.doesNotThrow()`. Write the code without the wrapper and add a comment instead." - - selector: "CallExpression:matches([callee.name='doesNotReject'], [callee.property.name='doesNotReject'])" - message: "Do not use `assert.doesNotReject()`. Write the code without the wrapper and add a comment instead." - - selector: "CallExpression:matches([callee.name='rejects'], [callee.property.name='rejects'])[arguments.length<2]" - message: "`assert.rejects()` must be invoked with at least two arguments." - - selector: "CallExpression[callee.property.name='strictEqual'][arguments.2.type='Literal']" - message: "Do not use a literal for the third argument of assert.strictEqual()" - - selector: "CallExpression:matches([callee.name='throws'], [callee.property.name='throws'])[arguments.1.type='Literal']:not([arguments.1.regex])" - message: "Use an object as second argument of `assert.throws()`." - - selector: "CallExpression:matches([callee.name='throws'], [callee.property.name='throws'])[arguments.length<2]" - message: "`assert.throws()` must be invoked with at least two arguments." - - selector: "CallExpression[callee.name='setInterval'][arguments.length<2]" - message: "`setInterval()` must be invoked with at least two arguments." - - selector: "ThrowStatement > CallExpression[callee.name=/Error$/]" - message: "Use `new` keyword when throwing an `Error`." - - selector: "CallExpression:matches([callee.name='notDeepStrictEqual'], [callee.property.name='notDeepStrictEqual'])[arguments.0.type='Literal']:not([arguments.1.type='Literal']):not([arguments.1.type='ObjectExpression']):not([arguments.1.type='ArrayExpression']):not([arguments.1.type='UnaryExpression'])" - message: "The first argument should be the `actual`, not the `expected` value." - - selector: "CallExpression:matches([callee.name='notStrictEqual'], [callee.property.name='notStrictEqual'])[arguments.0.type='Literal']:not([arguments.1.type='Literal']):not([arguments.1.type='ObjectExpression']):not([arguments.1.type='ArrayExpression']):not([arguments.1.type='UnaryExpression'])" - message: "The first argument should be the `actual`, not the `expected` value." - - selector: "CallExpression:matches([callee.name='deepStrictEqual'], [callee.property.name='deepStrictEqual'])[arguments.0.type='Literal']:not([arguments.1.type='Literal']):not([arguments.1.type='ObjectExpression']):not([arguments.1.type='ArrayExpression']):not([arguments.1.type='UnaryExpression'])" - message: "The first argument should be the `actual`, not the `expected` value." - - selector: "CallExpression:matches([callee.name='strictEqual'], [callee.property.name='strictEqual'])[arguments.0.type='Literal']:not([arguments.1.type='Literal']):not([arguments.1.type='ObjectExpression']):not([arguments.1.type='ArrayExpression']):not([arguments.1.type='UnaryExpression'])" - message: "The first argument should be the `actual`, not the `expected` value." - - selector: "CallExpression[callee.name='isNaN']" - message: "Use Number.isNaN() instead of the global isNaN() function." - - selector: "VariableDeclarator > CallExpression:matches([callee.name='debuglog'], [callee.property.name='debuglog']):not([arguments.0.value='test'])" - message: "Use 'test' as debuglog value in tests." + - selector: CallExpression:matches([callee.name='deepStrictEqual'], [callee.property.name='deepStrictEqual']):matches([arguments.1.type='Literal']:not([arguments.1.regex]), [arguments.1.type='Identifier'][arguments.1.name='undefined']) + message: Use strictEqual instead of deepStrictEqual for literals or undefined. + - selector: CallExpression:matches([callee.name='notDeepStrictEqual'], [callee.property.name='notDeepStrictEqual']):matches([arguments.1.type='Literal']:not([arguments.1.regex]), [arguments.1.type='Identifier'][arguments.1.name='undefined']) + message: Use notStrictEqual instead of notDeepStrictEqual for literals or undefined. + - selector: CallExpression:matches([callee.name='deepStrictEqual'], [callee.property.name='deepStrictEqual'])[arguments.2.type='Literal'] + message: Do not use a literal for the third argument of assert.deepStrictEqual() + - selector: CallExpression:matches([callee.name='doesNotThrow'], [callee.property.name='doesNotThrow']) + message: Do not use `assert.doesNotThrow()`. Write the code without the wrapper and add a comment instead. + - selector: CallExpression:matches([callee.name='doesNotReject'], [callee.property.name='doesNotReject']) + message: Do not use `assert.doesNotReject()`. Write the code without the wrapper and add a comment instead. + - selector: CallExpression:matches([callee.name='rejects'], [callee.property.name='rejects'])[arguments.length<2] + message: '`assert.rejects()` must be invoked with at least two arguments.' + - selector: CallExpression[callee.property.name='strictEqual'][arguments.2.type='Literal'] + message: Do not use a literal for the third argument of assert.strictEqual() + - selector: CallExpression:matches([callee.name='throws'], [callee.property.name='throws'])[arguments.1.type='Literal']:not([arguments.1.regex]) + message: Use an object as second argument of `assert.throws()`. + - selector: CallExpression:matches([callee.name='throws'], [callee.property.name='throws'])[arguments.length<2] + message: '`assert.throws()` must be invoked with at least two arguments.' + - selector: CallExpression[callee.name='setInterval'][arguments.length<2] + message: '`setInterval()` must be invoked with at least two arguments.' + - selector: ThrowStatement > CallExpression[callee.name=/Error$/] + message: Use `new` keyword when throwing an `Error`. + - selector: CallExpression:matches([callee.name='notDeepStrictEqual'], [callee.property.name='notDeepStrictEqual'])[arguments.0.type='Literal']:not([arguments.1.type='Literal']):not([arguments.1.type='ObjectExpression']):not([arguments.1.type='ArrayExpression']):not([arguments.1.type='UnaryExpression']) + message: The first argument should be the `actual`, not the `expected` value. + - selector: CallExpression:matches([callee.name='notStrictEqual'], [callee.property.name='notStrictEqual'])[arguments.0.type='Literal']:not([arguments.1.type='Literal']):not([arguments.1.type='ObjectExpression']):not([arguments.1.type='ArrayExpression']):not([arguments.1.type='UnaryExpression']) + message: The first argument should be the `actual`, not the `expected` value. + - selector: CallExpression:matches([callee.name='deepStrictEqual'], [callee.property.name='deepStrictEqual'])[arguments.0.type='Literal']:not([arguments.1.type='Literal']):not([arguments.1.type='ObjectExpression']):not([arguments.1.type='ArrayExpression']):not([arguments.1.type='UnaryExpression']) + message: The first argument should be the `actual`, not the `expected` value. + - selector: CallExpression:matches([callee.name='strictEqual'], [callee.property.name='strictEqual'])[arguments.0.type='Literal']:not([arguments.1.type='Literal']):not([arguments.1.type='ObjectExpression']):not([arguments.1.type='ArrayExpression']):not([arguments.1.type='UnaryExpression']) + message: The first argument should be the `actual`, not the `expected` value. + - selector: CallExpression[callee.name='isNaN'] + message: Use Number.isNaN() instead of the global isNaN() function. + - selector: VariableDeclarator > CallExpression:matches([callee.name='debuglog'], [callee.property.name='debuglog']):not([arguments.0.value='test']) + message: Use 'test' as debuglog value in tests. # Custom rules in tools/eslint-rules node-core/prefer-assert-iferror: error @@ -60,7 +60,7 @@ rules: ## common module is mandatory in tests node-core/required-modules: - error - - common: 'common(/index\.(m)?js)?$' + - common: common(/index\.(m)?js)?$ node-core/require-common-first: error node-core/no-duplicate-requires: off diff --git a/tools/.eslintrc.yaml b/tools/.eslintrc.yaml index d2fe553393693d..de30cf6d123f33 100644 --- a/tools/.eslintrc.yaml +++ b/tools/.eslintrc.yaml @@ -5,11 +5,11 @@ env: rules: camelcase: - error - - properties: 'never' + - properties: never ignoreDestructuring: true - allow: ['child_process'] + allow: [child_process] no-unused-vars: - error - - args: 'after-used' + - args: after-used prefer-arrow-callback: error no-var: error