Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor(ast): remove JsImportNamespaceClause #431

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,6 @@ impl Rule for OrganizeImports {
AnyJsImportClause::JsImportBareClause(clause) => clause.source().ok()?,
AnyJsImportClause::JsImportDefaultClause(clause) => clause.source().ok()?,
AnyJsImportClause::JsImportNamedClause(clause) => clause.source().ok()?,
AnyJsImportClause::JsImportNamespaceClause(clause) => clause.source().ok()?,
};

let key = source.inner_string_text().ok()?;
Expand Down Expand Up @@ -338,8 +337,7 @@ impl From<JsImport> for ImportNode {
let specifiers = import_clause.and_then(|import_clause| {
let import_named_clause = match import_clause {
AnyJsImportClause::JsImportBareClause(_)
| AnyJsImportClause::JsImportDefaultClause(_)
| AnyJsImportClause::JsImportNamespaceClause(_) => return None,
| AnyJsImportClause::JsImportDefaultClause(_) => return None,
AnyJsImportClause::JsImportNamedClause(import_clause) => import_clause,
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,6 @@ fn suggested_fix_if_unused(binding: &AnyJsIdentifierBinding) -> Option<Suggested
AnyJsBindingDeclaration::JsBogusParameter(_)
// Imports are never ok to be unused
| AnyJsBindingDeclaration::JsImportDefaultClause(_)
| AnyJsBindingDeclaration::JsImportNamespaceClause(_)
| AnyJsBindingDeclaration::JsShorthandNamedImportSpecifier(_)
| AnyJsBindingDeclaration::JsNamedImportSpecifier(_)
| AnyJsBindingDeclaration::JsBogusNamedImportSpecifier(_)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -482,7 +482,6 @@ fn capture_needs_to_be_in_the_dependency_list(
// This should not be unreachable because of the test
// if the capture is imported
AnyJsBindingDeclaration::JsImportDefaultClause(_)
| AnyJsBindingDeclaration::JsImportNamespaceClause(_)
| AnyJsBindingDeclaration::JsShorthandNamedImportSpecifier(_)
| AnyJsBindingDeclaration::JsNamedImportSpecifier(_)
| AnyJsBindingDeclaration::JsBogusNamedImportSpecifier(_)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -794,8 +794,7 @@ impl Named {
AnyJsBindingDeclaration::JsCatchDeclaration(_) => Some(Named::CatchParameter),
AnyJsBindingDeclaration::TsPropertyParameter(_) => Some(Named::ParameterProperty),
AnyJsBindingDeclaration::TsIndexSignatureParameter(_) => Some(Named::IndexParameter),
AnyJsBindingDeclaration::JsNamespaceImportSpecifier(_)
| AnyJsBindingDeclaration::JsImportNamespaceClause(_) => Some(Named::ImportNamespace),
AnyJsBindingDeclaration::JsNamespaceImportSpecifier(_) => Some(Named::ImportNamespace),
AnyJsBindingDeclaration::JsFunctionDeclaration(_)
| AnyJsBindingDeclaration::JsFunctionExpression(_)
| AnyJsBindingDeclaration::JsFunctionExportDefaultDeclaration(_)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@ use biome_console::markup;
use biome_js_semantic::ReferencesExtensions;
use biome_js_syntax::{
JsDefaultImportSpecifier, JsIdentifierAssignment, JsIdentifierBinding, JsImportDefaultClause,
JsImportNamespaceClause, JsNamedImportSpecifier, JsNamespaceImportSpecifier,
JsShorthandNamedImportSpecifier,
JsNamedImportSpecifier, JsNamespaceImportSpecifier, JsShorthandNamedImportSpecifier,
};

use biome_rowan::{declare_node_union, AstNode};
Expand Down Expand Up @@ -69,8 +68,6 @@ impl Rule for NoImportAssign {
let local_name_binding = match label_statement {
// `import xx from 'y'`
AnyJsImportLike::JsImportDefaultClause(clause) => clause.local_name().ok(),
// `import * as xxx from 'y'`
AnyJsImportLike::JsImportNamespaceClause(clause) => clause.local_name().ok(),
// `import {x as xx} from 'y'`
// ^^^^^^^
AnyJsImportLike::JsNamedImportSpecifier(specifier) => specifier.local_name().ok(),
Expand Down Expand Up @@ -125,5 +122,5 @@ impl Rule for NoImportAssign {
}

declare_node_union! {
pub(crate) AnyJsImportLike = JsImportDefaultClause | JsImportNamespaceClause | JsNamedImportSpecifier | JsShorthandNamedImportSpecifier | JsNamespaceImportSpecifier | JsDefaultImportSpecifier
pub(crate) AnyJsImportLike = JsImportDefaultClause | JsNamedImportSpecifier | JsShorthandNamedImportSpecifier | JsNamespaceImportSpecifier | JsDefaultImportSpecifier
}
51 changes: 0 additions & 51 deletions crates/biome_js_factory/src/generated/node_factory.rs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

61 changes: 0 additions & 61 deletions crates/biome_js_factory/src/generated/syntax_factory.rs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

40 changes: 0 additions & 40 deletions crates/biome_js_formatter/src/generated.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6321,46 +6321,6 @@ impl IntoFormat<JsFormatContext> for biome_js_syntax::JsImportDefaultClause {
)
}
}
impl FormatRule<biome_js_syntax::JsImportNamespaceClause>
for crate::js::module::import_namespace_clause::FormatJsImportNamespaceClause
{
type Context = JsFormatContext;
#[inline(always)]
fn fmt(
&self,
node: &biome_js_syntax::JsImportNamespaceClause,
f: &mut JsFormatter,
) -> FormatResult<()> {
FormatNodeRule::<biome_js_syntax::JsImportNamespaceClause>::fmt(self, node, f)
}
}
impl AsFormat<JsFormatContext> for biome_js_syntax::JsImportNamespaceClause {
type Format<'a> = FormatRefWithRule<
'a,
biome_js_syntax::JsImportNamespaceClause,
crate::js::module::import_namespace_clause::FormatJsImportNamespaceClause,
>;
fn format(&self) -> Self::Format<'_> {
#![allow(clippy::default_constructed_unit_structs)]
FormatRefWithRule::new(
self,
crate::js::module::import_namespace_clause::FormatJsImportNamespaceClause::default(),
)
}
}
impl IntoFormat<JsFormatContext> for biome_js_syntax::JsImportNamespaceClause {
type Format = FormatOwnedWithRule<
biome_js_syntax::JsImportNamespaceClause,
crate::js::module::import_namespace_clause::FormatJsImportNamespaceClause,
>;
fn into_format(self) -> Self::Format {
#![allow(clippy::default_constructed_unit_structs)]
FormatOwnedWithRule::new(
self,
crate::js::module::import_namespace_clause::FormatJsImportNamespaceClause::default(),
)
}
}
impl FormatRule<biome_js_syntax::JsModuleSource>
for crate::js::module::module_source::FormatJsModuleSource
{
Expand Down
1 change: 0 additions & 1 deletion crates/biome_js_formatter/src/js/any/import_clause.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ impl FormatRule<AnyJsImportClause> for FormatAnyJsImportClause {
AnyJsImportClause::JsImportBareClause(node) => node.format().fmt(f),
AnyJsImportClause::JsImportNamedClause(node) => node.format().fmt(f),
AnyJsImportClause::JsImportDefaultClause(node) => node.format().fmt(f),
AnyJsImportClause::JsImportNamespaceClause(node) => node.format().fmt(f),
}
}
}
47 changes: 0 additions & 47 deletions crates/biome_js_formatter/src/js/module/import_namespace_clause.rs

This file was deleted.

1 change: 0 additions & 1 deletion crates/biome_js_formatter/src/js/module/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ pub(crate) mod import_assertion_entry;
pub(crate) mod import_bare_clause;
pub(crate) mod import_default_clause;
pub(crate) mod import_named_clause;
pub(crate) mod import_namespace_clause;
pub(crate) mod literal_export_name;
pub(crate) mod module_source;
pub(crate) mod named_import_specifier;
Expand Down
17 changes: 1 addition & 16 deletions crates/biome_js_parser/src/syntax/module.rs
Original file line number Diff line number Diff line change
Expand Up @@ -280,8 +280,7 @@ fn parse_import_clause(p: &mut JsParser) -> ParsedSyntax {
}

let clause = match p.cur() {
T![*] => parse_import_namespace_clause_rest(p, m),
T!['{'] => parse_import_named_clause_rest(p, m),
T![*] | T!['{'] => parse_import_named_clause_rest(p, m),
_ if is_at_identifier_binding(p) => {
parse_identifier_binding(p).unwrap();
parse_import_default_or_named_clause_rest(p, m, is_typed)
Expand Down Expand Up @@ -358,20 +357,6 @@ fn parse_import_bare_clause(p: &mut JsParser) -> ParsedSyntax {
})
}

// test js import_decl
// import * as foo from "bla";
fn parse_import_namespace_clause_rest(p: &mut JsParser, m: Marker) -> CompletedMarker {
p.expect(T![*]);

p.expect(T![as]);
parse_binding(p).or_add_diagnostic(p, expected_binding);
p.expect(T![from]);
parse_module_source(p).or_add_diagnostic(p, expected_module_source);
parse_import_assertion(p).ok();

m.complete(p, JS_IMPORT_NAMESPACE_CLAUSE)
}

// test js import_named_clause
// import {} from "a";
// import { a, b, c, } from "b";
Expand Down
Loading