Skip to content

tools: add lint rule for aborted AbortController#63541

Open
trivikr wants to merge 5 commits into
nodejs:mainfrom
trivikr:eslint-abort-signal-abort
Open

tools: add lint rule for aborted AbortController#63541
trivikr wants to merge 5 commits into
nodejs:mainfrom
trivikr:eslint-abort-signal-abort

Conversation

@trivikr
Copy link
Copy Markdown
Member

@trivikr trivikr commented May 24, 2026

This adds an ESLint rule to prefer AbortSignal.abort() when a test creates an
AbortController, immediately aborts it, and only uses the resulting
controller.signal.

The rule is intentionally conservative and only fixes the simple already-aborted
signal pattern from #63489.


The rule uses ESLint scope analysis rather than text matching. After finding a
candidate declaration, it gets the declared variable with
sourceCode.scopeManager.getDeclaredVariables() and checks all references to
that variable.

It only reports when the variable has exactly two non-declaration references:

  1. the immediate controller.abort() call
  2. one controller.signal read

If the controller is logged, passed somewhere else, aborted later, read more than
once, or otherwise referenced, the rule does not report or autofix it.


Assisted-by: openai:gpt-5.5

@trivikr trivikr requested a review from aduh95 May 24, 2026 16:14
@nodejs-github-bot
Copy link
Copy Markdown
Collaborator

Review requested:

  • @nodejs/quic

@nodejs-github-bot nodejs-github-bot added needs-ci PRs that need a full CI run. tools Issues and PRs related to the tools directory. labels May 24, 2026
@codecov
Copy link
Copy Markdown

codecov Bot commented May 24, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 90.31%. Comparing base (4639dcb) to head (a506493).
⚠️ Report is 7 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main   #63541      +/-   ##
==========================================
+ Coverage   90.29%   90.31%   +0.02%     
==========================================
  Files         730      730              
  Lines      234695   234695              
  Branches    43956    43955       -1     
==========================================
+ Hits       211927   211974      +47     
+ Misses      14494    14436      -58     
- Partials     8274     8285      +11     

see 48 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@trivikr trivikr added the request-ci Add this label to start a Jenkins CI on a PR. label May 24, 2026
@trivikr trivikr force-pushed the eslint-abort-signal-abort branch from 55470dd to 2cd59c6 Compare May 25, 2026 01:44
Comment thread test/parallel/test-abortcontroller.js Outdated
Comment thread test/parallel/test-eslint-prefer-abort-signal-abort.js Outdated
Comment thread test/parallel/test-eslint-prefer-abort-signal-abort.js Outdated
Comment thread tools/eslint-rules/prefer-abort-signal-abort.js Outdated
@trivikr trivikr requested a review from aduh95 May 25, 2026 15:37
@github-actions github-actions Bot removed the request-ci Add this label to start a Jenkins CI on a PR. label May 27, 2026
@nodejs-github-bot

This comment was marked as outdated.

trivikr and others added 5 commits May 27, 2026 17:17
Refs: nodejs#63489

Signed-off-by: Kamat, Trivikram <16024985+trivikr@users.noreply.github.com>
Co-authored-by: Antoine du Hamel <duhamelantoine1995@gmail.com>
Assisted-by: openai:gpt-5.5
Co-authored-by: Antoine du Hamel <duhamelantoine1995@gmail.com>
@trivikr trivikr force-pushed the eslint-abort-signal-abort branch from be4a7ca to a506493 Compare May 28, 2026 00:17
@trivikr trivikr added the request-ci Add this label to start a Jenkins CI on a PR. label May 28, 2026
@github-actions github-actions Bot removed the request-ci Add this label to start a Jenkins CI on a PR. label May 28, 2026
@nodejs-github-bot
Copy link
Copy Markdown
Collaborator

@trivikr trivikr added the author ready PRs that have at least one approval, no pending requests for changes, and a CI started. label May 28, 2026
@trivikr

This comment was marked as outdated.

@trivikr trivikr added commit-queue Add this label to land a pull request using GitHub Actions. commit-queue-squash Add this label to instruct the Commit Queue to squash all the PR commits into the first one. labels May 28, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

author ready PRs that have at least one approval, no pending requests for changes, and a CI started. commit-queue Add this label to land a pull request using GitHub Actions. commit-queue-squash Add this label to instruct the Commit Queue to squash all the PR commits into the first one. needs-ci PRs that need a full CI run. tools Issues and PRs related to the tools directory.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants