Skip to content

fix(lint): code action for noRedundantUseStrict no longer produces syntactically invalid nodes#9191

Merged
ematipico merged 1 commit intomainfrom
dyc3/fix-panic-no-redundant-use-strict
Feb 22, 2026
Merged

fix(lint): code action for noRedundantUseStrict no longer produces syntactically invalid nodes#9191
ematipico merged 1 commit intomainfrom
dyc3/fix-panic-no-redundant-use-strict

Conversation

@dyc3
Copy link
Contributor

@dyc3 dyc3 commented Feb 22, 2026

Summary

This one was a bit of a weird one, tbh. Copying the note I left on the tests:

/// This issue was caused by noRedundantUseStrict's fix replacing the directive with a directive that was syntactically blank.
/// When fixes are applied, they also get formatted by our formatter. The formatter would try to format the
/// directive, but it expects the directive to have quotes, and since it was syntactically blank, it would panic
/// when trying to trim the quotes off.
///
/// Our unit tests didn't pick it up because linter unit tests don't include the formatting step.
///
/// This issue was fixed by changing the rule's fix to remove the node and transfer the trivia to the next token.

fixes #9180

Test Plan

added cli tests

Docs

@changeset-bot
Copy link

changeset-bot bot commented Feb 22, 2026

🦋 Changeset detected

Latest commit: 82776e6

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 13 packages
Name Type
@biomejs/biome Patch
@biomejs/cli-win32-x64 Patch
@biomejs/cli-win32-arm64 Patch
@biomejs/cli-darwin-x64 Patch
@biomejs/cli-darwin-arm64 Patch
@biomejs/cli-linux-x64 Patch
@biomejs/cli-linux-arm64 Patch
@biomejs/cli-linux-x64-musl Patch
@biomejs/cli-linux-arm64-musl Patch
@biomejs/wasm-web Patch
@biomejs/wasm-bundler Patch
@biomejs/wasm-nodejs Patch
@biomejs/backend-jsonrpc Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@github-actions github-actions bot added A-CLI Area: CLI A-Core Area: core A-Linter Area: linter L-JavaScript Language: JavaScript and super languages labels Feb 22, 2026
@codspeed-hq
Copy link

codspeed-hq bot commented Feb 22, 2026

Merging this PR will not alter performance

✅ 58 untouched benchmarks
⏩ 156 skipped benchmarks1


Comparing dyc3/fix-panic-no-redundant-use-strict (82776e6) with main (b76c42b)

Open in CodSpeed

Footnotes

  1. 156 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Feb 22, 2026

No actionable comments were generated in the recent review. 🎉


Walkthrough

This PR adds a BatchMutation method remove_node_keep_trivia and updates the noRedundantUseStrict lint to use it instead of replacing directive nodes. The new method removes a node while collecting its leading and trailing trivia and transfers that trivia to the next token (or to EOF). Two regression tests for issue #9180 are added and the test module is registered. A changeset for a patch release was also added.

Possibly related PRs

Suggested reviewers

  • ematipico
  • Conaclos
  • siketyan
🚥 Pre-merge checks | ✅ 4
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed Title accurately describes the main fix: preventing syntactically invalid nodes from being produced by the noRedundantUseStrict code action.
Description check ✅ Passed Description clearly explains the root cause (blank directive causing formatter panic), why tests missed it (no formatting step), and the solution (node removal with trivia preservation).
Linked Issues check ✅ Passed Changes fully address issue #9180: the rule's fix now removes the node and preserves trivia instead of producing a blank directive, preventing formatter panic; regression tests with formatting step were added.
Out of Scope Changes check ✅ Passed All changes are scoped to fixing the panic: the new remove_node_keep_trivia method enables proper trivia handling, the rule fix uses it, and CLI tests validate the complete flow—no extraneous changes.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
  • 📝 Generate docstrings (stacked PR)
  • 📝 Generate docstrings (commit on current branch)
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch dyc3/fix-panic-no-redundant-use-strict

Comment @coderabbitai help to get the list of available commands and usage tips.

@github-actions
Copy link
Contributor

Parser conformance results on

js/262

Test result main count This PR count Difference
Total 52912 52912 0
Passed 51692 51692 0
Failed 1178 1178 0
Panics 42 42 0
Coverage 97.69% 97.69% 0.00%

jsx/babel

Test result main count This PR count Difference
Total 38 38 0
Passed 37 37 0
Failed 1 1 0
Panics 0 0 0
Coverage 97.37% 97.37% 0.00%

markdown/commonmark

Test result main count This PR count Difference
Total 652 652 0
Passed 652 652 0
Failed 0 0 0
Panics 0 0 0
Coverage 100.00% 100.00% 0.00%

symbols/microsoft

Test result main count This PR count Difference
Total 5464 5464 0
Passed 1915 1915 0
Failed 3549 3549 0
Panics 0 0 0
Coverage 35.05% 35.05% 0.00%

ts/babel

Test result main count This PR count Difference
Total 629 629 0
Passed 563 563 0
Failed 66 66 0
Panics 0 0 0
Coverage 89.51% 89.51% 0.00%

ts/microsoft

Test result main count This PR count Difference
Total 18871 18871 0
Passed 13012 13012 0
Failed 5858 5858 0
Panics 1 1 0
Coverage 68.95% 68.95% 0.00%

@dyc3 dyc3 force-pushed the dyc3/fix-panic-no-redundant-use-strict branch from 601b528 to 82776e6 Compare February 22, 2026 16:20
@dyc3 dyc3 requested review from a team February 22, 2026 16:36
@ematipico ematipico merged commit 688fd34 into main Feb 22, 2026
34 checks passed
@ematipico ematipico deleted the dyc3/fix-panic-no-redundant-use-strict branch February 22, 2026 16:46
@github-actions github-actions bot mentioned this pull request Feb 22, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-CLI Area: CLI A-Core Area: core A-Linter Area: linter L-JavaScript Language: JavaScript and super languages

Projects

None yet

2 participants