Skip to content

Conversation

@wataryooou
Copy link
Contributor

@wataryooou wataryooou commented Dec 23, 2025

Summary

  • Fix noUnusedVariables so type parameters declared in ambient contexts (e.g., within declare module) are not reported as unused, aligning behavior with TypeScript/ESLint expectations.
  • Add a regression case using a common module augmentation example (declare module "react") to cover this scenario.
  • Include a changeset (.changeset/calm-ambient-type-params.md) since this is user-visible behavior.

Test Plan

  • cargo test -p biome_js_analyze --test spec_tests -- specs::correctness::no_unused_variables::valid_ambient_type_param_ts

Docs

  • No new options added; behavior correction only.
  • If desired for release notes: “Fixed noUnusedVariables incorrectly flagging ambient type parameters as unused.”

Playground link

https://biomejs.dev/playground/?lintRules=noUnusedVariables&code=ZABlAGMAbABhAHIAZQAgAG0AbwBkAHUAbABlACAAIgByAGUAYQBjAHQAIgAgAHsACgAgACAAZQB4AHAAbwByAHQAIABpAG4AdABlAHIAZgBhAGMAZQAgAEMAbwBtAHAAbwBuAGUAbgB0AE0AZQB0AGEAPABUAD4AIAB7AAoAIAAgACAAIABkAGkAcwBwAGwAYQB5AE4AYQBtAGUAPwA6ACAAcwB0AHIAaQBuAGcAOwAKACAAIAAgACAAdgBlAHIAcwBpAG8AbgA%2FADoAIABzAHQAcgBpAG4AZwA7AAoAIAAgAH0ACgAKACAAIABlAHgAcABvAHIAdAAgAGkAbgB0AGUAcgBmAGEAYwBlACAASABvAG8AawBSAGUAcwB1AGwAdAA8AFQAPgAgAHsACgAgACAAIAAgAGUAcgByAG8AcgA%2FADoAIABFAHIAcgBvAHIAIAB8ACAAbgB1AGwAbAA7AAoAIAAgACAAIABpAHMATABvAGEAZABpAG4AZwA6ACAAYgBvAG8AbABlAGEAbgA7AAoAIAAgAH0ACgB9AA%3D%3D&language=ts

@changeset-bot
Copy link

changeset-bot bot commented Dec 23, 2025

🦋 Changeset detected

Latest commit: 44261d5

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-Linter Area: linter L-JavaScript Language: JavaScript and super languages labels Dec 23, 2025
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Dec 23, 2025

Walkthrough

This pull request refines the noUnusedVariables lint rule to handle TypeScript type parameters in ambient contexts correctly. The fix modifies the rule to skip suggesting prefix underscore for type parameters declared within ambient blocks (such as declare module statements), rather than treating them uniformly. A test file with ambient module declarations for React is added to validate the behaviour.

Suggested labels

A-Linter, L-JavaScript

Suggested reviewers

  • dyc3
  • ematipico

Pre-merge checks and finishing touches

✅ Passed checks (2 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately and concisely describes the main change: fixing noUnusedVariables to ignore type parameters in ambient contexts.
Description check ✅ Passed The pull request description clearly describes the changeset: fixing noUnusedVariables to ignore type parameters in ambient contexts, adding a regression test, and including a changeset file.
✨ Finishing touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

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

@codspeed-hq
Copy link

codspeed-hq bot commented Dec 24, 2025

CodSpeed Performance Report

Merging #8561 will not alter performance

Comparing wataryooou:fix/no-unused-variables-type-params (44261d5) with main (d80fa41)1

Summary

✅ 58 untouched
⏩ 95 skipped2

Footnotes

  1. No successful run was found on main (25cdd50) during the generation of this report, so d80fa41 was used instead as the comparison base. There might be some changes unrelated to this pull request in this report.

  2. 95 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.

Copy link
Contributor

@arendjr arendjr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you!

@arendjr arendjr merged commit 981affb into biomejs:main Jan 7, 2026
19 checks passed
@github-actions github-actions bot mentioned this pull request Jan 5, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

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

2 participants