Skip to content

Conversation

@hirokiokada77
Copy link
Contributor

Summary

This PR fixes the noUnusedImports rule to detect JSDoc tags on object properties.

Closes #8300.

Test Plan

Test cases were added to:

  • crates/biome_js_analyze/tests/specs/correctness/noUnusedImports/issue_4677_jsdoc.js
  • crates/biome_js_analyze/tests/specs/correctness/noUnusedImports/issue_4677_tsdoc.ts
  • crates/biome_js_analyze/tests/specs/correctness/noUnusedImports/issue_7876_tsdoc_linkcode.ts
  • crates/biome_js_analyze/tests/specs/correctness/noUnusedImports/issue_7876_tsdoc_linkplain.ts

@changeset-bot
Copy link

changeset-bot bot commented Nov 28, 2025

🦋 Changeset detected

Latest commit: f79b5f9

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 Nov 28, 2025
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Nov 28, 2025

Walkthrough

The PR updates the noUnusedImports linter to recognise JSDoc/TSDoc references attached to object properties by adding AnyJsObjectMember to the node union used when collecting JSDoc type references. Tests were added for JavaScript and TypeScript cases that place JSDoc/TSDoc references on object properties to verify those imports are treated as used.

Possibly related PRs

Suggested reviewers

  • ematipico
  • dyc3

Pre-merge checks and finishing touches

✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The PR title clearly summarises the main fix: enabling the noUnusedImports rule to detect JSDoc tags on object properties, which directly matches the core objective.
Description check ✅ Passed The description is relevant to the changeset, explaining the fix for noUnusedImports rule and references the related issue #8300 with concrete test file locations.
Linked Issues check ✅ Passed The code changes directly address issue #8300 by adding AnyJsObjectMember to JSDoc type-reference detection and including test cases for JSDoc/TSDoc tags on object properties, meeting the requirement to handle property-level comments.
Out of Scope Changes check ✅ Passed All changes are within scope: the linter rule update, changelog entry, and four test files demonstrating JSDoc/TSDoc detection on object properties align with the issue requirements and PR objectives.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

📜 Recent review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 48c0402 and f79b5f9.

⛔ Files ignored due to path filters (4)
  • crates/biome_js_analyze/tests/specs/correctness/noUnusedImports/issue_4677_jsdoc.js.snap is excluded by !**/*.snap and included by **
  • crates/biome_js_analyze/tests/specs/correctness/noUnusedImports/issue_4677_tsdoc.ts.snap is excluded by !**/*.snap and included by **
  • crates/biome_js_analyze/tests/specs/correctness/noUnusedImports/issue_7876_tsdoc_linkcode.ts.snap is excluded by !**/*.snap and included by **
  • crates/biome_js_analyze/tests/specs/correctness/noUnusedImports/issue_7876_tsdoc_linkplain.ts.snap is excluded by !**/*.snap and included by **
📒 Files selected for processing (6)
  • .changeset/silent-bottles-film.md (1 hunks)
  • crates/biome_js_analyze/src/lint/correctness/no_unused_imports.rs (2 hunks)
  • crates/biome_js_analyze/tests/specs/correctness/noUnusedImports/issue_4677_jsdoc.js (2 hunks)
  • crates/biome_js_analyze/tests/specs/correctness/noUnusedImports/issue_4677_tsdoc.ts (2 hunks)
  • crates/biome_js_analyze/tests/specs/correctness/noUnusedImports/issue_7876_tsdoc_linkcode.ts (2 hunks)
  • crates/biome_js_analyze/tests/specs/correctness/noUnusedImports/issue_7876_tsdoc_linkplain.ts (2 hunks)
🚧 Files skipped from review as they are similar to previous changes (4)
  • crates/biome_js_analyze/src/lint/correctness/no_unused_imports.rs
  • .changeset/silent-bottles-film.md
  • crates/biome_js_analyze/tests/specs/correctness/noUnusedImports/issue_4677_tsdoc.ts
  • crates/biome_js_analyze/tests/specs/correctness/noUnusedImports/issue_7876_tsdoc_linkplain.ts
🧰 Additional context used
📓 Path-based instructions (1)
**/*.ts

📄 CodeRabbit inference engine (CONTRIBUTING.md)

For Node.js package development, build WebAssembly bindings and JSON-RPC bindings; run tests against compiled files after implementing features or bug fixes

Files:

  • crates/biome_js_analyze/tests/specs/correctness/noUnusedImports/issue_7876_tsdoc_linkcode.ts
🧠 Learnings (4)
📓 Common learnings
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_analyze/CONTRIBUTING.md:0-0
Timestamp: 2025-11-27T23:04:02.022Z
Learning: Applies to crates/biome_analyze/**/*analyze/src/lint/**/*.rs : Use language tags in documentation code blocks (js, ts, tsx, json, css) and order properties consistently as: language, then `expect_diagnostic`, then options modifiers, then `ignore`, then `file=path`
📚 Learning: 2025-11-24T18:05:42.356Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_js_type_info/CONTRIBUTING.md:0-0
Timestamp: 2025-11-24T18:05:42.356Z
Learning: Applies to crates/biome_js_type_info/**/*.rs : Distinguish between `TypeData::Unknown` and `TypeData::UnknownKeyword` to measure inference effectiveness versus explicit user-provided unknown types

