Skip to content

fix(lint): recognize aliased Svelte imports in templates#9645

Closed
raashish1601 wants to merge 1 commit intobiomejs:mainfrom
raashish1601:contributor-22/issue-9543-svelte-import-alias
Closed

fix(lint): recognize aliased Svelte imports in templates#9645
raashish1601 wants to merge 1 commit intobiomejs:mainfrom
raashish1601:contributor-22/issue-9543-svelte-import-alias

Conversation

@raashish1601
Copy link
Copy Markdown

Summary

Testing

  • git diff --check
  • rustfmt --check crates/biome_service/src/workspace/document/services/embedded_bindings.rs
  • attempted cargo test -p biome_service --lib tracks_renamed_named_imports_by_local_name -- --exact --nocapture on this Windows worker, but it timed out during compilation

Closes #9543.

@changeset-bot
Copy link
Copy Markdown

changeset-bot bot commented Mar 28, 2026

⚠️ No Changeset found

Latest commit: a16423d

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

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

@github-actions github-actions bot added A-Project Area: project A-Linter Area: linter L-JavaScript Language: JavaScript and super languages labels Mar 28, 2026
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Mar 28, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: ac096b5f-cacf-4057-a21b-99fa213794f2

📥 Commits

Reviewing files that changed from the base of the PR and between 5bfee36 and a16423d.

⛔ Files ignored due to path filters (3)
  • crates/biome_js_analyze/tests/specs/correctness/noUnusedImports/Issue9543Component.svelte.snap is excluded by !**/*.snap and included by **
  • crates/biome_js_analyze/tests/specs/correctness/noUnusedImports/issue-9543-reexport.ts.snap is excluded by !**/*.snap and included by **
  • crates/biome_js_analyze/tests/specs/correctness/noUnusedImports/valid-issue-9543.svelte.snap is excluded by !**/*.snap and included by **
📒 Files selected for processing (4)
  • crates/biome_js_analyze/tests/specs/correctness/noUnusedImports/Issue9543Component.svelte
  • crates/biome_js_analyze/tests/specs/correctness/noUnusedImports/issue-9543-reexport.ts
  • crates/biome_js_analyze/tests/specs/correctness/noUnusedImports/valid-issue-9543.svelte
  • crates/biome_service/src/workspace/document/services/embedded_bindings.rs

Walkthrough

This PR fixes a bug in the noUnusedImports linting rule where renamed imports that are re-exported from Svelte components are incorrectly flagged as unused. The core change updates EmbeddedBuilder::visit_js_import to track named import bindings by their local identifier name (post-alias) rather than the original imported name. Three new test fixtures validate the fix for Svelte component re-export scenarios with renamed imports.

Possibly related PRs

Suggested labels

A-Linter, A-Project, L-JavaScript

Suggested reviewers

  • dyc3
  • ematipico
🚥 Pre-merge checks | ✅ 4
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately captures the core fix: recognising aliased Svelte imports in templates, which directly addresses the main change in the embedded_bindings.rs file.
Description check ✅ Passed The description clearly outlines the changes made, including tracking imports by local name, adding unit tests, and regression specs—all aligned with the changeset.
Linked Issues check ✅ Passed The PR addresses the core objective from #9543: making the linter recognise renamed/aliased Svelte imports as used by updating embedded binding tracking to use local names instead of imported names, and adds regression test coverage.
Out of Scope Changes check ✅ Passed All changes are directly scoped to fixing the aliased import issue: updating binding tracking logic, adding a focused unit test, and creating regression specs for the specific #9543 case.

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

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

@Conaclos Conaclos added the M-Likely Agent This was likely an automated PR without a human in the loop label Mar 29, 2026
@ematipico ematipico closed this Mar 29, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-Linter Area: linter A-Project Area: project L-JavaScript Language: JavaScript and super languages M-Likely Agent This was likely an automated PR without a human in the loop

Projects

None yet

Development

Successfully merging this pull request may close these issues.

💅 Linter assumes reexported svelte file that gets renamed when imported isn't used

3 participants