Skip to content

tools: add lint rule for aborted AbortController#63541

Open
trivikr wants to merge 1 commit into
nodejs:mainfrom
trivikr:eslint-abort-signal-abort
Open

tools: add lint rule for aborted AbortController#63541
trivikr wants to merge 1 commit 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

Refs: nodejs#63489

Signed-off-by: Kamat, Trivikram <16024985+trivikr@users.noreply.github.com>
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.33%. Comparing base (8c3e9bd) to head (55470dd).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main   #63541      +/-   ##
==========================================
+ Coverage   90.31%   90.33%   +0.01%     
==========================================
  Files         730      730              
  Lines      234152   234152              
  Branches    43913    43917       +4     
==========================================
+ Hits       211482   211527      +45     
+ Misses      14381    14356      -25     
+ Partials     8289     8269      -20     

see 28 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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

needs-ci PRs that need a full CI run. request-ci Add this label to start a Jenkins CI on a PR. tools Issues and PRs related to the tools directory.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants