Skip to content

fix(lint): don't report Props interface as unused in Astro files#9101

Merged
siketyan merged 4 commits intomainfrom
fix/GH-9080
Feb 16, 2026
Merged

fix(lint): don't report Props interface as unused in Astro files#9101
siketyan merged 4 commits intomainfrom
fix/GH-9080

Conversation

@siketyan
Copy link
Copy Markdown
Member

@siketyan siketyan commented Feb 16, 2026

Summary

Fixes #9080

Props interface declarations at the top-level of Astro files are used to add typing to props and it's read by the framework implicitly. This pull request adds an exception to the noUnusedVariable to ignore that case.

Test Plan

Added snapshot tests.

Docs

Added description for the exception to the rule doc.

@siketyan siketyan requested review from a team February 16, 2026 14:00
@siketyan siketyan self-assigned this Feb 16, 2026
@changeset-bot
Copy link
Copy Markdown

changeset-bot Bot commented Feb 16, 2026

🦋 Changeset detected

Latest commit: 74d5df4

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-Linter Area: linter L-JavaScript Language: JavaScript and super languages labels Feb 16, 2026
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Feb 16, 2026

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review

No actionable comments were generated in the recent review. 🎉


Walkthrough

Adds an Astro-specific guard to the correctness/noUnusedVariables rule so a top-level TsInterfaceDeclaration or TsTypeAliasDeclaration named Props is considered used when the binding is top-level and referenced via Astro.props in an Astro embedding. Refactors binding-name handling to compute the name once, consolidates early-return guards, updates imports and rule documentation (adds an Astro Props example), adds tests covering top-level and nested Props in Astro files, and adds a patch changeset addressing issue #9080.

Possibly related PRs

Suggested reviewers

  • arendjr
  • dyc3
🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Merge Conflict Detection ⚠️ Warning ❌ Merge conflicts detected (34 files):

⚔️ crates/biome_cli/src/runner/mod.rs (content)
⚔️ crates/biome_cli/src/runner/scan_kind.rs (content)
⚔️ crates/biome_cli/tests/cases/handle_astro_files.rs (content)
⚔️ crates/biome_cli/tests/snapshots/main_cases_handle_astro_files/full_support.snap (content)
⚔️ crates/biome_css_analyze/src/lint/correctness/no_unknown_pseudo_element.rs (content)
⚔️ crates/biome_js_analyze/src/lint/correctness/no_unused_variables.rs (content)
⚔️ packages/@biomejs/backend-jsonrpc/CHANGELOG.md (content)
⚔️ packages/@biomejs/backend-jsonrpc/package.json (content)
⚔️ packages/@biomejs/biome/CHANGELOG.md (content)
⚔️ packages/@biomejs/biome/package.json (content)
⚔️ packages/@biomejs/cli-darwin-arm64/CHANGELOG.md (content)
⚔️ packages/@biomejs/cli-darwin-arm64/package.json (content)
⚔️ packages/@biomejs/cli-darwin-x64/CHANGELOG.md (content)
⚔️ packages/@biomejs/cli-darwin-x64/package.json (content)
⚔️ packages/@biomejs/cli-linux-arm64-musl/CHANGELOG.md (content)
⚔️ packages/@biomejs/cli-linux-arm64-musl/package.json (content)
⚔️ packages/@biomejs/cli-linux-arm64/CHANGELOG.md (content)
⚔️ packages/@biomejs/cli-linux-arm64/package.json (content)
⚔️ packages/@biomejs/cli-linux-x64-musl/CHANGELOG.md (content)
⚔️ packages/@biomejs/cli-linux-x64-musl/package.json (content)
⚔️ packages/@biomejs/cli-linux-x64/CHANGELOG.md (content)
⚔️ packages/@biomejs/cli-linux-x64/package.json (content)
⚔️ packages/@biomejs/cli-win32-arm64/CHANGELOG.md (content)
⚔️ packages/@biomejs/cli-win32-arm64/package.json (content)
⚔️ packages/@biomejs/cli-win32-x64/CHANGELOG.md (content)
⚔️ packages/@biomejs/cli-win32-x64/package.json (content)
⚔️ packages/@biomejs/js-api/package.json (content)
⚔️ packages/@biomejs/wasm-bundler/CHANGELOG.md (content)
⚔️ packages/@biomejs/wasm-bundler/package.json (content)
⚔️ packages/@biomejs/wasm-nodejs/CHANGELOG.md (content)
⚔️ packages/@biomejs/wasm-nodejs/package.json (content)
⚔️ packages/@biomejs/wasm-web/CHANGELOG.md (content)
⚔️ packages/@biomejs/wasm-web/package.json (content)
⚔️ pnpm-lock.yaml (content)