Applied to files:

  • crates/biome_js_analyze/tests/specs/correctness/noUnusedImports/issue_4677_jsdoc.js
📚 Learning: 2025-11-27T23:04:02.022Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_analyze/CONTRIBUTING.md:0-0
Timestamp: 2025-11-27T23:04:02.022Z
Learning: Applies to crates/biome_analyze/**/*analyze/src/lint/**/*.rs : Use language tags in documentation code blocks (js, ts, tsx, json, css) and order properties consistently as: language, then `expect_diagnostic`, then options modifiers, then `ignore`, then `file=path`

Applied to files:

  • crates/biome_js_analyze/tests/specs/correctness/noUnusedImports/issue_7876_tsdoc_linkcode.ts
📚 Learning: 2025-11-27T23:04:02.022Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_analyze/CONTRIBUTING.md:0-0
Timestamp: 2025-11-27T23:04:02.022Z
Learning: Applies to crates/biome_analyze/**/tests/specs/**/*.jsonc : Use `.jsonc` files in test specs with code snippets as array of strings to test rules in script environment (no import/export syntax)

Applied to files:

  • crates/biome_js_analyze/tests/specs/correctness/noUnusedImports/issue_7876_tsdoc_linkcode.ts
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (12)
  • GitHub Check: Check Dependencies
  • GitHub Check: Documentation
  • GitHub Check: Lint project (depot-ubuntu-24.04-arm-16)
  • GitHub Check: End-to-end tests
  • GitHub Check: Test (depot-windows-2022-16)
  • GitHub Check: Test (depot-ubuntu-24.04-arm-16)
  • GitHub Check: Lint project (depot-windows-2022)
  • GitHub Check: Test Node.js API
  • GitHub Check: autofix
  • GitHub Check: Bench (biome_js_formatter)
  • GitHub Check: Bench (biome_js_analyze)
  • GitHub Check: Bench (biome_js_parser)
🔇 Additional comments (3)
crates/biome_js_analyze/tests/specs/correctness/noUnusedImports/issue_7876_tsdoc_linkcode.ts (2)

23-24: Import addition looks consistent and correct

LinkOnObjectProperty follows the same import type ... from "mod" pattern as the rest of this fixture and is clearly paired with the new object‑property test below, so the import side of the regression test looks good to me.


113-120: Good coverage for TSDoc links on object properties

This testLinkOnObjectProperty block neatly extends the existing matrix of {@linkcode ...} locations to object properties, with the identifier in the comment matching the new import exactly. That should give noUnusedImports a precise regression guard for the original bug.

crates/biome_js_analyze/tests/specs/correctness/noUnusedImports/issue_4677_jsdoc.js (1)

12-12: JS JSDoc object‑property case wired up nicely

The TypeOnObjectProperty import and the testTypeOnObjectProperty object with its @type {TypeOnObjectProperty} JSDoc give a clear JS‑side reproduction of the property‑level usage case. This should stop noUnusedImports from crying wolf on that import while keeping the rest of the fixture’s behaviour unchanged.

Also applies to: 63-68

Tip

📝 Customizable high-level summaries are now available in beta!

You can now customize how CodeRabbit generates the high-level summary in your pull requests — including its content, structure, tone, and formatting.

  • Provide your own instructions using the high_level_summary_instructions setting.
  • Format the summary however you like (bullet lists, tables, multi-section layouts, contributor stats, etc.).
  • Use high_level_summary_in_walkthrough to move the summary from the description to the walkthrough section.

Example instruction:

"Divide the high-level summary into five sections:

  1. 📝 Description — Summarize the main change in 50–60 words, explaining what was done.
  2. 📓 References — List relevant issues, discussions, documentation, or related PRs.
  3. 📦 Dependencies & Requirements — Mention any new/updated dependencies, environment variable changes, or configuration updates.
  4. 📊 Contributor Summary — Include a Markdown table showing contributions:
    | Contributor | Lines Added | Lines Removed | Files Changed |
  5. ✔️ Additional Notes — Add any extra reviewer context.
    Keep each section concise (under 200 words) and use bullet or numbered lists for clarity."

Note: This feature is currently in beta for Pro-tier users, and pricing will be announced later.


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 Nov 28, 2025

CodSpeed Performance Report

Merging #8303 will not alter performance

Comparing hirokiokada77:fix/no-unused-imports (f79b5f9) with main (e7e0f6c)1

Summary

✅ 58 untouched
⏩ 95 skipped2

Footnotes

  1. No successful run was found on main (93182ea) during the generation of this report, so e7e0f6c 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.

@dyc3 dyc3 merged commit db2c65b into biomejs:main Nov 28, 2025
18 checks passed
@github-actions github-actions bot mentioned this pull request Nov 28, 2025
@hirokiokada77 hirokiokada77 deleted the fix/no-unused-imports branch November 28, 2025 18:12
This was referenced Dec 15, 2025
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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

💅 noUnusedImports TSDoc detection doesn't work on object properties

2 participants