fix(core): track of default specifiers#9878
Conversation
🦋 Changeset detectedLatest commit: e5168c9 The changes in this PR will be included in the next version bump. This PR includes changesets to release 13 packages
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 |
Parser conformance results onjs/262
jsx/babel
markdown/commonmark
symbols/microsoft
ts/babel
ts/microsoft
|
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Run ID: ⛔ Files ignored due to path filters (1)
📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
WalkthroughAdds a changeset marking a patch for Suggested reviewers
🚥 Pre-merge checks | ✅ 4✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
crates/biome_service/src/workspace/document/services/embedded_bindings.rs (1)
116-124: Avoid dual paths for default import registration.Line 116-124 already handles default imports generically; Line 126-134 re-handles default clauses again. It works, but it’s duplicate logic and easy to desynchronise later.
Suggested tidy-up
- if let Some(default_specifiers) = clause.default_specifiers() { - let local_name = default_specifiers.local_name().ok()?; + if let Some(default_specifier) = clause.default_specifiers() { + let local_name = default_specifier.local_name().ok()?; let local_name = local_name.as_js_identifier_binding()?; let local_name = local_name.name_token().ok()?; self.js_bindings.insert( local_name.text_trimmed_range(), local_name.token_text_trimmed(), ); } - - // Handle default clause using accessors generated by the syntax crate. - if let Some(import) = clause.as_js_import_default_clause() { - let name = import.default_specifier().ok()?; - let name = name.local_name().ok()?; - let name = name.as_js_identifier_binding()?; - let name = name.name_token().ok()?; - self.js_bindings - .insert(name.text_trimmed_range(), name.token_text_trimmed()); - }One code path, one source of truth — future-you will thank present-you.
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@crates/biome_service/src/workspace/document/services/embedded_bindings.rs` around lines 116 - 124, The code currently registers default imports in two places causing duplicated logic; keep the existing generic path that extracts default_specifiers via clause.default_specifiers(), converts through as_js_identifier_binding() and name_token(), and inserts into self.js_bindings using text_trimmed_range() and token_text_trimmed(), and remove the redundant second block that re-handles default clauses (the duplicate that performs the same local_name extraction and self.js_bindings.insert). Consolidate any remaining variant-specific logic into the single clause.default_specifiers() path so there's one source of truth for default import registration.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Nitpick comments:
In `@crates/biome_service/src/workspace/document/services/embedded_bindings.rs`:
- Around line 116-124: The code currently registers default imports in two
places causing duplicated logic; keep the existing generic path that extracts
default_specifiers via clause.default_specifiers(), converts through
as_js_identifier_binding() and name_token(), and inserts into self.js_bindings
using text_trimmed_range() and token_text_trimmed(), and remove the redundant
second block that re-handles default clauses (the duplicate that performs the
same local_name extraction and self.js_bindings.insert). Consolidate any
remaining variant-specific logic into the single clause.default_specifiers()
path so there's one source of truth for default import registration.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: 715e1ae5-983e-41f7-8295-91f7caabe6ac
⛔ Files ignored due to path filters (3)
crates/biome_js_analyze/tests/specs/correctness/noUnusedImports/valid_issue_9118.astro.snapis excluded by!**/*.snapand included by**crates/biome_js_analyze/tests/specs/correctness/noUnusedImports/valid_issue_9118.svelte.snapis excluded by!**/*.snapand included by**crates/biome_js_analyze/tests/specs/correctness/noUnusedImports/valid_issue_9118.vue.snapis excluded by!**/*.snapand included by**
📒 Files selected for processing (6)
.changeset/funny-candles-shake.mdcrates/biome_js_analyze/tests/specs/correctness/noUnusedImports/valid_issue_9118.astrocrates/biome_js_analyze/tests/specs/correctness/noUnusedImports/valid_issue_9118.sveltecrates/biome_js_analyze/tests/specs/correctness/noUnusedImports/valid_issue_9118.vuecrates/biome_js_syntax/src/import_ext.rscrates/biome_service/src/workspace/document/services/embedded_bindings.rs
Merging this PR will not alter performance
Comparing Footnotes
|
Summary
Closes #9118
Test Plan
Added new tests
Docs