These conflicts must be resolved before merging into main.
Resolve conflicts locally and push changes to this branch.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately summarises the main change: fixing the noUnusedVariables rule to ignore top-level Props interfaces in Astro files.
Description check ✅ Passed The description is directly related to the changeset, explaining the fix for issue #9080, test coverage, and documentation updates.
Linked Issues check ✅ Passed The PR fully addresses issue #9080 by implementing an exception to noUnusedVariables that ignores top-level Props interface declarations in Astro files, with tests and documentation.
Out of Scope Changes check ✅ Passed All changes are directly related to the stated objective: fixing the Props interface issue in Astro files, with appropriate test cases and documentation updates.

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

✨ Finishing touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch fix/GH-9080
⚔️ Resolve merge conflicts (beta)
  • Auto-commit resolved conflicts to branch fix/GH-9080
  • Create stacked PR with resolved conflicts
  • Post resolved changes as copyable diffs in a comment

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

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Fix all issues with AI agents
In `@crates/biome_js_analyze/src/lint/correctness/no_unused_variables.rs`:
- Around line 345-350: Remove the leftover dbg! invocation that prints
binding_name, is_underscore_prefixed, is_defined_in_embedded_binding, and
is_used_as_reference from the no-unused-variables lint implementation; locate
the dbg!(binding_name, is_underscore_prefixed, is_defined_in_embedded_binding,
is_used_as_reference) call in the no_unused_variables rule and delete it (or
replace with a non-std debug logger like trace! if structured runtime logging is
required).
🧹 Nitpick comments (1)
crates/biome_js_analyze/src/lint/correctness/no_unused_variables.rs (1)

356-365: Astro Props handling looks correct.

The logic properly checks all conditions: binding name, embedding kind, binding type, interface declaration, and top-level position via JsModuleItemList.

Minor style note: let Some(_) = decl.parent::<JsModuleItemList>() could be written as decl.parent::<JsModuleItemList>().is_some() for consistency with idiomatic Rust, but this is entirely optional.

,

♻️ Optional: more idiomatic check
         if binding_name == "Props"
             && let EmbeddingKind::Astro { .. } = file_source.as_embedding_kind()
             && let AnyJsIdentifierBinding::TsIdentifierBinding(binding) = binding
             && let Some(decl) = binding.parent::<TsInterfaceDeclaration>()
-            && let Some(_) = decl.parent::<JsModuleItemList>()
+            && decl.parent::<JsModuleItemList>().is_some()
         {

Comment thread crates/biome_js_analyze/src/lint/correctness/no_unused_variables.rs Outdated
@codspeed-hq
Copy link
Copy Markdown

codspeed-hq Bot commented Feb 16, 2026

Merging this PR will not alter performance

✅ 58 untouched benchmarks
⏩ 95 skipped benchmarks1


Comparing fix/GH-9080 (74d5df4) with main (89d6384)

Open in CodSpeed

Footnotes

  1. 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
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🧹 Nitpick comments (1)
crates/biome_js_analyze/src/lint/correctness/no_unused_variables.rs (1)

302-365: Housekeeping: regen rule metadata and run format/lint.
Please confirm just gen-rules + just gen-configuration (rule change in *_analyze) and just f + just l before merge. As per coding guidelines, “Run just gen-rules and just gen-configuration before opening a PR when implementing changes to lint rules in *_analyze directories” and “Always run just f (code formatting) and just l (linting) before committing code.”

Comment thread crates/biome_js_analyze/src/lint/correctness/no_unused_variables.rs Outdated
Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

🧹 Nitpick comments (1)
crates/biome_js_analyze/src/lint/correctness/no_unused_variables.rs (1)

337-365: Reminder: Pre-PR commands

As per the coding guidelines, please ensure you've run just gen-rules, just gen-configuration, just f, and just l before finalising. (You likely have, but just checking!)

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Fix all issues with AI agents
In @.changeset/smooth-tips-fry.md:
- Around line 1-5: The changeset contains a typo in the rule name: replace the
incorrect "noUnusedVariable" with the correct rule identifier
"noUnusedVariables" in the changeset text so the rule name matches the docs and
rule identifier; update the string in .changeset/smooth-tips-fry.md wherever
"noUnusedVariable" appears to "noUnusedVariables".

Comment thread .changeset/smooth-tips-fry.md Outdated
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
@siketyan siketyan merged commit 0c0fb6f into main Feb 16, 2026
18 checks passed
@siketyan siketyan deleted the fix/GH-9080 branch February 16, 2026 17:53
@github-actions github-actions Bot mentioned this pull request Feb 16, 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-Linter Area: linter L-JavaScript Language: JavaScript and super languages

Projects

None yet

Development

Successfully merging this pull request may close these issues.

💅 Astro Props interface reported as unused in Biome 2.4

3 participants