Skip to content

Commit

Permalink
fix(analyze/js): fix some imports not being detected
Browse files Browse the repository at this point in the history
  • Loading branch information
dyc3 committed Nov 19, 2024
1 parent 352556a commit a723d56
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -597,18 +597,14 @@ fn capture_needs_to_be_in_the_dependency_list(
| AnyJsBindingDeclaration::JsArrayBindingPatternRestElement(_)
| AnyJsBindingDeclaration::JsObjectBindingPatternProperty(_)
| AnyJsBindingDeclaration::JsObjectBindingPatternRest(_)
| AnyJsBindingDeclaration::JsObjectBindingPatternShorthandProperty(_) => {
unreachable!("The declaration should be resolved to its prent declaration")
}
| AnyJsBindingDeclaration::JsObjectBindingPatternShorthandProperty(_) => true,

// This should be unreachable because of the test if the capture is imported
AnyJsBindingDeclaration::JsShorthandNamedImportSpecifier(_)
| AnyJsBindingDeclaration::JsNamedImportSpecifier(_)
| AnyJsBindingDeclaration::JsBogusNamedImportSpecifier(_)
| AnyJsBindingDeclaration::JsDefaultImportSpecifier(_)
| AnyJsBindingDeclaration::JsNamespaceImportSpecifier(_) => {
unreachable!()
}
| AnyJsBindingDeclaration::JsNamespaceImportSpecifier(_) => false,
}
}

Expand Down
10 changes: 8 additions & 2 deletions crates/biome_js_semantic/src/semantic_model/import.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,14 @@ use biome_js_syntax::{
use biome_rowan::AstNode;

pub(crate) fn is_imported(node: &JsSyntaxNode) -> bool {
node.ancestors()
.any(|x| matches!(x.kind(), JsSyntaxKind::JS_IMPORT))
node.ancestors().any(|x| {
matches!(
x.kind(),
JsSyntaxKind::JS_IMPORT
| JsSyntaxKind::JS_NAMED_IMPORT_SPECIFIERS
| JsSyntaxKind::JS_DEFAULT_IMPORT_SPECIFIER
)
})
}

/// Marker trait that groups all "AstNode" that can be imported or
Expand Down

0 comments on commit a723d56

Please sign in to comment.