From 15726c58922928f80d63da776b3bbf44c06c15db Mon Sep 17 00:00:00 2001 From: Carson McManus Date: Wed, 23 Oct 2024 16:54:52 -0400 Subject: [PATCH] refactor(parser/js): rename import assertions to import attributes --- .../src/lint/correctness/no_unused_imports.rs | 8 +- .../src/lint/nursery/use_explicit_type.rs | 6 +- .../src/lint/style/use_import_type.rs | 4 +- .../no_type_only_import_attributes.rs | 12 +- .../src/generated/node_factory.rs | 104 +++---- .../src/generated/syntax_factory.rs | 34 +-- crates/biome_js_formatter/src/comments.rs | 2 +- crates/biome_js_formatter/src/format.rs | 4 +- crates/biome_js_formatter/src/generated.rs | 104 +++---- .../src/js/any/import_assertion_entry.rs | 15 - .../src/js/any/import_attribute_entry.rs | 15 + crates/biome_js_formatter/src/js/any/mod.rs | 2 +- .../js/bogus/bogus_import_assertion_entry.rs | 7 - .../js/bogus/bogus_import_attribute_entry.rs | 5 + crates/biome_js_formatter/src/js/bogus/mod.rs | 2 +- ...list.rs => import_attribute_entry_list.rs} | 8 +- crates/biome_js_formatter/src/js/lists/mod.rs | 2 +- .../src/js/module/export_from_clause.rs | 6 +- .../src/js/module/export_named_from_clause.rs | 6 +- ...mport_assertion.rs => import_attribute.rs} | 20 +- ...ion_entry.rs => import_attribute_entry.rs} | 14 +- .../src/js/module/import_bare_clause.rs | 6 +- .../src/js/module/import_combined_clause.rs | 6 +- .../src/js/module/import_default_clause.rs | 6 +- .../src/js/module/import_named_clause.rs | 6 +- .../src/js/module/import_namespace_clause.rs | 6 +- .../biome_js_formatter/src/js/module/mod.rs | 4 +- crates/biome_js_parser/README.md | 8 + crates/biome_js_parser/src/syntax/module.rs | 31 +- .../inline/err/export_decl_not_top_level.rast | 2 +- .../inline/err/export_from_clause_err.rast | 16 +- .../err/export_named_from_clause_err.rast | 4 +- .../inline/err/import_as_identifier_err.rast | 2 +- .../inline/err/import_assertion_err.rast | 16 +- .../inline/err/import_attribute_err.rast | 92 +++--- .../inline/err/import_decl_not_top_level.rast | 2 +- .../test_data/inline/err/import_err.rast | 16 +- .../err/ts_named_import_specifier_error.rast | 10 +- .../inline/ok/export_from_clause.rast | 26 +- .../inline/ok/export_named_from_clause.rast | 26 +- .../inline/ok/import_as_as_as_identifier.rast | 2 +- .../inline/ok/import_as_identifier.rast | 2 +- .../test_data/inline/ok/import_attribute.rast | 76 ++--- .../inline/ok/import_bare_clause.rast | 4 +- .../test_data/inline/ok/import_decl.rast | 2 +- .../inline/ok/import_default_clause.rast | 2 +- .../inline/ok/import_default_clauses.rast | 2 +- .../inline/ok/import_named_clause.rast | 6 +- .../test_data/inline/ok/metavar.rast | 4 +- .../test_data/inline/ok/module.rast | 4 +- ...export_named_from_specifier_with_type.rast | 4 +- .../inline/ok/ts_export_type_named_from.rast | 2 +- .../inline/ok/ts_import_clause_types.rast | 10 +- .../ts_named_import_specifier_with_type.rast | 10 +- crates/biome_js_syntax/src/generated/kind.rs | 10 +- .../biome_js_syntax/src/generated/macros.rs | 16 +- crates/biome_js_syntax/src/generated/nodes.rs | 272 +++++++++--------- .../src/generated/nodes_mut.rs | 20 +- crates/biome_js_syntax/src/import_ext.rs | 16 +- crates/biome_js_syntax/src/lib.rs | 4 +- xtask/codegen/js.ungram | 38 +-- xtask/codegen/src/js_kinds_src.rs | 8 +- 62 files changed, 592 insertions(+), 587 deletions(-) delete mode 100644 crates/biome_js_formatter/src/js/any/import_assertion_entry.rs create mode 100644 crates/biome_js_formatter/src/js/any/import_attribute_entry.rs delete mode 100644 crates/biome_js_formatter/src/js/bogus/bogus_import_assertion_entry.rs create mode 100644 crates/biome_js_formatter/src/js/bogus/bogus_import_attribute_entry.rs rename crates/biome_js_formatter/src/js/lists/{import_assertion_entry_list.rs => import_attribute_entry_list.rs} (66%) rename crates/biome_js_formatter/src/js/module/{import_assertion.rs => import_attribute.rs} (76%) rename crates/biome_js_formatter/src/js/module/{import_assertion_entry.rs => import_attribute_entry.rs} (77%) diff --git a/crates/biome_js_analyze/src/lint/correctness/no_unused_imports.rs b/crates/biome_js_analyze/src/lint/correctness/no_unused_imports.rs index fece37913250..a1b53e044fd9 100644 --- a/crates/biome_js_analyze/src/lint/correctness/no_unused_imports.rs +++ b/crates/biome_js_analyze/src/lint/correctness/no_unused_imports.rs @@ -178,14 +178,14 @@ fn remove_import_specifier( let default_specifier = default_extra_clause.default_specifier().ok()?; let from_token = default_extra_clause.from_token().ok()?; let source = default_extra_clause.source().ok()?; - let assertion = default_extra_clause.assertion(); + let assertion = default_extra_clause.attribute(); if default_specifier.syntax() == specifier { let new_clause = match default_extra_clause.specifier().ok()? { AnyJsCombinedSpecifier::JsNamedImportSpecifiers(named_specifier) => { let named_clause = make::js_import_named_clause(named_specifier, from_token, source); let named_clause = if let Some(assertion) = assertion { - named_clause.with_assertion(assertion) + named_clause.with_attribute(assertion) } else { named_clause }; @@ -198,7 +198,7 @@ fn remove_import_specifier( source, ); let namespace_clause = if let Some(assertion) = assertion { - namespace_clause.with_assertion(assertion) + namespace_clause.with_attribute(assertion) } else { namespace_clause }; @@ -212,7 +212,7 @@ fn remove_import_specifier( let default_clause = make::js_import_default_clause(default_specifier, from_token, source); let default_clause = if let Some(assertion) = assertion { - default_clause.with_assertion(assertion) + default_clause.with_attribute(assertion) } else { default_clause }; diff --git a/crates/biome_js_analyze/src/lint/nursery/use_explicit_type.rs b/crates/biome_js_analyze/src/lint/nursery/use_explicit_type.rs index e76dcf20e480..ed367de9ddee 100644 --- a/crates/biome_js_analyze/src/lint/nursery/use_explicit_type.rs +++ b/crates/biome_js_analyze/src/lint/nursery/use_explicit_type.rs @@ -533,7 +533,7 @@ fn is_property_of_object_with_type(syntax: &SyntaxNode) -> bool { /// const castTyped = <() => string>(() => ''); /// ``` fn is_type_assertion(syntax: &SyntaxNode) -> bool { - fn is_assertion_kind(kind: JsSyntaxKind) -> bool { + fn is_attribute_kind(kind: JsSyntaxKind) -> bool { matches!( kind, JsSyntaxKind::TS_AS_EXPRESSION | JsSyntaxKind::TS_TYPE_ASSERTION_EXPRESSION @@ -544,9 +544,9 @@ fn is_type_assertion(syntax: &SyntaxNode) -> bool { if parent.kind() == JsSyntaxKind::JS_PARENTHESIZED_EXPRESSION { parent .parent() - .is_some_and(|grandparent| is_assertion_kind(grandparent.kind())) + .is_some_and(|grandparent| is_attribute_kind(grandparent.kind())) } else { - is_assertion_kind(parent.kind()) + is_attribute_kind(parent.kind()) } }) } diff --git a/crates/biome_js_analyze/src/lint/style/use_import_type.rs b/crates/biome_js_analyze/src/lint/style/use_import_type.rs index 3bf082d239af..aaf428b27548 100644 --- a/crates/biome_js_analyze/src/lint/style/use_import_type.rs +++ b/crates/biome_js_analyze/src/lint/style/use_import_type.rs @@ -133,11 +133,11 @@ impl Rule for UseImportType { } let import = ctx.query(); let import_clause = import.import_clause().ok()?; - if import_clause.assertion().is_some() { + if import_clause.attribute().is_some() { return None; } // Import attributes and type-only imports are not compatible. - if import_clause.assertion().is_some() { + if import_clause.attribute().is_some() { return None; } let model = ctx.model(); diff --git a/crates/biome_js_analyze/src/syntax/correctness/no_type_only_import_attributes.rs b/crates/biome_js_analyze/src/syntax/correctness/no_type_only_import_attributes.rs index 84a58e732c90..c1725e5ec78e 100644 --- a/crates/biome_js_analyze/src/syntax/correctness/no_type_only_import_attributes.rs +++ b/crates/biome_js_analyze/src/syntax/correctness/no_type_only_import_attributes.rs @@ -56,11 +56,11 @@ impl Rule for NoTypeOnlyImportAttributes { | AnyJsExportClause::TsExportAssignmentClause(_) | AnyJsExportClause::TsExportDeclareClause(_) => None, AnyJsExportClause::JsExportFromClause(clause) => Some(RuleState { - assertion_range: clause.assertion()?.range(), + assertion_range: clause.attribute()?.range(), type_token_range: clause.type_token()?.text_trimmed_range(), }), AnyJsExportClause::JsExportNamedFromClause(clause) => { - let assertion_range = clause.assertion()?.range(); + let assertion_range = clause.attribute()?.range(); let type_token = clause.type_token().or_else(|| { clause .specifiers() @@ -77,7 +77,7 @@ impl Rule for NoTypeOnlyImportAttributes { AnyJsModuleItem::JsImport(import) => match import.import_clause().ok()? { AnyJsImportClause::JsImportBareClause(_) => None, AnyJsImportClause::JsImportCombinedClause(clause) => { - let assertion_range = clause.assertion()?.range(); + let assertion_range = clause.attribute()?.range(); let type_token = find_first_type_token( clause.specifier().ok()?.as_js_named_import_specifiers()?, )?; @@ -87,11 +87,11 @@ impl Rule for NoTypeOnlyImportAttributes { }) } AnyJsImportClause::JsImportDefaultClause(clause) => Some(RuleState { - assertion_range: clause.assertion()?.range(), + assertion_range: clause.attribute()?.range(), type_token_range: clause.type_token()?.text_trimmed_range(), }), AnyJsImportClause::JsImportNamedClause(clause) => { - let assertion_range = clause.assertion()?.range(); + let assertion_range = clause.attribute()?.range(); let type_token = clause .type_token() .or_else(|| find_first_type_token(&clause.named_specifiers().ok()?))?; @@ -101,7 +101,7 @@ impl Rule for NoTypeOnlyImportAttributes { }) } AnyJsImportClause::JsImportNamespaceClause(clause) => Some(RuleState { - assertion_range: clause.assertion()?.range(), + assertion_range: clause.attribute()?.range(), type_token_range: clause.type_token()?.text_trimmed_range(), }), }, diff --git a/crates/biome_js_factory/src/generated/node_factory.rs b/crates/biome_js_factory/src/generated/node_factory.rs index d4b1b7579a77..be4a75d5ded3 100644 --- a/crates/biome_js_factory/src/generated/node_factory.rs +++ b/crates/biome_js_factory/src/generated/node_factory.rs @@ -1043,7 +1043,7 @@ pub fn js_export_from_clause( source, type_token: None, export_as: None, - assertion: None, + attribute: None, semicolon_token: None, } } @@ -1053,7 +1053,7 @@ pub struct JsExportFromClauseBuilder { source: AnyJsModuleSource, type_token: Option, export_as: Option, - assertion: Option, + attribute: Option, semicolon_token: Option, } impl JsExportFromClauseBuilder { @@ -1065,8 +1065,8 @@ impl JsExportFromClauseBuilder { self.export_as = Some(export_as); self } - pub fn with_assertion(mut self, assertion: JsImportAssertion) -> Self { - self.assertion = Some(assertion); + pub fn with_attribute(mut self, attribute: JsImportAttribute) -> Self { + self.attribute = Some(attribute); self } pub fn with_semicolon_token(mut self, semicolon_token: SyntaxToken) -> Self { @@ -1083,7 +1083,7 @@ impl JsExportFromClauseBuilder { .map(|token| SyntaxElement::Node(token.into_syntax())), Some(SyntaxElement::Token(self.from_token)), Some(SyntaxElement::Node(self.source.into_syntax())), - self.assertion + self.attribute .map(|token| SyntaxElement::Node(token.into_syntax())), self.semicolon_token .map(|token| SyntaxElement::Token(token)), @@ -1148,7 +1148,7 @@ pub fn js_export_named_from_clause( from_token, source, type_token: None, - assertion: None, + attribute: None, semicolon_token: None, } } @@ -1159,7 +1159,7 @@ pub struct JsExportNamedFromClauseBuilder { from_token: SyntaxToken, source: AnyJsModuleSource, type_token: Option, - assertion: Option, + attribute: Option, semicolon_token: Option, } impl JsExportNamedFromClauseBuilder { @@ -1167,8 +1167,8 @@ impl JsExportNamedFromClauseBuilder { self.type_token = Some(type_token); self } - pub fn with_assertion(mut self, assertion: JsImportAssertion) -> Self { - self.assertion = Some(assertion); + pub fn with_attribute(mut self, attribute: JsImportAttribute) -> Self { + self.attribute = Some(attribute); self } pub fn with_semicolon_token(mut self, semicolon_token: SyntaxToken) -> Self { @@ -1185,7 +1185,7 @@ impl JsExportNamedFromClauseBuilder { Some(SyntaxElement::Token(self.r_curly_token)), Some(SyntaxElement::Token(self.from_token)), Some(SyntaxElement::Node(self.source.into_syntax())), - self.assertion + self.attribute .map(|token| SyntaxElement::Node(token.into_syntax())), self.semicolon_token .map(|token| SyntaxElement::Token(token)), @@ -1987,29 +1987,29 @@ impl JsImportBuilder { )) } } -pub fn js_import_assertion( +pub fn js_import_attribute( with_token: SyntaxToken, l_curly_token: SyntaxToken, - assertions: JsImportAssertionEntryList, + attributes: JsImportAttributeEntryList, r_curly_token: SyntaxToken, -) -> JsImportAssertion { - JsImportAssertion::unwrap_cast(SyntaxNode::new_detached( - JsSyntaxKind::JS_IMPORT_ASSERTION, +) -> JsImportAttribute { + JsImportAttribute::unwrap_cast(SyntaxNode::new_detached( + JsSyntaxKind::JS_IMPORT_ATTRIBUTE, [ Some(SyntaxElement::Token(with_token)), Some(SyntaxElement::Token(l_curly_token)), - Some(SyntaxElement::Node(assertions.into_syntax())), + Some(SyntaxElement::Node(attributes.into_syntax())), Some(SyntaxElement::Token(r_curly_token)), ], )) } -pub fn js_import_assertion_entry( +pub fn js_import_attribute_entry( key_token: SyntaxToken, colon_token: SyntaxToken, value_token: SyntaxToken, -) -> JsImportAssertionEntry { - JsImportAssertionEntry::unwrap_cast(SyntaxNode::new_detached( - JsSyntaxKind::JS_IMPORT_ASSERTION_ENTRY, +) -> JsImportAttributeEntry { + JsImportAttributeEntry::unwrap_cast(SyntaxNode::new_detached( + JsSyntaxKind::JS_IMPORT_ATTRIBUTE_ENTRY, [ Some(SyntaxElement::Token(key_token)), Some(SyntaxElement::Token(colon_token)), @@ -2020,16 +2020,16 @@ pub fn js_import_assertion_entry( pub fn js_import_bare_clause(source: AnyJsModuleSource) -> JsImportBareClauseBuilder { JsImportBareClauseBuilder { source, - assertion: None, + attribute: None, } } pub struct JsImportBareClauseBuilder { source: AnyJsModuleSource, - assertion: Option, + attribute: Option, } impl JsImportBareClauseBuilder { - pub fn with_assertion(mut self, assertion: JsImportAssertion) -> Self { - self.assertion = Some(assertion); + pub fn with_attribute(mut self, attribute: JsImportAttribute) -> Self { + self.attribute = Some(attribute); self } pub fn build(self) -> JsImportBareClause { @@ -2037,7 +2037,7 @@ impl JsImportBareClauseBuilder { JsSyntaxKind::JS_IMPORT_BARE_CLAUSE, [ Some(SyntaxElement::Node(self.source.into_syntax())), - self.assertion + self.attribute .map(|token| SyntaxElement::Node(token.into_syntax())), ], )) @@ -2068,7 +2068,7 @@ pub fn js_import_combined_clause( specifier, from_token, source, - assertion: None, + attribute: None, } } pub struct JsImportCombinedClauseBuilder { @@ -2077,11 +2077,11 @@ pub struct JsImportCombinedClauseBuilder { specifier: AnyJsCombinedSpecifier, from_token: SyntaxToken, source: AnyJsModuleSource, - assertion: Option, + attribute: Option, } impl JsImportCombinedClauseBuilder { - pub fn with_assertion(mut self, assertion: JsImportAssertion) -> Self { - self.assertion = Some(assertion); + pub fn with_attribute(mut self, attribute: JsImportAttribute) -> Self { + self.attribute = Some(attribute); self } pub fn build(self) -> JsImportCombinedClause { @@ -2093,7 +2093,7 @@ impl JsImportCombinedClauseBuilder { Some(SyntaxElement::Node(self.specifier.into_syntax())), Some(SyntaxElement::Token(self.from_token)), Some(SyntaxElement::Node(self.source.into_syntax())), - self.assertion + self.attribute .map(|token| SyntaxElement::Node(token.into_syntax())), ], )) @@ -2109,7 +2109,7 @@ pub fn js_import_default_clause( from_token, source, type_token: None, - assertion: None, + attribute: None, } } pub struct JsImportDefaultClauseBuilder { @@ -2117,15 +2117,15 @@ pub struct JsImportDefaultClauseBuilder { from_token: SyntaxToken, source: AnyJsModuleSource, type_token: Option, - assertion: Option, + attribute: Option, } impl JsImportDefaultClauseBuilder { pub fn with_type_token(mut self, type_token: SyntaxToken) -> Self { self.type_token = Some(type_token); self } - pub fn with_assertion(mut self, assertion: JsImportAssertion) -> Self { - self.assertion = Some(assertion); + pub fn with_attribute(mut self, attribute: JsImportAttribute) -> Self { + self.attribute = Some(attribute); self } pub fn build(self) -> JsImportDefaultClause { @@ -2136,7 +2136,7 @@ impl JsImportDefaultClauseBuilder { Some(SyntaxElement::Node(self.default_specifier.into_syntax())), Some(SyntaxElement::Token(self.from_token)), Some(SyntaxElement::Node(self.source.into_syntax())), - self.assertion + self.attribute .map(|token| SyntaxElement::Node(token.into_syntax())), ], )) @@ -2166,7 +2166,7 @@ pub fn js_import_named_clause( from_token, source, type_token: None, - assertion: None, + attribute: None, } } pub struct JsImportNamedClauseBuilder { @@ -2174,15 +2174,15 @@ pub struct JsImportNamedClauseBuilder { from_token: SyntaxToken, source: AnyJsModuleSource, type_token: Option, - assertion: Option, + attribute: Option, } impl JsImportNamedClauseBuilder { pub fn with_type_token(mut self, type_token: SyntaxToken) -> Self { self.type_token = Some(type_token); self } - pub fn with_assertion(mut self, assertion: JsImportAssertion) -> Self { - self.assertion = Some(assertion); + pub fn with_attribute(mut self, attribute: JsImportAttribute) -> Self { + self.attribute = Some(attribute); self } pub fn build(self) -> JsImportNamedClause { @@ -2193,7 +2193,7 @@ impl JsImportNamedClauseBuilder { Some(SyntaxElement::Node(self.named_specifiers.into_syntax())), Some(SyntaxElement::Token(self.from_token)), Some(SyntaxElement::Node(self.source.into_syntax())), - self.assertion + self.attribute .map(|token| SyntaxElement::Node(token.into_syntax())), ], )) @@ -2209,7 +2209,7 @@ pub fn js_import_namespace_clause( from_token, source, type_token: None, - assertion: None, + attribute: None, } } pub struct JsImportNamespaceClauseBuilder { @@ -2217,15 +2217,15 @@ pub struct JsImportNamespaceClauseBuilder { from_token: SyntaxToken, source: AnyJsModuleSource, type_token: Option, - assertion: Option, + attribute: Option, } impl JsImportNamespaceClauseBuilder { pub fn with_type_token(mut self, type_token: SyntaxToken) -> Self { self.type_token = Some(type_token); self } - pub fn with_assertion(mut self, assertion: JsImportAssertion) -> Self { - self.assertion = Some(assertion); + pub fn with_attribute(mut self, attribute: JsImportAttribute) -> Self { + self.attribute = Some(attribute); self } pub fn build(self) -> JsImportNamespaceClause { @@ -2236,7 +2236,7 @@ impl JsImportNamespaceClauseBuilder { Some(SyntaxElement::Node(self.namespace_specifier.into_syntax())), Some(SyntaxElement::Token(self.from_token)), Some(SyntaxElement::Node(self.source.into_syntax())), - self.assertion + self.attribute .map(|token| SyntaxElement::Node(token.into_syntax())), ], )) @@ -6780,9 +6780,9 @@ where }), )) } -pub fn js_import_assertion_entry_list(items: I, separators: S) -> JsImportAssertionEntryList +pub fn js_import_attribute_entry_list(items: I, separators: S) -> JsImportAttributeEntryList where - I: IntoIterator, + I: IntoIterator, I::IntoIter: ExactSizeIterator, S: IntoIterator, S::IntoIter: ExactSizeIterator, @@ -6790,8 +6790,8 @@ where let mut items = items.into_iter(); let mut separators = separators.into_iter(); let length = items.len() + separators.len(); - JsImportAssertionEntryList::unwrap_cast(SyntaxNode::new_detached( - JsSyntaxKind::JS_IMPORT_ASSERTION_ENTRY_LIST, + JsImportAttributeEntryList::unwrap_cast(SyntaxNode::new_detached( + JsSyntaxKind::JS_IMPORT_ATTRIBUTE_ENTRY_LIST, (0..length).map(|index| { if index % 2 == 0 { Some(items.next()?.into_syntax().into()) @@ -7300,13 +7300,13 @@ where slots, )) } -pub fn js_bogus_import_assertion_entry(slots: I) -> JsBogusImportAssertionEntry +pub fn js_bogus_import_attribute_entry(slots: I) -> JsBogusImportAttributeEntry where I: IntoIterator>, I::IntoIter: ExactSizeIterator, { - JsBogusImportAssertionEntry::unwrap_cast(SyntaxNode::new_detached( - JsSyntaxKind::JS_BOGUS_IMPORT_ASSERTION_ENTRY, + JsBogusImportAttributeEntry::unwrap_cast(SyntaxNode::new_detached( + JsSyntaxKind::JS_BOGUS_IMPORT_ATTRIBUTE_ENTRY, slots, )) } diff --git a/crates/biome_js_factory/src/generated/syntax_factory.rs b/crates/biome_js_factory/src/generated/syntax_factory.rs index 04985d8a2bf1..b90c7b506efe 100644 --- a/crates/biome_js_factory/src/generated/syntax_factory.rs +++ b/crates/biome_js_factory/src/generated/syntax_factory.rs @@ -18,7 +18,7 @@ impl SyntaxFactory for JsSyntaxFactory { | JS_BOGUS_ASSIGNMENT | JS_BOGUS_BINDING | JS_BOGUS_EXPRESSION - | JS_BOGUS_IMPORT_ASSERTION_ENTRY + | JS_BOGUS_IMPORT_ATTRIBUTE_ENTRY | JS_BOGUS_MEMBER | JS_BOGUS_NAMED_IMPORT_SPECIFIER | JS_BOGUS_PARAMETER @@ -1666,7 +1666,7 @@ impl SyntaxFactory for JsSyntaxFactory { } slots.next_slot(); if let Some(element) = ¤t_element { - if JsImportAssertion::can_cast(element.kind()) { + if JsImportAttribute::can_cast(element.kind()) { slots.mark_present(); current_element = elements.next(); } @@ -1781,7 +1781,7 @@ impl SyntaxFactory for JsSyntaxFactory { } slots.next_slot(); if let Some(element) = ¤t_element { - if JsImportAssertion::can_cast(element.kind()) { + if JsImportAttribute::can_cast(element.kind()) { slots.mark_present(); current_element = elements.next(); } @@ -2799,7 +2799,7 @@ impl SyntaxFactory for JsSyntaxFactory { } slots.into_node(JS_IMPORT, children) } - JS_IMPORT_ASSERTION => { + JS_IMPORT_ATTRIBUTE => { let mut elements = (&children).into_iter(); let mut slots: RawNodeSlots<4usize> = RawNodeSlots::default(); let mut current_element = elements.next(); @@ -2818,7 +2818,7 @@ impl SyntaxFactory for JsSyntaxFactory { } slots.next_slot(); if let Some(element) = ¤t_element { - if JsImportAssertionEntryList::can_cast(element.kind()) { + if JsImportAttributeEntryList::can_cast(element.kind()) { slots.mark_present(); current_element = elements.next(); } @@ -2833,13 +2833,13 @@ impl SyntaxFactory for JsSyntaxFactory { slots.next_slot(); if current_element.is_some() { return RawSyntaxNode::new( - JS_IMPORT_ASSERTION.to_bogus(), + JS_IMPORT_ATTRIBUTE.to_bogus(), children.into_iter().map(Some), ); } - slots.into_node(JS_IMPORT_ASSERTION, children) + slots.into_node(JS_IMPORT_ATTRIBUTE, children) } - JS_IMPORT_ASSERTION_ENTRY => { + JS_IMPORT_ATTRIBUTE_ENTRY => { let mut elements = (&children).into_iter(); let mut slots: RawNodeSlots<3usize> = RawNodeSlots::default(); let mut current_element = elements.next(); @@ -2866,11 +2866,11 @@ impl SyntaxFactory for JsSyntaxFactory { slots.next_slot(); if current_element.is_some() { return RawSyntaxNode::new( - JS_IMPORT_ASSERTION_ENTRY.to_bogus(), + JS_IMPORT_ATTRIBUTE_ENTRY.to_bogus(), children.into_iter().map(Some), ); } - slots.into_node(JS_IMPORT_ASSERTION_ENTRY, children) + slots.into_node(JS_IMPORT_ATTRIBUTE_ENTRY, children) } JS_IMPORT_BARE_CLAUSE => { let mut elements = (&children).into_iter(); @@ -2884,7 +2884,7 @@ impl SyntaxFactory for JsSyntaxFactory { } slots.next_slot(); if let Some(element) = ¤t_element { - if JsImportAssertion::can_cast(element.kind()) { + if JsImportAttribute::can_cast(element.kind()) { slots.mark_present(); current_element = elements.next(); } @@ -2964,7 +2964,7 @@ impl SyntaxFactory for JsSyntaxFactory { } slots.next_slot(); if let Some(element) = ¤t_element { - if JsImportAssertion::can_cast(element.kind()) { + if JsImportAttribute::can_cast(element.kind()) { slots.mark_present(); current_element = elements.next(); } @@ -3011,7 +3011,7 @@ impl SyntaxFactory for JsSyntaxFactory { } slots.next_slot(); if let Some(element) = ¤t_element { - if JsImportAssertion::can_cast(element.kind()) { + if JsImportAttribute::can_cast(element.kind()) { slots.mark_present(); current_element = elements.next(); } @@ -3091,7 +3091,7 @@ impl SyntaxFactory for JsSyntaxFactory { } slots.next_slot(); if let Some(element) = ¤t_element { - if JsImportAssertion::can_cast(element.kind()) { + if JsImportAttribute::can_cast(element.kind()) { slots.mark_present(); current_element = elements.next(); } @@ -3138,7 +3138,7 @@ impl SyntaxFactory for JsSyntaxFactory { } slots.next_slot(); if let Some(element) = ¤t_element { - if JsImportAssertion::can_cast(element.kind()) { + if JsImportAttribute::can_cast(element.kind()) { slots.mark_present(); current_element = elements.next(); } @@ -9957,10 +9957,10 @@ impl SyntaxFactory for JsSyntaxFactory { T ! [,], true, ), - JS_IMPORT_ASSERTION_ENTRY_LIST => Self::make_separated_list_syntax( + JS_IMPORT_ATTRIBUTE_ENTRY_LIST => Self::make_separated_list_syntax( kind, children, - AnyJsImportAssertionEntry::can_cast, + AnyJsImportAttributeEntry::can_cast, T ! [,], true, ), diff --git a/crates/biome_js_formatter/src/comments.rs b/crates/biome_js_formatter/src/comments.rs index 21496779d9f8..f22551764541 100644 --- a/crates/biome_js_formatter/src/comments.rs +++ b/crates/biome_js_formatter/src/comments.rs @@ -1248,7 +1248,7 @@ fn handle_import_export_specifier_comment( CommentPlacement::leading(enclosing_node.clone(), comment) } // Make end of line or own line comments in the middle of an import assertion a leading comment of the assertion - JsSyntaxKind::JS_IMPORT_ASSERTION_ENTRY => { + JsSyntaxKind::JS_IMPORT_ATTRIBUTE_ENTRY => { CommentPlacement::leading(enclosing_node.clone(), comment) } diff --git a/crates/biome_js_formatter/src/format.rs b/crates/biome_js_formatter/src/format.rs index 0b85d670155f..2e7300f23702 100644 --- a/crates/biome_js_formatter/src/format.rs +++ b/crates/biome_js_formatter/src/format.rs @@ -827,7 +827,7 @@ impl Format for biome_js_syntax::JsModuleSource { self.format_node(formatter) } } -impl Format for biome_js_syntax::JsImportAssertion { +impl Format for biome_js_syntax::JsImportAttribute { fn format(&self, formatter: &Formatter) -> FormatResult { self.format_node(formatter) } @@ -862,7 +862,7 @@ impl Format for biome_js_syntax::JsLiteralExportName { self.format_node(formatter) } } -impl Format for biome_js_syntax::JsImportAssertionEntry { +impl Format for biome_js_syntax::JsImportAttributeEntry { fn format(&self, formatter: &Formatter) -> FormatResult { self.format_node(formatter) } diff --git a/crates/biome_js_formatter/src/generated.rs b/crates/biome_js_formatter/src/generated.rs index ec0e5390460c..3452b38b9a42 100644 --- a/crates/biome_js_formatter/src/generated.rs +++ b/crates/biome_js_formatter/src/generated.rs @@ -2572,83 +2572,83 @@ impl IntoFormat for biome_js_syntax::JsImport { FormatOwnedWithRule::new(self, crate::js::module::import::FormatJsImport::default()) } } -impl FormatRule - for crate::js::module::import_assertion::FormatJsImportAssertion +impl FormatRule + for crate::js::module::import_attribute::FormatJsImportAttribute { type Context = JsFormatContext; #[inline(always)] fn fmt( &self, - node: &biome_js_syntax::JsImportAssertion, + node: &biome_js_syntax::JsImportAttribute, f: &mut JsFormatter, ) -> FormatResult<()> { - FormatNodeRule::::fmt(self, node, f) + FormatNodeRule::::fmt(self, node, f) } } -impl AsFormat for biome_js_syntax::JsImportAssertion { +impl AsFormat for biome_js_syntax::JsImportAttribute { type Format<'a> = FormatRefWithRule< 'a, - biome_js_syntax::JsImportAssertion, - crate::js::module::import_assertion::FormatJsImportAssertion, + biome_js_syntax::JsImportAttribute, + crate::js::module::import_attribute::FormatJsImportAttribute, >; fn format(&self) -> Self::Format<'_> { #![allow(clippy::default_constructed_unit_structs)] FormatRefWithRule::new( self, - crate::js::module::import_assertion::FormatJsImportAssertion::default(), + crate::js::module::import_attribute::FormatJsImportAttribute::default(), ) } } -impl IntoFormat for biome_js_syntax::JsImportAssertion { +impl IntoFormat for biome_js_syntax::JsImportAttribute { type Format = FormatOwnedWithRule< - biome_js_syntax::JsImportAssertion, - crate::js::module::import_assertion::FormatJsImportAssertion, + biome_js_syntax::JsImportAttribute, + crate::js::module::import_attribute::FormatJsImportAttribute, >; fn into_format(self) -> Self::Format { #![allow(clippy::default_constructed_unit_structs)] FormatOwnedWithRule::new( self, - crate::js::module::import_assertion::FormatJsImportAssertion::default(), + crate::js::module::import_attribute::FormatJsImportAttribute::default(), ) } } -impl FormatRule - for crate::js::module::import_assertion_entry::FormatJsImportAssertionEntry +impl FormatRule + for crate::js::module::import_attribute_entry::FormatJsImportAttributeEntry { type Context = JsFormatContext; #[inline(always)] fn fmt( &self, - node: &biome_js_syntax::JsImportAssertionEntry, + node: &biome_js_syntax::JsImportAttributeEntry, f: &mut JsFormatter, ) -> FormatResult<()> { - FormatNodeRule::::fmt(self, node, f) + FormatNodeRule::::fmt(self, node, f) } } -impl AsFormat for biome_js_syntax::JsImportAssertionEntry { +impl AsFormat for biome_js_syntax::JsImportAttributeEntry { type Format<'a> = FormatRefWithRule< 'a, - biome_js_syntax::JsImportAssertionEntry, - crate::js::module::import_assertion_entry::FormatJsImportAssertionEntry, + biome_js_syntax::JsImportAttributeEntry, + crate::js::module::import_attribute_entry::FormatJsImportAttributeEntry, >; fn format(&self) -> Self::Format<'_> { #![allow(clippy::default_constructed_unit_structs)] FormatRefWithRule::new( self, - crate::js::module::import_assertion_entry::FormatJsImportAssertionEntry::default(), + crate::js::module::import_attribute_entry::FormatJsImportAttributeEntry::default(), ) } } -impl IntoFormat for biome_js_syntax::JsImportAssertionEntry { +impl IntoFormat for biome_js_syntax::JsImportAttributeEntry { type Format = FormatOwnedWithRule< - biome_js_syntax::JsImportAssertionEntry, - crate::js::module::import_assertion_entry::FormatJsImportAssertionEntry, + biome_js_syntax::JsImportAttributeEntry, + crate::js::module::import_attribute_entry::FormatJsImportAttributeEntry, >; fn into_format(self) -> Self::Format { #![allow(clippy::default_constructed_unit_structs)] FormatOwnedWithRule::new( self, - crate::js::module::import_assertion_entry::FormatJsImportAssertionEntry::default(), + crate::js::module::import_attribute_entry::FormatJsImportAttributeEntry::default(), ) } } @@ -10707,25 +10707,25 @@ impl IntoFormat for biome_js_syntax::JsExportNamedSpecifierList FormatOwnedWithRule :: new (self , crate :: js :: lists :: export_named_specifier_list :: FormatJsExportNamedSpecifierList :: default ()) } } -impl AsFormat for biome_js_syntax::JsImportAssertionEntryList { +impl AsFormat for biome_js_syntax::JsImportAttributeEntryList { type Format<'a> = FormatRefWithRule< 'a, - biome_js_syntax::JsImportAssertionEntryList, - crate::js::lists::import_assertion_entry_list::FormatJsImportAssertionEntryList, + biome_js_syntax::JsImportAttributeEntryList, + crate::js::lists::import_attribute_entry_list::FormatJsImportAttributeEntryList, >; fn format(&self) -> Self::Format<'_> { #![allow(clippy::default_constructed_unit_structs)] - FormatRefWithRule :: new (self , crate :: js :: lists :: import_assertion_entry_list :: FormatJsImportAssertionEntryList :: default ()) + FormatRefWithRule :: new (self , crate :: js :: lists :: import_attribute_entry_list :: FormatJsImportAttributeEntryList :: default ()) } } -impl IntoFormat for biome_js_syntax::JsImportAssertionEntryList { +impl IntoFormat for biome_js_syntax::JsImportAttributeEntryList { type Format = FormatOwnedWithRule< - biome_js_syntax::JsImportAssertionEntryList, - crate::js::lists::import_assertion_entry_list::FormatJsImportAssertionEntryList, + biome_js_syntax::JsImportAttributeEntryList, + crate::js::lists::import_attribute_entry_list::FormatJsImportAttributeEntryList, >; fn into_format(self) -> Self::Format { #![allow(clippy::default_constructed_unit_structs)] - FormatOwnedWithRule :: new (self , crate :: js :: lists :: import_assertion_entry_list :: FormatJsImportAssertionEntryList :: default ()) + FormatOwnedWithRule :: new (self , crate :: js :: lists :: import_attribute_entry_list :: FormatJsImportAttributeEntryList :: default ()) } } impl AsFormat for biome_js_syntax::JsMethodModifierList { @@ -11555,38 +11555,38 @@ impl IntoFormat for biome_js_syntax::JsBogusExpression { ) } } -impl FormatRule - for crate::js::bogus::bogus_import_assertion_entry::FormatJsBogusImportAssertionEntry +impl FormatRule + for crate::js::bogus::bogus_import_attribute_entry::FormatJsBogusImportAttributeEntry { type Context = JsFormatContext; #[inline(always)] fn fmt( &self, - node: &biome_js_syntax::JsBogusImportAssertionEntry, + node: &biome_js_syntax::JsBogusImportAttributeEntry, f: &mut JsFormatter, ) -> FormatResult<()> { - FormatBogusNodeRule::::fmt(self, node, f) + FormatBogusNodeRule::::fmt(self, node, f) } } -impl AsFormat for biome_js_syntax::JsBogusImportAssertionEntry { +impl AsFormat for biome_js_syntax::JsBogusImportAttributeEntry { type Format<'a> = FormatRefWithRule< 'a, - biome_js_syntax::JsBogusImportAssertionEntry, - crate::js::bogus::bogus_import_assertion_entry::FormatJsBogusImportAssertionEntry, + biome_js_syntax::JsBogusImportAttributeEntry, + crate::js::bogus::bogus_import_attribute_entry::FormatJsBogusImportAttributeEntry, >; fn format(&self) -> Self::Format<'_> { #![allow(clippy::default_constructed_unit_structs)] - FormatRefWithRule :: new (self , crate :: js :: bogus :: bogus_import_assertion_entry :: FormatJsBogusImportAssertionEntry :: default ()) + FormatRefWithRule :: new (self , crate :: js :: bogus :: bogus_import_attribute_entry :: FormatJsBogusImportAttributeEntry :: default ()) } } -impl IntoFormat for biome_js_syntax::JsBogusImportAssertionEntry { +impl IntoFormat for biome_js_syntax::JsBogusImportAttributeEntry { type Format = FormatOwnedWithRule< - biome_js_syntax::JsBogusImportAssertionEntry, - crate::js::bogus::bogus_import_assertion_entry::FormatJsBogusImportAssertionEntry, + biome_js_syntax::JsBogusImportAttributeEntry, + crate::js::bogus::bogus_import_attribute_entry::FormatJsBogusImportAttributeEntry, >; fn into_format(self) -> Self::Format { #![allow(clippy::default_constructed_unit_structs)] - FormatOwnedWithRule :: new (self , crate :: js :: bogus :: bogus_import_assertion_entry :: FormatJsBogusImportAssertionEntry :: default ()) + FormatOwnedWithRule :: new (self , crate :: js :: bogus :: bogus_import_attribute_entry :: FormatJsBogusImportAttributeEntry :: default ()) } } impl FormatRule @@ -12442,30 +12442,30 @@ impl IntoFormat for biome_js_syntax::AnyJsFunctionBody { ) } } -impl AsFormat for biome_js_syntax::AnyJsImportAssertionEntry { +impl AsFormat for biome_js_syntax::AnyJsImportAttributeEntry { type Format<'a> = FormatRefWithRule< 'a, - biome_js_syntax::AnyJsImportAssertionEntry, - crate::js::any::import_assertion_entry::FormatAnyJsImportAssertionEntry, + biome_js_syntax::AnyJsImportAttributeEntry, + crate::js::any::import_attribute_entry::FormatAnyJsImportAttributeEntry, >; fn format(&self) -> Self::Format<'_> { #![allow(clippy::default_constructed_unit_structs)] FormatRefWithRule::new( self, - crate::js::any::import_assertion_entry::FormatAnyJsImportAssertionEntry::default(), + crate::js::any::import_attribute_entry::FormatAnyJsImportAttributeEntry::default(), ) } } -impl IntoFormat for biome_js_syntax::AnyJsImportAssertionEntry { +impl IntoFormat for biome_js_syntax::AnyJsImportAttributeEntry { type Format = FormatOwnedWithRule< - biome_js_syntax::AnyJsImportAssertionEntry, - crate::js::any::import_assertion_entry::FormatAnyJsImportAssertionEntry, + biome_js_syntax::AnyJsImportAttributeEntry, + crate::js::any::import_attribute_entry::FormatAnyJsImportAttributeEntry, >; fn into_format(self) -> Self::Format { #![allow(clippy::default_constructed_unit_structs)] FormatOwnedWithRule::new( self, - crate::js::any::import_assertion_entry::FormatAnyJsImportAssertionEntry::default(), + crate::js::any::import_attribute_entry::FormatAnyJsImportAttributeEntry::default(), ) } } diff --git a/crates/biome_js_formatter/src/js/any/import_assertion_entry.rs b/crates/biome_js_formatter/src/js/any/import_assertion_entry.rs deleted file mode 100644 index 3fc7fe563492..000000000000 --- a/crates/biome_js_formatter/src/js/any/import_assertion_entry.rs +++ /dev/null @@ -1,15 +0,0 @@ -//! This is a generated file. Don't modify it by hand! Run 'cargo codegen formatter' to re-generate the file. - -use crate::prelude::*; -use biome_js_syntax::AnyJsImportAssertionEntry; -#[derive(Debug, Clone, Default)] -pub(crate) struct FormatAnyJsImportAssertionEntry; -impl FormatRule for FormatAnyJsImportAssertionEntry { - type Context = JsFormatContext; - fn fmt(&self, node: &AnyJsImportAssertionEntry, f: &mut JsFormatter) -> FormatResult<()> { - match node { - AnyJsImportAssertionEntry::JsBogusImportAssertionEntry(node) => node.format().fmt(f), - AnyJsImportAssertionEntry::JsImportAssertionEntry(node) => node.format().fmt(f), - } - } -} diff --git a/crates/biome_js_formatter/src/js/any/import_attribute_entry.rs b/crates/biome_js_formatter/src/js/any/import_attribute_entry.rs new file mode 100644 index 000000000000..5472594ec99b --- /dev/null +++ b/crates/biome_js_formatter/src/js/any/import_attribute_entry.rs @@ -0,0 +1,15 @@ +//! This is a generated file. Don't modify it by hand! Run 'cargo codegen formatter' to re-generate the file. + +use crate::prelude::*; +use biome_js_syntax::AnyJsImportAttributeEntry; +#[derive(Debug, Clone, Default)] +pub(crate) struct FormatAnyJsImportAttributeEntry; +impl FormatRule for FormatAnyJsImportAttributeEntry { + type Context = JsFormatContext; + fn fmt(&self, node: &AnyJsImportAttributeEntry, f: &mut JsFormatter) -> FormatResult<()> { + match node { + AnyJsImportAttributeEntry::JsBogusImportAttributeEntry(node) => node.format().fmt(f), + AnyJsImportAttributeEntry::JsImportAttributeEntry(node) => node.format().fmt(f), + } + } +} diff --git a/crates/biome_js_formatter/src/js/any/mod.rs b/crates/biome_js_formatter/src/js/any/mod.rs index 95a61e6efc03..2abe553ddaf5 100644 --- a/crates/biome_js_formatter/src/js/any/mod.rs +++ b/crates/biome_js_formatter/src/js/any/mod.rs @@ -26,7 +26,7 @@ pub(crate) mod for_initializer; pub(crate) mod formal_parameter; pub(crate) mod function; pub(crate) mod function_body; -pub(crate) mod import_assertion_entry; +pub(crate) mod import_attribute_entry; pub(crate) mod import_clause; pub(crate) mod in_property; pub(crate) mod literal_expression; diff --git a/crates/biome_js_formatter/src/js/bogus/bogus_import_assertion_entry.rs b/crates/biome_js_formatter/src/js/bogus/bogus_import_assertion_entry.rs deleted file mode 100644 index fb0529211351..000000000000 --- a/crates/biome_js_formatter/src/js/bogus/bogus_import_assertion_entry.rs +++ /dev/null @@ -1,7 +0,0 @@ -use crate::FormatBogusNodeRule; -use biome_js_syntax::JsBogusImportAssertionEntry; - -#[derive(Debug, Clone, Default)] -pub(crate) struct FormatJsBogusImportAssertionEntry; - -impl FormatBogusNodeRule for FormatJsBogusImportAssertionEntry {} diff --git a/crates/biome_js_formatter/src/js/bogus/bogus_import_attribute_entry.rs b/crates/biome_js_formatter/src/js/bogus/bogus_import_attribute_entry.rs new file mode 100644 index 000000000000..ca66b4674b0e --- /dev/null +++ b/crates/biome_js_formatter/src/js/bogus/bogus_import_attribute_entry.rs @@ -0,0 +1,5 @@ +use crate::FormatBogusNodeRule; +use biome_js_syntax::JsBogusImportAttributeEntry; +#[derive(Debug, Clone, Default)] +pub(crate) struct FormatJsBogusImportAttributeEntry; +impl FormatBogusNodeRule for FormatJsBogusImportAttributeEntry {} diff --git a/crates/biome_js_formatter/src/js/bogus/mod.rs b/crates/biome_js_formatter/src/js/bogus/mod.rs index 217dc033ce43..98c448f420c0 100644 --- a/crates/biome_js_formatter/src/js/bogus/mod.rs +++ b/crates/biome_js_formatter/src/js/bogus/mod.rs @@ -5,7 +5,7 @@ pub(crate) mod bogus; pub(crate) mod bogus_assignment; pub(crate) mod bogus_binding; pub(crate) mod bogus_expression; -pub(crate) mod bogus_import_assertion_entry; +pub(crate) mod bogus_import_attribute_entry; pub(crate) mod bogus_member; pub(crate) mod bogus_named_import_specifier; pub(crate) mod bogus_parameter; diff --git a/crates/biome_js_formatter/src/js/lists/import_assertion_entry_list.rs b/crates/biome_js_formatter/src/js/lists/import_attribute_entry_list.rs similarity index 66% rename from crates/biome_js_formatter/src/js/lists/import_assertion_entry_list.rs rename to crates/biome_js_formatter/src/js/lists/import_attribute_entry_list.rs index 9e437778533b..9a5476913227 100644 --- a/crates/biome_js_formatter/src/js/lists/import_assertion_entry_list.rs +++ b/crates/biome_js_formatter/src/js/lists/import_attribute_entry_list.rs @@ -1,14 +1,14 @@ use crate::context::trailing_commas::FormatTrailingCommas; use crate::prelude::*; -use biome_js_syntax::JsImportAssertionEntryList; +use biome_js_syntax::JsImportAttributeEntryList; #[derive(Debug, Clone, Default)] -pub(crate) struct FormatJsImportAssertionEntryList; +pub(crate) struct FormatJsImportAttributeEntryList; -impl FormatRule for FormatJsImportAssertionEntryList { +impl FormatRule for FormatJsImportAttributeEntryList { type Context = JsFormatContext; - fn fmt(&self, node: &JsImportAssertionEntryList, f: &mut JsFormatter) -> FormatResult<()> { + fn fmt(&self, node: &JsImportAttributeEntryList, f: &mut JsFormatter) -> FormatResult<()> { let trailing_separator = FormatTrailingCommas::ES5.trailing_separator(f.options()); f.join_with(&soft_line_break_or_space()) diff --git a/crates/biome_js_formatter/src/js/lists/mod.rs b/crates/biome_js_formatter/src/js/lists/mod.rs index 445d4d707c91..a89124f9e2c1 100644 --- a/crates/biome_js_formatter/src/js/lists/mod.rs +++ b/crates/biome_js_formatter/src/js/lists/mod.rs @@ -11,7 +11,7 @@ pub(crate) mod decorator_list; pub(crate) mod directive_list; pub(crate) mod export_named_from_specifier_list; pub(crate) mod export_named_specifier_list; -pub(crate) mod import_assertion_entry_list; +pub(crate) mod import_attribute_entry_list; pub(crate) mod method_modifier_list; pub(crate) mod module_item_list; pub(crate) mod named_import_specifier_list; diff --git a/crates/biome_js_formatter/src/js/module/export_from_clause.rs b/crates/biome_js_formatter/src/js/module/export_from_clause.rs index f06c7e16fa82..82735c56cc85 100644 --- a/crates/biome_js_formatter/src/js/module/export_from_clause.rs +++ b/crates/biome_js_formatter/src/js/module/export_from_clause.rs @@ -17,7 +17,7 @@ impl FormatNodeRule for FormatJsExportFromClause { export_as, from_token, source, - assertion, + attribute, semicolon_token, } = node.as_fields(); @@ -33,8 +33,8 @@ impl FormatNodeRule for FormatJsExportFromClause { write!(f, [from_token.format(), space(), source.format()])?; - if let Some(assertion) = assertion { - write!(f, [assertion.format()])?; + if let Some(attribute) = attribute { + write!(f, [attribute.format()])?; } FormatStatementSemicolon::new(semicolon_token.as_ref()).fmt(f) diff --git a/crates/biome_js_formatter/src/js/module/export_named_from_clause.rs b/crates/biome_js_formatter/src/js/module/export_named_from_clause.rs index afd6aca8862d..d8fbe87c91d7 100644 --- a/crates/biome_js_formatter/src/js/module/export_named_from_clause.rs +++ b/crates/biome_js_formatter/src/js/module/export_named_from_clause.rs @@ -18,7 +18,7 @@ impl FormatNodeRule for FormatJsExportNamedFromClause { r_curly_token, from_token, source, - assertion, + attribute, semicolon_token, } = node.as_fields(); let should_insert_space_around_brackets = f.options().bracket_spacing().value(); @@ -74,8 +74,8 @@ impl FormatNodeRule for FormatJsExportNamedFromClause { ] ]?; - if let Some(assertion) = &assertion { - write!(f, [assertion.format()])?; + if let Some(attribute) = &attribute { + write!(f, [attribute.format()])?; } write!(f, [FormatStatementSemicolon::new(semicolon_token.as_ref())]) diff --git a/crates/biome_js_formatter/src/js/module/import_assertion.rs b/crates/biome_js_formatter/src/js/module/import_attribute.rs similarity index 76% rename from crates/biome_js_formatter/src/js/module/import_assertion.rs rename to crates/biome_js_formatter/src/js/module/import_attribute.rs index d7a132968ba0..ccf35f79a2c4 100644 --- a/crates/biome_js_formatter/src/js/module/import_assertion.rs +++ b/crates/biome_js_formatter/src/js/module/import_attribute.rs @@ -1,21 +1,21 @@ use crate::prelude::*; use biome_formatter::write; -use biome_js_syntax::JsImportAssertion; -use biome_js_syntax::JsImportAssertionFields; +use biome_js_syntax::JsImportAttribute; +use biome_js_syntax::JsImportAttributeFields; #[derive(Debug, Clone, Default)] -pub(crate) struct FormatJsImportAssertion; +pub(crate) struct FormatJsImportAttribute; -impl FormatNodeRule for FormatJsImportAssertion { - fn fmt_fields(&self, node: &JsImportAssertion, f: &mut JsFormatter) -> FormatResult<()> { - let JsImportAssertionFields { +impl FormatNodeRule for FormatJsImportAttribute { + fn fmt_fields(&self, node: &JsImportAttribute, f: &mut JsFormatter) -> FormatResult<()> { + let JsImportAttributeFields { l_curly_token, - assertions, + attributes, r_curly_token, with_token, } = node.as_fields(); - if assertions.is_empty() { + if attributes.is_empty() { let has_dangling = f.comments().has_dangling_comments(node.syntax()); write!( f, @@ -37,7 +37,7 @@ impl FormatNodeRule for FormatJsImportAssertion { space(), l_curly_token.format(), group(&soft_block_indent_with_maybe_space( - &assertions.format(), + &attributes.format(), should_insert_space_around_brackets )), r_curly_token.format() @@ -48,7 +48,7 @@ impl FormatNodeRule for FormatJsImportAssertion { fn fmt_dangling_comments( &self, - _: &JsImportAssertion, + _: &JsImportAttribute, _: &mut JsFormatter, ) -> FormatResult<()> { // Handled as part of `fmt_fields` diff --git a/crates/biome_js_formatter/src/js/module/import_assertion_entry.rs b/crates/biome_js_formatter/src/js/module/import_attribute_entry.rs similarity index 77% rename from crates/biome_js_formatter/src/js/module/import_assertion_entry.rs rename to crates/biome_js_formatter/src/js/module/import_attribute_entry.rs index 3a4ee5a770dc..96d79ca39d88 100644 --- a/crates/biome_js_formatter/src/js/module/import_assertion_entry.rs +++ b/crates/biome_js_formatter/src/js/module/import_attribute_entry.rs @@ -3,15 +3,15 @@ use biome_formatter::write; use crate::utils::{FormatLiteralStringToken, StringLiteralParentKind}; -use biome_js_syntax::JsImportAssertionEntryFields; -use biome_js_syntax::{JsImportAssertionEntry, JsSyntaxKind}; +use biome_js_syntax::JsImportAttributeEntryFields; +use biome_js_syntax::{JsImportAttributeEntry, JsSyntaxKind}; #[derive(Debug, Clone, Default)] -pub(crate) struct FormatJsImportAssertionEntry; +pub(crate) struct FormatJsImportAttributeEntry; -impl FormatNodeRule for FormatJsImportAssertionEntry { - fn fmt_fields(&self, node: &JsImportAssertionEntry, f: &mut JsFormatter) -> FormatResult<()> { - let JsImportAssertionEntryFields { +impl FormatNodeRule for FormatJsImportAttributeEntry { + fn fmt_fields(&self, node: &JsImportAttributeEntry, f: &mut JsFormatter) -> FormatResult<()> { + let JsImportAttributeEntryFields { key, colon_token, value_token, @@ -54,7 +54,7 @@ impl FormatNodeRule for FormatJsImportAssertionEntry { fn fmt_dangling_comments( &self, - _: &JsImportAssertionEntry, + _: &JsImportAttributeEntry, _: &mut JsFormatter, ) -> FormatResult<()> { // Handled inside `fmt_fields` diff --git a/crates/biome_js_formatter/src/js/module/import_bare_clause.rs b/crates/biome_js_formatter/src/js/module/import_bare_clause.rs index b0fb3be3e459..5aed6cf29746 100644 --- a/crates/biome_js_formatter/src/js/module/import_bare_clause.rs +++ b/crates/biome_js_formatter/src/js/module/import_bare_clause.rs @@ -9,12 +9,12 @@ pub(crate) struct FormatJsImportBareClause; impl FormatNodeRule for FormatJsImportBareClause { fn fmt_fields(&self, node: &JsImportBareClause, f: &mut JsFormatter) -> FormatResult<()> { - let JsImportBareClauseFields { source, assertion } = node.as_fields(); + let JsImportBareClauseFields { source, attribute } = node.as_fields(); write!(f, [source.format()])?; - if let Some(assertion) = assertion { - write!(f, [assertion.format()])?; + if let Some(attribute) = attribute { + write!(f, [attribute.format()])?; } Ok(()) diff --git a/crates/biome_js_formatter/src/js/module/import_combined_clause.rs b/crates/biome_js_formatter/src/js/module/import_combined_clause.rs index 8b202726cf33..8d5910ddbd01 100644 --- a/crates/biome_js_formatter/src/js/module/import_combined_clause.rs +++ b/crates/biome_js_formatter/src/js/module/import_combined_clause.rs @@ -15,7 +15,7 @@ impl FormatNodeRule for FormatJsImportCombinedClause { specifier, from_token, source, - assertion, + attribute, } = node.as_fields(); write![ f, @@ -31,8 +31,8 @@ impl FormatNodeRule for FormatJsImportCombinedClause { ] ]?; - if let Some(assertion) = assertion { - write!(f, [assertion.format()])?; + if let Some(attribute) = attribute { + write!(f, [attribute.format()])?; } Ok(()) diff --git a/crates/biome_js_formatter/src/js/module/import_default_clause.rs b/crates/biome_js_formatter/src/js/module/import_default_clause.rs index 5097d00a6467..3a8dd103a773 100644 --- a/crates/biome_js_formatter/src/js/module/import_default_clause.rs +++ b/crates/biome_js_formatter/src/js/module/import_default_clause.rs @@ -14,7 +14,7 @@ impl FormatNodeRule for FormatJsImportDefaultClause { default_specifier, from_token, source, - assertion, + attribute, } = node.as_fields(); if let Some(type_token) = type_token { @@ -32,8 +32,8 @@ impl FormatNodeRule for FormatJsImportDefaultClause { ] ]?; - if let Some(assertion) = assertion { - write!(f, [assertion.format()])?; + if let Some(attribute) = attribute { + write!(f, [attribute.format()])?; } Ok(()) diff --git a/crates/biome_js_formatter/src/js/module/import_named_clause.rs b/crates/biome_js_formatter/src/js/module/import_named_clause.rs index 1e274aa664d8..fc80da4f53b2 100644 --- a/crates/biome_js_formatter/src/js/module/import_named_clause.rs +++ b/crates/biome_js_formatter/src/js/module/import_named_clause.rs @@ -15,7 +15,7 @@ impl FormatNodeRule for FormatJsImportNamedClause { named_specifiers, from_token, source, - assertion, + attribute, } = node.as_fields(); if let Some(type_token) = type_token { @@ -88,8 +88,8 @@ impl FormatNodeRule for FormatJsImportNamedClause { write![f, [space(), from_token.format(), space(), source.format(),]]?; - if let Some(assertion) = assertion { - write!(f, [assertion.format()])?; + if let Some(attribute) = attribute { + write!(f, [attribute.format()])?; } Ok(()) diff --git a/crates/biome_js_formatter/src/js/module/import_namespace_clause.rs b/crates/biome_js_formatter/src/js/module/import_namespace_clause.rs index 0ddc63937025..4dd42bc21319 100644 --- a/crates/biome_js_formatter/src/js/module/import_namespace_clause.rs +++ b/crates/biome_js_formatter/src/js/module/import_namespace_clause.rs @@ -14,7 +14,7 @@ impl FormatNodeRule for FormatJsImportNamespaceClause { namespace_specifier, from_token, source, - assertion, + attribute, } = node.as_fields(); if let Some(type_token) = type_token { @@ -32,8 +32,8 @@ impl FormatNodeRule for FormatJsImportNamespaceClause { ] ]?; - if let Some(assertion) = assertion { - write!(f, [assertion.format()])?; + if let Some(attribute) = attribute { + write!(f, [attribute.format()])?; } Ok(()) diff --git a/crates/biome_js_formatter/src/js/module/mod.rs b/crates/biome_js_formatter/src/js/module/mod.rs index 2cb017088f1c..14bcacb5b85f 100644 --- a/crates/biome_js_formatter/src/js/module/mod.rs +++ b/crates/biome_js_formatter/src/js/module/mod.rs @@ -12,8 +12,8 @@ pub(crate) mod export_named_from_specifier; pub(crate) mod export_named_shorthand_specifier; pub(crate) mod export_named_specifier; pub(crate) mod import; -pub(crate) mod import_assertion; -pub(crate) mod import_assertion_entry; +pub(crate) mod import_attribute; +pub(crate) mod import_attribute_entry; pub(crate) mod import_bare_clause; pub(crate) mod import_combined_clause; pub(crate) mod import_default_clause; diff --git a/crates/biome_js_parser/README.md b/crates/biome_js_parser/README.md index 6d99a4ed5d6d..759f7b54de54 100644 --- a/crates/biome_js_parser/README.md +++ b/crates/biome_js_parser/README.md @@ -17,3 +17,11 @@ # `biome_js_parser` Biome's JavaScript parser implementation. Follow the [documentation](https://docs.rs/biome_js_parser/). + +## Testing + +To update the `.rast` snapshots, run: + +```bash +UPDATE_EXPECT=1 cargo test -p biome_js_parser +``` diff --git a/crates/biome_js_parser/src/syntax/module.rs b/crates/biome_js_parser/src/syntax/module.rs index f170f37b396f..58787cd3a0e5 100644 --- a/crates/biome_js_parser/src/syntax/module.rs +++ b/crates/biome_js_parser/src/syntax/module.rs @@ -355,7 +355,7 @@ fn parse_import_default_clauses_rest( }; p.expect(T![from]); parse_module_source(p).or_add_diagnostic(p, expected_module_source); - parse_import_assertion(p).ok(); + parse_import_attribute(p).ok(); m.complete(p, syntax_type) } @@ -365,7 +365,7 @@ fn parse_import_default_clauses_rest( fn parse_import_bare_clause(p: &mut JsParser) -> ParsedSyntax { parse_module_source(p).map(|module_source| { let m = module_source.precede(p); - parse_import_assertion(p).ok(); + parse_import_attribute(p).ok(); m.complete(p, JS_IMPORT_BARE_CLAUSE) }) } @@ -376,7 +376,7 @@ fn parse_import_namespace_clause_rest(p: &mut JsParser, m: Marker) -> CompletedM parse_namespace_import_specifier(p).or_add_diagnostic(p, expected_namespace_import); p.expect(T![from]); parse_module_source(p).or_add_diagnostic(p, expected_module_source); - parse_import_assertion(p).ok(); + parse_import_attribute(p).ok(); m.complete(p, JS_IMPORT_NAMESPACE_CLAUSE) } @@ -389,7 +389,7 @@ fn parse_import_named_clause_rest(p: &mut JsParser, m: Marker) -> CompletedMarke parse_named_import_specifier_list(p).or_add_diagnostic(p, expected_named_import); p.expect(T![from]); parse_module_source(p).or_add_diagnostic(p, expected_module_source); - parse_import_assertion(p).ok(); + parse_import_attribute(p).ok(); m.complete(p, JS_IMPORT_NAMED_CLAUSE) } @@ -537,7 +537,7 @@ fn parse_any_named_import_specifier(p: &mut JsParser) -> ParsedSyntax { // import "x" with; // import ipsum from "ipsum.json" with { type: "json", lazy: true, startAtLine: 1 }; // import { a } from "a.json" with -fn parse_import_assertion(p: &mut JsParser) -> ParsedSyntax { +fn parse_import_attribute(p: &mut JsParser) -> ParsedSyntax { if p.has_preceding_line_break() { return Absent; } @@ -556,13 +556,12 @@ fn parse_import_assertion(p: &mut JsParser) -> ParsedSyntax { } }; - // bump assert or with + // bump "with" p.expect(T!['{']); ImportAssertionList::default().parse_list(p); - p.expect(T!['}']); - Present(m.complete(p, JS_IMPORT_ASSERTION)) + Present(m.complete(p, JS_IMPORT_ATTRIBUTE)) } #[derive(Default)] @@ -574,10 +573,10 @@ impl ParseSeparatedList for ImportAssertionList { type Kind = JsSyntaxKind; type Parser<'source> = JsParser<'source>; - const LIST_KIND: Self::Kind = JS_IMPORT_ASSERTION_ENTRY_LIST; + const LIST_KIND: Self::Kind = JS_IMPORT_ATTRIBUTE_ENTRY_LIST; fn parse_element(&mut self, p: &mut JsParser) -> ParsedSyntax { - parse_import_assertion_entry(p, &mut self.assertion_keys) + parse_import_attribute_entry(p, &mut self.assertion_keys) } fn is_at_list_end(&self, p: &mut JsParser) -> bool { @@ -588,11 +587,11 @@ impl ParseSeparatedList for ImportAssertionList { parsed_element.or_recover_with_token_set( p, &ParseRecoveryTokenSet::new( - JS_BOGUS_IMPORT_ASSERTION_ENTRY, + JS_BOGUS_IMPORT_ATTRIBUTE_ENTRY, STMT_RECOVERY_SET.union(token_set![T![,], T!['}']]), ) .enable_recovery_on_line_break(), - |p, range| expected_node("import assertion entry", range, p), + |p, range| expected_node("import attribute entry", range, p), ) } @@ -605,7 +604,7 @@ impl ParseSeparatedList for ImportAssertionList { } } -fn parse_import_assertion_entry( +fn parse_import_attribute_entry( p: &mut JsParser, seen_assertion_keys: &mut FxHashMap, ) -> ParsedSyntax { @@ -656,7 +655,7 @@ fn parse_import_assertion_entry( p.expect(T![:]); p.expect(JS_STRING_LITERAL); - let mut entry = m.complete(p, JS_IMPORT_ASSERTION_ENTRY); + let mut entry = m.complete(p, JS_IMPORT_ATTRIBUTE_ENTRY); if !valid { entry.change_to_bogus(p); @@ -1030,7 +1029,7 @@ fn parse_export_from_clause(p: &mut JsParser) -> ParsedSyntax { parse_export_as_clause(p).ok(); p.expect(T![from]); parse_module_source(p).or_add_diagnostic(p, expected_module_source); - parse_import_assertion(p).ok(); + parse_import_attribute(p).ok(); semi(p, TextRange::new(start, p.cur_range().end())); Present(m.complete(p, JS_EXPORT_FROM_CLAUSE)) @@ -1076,7 +1075,7 @@ fn parse_export_named_from_clause(p: &mut JsParser) -> ParsedSyntax { p.expect(T![from]); parse_module_source(p).or_add_diagnostic(p, expected_module_source); - parse_import_assertion(p).ok(); + parse_import_attribute(p).ok(); semi(p, TextRange::new(start, p.cur_range().start())); diff --git a/crates/biome_js_parser/test_data/inline/err/export_decl_not_top_level.rast b/crates/biome_js_parser/test_data/inline/err/export_decl_not_top_level.rast index e8f26c1307e0..fa4047801708 100644 --- a/crates/biome_js_parser/test_data/inline/err/export_decl_not_top_level.rast +++ b/crates/biome_js_parser/test_data/inline/err/export_decl_not_top_level.rast @@ -27,7 +27,7 @@ JsModule { source: JsModuleSource { value_token: JS_STRING_LITERAL@24..30 "\"life\"" [] [], }, - assertion: missing (optional), + attribute: missing (optional), semicolon_token: SEMICOLON@30..31 ";" [] [], }, ], diff --git a/crates/biome_js_parser/test_data/inline/err/export_from_clause_err.rast b/crates/biome_js_parser/test_data/inline/err/export_from_clause_err.rast index 4717e5773db4..464b27b9f860 100644 --- a/crates/biome_js_parser/test_data/inline/err/export_from_clause_err.rast +++ b/crates/biome_js_parser/test_data/inline/err/export_from_clause_err.rast @@ -12,7 +12,7 @@ JsModule { export_as: missing (optional), from_token: missing (required), source: missing (required), - assertion: missing (optional), + attribute: missing (optional), semicolon_token: SEMICOLON@8..9 ";" [] [], }, }, @@ -25,7 +25,7 @@ JsModule { export_as: missing (optional), from_token: FROM_KW@19..24 "from" [] [Whitespace(" ")], source: missing (required), - assertion: missing (optional), + attribute: missing (optional), semicolon_token: missing (optional), }, }, @@ -51,7 +51,7 @@ JsModule { source: JsModuleSource { value_token: JS_STRING_LITERAL@42..48 "\"test\"" [] [], }, - assertion: missing (optional), + attribute: missing (optional), semicolon_token: SEMICOLON@48..49 ";" [] [], }, }, @@ -66,7 +66,7 @@ JsModule { source: JsModuleSource { value_token: JS_STRING_LITERAL@62..68 "\"test\"" [] [], }, - assertion: missing (optional), + attribute: missing (optional), semicolon_token: SEMICOLON@68..69 ";" [] [], }, }, @@ -79,7 +79,7 @@ JsModule { export_as: missing (optional), from_token: missing (required), source: missing (required), - assertion: missing (optional), + attribute: missing (optional), semicolon_token: SEMICOLON@83..84 ";" [] [], }, }, @@ -92,7 +92,7 @@ JsModule { export_as: missing (optional), from_token: FROM_KW@99..103 "from" [] [], source: missing (required), - assertion: missing (optional), + attribute: missing (optional), semicolon_token: SEMICOLON@103..104 ";" [] [], }, }, @@ -110,7 +110,7 @@ JsModule { }, from_token: missing (required), source: missing (required), - assertion: missing (optional), + attribute: missing (optional), semicolon_token: SEMICOLON@126..127 ";" [] [], }, }, @@ -128,7 +128,7 @@ JsModule { }, from_token: FROM_KW@148..152 "from" [] [], source: missing (required), - assertion: missing (optional), + attribute: missing (optional), semicolon_token: SEMICOLON@152..153 ";" [] [], }, }, diff --git a/crates/biome_js_parser/test_data/inline/err/export_named_from_clause_err.rast b/crates/biome_js_parser/test_data/inline/err/export_named_from_clause_err.rast index 2038c35ee9b5..b182fdcd5102 100644 --- a/crates/biome_js_parser/test_data/inline/err/export_named_from_clause_err.rast +++ b/crates/biome_js_parser/test_data/inline/err/export_named_from_clause_err.rast @@ -26,7 +26,7 @@ JsModule { source: JsModuleSource { value_token: JS_STRING_LITERAL@21..26 "\"mod\"" [] [], }, - assertion: missing (optional), + attribute: missing (optional), semicolon_token: SEMICOLON@26..27 ";" [] [], }, }, @@ -102,7 +102,7 @@ JsModule { source: JsModuleSource { value_token: JS_STRING_LITERAL@80..85 "\"mod\"" [] [], }, - assertion: missing (optional), + attribute: missing (optional), semicolon_token: SEMICOLON@85..86 ";" [] [], }, }, diff --git a/crates/biome_js_parser/test_data/inline/err/import_as_identifier_err.rast b/crates/biome_js_parser/test_data/inline/err/import_as_identifier_err.rast index 7754de5f8b1e..11944a9be781 100644 --- a/crates/biome_js_parser/test_data/inline/err/import_as_identifier_err.rast +++ b/crates/biome_js_parser/test_data/inline/err/import_as_identifier_err.rast @@ -25,7 +25,7 @@ JsModule { source: JsModuleSource { value_token: JS_STRING_LITERAL@21..27 "\"test\"" [] [], }, - assertion: missing (optional), + attribute: missing (optional), }, semicolon_token: SEMICOLON@27..28 ";" [] [], }, diff --git a/crates/biome_js_parser/test_data/inline/err/import_assertion_err.rast b/crates/biome_js_parser/test_data/inline/err/import_assertion_err.rast index 7e9bb834fcb0..4c71b89bf5ae 100644 --- a/crates/biome_js_parser/test_data/inline/err/import_assertion_err.rast +++ b/crates/biome_js_parser/test_data/inline/err/import_assertion_err.rast @@ -9,7 +9,7 @@ JsModule { source: JsModuleSource { value_token: JS_STRING_LITERAL@7..13 "\"foo\"" [] [Whitespace(" ")], }, - assertion: missing (optional), + attribute: missing (optional), }, semicolon_token: missing (optional), }, @@ -50,7 +50,7 @@ JsModule { source: JsModuleSource { value_token: JS_STRING_LITERAL@45..51 "\"bar\"" [] [Whitespace(" ")], }, - assertion: missing (optional), + attribute: missing (optional), }, semicolon_token: missing (optional), }, @@ -101,7 +101,7 @@ JsModule { }, from_token: missing (required), source: missing (required), - assertion: missing (optional), + attribute: missing (optional), }, semicolon_token: missing (optional), }, @@ -140,7 +140,7 @@ JsModule { source: JsModuleSource { value_token: JS_STRING_LITERAL@128..135 "\"lorem\"" [] [], }, - assertion: missing (optional), + attribute: missing (optional), }, semicolon_token: missing (optional), }, @@ -183,7 +183,7 @@ JsModule { source: JsModuleSource { value_token: JS_STRING_LITERAL@177..188 "\"foo.json\"" [] [Whitespace(" ")], }, - assertion: missing (optional), + attribute: missing (optional), }, semicolon_token: missing (optional), }, @@ -247,7 +247,7 @@ JsModule { source: JsModuleSource { value_token: JS_STRING_LITERAL@250..254 "\"x\"" [] [Whitespace(" ")], }, - assertion: missing (optional), + attribute: missing (optional), }, semicolon_token: missing (optional), }, @@ -272,7 +272,7 @@ JsModule { source: JsModuleSource { value_token: JS_STRING_LITERAL@280..293 "\"ipsum.json\"" [] [Whitespace(" ")], }, - assertion: missing (optional), + attribute: missing (optional), }, semicolon_token: missing (optional), }, @@ -343,7 +343,7 @@ JsModule { source: JsModuleSource { value_token: JS_STRING_LITERAL@364..373 "\"a.json\"" [] [Whitespace(" ")], }, - assertion: missing (optional), + attribute: missing (optional), }, semicolon_token: missing (optional), }, diff --git a/crates/biome_js_parser/test_data/inline/err/import_attribute_err.rast b/crates/biome_js_parser/test_data/inline/err/import_attribute_err.rast index a4d8e7650b52..36b45a93dd4b 100644 --- a/crates/biome_js_parser/test_data/inline/err/import_attribute_err.rast +++ b/crates/biome_js_parser/test_data/inline/err/import_attribute_err.rast @@ -9,17 +9,17 @@ JsModule { source: JsModuleSource { value_token: JS_STRING_LITERAL@7..13 "\"foo\"" [] [Whitespace(" ")], }, - assertion: JsImportAssertion { + attribute: JsImportAttribute { with_token: WITH_KW@13..18 "with" [] [Whitespace(" ")], l_curly_token: L_CURLY@18..20 "{" [] [Whitespace(" ")], - assertions: JsImportAssertionEntryList [ - JsImportAssertionEntry { + attributes: JsImportAttributeEntryList [ + JsImportAttributeEntry { key: IDENT@20..24 "type" [] [], colon_token: missing (required), value_token: missing (required), }, COMMA@24..26 "," [] [Whitespace(" ")], - JsImportAssertionEntry { + JsImportAttributeEntry { key: JS_STRING_LITERAL@26..33 "\"json\"" [] [Whitespace(" ")], colon_token: missing (required), value_token: missing (required), @@ -48,11 +48,11 @@ JsModule { }, from_token: missing (required), source: missing (required), - assertion: JsImportAssertion { + attribute: JsImportAttribute { with_token: WITH_KW@51..56 "with" [] [Whitespace(" ")], l_curly_token: L_CURLY@56..58 "{" [] [Whitespace(" ")], - assertions: JsImportAssertionEntryList [ - JsImportAssertionEntry { + attributes: JsImportAttributeEntryList [ + JsImportAttributeEntry { key: IDENT@58..62 "type" [] [], colon_token: COLON@62..64 ":" [] [Whitespace(" ")], value_token: JS_STRING_LITERAL@64..71 "\"json\"" [] [Whitespace(" ")], @@ -76,17 +76,17 @@ JsModule { source: JsModuleSource { value_token: JS_STRING_LITERAL@91..102 "\"foo.json\"" [] [Whitespace(" ")], }, - assertion: JsImportAssertion { + attribute: JsImportAttribute { with_token: WITH_KW@102..107 "with" [] [Whitespace(" ")], l_curly_token: L_CURLY@107..109 "{" [] [Whitespace(" ")], - assertions: JsImportAssertionEntryList [ - JsImportAssertionEntry { + attributes: JsImportAttributeEntryList [ + JsImportAttributeEntry { key: JS_STRING_LITERAL@109..115 "\"type\"" [] [], colon_token: COLON@115..117 ":" [] [Whitespace(" ")], value_token: JS_STRING_LITERAL@117..123 "\"json\"" [] [], }, COMMA@123..125 "," [] [Whitespace(" ")], - JsBogusImportAssertionEntry { + JsBogusImportAttributeEntry { items: [ IDENT@125..129 "type" [] [], COLON@129..131 ":" [] [Whitespace(" ")], @@ -94,7 +94,7 @@ JsModule { ], }, COMMA@137..139 "," [] [Whitespace(" ")], - JsBogusImportAssertionEntry { + JsBogusImportAttributeEntry { items: [ JS_STRING_LITERAL@139..145 "\"type\"" [] [], COLON@145..147 ":" [] [Whitespace(" ")], @@ -113,10 +113,10 @@ JsModule { source: JsModuleSource { value_token: JS_STRING_LITERAL@162..166 "\"x\"" [] [Whitespace(" ")], }, - assertion: JsImportAssertion { + attribute: JsImportAttribute { with_token: WITH_KW@166..170 "with" [] [], l_curly_token: missing (required), - assertions: JsImportAssertionEntryList [], + attributes: JsImportAttributeEntryList [], r_curly_token: missing (required), }, }, @@ -135,35 +135,35 @@ JsModule { source: JsModuleSource { value_token: JS_STRING_LITERAL@190..203 "\"ipsum.json\"" [] [Whitespace(" ")], }, - assertion: JsImportAssertion { + attribute: JsImportAttribute { with_token: WITH_KW@203..208 "with" [] [Whitespace(" ")], l_curly_token: L_CURLY@208..210 "{" [] [Whitespace(" ")], - assertions: JsImportAssertionEntryList [ - JsImportAssertionEntry { + attributes: JsImportAttributeEntryList [ + JsImportAttributeEntry { key: IDENT@210..214 "type" [] [], colon_token: COLON@214..216 ":" [] [Whitespace(" ")], value_token: JS_STRING_LITERAL@216..222 "\"json\"" [] [], }, COMMA@222..224 "," [] [Whitespace(" ")], - JsImportAssertionEntry { + JsImportAttributeEntry { key: IDENT@224..228 "lazy" [] [], colon_token: COLON@228..230 ":" [] [Whitespace(" ")], value_token: missing (required), }, missing separator, - JsImportAssertionEntry { + JsImportAttributeEntry { key: IDENT@230..234 "true" [] [], colon_token: missing (required), value_token: missing (required), }, COMMA@234..236 "," [] [Whitespace(" ")], - JsImportAssertionEntry { + JsImportAttributeEntry { key: IDENT@236..247 "startAtLine" [] [], colon_token: COLON@247..249 ":" [] [Whitespace(" ")], value_token: missing (required), }, missing separator, - JsBogusImportAssertionEntry { + JsBogusImportAttributeEntry { items: [ JS_NUMBER_LITERAL@249..251 "1" [] [Whitespace(" ")], ], @@ -194,10 +194,10 @@ JsModule { source: JsModuleSource { value_token: JS_STRING_LITERAL@272..281 "\"a.json\"" [] [Whitespace(" ")], }, - assertion: JsImportAssertion { + attribute: JsImportAttribute { with_token: WITH_KW@281..285 "with" [] [], l_curly_token: missing (required), - assertions: JsImportAssertionEntryList [], + attributes: JsImportAttributeEntryList [], r_curly_token: missing (required), }, }, @@ -217,16 +217,16 @@ JsModule { 1: JS_IMPORT_BARE_CLAUSE@7..34 0: JS_MODULE_SOURCE@7..13 0: JS_STRING_LITERAL@7..13 "\"foo\"" [] [Whitespace(" ")] - 1: JS_IMPORT_ASSERTION@13..34 + 1: JS_IMPORT_ATTRIBUTE@13..34 0: WITH_KW@13..18 "with" [] [Whitespace(" ")] 1: L_CURLY@18..20 "{" [] [Whitespace(" ")] - 2: JS_IMPORT_ASSERTION_ENTRY_LIST@20..33 - 0: JS_IMPORT_ASSERTION_ENTRY@20..24 + 2: JS_IMPORT_ATTRIBUTE_ENTRY_LIST@20..33 + 0: JS_IMPORT_ATTRIBUTE_ENTRY@20..24 0: IDENT@20..24 "type" [] [] 1: (empty) 2: (empty) 1: COMMA@24..26 "," [] [Whitespace(" ")] - 2: JS_IMPORT_ASSERTION_ENTRY@26..33 + 2: JS_IMPORT_ATTRIBUTE_ENTRY@26..33 0: JS_STRING_LITERAL@26..33 "\"json\"" [] [Whitespace(" ")] 1: (empty) 2: (empty) @@ -246,11 +246,11 @@ JsModule { 2: R_CURLY@49..51 "}" [] [Whitespace(" ")] 2: (empty) 3: (empty) - 4: JS_IMPORT_ASSERTION@51..72 + 4: JS_IMPORT_ATTRIBUTE@51..72 0: WITH_KW@51..56 "with" [] [Whitespace(" ")] 1: L_CURLY@56..58 "{" [] [Whitespace(" ")] - 2: JS_IMPORT_ASSERTION_ENTRY_LIST@58..71 - 0: JS_IMPORT_ASSERTION_ENTRY@58..71 + 2: JS_IMPORT_ATTRIBUTE_ENTRY_LIST@58..71 + 0: JS_IMPORT_ATTRIBUTE_ENTRY@58..71 0: IDENT@58..62 "type" [] [] 1: COLON@62..64 ":" [] [Whitespace(" ")] 2: JS_STRING_LITERAL@64..71 "\"json\"" [] [Whitespace(" ")] @@ -266,21 +266,21 @@ JsModule { 2: FROM_KW@86..91 "from" [] [Whitespace(" ")] 3: JS_MODULE_SOURCE@91..102 0: JS_STRING_LITERAL@91..102 "\"foo.json\"" [] [Whitespace(" ")] - 4: JS_IMPORT_ASSERTION@102..153 + 4: JS_IMPORT_ATTRIBUTE@102..153 0: WITH_KW@102..107 "with" [] [Whitespace(" ")] 1: L_CURLY@107..109 "{" [] [Whitespace(" ")] - 2: JS_IMPORT_ASSERTION_ENTRY_LIST@109..152 - 0: JS_IMPORT_ASSERTION_ENTRY@109..123 + 2: JS_IMPORT_ATTRIBUTE_ENTRY_LIST@109..152 + 0: JS_IMPORT_ATTRIBUTE_ENTRY@109..123 0: JS_STRING_LITERAL@109..115 "\"type\"" [] [] 1: COLON@115..117 ":" [] [Whitespace(" ")] 2: JS_STRING_LITERAL@117..123 "\"json\"" [] [] 1: COMMA@123..125 "," [] [Whitespace(" ")] - 2: JS_BOGUS_IMPORT_ASSERTION_ENTRY@125..137 + 2: JS_BOGUS_IMPORT_ATTRIBUTE_ENTRY@125..137 0: IDENT@125..129 "type" [] [] 1: COLON@129..131 ":" [] [Whitespace(" ")] 2: JS_STRING_LITERAL@131..137 "\"html\"" [] [] 3: COMMA@137..139 "," [] [Whitespace(" ")] - 4: JS_BOGUS_IMPORT_ASSERTION_ENTRY@139..152 + 4: JS_BOGUS_IMPORT_ATTRIBUTE_ENTRY@139..152 0: JS_STRING_LITERAL@139..145 "\"type\"" [] [] 1: COLON@145..147 ":" [] [Whitespace(" ")] 2: JS_STRING_LITERAL@147..152 "\"js\"" [] [Whitespace(" ")] @@ -291,10 +291,10 @@ JsModule { 1: JS_IMPORT_BARE_CLAUSE@162..170 0: JS_MODULE_SOURCE@162..166 0: JS_STRING_LITERAL@162..166 "\"x\"" [] [Whitespace(" ")] - 1: JS_IMPORT_ASSERTION@166..170 + 1: JS_IMPORT_ATTRIBUTE@166..170 0: WITH_KW@166..170 "with" [] [] 1: (empty) - 2: JS_IMPORT_ASSERTION_ENTRY_LIST@170..170 + 2: JS_IMPORT_ATTRIBUTE_ENTRY_LIST@170..170 3: (empty) 2: SEMICOLON@170..171 ";" [] [] 4: JS_IMPORT@171..253 @@ -307,31 +307,31 @@ JsModule { 2: FROM_KW@185..190 "from" [] [Whitespace(" ")] 3: JS_MODULE_SOURCE@190..203 0: JS_STRING_LITERAL@190..203 "\"ipsum.json\"" [] [Whitespace(" ")] - 4: JS_IMPORT_ASSERTION@203..252 + 4: JS_IMPORT_ATTRIBUTE@203..252 0: WITH_KW@203..208 "with" [] [Whitespace(" ")] 1: L_CURLY@208..210 "{" [] [Whitespace(" ")] - 2: JS_IMPORT_ASSERTION_ENTRY_LIST@210..251 - 0: JS_IMPORT_ASSERTION_ENTRY@210..222 + 2: JS_IMPORT_ATTRIBUTE_ENTRY_LIST@210..251 + 0: JS_IMPORT_ATTRIBUTE_ENTRY@210..222 0: IDENT@210..214 "type" [] [] 1: COLON@214..216 ":" [] [Whitespace(" ")] 2: JS_STRING_LITERAL@216..222 "\"json\"" [] [] 1: COMMA@222..224 "," [] [Whitespace(" ")] - 2: JS_IMPORT_ASSERTION_ENTRY@224..230 + 2: JS_IMPORT_ATTRIBUTE_ENTRY@224..230 0: IDENT@224..228 "lazy" [] [] 1: COLON@228..230 ":" [] [Whitespace(" ")] 2: (empty) 3: (empty) - 4: JS_IMPORT_ASSERTION_ENTRY@230..234 + 4: JS_IMPORT_ATTRIBUTE_ENTRY@230..234 0: IDENT@230..234 "true" [] [] 1: (empty) 2: (empty) 5: COMMA@234..236 "," [] [Whitespace(" ")] - 6: JS_IMPORT_ASSERTION_ENTRY@236..249 + 6: JS_IMPORT_ATTRIBUTE_ENTRY@236..249 0: IDENT@236..247 "startAtLine" [] [] 1: COLON@247..249 ":" [] [Whitespace(" ")] 2: (empty) 7: (empty) - 8: JS_BOGUS_IMPORT_ASSERTION_ENTRY@249..251 + 8: JS_BOGUS_IMPORT_ATTRIBUTE_ENTRY@249..251 0: JS_NUMBER_LITERAL@249..251 "1" [] [Whitespace(" ")] 3: R_CURLY@251..252 "}" [] [] 2: SEMICOLON@252..253 ";" [] [] @@ -350,10 +350,10 @@ JsModule { 2: FROM_KW@267..272 "from" [] [Whitespace(" ")] 3: JS_MODULE_SOURCE@272..281 0: JS_STRING_LITERAL@272..281 "\"a.json\"" [] [Whitespace(" ")] - 4: JS_IMPORT_ASSERTION@281..285 + 4: JS_IMPORT_ATTRIBUTE@281..285 0: WITH_KW@281..285 "with" [] [] 1: (empty) - 2: JS_IMPORT_ASSERTION_ENTRY_LIST@285..285 + 2: JS_IMPORT_ATTRIBUTE_ENTRY_LIST@285..285 3: (empty) 2: (empty) 4: EOF@285..286 "" [Newline("\n")] [] diff --git a/crates/biome_js_parser/test_data/inline/err/import_decl_not_top_level.rast b/crates/biome_js_parser/test_data/inline/err/import_decl_not_top_level.rast index 3db1686c5362..8f34b13c7fcd 100644 --- a/crates/biome_js_parser/test_data/inline/err/import_decl_not_top_level.rast +++ b/crates/biome_js_parser/test_data/inline/err/import_decl_not_top_level.rast @@ -20,7 +20,7 @@ JsModule { source: JsModuleSource { value_token: JS_STRING_LITERAL@19..24 "\"bar\"" [] [], }, - assertion: missing (optional), + attribute: missing (optional), }, SEMICOLON@24..25 ";" [] [], ], diff --git a/crates/biome_js_parser/test_data/inline/err/import_err.rast b/crates/biome_js_parser/test_data/inline/err/import_err.rast index 33550b72d731..f9a3efc8d46b 100644 --- a/crates/biome_js_parser/test_data/inline/err/import_err.rast +++ b/crates/biome_js_parser/test_data/inline/err/import_err.rast @@ -19,7 +19,7 @@ JsModule { }, from_token: missing (required), source: missing (required), - assertion: missing (optional), + attribute: missing (optional), }, semicolon_token: SEMICOLON@16..17 ";" [] [], }, @@ -36,7 +36,7 @@ JsModule { }, from_token: missing (required), source: missing (required), - assertion: missing (optional), + attribute: missing (optional), }, semicolon_token: missing (optional), }, @@ -115,7 +115,7 @@ JsModule { source: JsModuleSource { value_token: JS_STRING_LITERAL@80..83 "\"c\"" [] [], }, - assertion: missing (optional), + attribute: missing (optional), }, semicolon_token: SEMICOLON@83..84 ";" [] [], }, @@ -146,7 +146,7 @@ JsModule { source: JsModuleSource { value_token: JS_STRING_LITERAL@108..111 "\"c\"" [] [], }, - assertion: missing (optional), + attribute: missing (optional), }, semicolon_token: SEMICOLON@111..112 ";" [] [], }, @@ -172,7 +172,7 @@ JsModule { source: JsModuleSource { value_token: JS_STRING_LITERAL@137..140 "\"c\"" [] [], }, - assertion: missing (optional), + attribute: missing (optional), }, semicolon_token: SEMICOLON@140..141 ";" [] [], }, @@ -198,7 +198,7 @@ JsModule { source: JsModuleSource { value_token: JS_STRING_LITERAL@162..165 "\"c\"" [] [], }, - assertion: missing (optional), + attribute: missing (optional), }, semicolon_token: SEMICOLON@165..166 ";" [] [], }, @@ -224,7 +224,7 @@ JsModule { source: JsModuleSource { value_token: JS_STRING_LITERAL@188..191 "\"c\"" [] [], }, - assertion: missing (optional), + attribute: missing (optional), }, semicolon_token: SEMICOLON@191..192 ";" [] [], }, @@ -264,7 +264,7 @@ JsModule { }, from_token: FROM_KW@221..226 "from" [] [Whitespace(" ")], source: missing (required), - assertion: missing (optional), + attribute: missing (optional), }, semicolon_token: missing (optional), }, diff --git a/crates/biome_js_parser/test_data/inline/err/ts_named_import_specifier_error.rast b/crates/biome_js_parser/test_data/inline/err/ts_named_import_specifier_error.rast index d7651765879b..46015e3640c6 100644 --- a/crates/biome_js_parser/test_data/inline/err/ts_named_import_specifier_error.rast +++ b/crates/biome_js_parser/test_data/inline/err/ts_named_import_specifier_error.rast @@ -25,7 +25,7 @@ JsModule { source: JsModuleSource { value_token: JS_STRING_LITERAL@24..31 "\"./mod\"" [] [], }, - assertion: missing (optional), + attribute: missing (optional), }, semicolon_token: SEMICOLON@31..32 ";" [] [], }, @@ -51,7 +51,7 @@ JsModule { source: JsModuleSource { value_token: JS_STRING_LITERAL@62..69 "\"./mod\"" [] [], }, - assertion: missing (optional), + attribute: missing (optional), }, semicolon_token: SEMICOLON@69..70 ";" [] [], }, @@ -77,7 +77,7 @@ JsModule { source: JsModuleSource { value_token: JS_STRING_LITERAL@102..109 "\"./mod\"" [] [], }, - assertion: missing (optional), + attribute: missing (optional), }, semicolon_token: SEMICOLON@109..110 ";" [] [], }, @@ -103,7 +103,7 @@ JsModule { source: JsModuleSource { value_token: JS_STRING_LITERAL@147..154 "\"./mod\"" [] [], }, - assertion: missing (optional), + attribute: missing (optional), }, semicolon_token: SEMICOLON@154..155 ";" [] [], }, @@ -118,7 +118,7 @@ JsModule { }, from_token: missing (required), source: missing (required), - assertion: missing (optional), + attribute: missing (optional), }, semicolon_token: missing (optional), }, diff --git a/crates/biome_js_parser/test_data/inline/ok/export_from_clause.rast b/crates/biome_js_parser/test_data/inline/ok/export_from_clause.rast index 8351215a7ebf..a9a33e89da8f 100644 --- a/crates/biome_js_parser/test_data/inline/ok/export_from_clause.rast +++ b/crates/biome_js_parser/test_data/inline/ok/export_from_clause.rast @@ -28,7 +28,7 @@ JsModule { source: JsModuleSource { value_token: JS_STRING_LITERAL@33..36 "\"b\"" [] [], }, - assertion: missing (optional), + attribute: missing (optional), semicolon_token: SEMICOLON@36..37 ";" [] [], }, }, @@ -57,7 +57,7 @@ JsModule { source: JsModuleSource { value_token: JS_STRING_LITERAL@67..70 "\"b\"" [] [], }, - assertion: missing (optional), + attribute: missing (optional), semicolon_token: SEMICOLON@70..71 ";" [] [], }, }, @@ -72,7 +72,7 @@ JsModule { source: JsModuleSource { value_token: JS_STRING_LITERAL@86..89 "\"a\"" [] [], }, - assertion: missing (optional), + attribute: missing (optional), semicolon_token: SEMICOLON@89..90 ";" [] [], }, }, @@ -92,7 +92,7 @@ JsModule { source: JsModuleSource { value_token: JS_STRING_LITERAL@110..113 "\"b\"" [] [], }, - assertion: missing (optional), + attribute: missing (optional), semicolon_token: SEMICOLON@113..114 ";" [] [], }, }, @@ -112,7 +112,7 @@ JsModule { source: JsModuleSource { value_token: JS_STRING_LITERAL@140..143 "\"b\"" [] [], }, - assertion: missing (optional), + attribute: missing (optional), semicolon_token: missing (optional), }, }, @@ -127,11 +127,11 @@ JsModule { source: JsModuleSource { value_token: JS_STRING_LITERAL@158..164 "\"mod\"" [] [Whitespace(" ")], }, - assertion: JsImportAssertion { + attribute: JsImportAttribute { with_token: WITH_KW@164..169 "with" [] [Whitespace(" ")], l_curly_token: L_CURLY@169..171 "{" [] [Whitespace(" ")], - assertions: JsImportAssertionEntryList [ - JsImportAssertionEntry { + attributes: JsImportAttributeEntryList [ + JsImportAttributeEntry { key: IDENT@171..175 "type" [] [], colon_token: COLON@175..177 ":" [] [Whitespace(" ")], value_token: JS_STRING_LITERAL@177..184 "\"json\"" [] [Whitespace(" ")], @@ -153,7 +153,7 @@ JsModule { source: JsModuleSource { value_token: JS_STRING_LITERAL@205..212 "\"types\"" [] [], }, - assertion: missing (optional), + attribute: missing (optional), semicolon_token: SEMICOLON@212..213 ";" [] [], }, }, @@ -173,7 +173,7 @@ JsModule { source: JsModuleSource { value_token: JS_STRING_LITERAL@242..249 "\"types\"" [] [], }, - assertion: missing (optional), + attribute: missing (optional), semicolon_token: SEMICOLON@249..250 ";" [] [], }, }, @@ -280,11 +280,11 @@ JsModule { 3: FROM_KW@153..158 "from" [] [Whitespace(" ")] 4: JS_MODULE_SOURCE@158..164 0: JS_STRING_LITERAL@158..164 "\"mod\"" [] [Whitespace(" ")] - 5: JS_IMPORT_ASSERTION@164..185 + 5: JS_IMPORT_ATTRIBUTE@164..185 0: WITH_KW@164..169 "with" [] [Whitespace(" ")] 1: L_CURLY@169..171 "{" [] [Whitespace(" ")] - 2: JS_IMPORT_ASSERTION_ENTRY_LIST@171..184 - 0: JS_IMPORT_ASSERTION_ENTRY@171..184 + 2: JS_IMPORT_ATTRIBUTE_ENTRY_LIST@171..184 + 0: JS_IMPORT_ATTRIBUTE_ENTRY@171..184 0: IDENT@171..175 "type" [] [] 1: COLON@175..177 ":" [] [Whitespace(" ")] 2: JS_STRING_LITERAL@177..184 "\"json\"" [] [Whitespace(" ")] diff --git a/crates/biome_js_parser/test_data/inline/ok/export_named_from_clause.rast b/crates/biome_js_parser/test_data/inline/ok/export_named_from_clause.rast index e08b7b4e321d..a41cab142296 100644 --- a/crates/biome_js_parser/test_data/inline/ok/export_named_from_clause.rast +++ b/crates/biome_js_parser/test_data/inline/ok/export_named_from_clause.rast @@ -31,7 +31,7 @@ JsModule { source: JsModuleSource { value_token: JS_STRING_LITERAL@27..32 "\"mod\"" [] [], }, - assertion: missing (optional), + attribute: missing (optional), semicolon_token: SEMICOLON@32..33 ";" [] [], }, }, @@ -86,7 +86,7 @@ JsModule { source: JsModuleSource { value_token: JS_STRING_LITERAL@81..86 "\"mod\"" [] [], }, - assertion: missing (optional), + attribute: missing (optional), semicolon_token: missing (optional), }, }, @@ -110,7 +110,7 @@ JsModule { source: JsModuleSource { value_token: JS_STRING_LITERAL@106..111 "\"mod\"" [] [], }, - assertion: missing (optional), + attribute: missing (optional), semicolon_token: SEMICOLON@111..112 ";" [] [], }, }, @@ -139,7 +139,7 @@ JsModule { source: JsModuleSource { value_token: JS_STRING_LITERAL@144..149 "\"mod\"" [] [], }, - assertion: missing (optional), + attribute: missing (optional), semicolon_token: SEMICOLON@149..150 ";" [] [], }, }, @@ -168,7 +168,7 @@ JsModule { source: JsModuleSource { value_token: JS_STRING_LITERAL@176..181 "\"mod\"" [] [], }, - assertion: missing (optional), + attribute: missing (optional), semicolon_token: SEMICOLON@181..182 ";" [] [], }, }, @@ -192,11 +192,11 @@ JsModule { source: JsModuleSource { value_token: JS_STRING_LITERAL@201..207 "\"mod\"" [] [Whitespace(" ")], }, - assertion: JsImportAssertion { + attribute: JsImportAttribute { with_token: WITH_KW@207..212 "with" [] [Whitespace(" ")], l_curly_token: L_CURLY@212..214 "{" [] [Whitespace(" ")], - assertions: JsImportAssertionEntryList [ - JsImportAssertionEntry { + attributes: JsImportAttributeEntryList [ + JsImportAttributeEntry { key: IDENT@214..218 "type" [] [], colon_token: COLON@218..220 ":" [] [Whitespace(" ")], value_token: JS_STRING_LITERAL@220..227 "\"json\"" [] [Whitespace(" ")], @@ -227,7 +227,7 @@ JsModule { source: JsModuleSource { value_token: JS_STRING_LITERAL@249..256 "\"./mod\"" [] [], }, - assertion: missing (optional), + attribute: missing (optional), semicolon_token: SEMICOLON@256..257 ";" [] [], }, }, @@ -251,7 +251,7 @@ JsModule { source: JsModuleSource { value_token: JS_STRING_LITERAL@283..290 "\"./mod\"" [] [], }, - assertion: missing (optional), + attribute: missing (optional), semicolon_token: SEMICOLON@290..291 ";" [] [], }, }, @@ -403,11 +403,11 @@ JsModule { 4: FROM_KW@196..201 "from" [] [Whitespace(" ")] 5: JS_MODULE_SOURCE@201..207 0: JS_STRING_LITERAL@201..207 "\"mod\"" [] [Whitespace(" ")] - 6: JS_IMPORT_ASSERTION@207..228 + 6: JS_IMPORT_ATTRIBUTE@207..228 0: WITH_KW@207..212 "with" [] [Whitespace(" ")] 1: L_CURLY@212..214 "{" [] [Whitespace(" ")] - 2: JS_IMPORT_ASSERTION_ENTRY_LIST@214..227 - 0: JS_IMPORT_ASSERTION_ENTRY@214..227 + 2: JS_IMPORT_ATTRIBUTE_ENTRY_LIST@214..227 + 0: JS_IMPORT_ATTRIBUTE_ENTRY@214..227 0: IDENT@214..218 "type" [] [] 1: COLON@218..220 ":" [] [Whitespace(" ")] 2: JS_STRING_LITERAL@220..227 "\"json\"" [] [Whitespace(" ")] diff --git a/crates/biome_js_parser/test_data/inline/ok/import_as_as_as_identifier.rast b/crates/biome_js_parser/test_data/inline/ok/import_as_as_as_identifier.rast index 5dc1a7efe871..c40a37418ba9 100644 --- a/crates/biome_js_parser/test_data/inline/ok/import_as_as_as_identifier.rast +++ b/crates/biome_js_parser/test_data/inline/ok/import_as_as_as_identifier.rast @@ -27,7 +27,7 @@ JsModule { source: JsModuleSource { value_token: JS_STRING_LITERAL@25..31 "\"test\"" [] [], }, - assertion: missing (optional), + attribute: missing (optional), }, semicolon_token: SEMICOLON@31..32 ";" [] [], }, diff --git a/crates/biome_js_parser/test_data/inline/ok/import_as_identifier.rast b/crates/biome_js_parser/test_data/inline/ok/import_as_identifier.rast index abd11356bc90..a66af1dc18ad 100644 --- a/crates/biome_js_parser/test_data/inline/ok/import_as_identifier.rast +++ b/crates/biome_js_parser/test_data/inline/ok/import_as_identifier.rast @@ -23,7 +23,7 @@ JsModule { source: JsModuleSource { value_token: JS_STRING_LITERAL@19..25 "\"test\"" [] [], }, - assertion: missing (optional), + attribute: missing (optional), }, semicolon_token: SEMICOLON@25..26 ";" [] [], }, diff --git a/crates/biome_js_parser/test_data/inline/ok/import_attribute.rast b/crates/biome_js_parser/test_data/inline/ok/import_attribute.rast index b609e41d264f..37b690887e2d 100644 --- a/crates/biome_js_parser/test_data/inline/ok/import_attribute.rast +++ b/crates/biome_js_parser/test_data/inline/ok/import_attribute.rast @@ -9,11 +9,11 @@ JsModule { source: JsModuleSource { value_token: JS_STRING_LITERAL@7..11 "\"x\"" [] [Whitespace(" ")], }, - assertion: JsImportAssertion { + attribute: JsImportAttribute { with_token: WITH_KW@11..16 "with" [] [Whitespace(" ")], l_curly_token: L_CURLY@16..18 "{" [] [Whitespace(" ")], - assertions: JsImportAssertionEntryList [ - JsImportAssertionEntry { + attributes: JsImportAttributeEntryList [ + JsImportAttributeEntry { key: IDENT@18..22 "type" [] [], colon_token: COLON@22..24 ":" [] [Whitespace(" ")], value_token: JS_STRING_LITERAL@24..31 "\"json\"" [] [Whitespace(" ")], @@ -30,11 +30,11 @@ JsModule { source: JsModuleSource { value_token: JS_STRING_LITERAL@40..46 "\"foo\"" [] [Whitespace(" ")], }, - assertion: JsImportAssertion { + attribute: JsImportAttribute { with_token: WITH_KW@46..51 "with" [] [Whitespace(" ")], l_curly_token: L_CURLY@51..53 "{" [] [Whitespace(" ")], - assertions: JsImportAssertionEntryList [ - JsImportAssertionEntry { + attributes: JsImportAttributeEntryList [ + JsImportAttributeEntry { key: JS_STRING_LITERAL@53..59 "\"type\"" [] [], colon_token: COLON@59..61 ":" [] [Whitespace(" ")], value_token: JS_STRING_LITERAL@61..68 "\"json\"" [] [Whitespace(" ")], @@ -58,11 +58,11 @@ JsModule { source: JsModuleSource { value_token: JS_STRING_LITERAL@87..98 "\"foo.json\"" [] [Whitespace(" ")], }, - assertion: JsImportAssertion { + attribute: JsImportAttribute { with_token: WITH_KW@98..103 "with" [] [Whitespace(" ")], l_curly_token: L_CURLY@103..105 "{" [] [Whitespace(" ")], - assertions: JsImportAssertionEntryList [ - JsImportAssertionEntry { + attributes: JsImportAttributeEntryList [ + JsImportAttributeEntry { key: IDENT@105..109 "type" [] [], colon_token: COLON@109..111 ":" [] [Whitespace(" ")], value_token: JS_STRING_LITERAL@111..118 "\"json\"" [] [Whitespace(" ")], @@ -93,11 +93,11 @@ JsModule { source: JsModuleSource { value_token: JS_STRING_LITERAL@140..151 "\"foo.json\"" [] [Whitespace(" ")], }, - assertion: JsImportAssertion { + attribute: JsImportAttribute { with_token: WITH_KW@151..156 "with" [] [Whitespace(" ")], l_curly_token: L_CURLY@156..158 "{" [] [Whitespace(" ")], - assertions: JsImportAssertionEntryList [ - JsImportAssertionEntry { + attributes: JsImportAttributeEntryList [ + JsImportAttributeEntry { key: IDENT@158..161 "for" [] [], colon_token: COLON@161..163 ":" [] [Whitespace(" ")], value_token: JS_STRING_LITERAL@163..169 "\"for\"" [] [Whitespace(" ")], @@ -121,17 +121,17 @@ JsModule { source: JsModuleSource { value_token: JS_STRING_LITERAL@192..203 "\"foo.json\"" [] [Whitespace(" ")], }, - assertion: JsImportAssertion { + attribute: JsImportAttribute { with_token: WITH_KW@203..208 "with" [] [Whitespace(" ")], l_curly_token: L_CURLY@208..210 "{" [] [Whitespace(" ")], - assertions: JsImportAssertionEntryList [ - JsImportAssertionEntry { + attributes: JsImportAttributeEntryList [ + JsImportAttributeEntry { key: IDENT@210..214 "type" [] [], colon_token: COLON@214..216 ":" [] [Whitespace(" ")], value_token: JS_STRING_LITERAL@216..222 "\"json\"" [] [], }, COMMA@222..224 "," [] [Whitespace(" ")], - JsImportAssertionEntry { + JsImportAttributeEntry { key: IDENT@224..238 "hasOwnProperty" [] [], colon_token: COLON@238..240 ":" [] [Whitespace(" ")], value_token: JS_STRING_LITERAL@240..247 "\"true\"" [] [Whitespace(" ")], @@ -148,11 +148,11 @@ JsModule { source: JsModuleSource { value_token: JS_STRING_LITERAL@257..261 "\"x\"" [] [Whitespace(" ")], }, - assertion: JsImportAssertion { + attribute: JsImportAttribute { with_token: WITH_KW@261..265 "with" [] [], l_curly_token: L_CURLY@265..268 "{" [Newline("\n")] [Whitespace(" ")], - assertions: JsImportAssertionEntryList [ - JsImportAssertionEntry { + attributes: JsImportAttributeEntryList [ + JsImportAttributeEntry { key: IDENT@268..272 "type" [] [], colon_token: COLON@272..274 ":" [] [Whitespace(" ")], value_token: JS_STRING_LITERAL@274..281 "\"json\"" [] [Whitespace(" ")], @@ -177,11 +177,11 @@ JsModule { 1: JS_IMPORT_BARE_CLAUSE@7..32 0: JS_MODULE_SOURCE@7..11 0: JS_STRING_LITERAL@7..11 "\"x\"" [] [Whitespace(" ")] - 1: JS_IMPORT_ASSERTION@11..32 + 1: JS_IMPORT_ATTRIBUTE@11..32 0: WITH_KW@11..16 "with" [] [Whitespace(" ")] 1: L_CURLY@16..18 "{" [] [Whitespace(" ")] - 2: JS_IMPORT_ASSERTION_ENTRY_LIST@18..31 - 0: JS_IMPORT_ASSERTION_ENTRY@18..31 + 2: JS_IMPORT_ATTRIBUTE_ENTRY_LIST@18..31 + 0: JS_IMPORT_ATTRIBUTE_ENTRY@18..31 0: IDENT@18..22 "type" [] [] 1: COLON@22..24 ":" [] [Whitespace(" ")] 2: JS_STRING_LITERAL@24..31 "\"json\"" [] [Whitespace(" ")] @@ -192,11 +192,11 @@ JsModule { 1: JS_IMPORT_BARE_CLAUSE@40..69 0: JS_MODULE_SOURCE@40..46 0: JS_STRING_LITERAL@40..46 "\"foo\"" [] [Whitespace(" ")] - 1: JS_IMPORT_ASSERTION@46..69 + 1: JS_IMPORT_ATTRIBUTE@46..69 0: WITH_KW@46..51 "with" [] [Whitespace(" ")] 1: L_CURLY@51..53 "{" [] [Whitespace(" ")] - 2: JS_IMPORT_ASSERTION_ENTRY_LIST@53..68 - 0: JS_IMPORT_ASSERTION_ENTRY@53..68 + 2: JS_IMPORT_ATTRIBUTE_ENTRY_LIST@53..68 + 0: JS_IMPORT_ATTRIBUTE_ENTRY@53..68 0: JS_STRING_LITERAL@53..59 "\"type\"" [] [] 1: COLON@59..61 ":" [] [Whitespace(" ")] 2: JS_STRING_LITERAL@61..68 "\"json\"" [] [Whitespace(" ")] @@ -212,11 +212,11 @@ JsModule { 2: FROM_KW@82..87 "from" [] [Whitespace(" ")] 3: JS_MODULE_SOURCE@87..98 0: JS_STRING_LITERAL@87..98 "\"foo.json\"" [] [Whitespace(" ")] - 4: JS_IMPORT_ASSERTION@98..119 + 4: JS_IMPORT_ATTRIBUTE@98..119 0: WITH_KW@98..103 "with" [] [Whitespace(" ")] 1: L_CURLY@103..105 "{" [] [Whitespace(" ")] - 2: JS_IMPORT_ASSERTION_ENTRY_LIST@105..118 - 0: JS_IMPORT_ASSERTION_ENTRY@105..118 + 2: JS_IMPORT_ATTRIBUTE_ENTRY_LIST@105..118 + 0: JS_IMPORT_ATTRIBUTE_ENTRY@105..118 0: IDENT@105..109 "type" [] [] 1: COLON@109..111 ":" [] [Whitespace(" ")] 2: JS_STRING_LITERAL@111..118 "\"json\"" [] [Whitespace(" ")] @@ -237,11 +237,11 @@ JsModule { 2: FROM_KW@135..140 "from" [] [Whitespace(" ")] 3: JS_MODULE_SOURCE@140..151 0: JS_STRING_LITERAL@140..151 "\"foo.json\"" [] [Whitespace(" ")] - 4: JS_IMPORT_ASSERTION@151..170 + 4: JS_IMPORT_ATTRIBUTE@151..170 0: WITH_KW@151..156 "with" [] [Whitespace(" ")] 1: L_CURLY@156..158 "{" [] [Whitespace(" ")] - 2: JS_IMPORT_ASSERTION_ENTRY_LIST@158..169 - 0: JS_IMPORT_ASSERTION_ENTRY@158..169 + 2: JS_IMPORT_ATTRIBUTE_ENTRY_LIST@158..169 + 0: JS_IMPORT_ATTRIBUTE_ENTRY@158..169 0: IDENT@158..161 "for" [] [] 1: COLON@161..163 ":" [] [Whitespace(" ")] 2: JS_STRING_LITERAL@163..169 "\"for\"" [] [Whitespace(" ")] @@ -257,16 +257,16 @@ JsModule { 2: FROM_KW@187..192 "from" [] [Whitespace(" ")] 3: JS_MODULE_SOURCE@192..203 0: JS_STRING_LITERAL@192..203 "\"foo.json\"" [] [Whitespace(" ")] - 4: JS_IMPORT_ASSERTION@203..248 + 4: JS_IMPORT_ATTRIBUTE@203..248 0: WITH_KW@203..208 "with" [] [Whitespace(" ")] 1: L_CURLY@208..210 "{" [] [Whitespace(" ")] - 2: JS_IMPORT_ASSERTION_ENTRY_LIST@210..247 - 0: JS_IMPORT_ASSERTION_ENTRY@210..222 + 2: JS_IMPORT_ATTRIBUTE_ENTRY_LIST@210..247 + 0: JS_IMPORT_ATTRIBUTE_ENTRY@210..222 0: IDENT@210..214 "type" [] [] 1: COLON@214..216 ":" [] [Whitespace(" ")] 2: JS_STRING_LITERAL@216..222 "\"json\"" [] [] 1: COMMA@222..224 "," [] [Whitespace(" ")] - 2: JS_IMPORT_ASSERTION_ENTRY@224..247 + 2: JS_IMPORT_ATTRIBUTE_ENTRY@224..247 0: IDENT@224..238 "hasOwnProperty" [] [] 1: COLON@238..240 ":" [] [Whitespace(" ")] 2: JS_STRING_LITERAL@240..247 "\"true\"" [] [Whitespace(" ")] @@ -277,11 +277,11 @@ JsModule { 1: JS_IMPORT_BARE_CLAUSE@257..282 0: JS_MODULE_SOURCE@257..261 0: JS_STRING_LITERAL@257..261 "\"x\"" [] [Whitespace(" ")] - 1: JS_IMPORT_ASSERTION@261..282 + 1: JS_IMPORT_ATTRIBUTE@261..282 0: WITH_KW@261..265 "with" [] [] 1: L_CURLY@265..268 "{" [Newline("\n")] [Whitespace(" ")] - 2: JS_IMPORT_ASSERTION_ENTRY_LIST@268..281 - 0: JS_IMPORT_ASSERTION_ENTRY@268..281 + 2: JS_IMPORT_ATTRIBUTE_ENTRY_LIST@268..281 + 0: JS_IMPORT_ATTRIBUTE_ENTRY@268..281 0: IDENT@268..272 "type" [] [] 1: COLON@272..274 ":" [] [Whitespace(" ")] 2: JS_STRING_LITERAL@274..281 "\"json\"" [] [Whitespace(" ")] diff --git a/crates/biome_js_parser/test_data/inline/ok/import_bare_clause.rast b/crates/biome_js_parser/test_data/inline/ok/import_bare_clause.rast index ec97ea07d0a3..04979680350c 100644 --- a/crates/biome_js_parser/test_data/inline/ok/import_bare_clause.rast +++ b/crates/biome_js_parser/test_data/inline/ok/import_bare_clause.rast @@ -9,7 +9,7 @@ JsModule { source: JsModuleSource { value_token: JS_STRING_LITERAL@7..13 "\"test\"" [] [], }, - assertion: missing (optional), + attribute: missing (optional), }, semicolon_token: SEMICOLON@13..14 ";" [] [], }, @@ -19,7 +19,7 @@ JsModule { source: JsModuleSource { value_token: JS_STRING_LITERAL@22..36 "\"no_semicolon\"" [] [], }, - assertion: missing (optional), + attribute: missing (optional), }, semicolon_token: missing (optional), }, diff --git a/crates/biome_js_parser/test_data/inline/ok/import_decl.rast b/crates/biome_js_parser/test_data/inline/ok/import_decl.rast index 7b59b6d531a6..a45f3e464cbf 100644 --- a/crates/biome_js_parser/test_data/inline/ok/import_decl.rast +++ b/crates/biome_js_parser/test_data/inline/ok/import_decl.rast @@ -18,7 +18,7 @@ JsModule { source: JsModuleSource { value_token: JS_STRING_LITERAL@21..26 "\"bla\"" [] [], }, - assertion: missing (optional), + attribute: missing (optional), }, semicolon_token: SEMICOLON@26..27 ";" [] [], }, diff --git a/crates/biome_js_parser/test_data/inline/ok/import_default_clause.rast b/crates/biome_js_parser/test_data/inline/ok/import_default_clause.rast index 256867c59fe5..5dbab6d95eaf 100644 --- a/crates/biome_js_parser/test_data/inline/ok/import_default_clause.rast +++ b/crates/biome_js_parser/test_data/inline/ok/import_default_clause.rast @@ -16,7 +16,7 @@ JsModule { source: JsModuleSource { value_token: JS_STRING_LITERAL@16..22 "\"test\"" [] [], }, - assertion: missing (optional), + attribute: missing (optional), }, semicolon_token: SEMICOLON@22..23 ";" [] [], }, diff --git a/crates/biome_js_parser/test_data/inline/ok/import_default_clauses.rast b/crates/biome_js_parser/test_data/inline/ok/import_default_clauses.rast index 709a24cb7b7f..75fc2b16d450 100644 --- a/crates/biome_js_parser/test_data/inline/ok/import_default_clauses.rast +++ b/crates/biome_js_parser/test_data/inline/ok/import_default_clauses.rast @@ -28,7 +28,7 @@ JsModule { source: JsModuleSource { value_token: JS_STRING_LITERAL@21..24 "\"b\"" [] [], }, - assertion: missing (optional), + attribute: missing (optional), }, semicolon_token: SEMICOLON@24..25 ";" [] [], }, diff --git a/crates/biome_js_parser/test_data/inline/ok/import_named_clause.rast b/crates/biome_js_parser/test_data/inline/ok/import_named_clause.rast index 41242827a991..d3b68bf74a8c 100644 --- a/crates/biome_js_parser/test_data/inline/ok/import_named_clause.rast +++ b/crates/biome_js_parser/test_data/inline/ok/import_named_clause.rast @@ -16,7 +16,7 @@ JsModule { source: JsModuleSource { value_token: JS_STRING_LITERAL@15..18 "\"a\"" [] [], }, - assertion: missing (optional), + attribute: missing (optional), }, semicolon_token: SEMICOLON@18..19 ";" [] [], }, @@ -55,7 +55,7 @@ JsModule { source: JsModuleSource { value_token: JS_STRING_LITERAL@45..48 "\"b\"" [] [], }, - assertion: missing (optional), + attribute: missing (optional), }, semicolon_token: SEMICOLON@48..49 ";" [] [], }, @@ -105,7 +105,7 @@ JsModule { source: JsModuleSource { value_token: JS_STRING_LITERAL@101..104 "\"b\"" [] [], }, - assertion: missing (optional), + attribute: missing (optional), }, semicolon_token: SEMICOLON@104..105 ";" [] [], }, diff --git a/crates/biome_js_parser/test_data/inline/ok/metavar.rast b/crates/biome_js_parser/test_data/inline/ok/metavar.rast index 57ed61f31eaa..3a51128f7be0 100644 --- a/crates/biome_js_parser/test_data/inline/ok/metavar.rast +++ b/crates/biome_js_parser/test_data/inline/ok/metavar.rast @@ -16,7 +16,7 @@ JsModule { source: JsMetavariable { value_token: GRIT_METAVARIABLE@28..36 "µsource" [] [], }, - assertion: missing (optional), + attribute: missing (optional), }, semicolon_token: SEMICOLON@36..37 ";" [] [], }, @@ -47,7 +47,7 @@ JsModule { source: JsMetavariable { value_token: GRIT_METAVARIABLE@86..94 "µsource" [] [], }, - assertion: missing (optional), + attribute: missing (optional), }, semicolon_token: SEMICOLON@94..95 ";" [] [], }, diff --git a/crates/biome_js_parser/test_data/inline/ok/module.rast b/crates/biome_js_parser/test_data/inline/ok/module.rast index 9f5eb380ff8f..dcadbbb3bcce 100644 --- a/crates/biome_js_parser/test_data/inline/ok/module.rast +++ b/crates/biome_js_parser/test_data/inline/ok/module.rast @@ -16,7 +16,7 @@ JsModule { source: JsModuleSource { value_token: JS_STRING_LITERAL@14..17 "\"b\"" [] [], }, - assertion: missing (optional), + attribute: missing (optional), }, semicolon_token: SEMICOLON@17..18 ";" [] [], }, @@ -75,7 +75,7 @@ JsModule { source: JsModuleSource { value_token: JS_STRING_LITERAL@56..59 "\"c\"" [] [], }, - assertion: missing (optional), + attribute: missing (optional), }, semicolon_token: SEMICOLON@59..60 ";" [] [], }, diff --git a/crates/biome_js_parser/test_data/inline/ok/ts_export_named_from_specifier_with_type.rast b/crates/biome_js_parser/test_data/inline/ok/ts_export_named_from_specifier_with_type.rast index 90395473772d..289f94c13c80 100644 --- a/crates/biome_js_parser/test_data/inline/ok/ts_export_named_from_specifier_with_type.rast +++ b/crates/biome_js_parser/test_data/inline/ok/ts_export_named_from_specifier_with_type.rast @@ -23,7 +23,7 @@ JsModule { source: JsModuleSource { value_token: JS_STRING_LITERAL@23..26 "\"a\"" [] [], }, - assertion: missing (optional), + attribute: missing (optional), semicolon_token: missing (optional), }, }, @@ -47,7 +47,7 @@ JsModule { source: JsModuleSource { value_token: JS_STRING_LITERAL@48..56 "\"./type\"" [] [], }, - assertion: missing (optional), + attribute: missing (optional), semicolon_token: SEMICOLON@56..57 ";" [] [], }, }, diff --git a/crates/biome_js_parser/test_data/inline/ok/ts_export_type_named_from.rast b/crates/biome_js_parser/test_data/inline/ok/ts_export_type_named_from.rast index fd4d940904c0..00281cbd7f7b 100644 --- a/crates/biome_js_parser/test_data/inline/ok/ts_export_type_named_from.rast +++ b/crates/biome_js_parser/test_data/inline/ok/ts_export_type_named_from.rast @@ -23,7 +23,7 @@ JsModule { source: JsModuleSource { value_token: JS_STRING_LITERAL@23..26 "\"a\"" [] [], }, - assertion: missing (optional), + attribute: missing (optional), semicolon_token: SEMICOLON@26..27 ";" [] [], }, }, diff --git a/crates/biome_js_parser/test_data/inline/ok/ts_import_clause_types.rast b/crates/biome_js_parser/test_data/inline/ok/ts_import_clause_types.rast index 379f48b097a6..3159f0b5b429 100644 --- a/crates/biome_js_parser/test_data/inline/ok/ts_import_clause_types.rast +++ b/crates/biome_js_parser/test_data/inline/ok/ts_import_clause_types.rast @@ -16,7 +16,7 @@ JsModule { source: JsModuleSource { value_token: JS_STRING_LITERAL@17..24 "\"./mod\"" [] [], }, - assertion: missing (optional), + attribute: missing (optional), }, semicolon_token: SEMICOLON@24..39 ";" [] [Whitespace(" "), Comments("// not a type")], }, @@ -33,7 +33,7 @@ JsModule { source: JsModuleSource { value_token: JS_STRING_LITERAL@61..68 "\"./mod\"" [] [], }, - assertion: missing (optional), + attribute: missing (optional), }, semicolon_token: SEMICOLON@68..69 ";" [] [], }, @@ -52,7 +52,7 @@ JsModule { source: JsModuleSource { value_token: JS_STRING_LITERAL@97..104 "\"./mod\"" [] [], }, - assertion: missing (optional), + attribute: missing (optional), }, semicolon_token: SEMICOLON@104..105 ";" [] [], }, @@ -76,7 +76,7 @@ JsModule { source: JsModuleSource { value_token: JS_STRING_LITERAL@132..137 "\"mod\"" [] [], }, - assertion: missing (optional), + attribute: missing (optional), }, semicolon_token: SEMICOLON@137..138 ";" [] [], }, @@ -93,7 +93,7 @@ JsModule { source: JsModuleSource { value_token: JS_STRING_LITERAL@161..168 "\"./mod\"" [] [], }, - assertion: missing (optional), + attribute: missing (optional), }, semicolon_token: SEMICOLON@168..169 ";" [] [], }, diff --git a/crates/biome_js_parser/test_data/inline/ok/ts_named_import_specifier_with_type.rast b/crates/biome_js_parser/test_data/inline/ok/ts_named_import_specifier_with_type.rast index 45b198d49c43..2f386ac3b504 100644 --- a/crates/biome_js_parser/test_data/inline/ok/ts_named_import_specifier_with_type.rast +++ b/crates/biome_js_parser/test_data/inline/ok/ts_named_import_specifier_with_type.rast @@ -30,7 +30,7 @@ JsModule { source: JsModuleSource { value_token: JS_STRING_LITERAL@30..37 "\"./mod\"" [] [], }, - assertion: missing (optional), + attribute: missing (optional), }, semicolon_token: SEMICOLON@37..38 ";" [] [], }, @@ -58,7 +58,7 @@ JsModule { source: JsModuleSource { value_token: JS_STRING_LITERAL@69..76 "\"./mod\"" [] [], }, - assertion: missing (optional), + attribute: missing (optional), }, semicolon_token: missing (optional), }, @@ -86,7 +86,7 @@ JsModule { source: JsModuleSource { value_token: JS_STRING_LITERAL@104..111 "\"./mod\"" [] [], }, - assertion: missing (optional), + attribute: missing (optional), }, semicolon_token: SEMICOLON@111..112 ";" [] [], }, @@ -114,7 +114,7 @@ JsModule { source: JsModuleSource { value_token: JS_STRING_LITERAL@143..150 "\"./mod\"" [] [], }, - assertion: missing (optional), + attribute: missing (optional), }, semicolon_token: missing (optional), }, @@ -142,7 +142,7 @@ JsModule { source: JsModuleSource { value_token: JS_STRING_LITERAL@192..199 "\"./mod\"" [] [], }, - assertion: missing (optional), + attribute: missing (optional), }, semicolon_token: SEMICOLON@199..200 ";" [] [], }, diff --git a/crates/biome_js_syntax/src/generated/kind.rs b/crates/biome_js_syntax/src/generated/kind.rs index febf32803792..b7cf00982349 100644 --- a/crates/biome_js_syntax/src/generated/kind.rs +++ b/crates/biome_js_syntax/src/generated/kind.rs @@ -349,9 +349,9 @@ pub enum JsSyntaxKind { JS_DEFAULT_IMPORT_SPECIFIER, JS_NAMED_IMPORT_SPECIFIER, JS_SHORTHAND_NAMED_IMPORT_SPECIFIER, - JS_IMPORT_ASSERTION, - JS_IMPORT_ASSERTION_ENTRY_LIST, - JS_IMPORT_ASSERTION_ENTRY, + JS_IMPORT_ATTRIBUTE, + JS_IMPORT_ATTRIBUTE_ENTRY_LIST, + JS_IMPORT_ATTRIBUTE_ENTRY, JS_MODULE_SOURCE, JS_EXPORT, JS_EXPORT_NAMED_CLAUSE, @@ -508,7 +508,7 @@ pub enum JsSyntaxKind { JS_BOGUS_MEMBER, JS_BOGUS_BINDING, JS_BOGUS_PARAMETER, - JS_BOGUS_IMPORT_ASSERTION_ENTRY, + JS_BOGUS_IMPORT_ATTRIBUTE_ENTRY, JS_BOGUS_NAMED_IMPORT_SPECIFIER, JS_BOGUS_ASSIGNMENT, TS_BOGUS_TYPE, @@ -559,7 +559,7 @@ impl JsSyntaxKind { | JS_ARRAY_ASSIGNMENT_PATTERN_ELEMENT_LIST | JS_OBJECT_ASSIGNMENT_PATTERN_PROPERTY_LIST | JS_NAMED_IMPORT_SPECIFIER_LIST - | JS_IMPORT_ASSERTION_ENTRY_LIST + | JS_IMPORT_ATTRIBUTE_ENTRY_LIST | JS_EXPORT_NAMED_SPECIFIER_LIST | JS_EXPORT_NAMED_FROM_SPECIFIER_LIST | JS_DECORATOR_LIST diff --git a/crates/biome_js_syntax/src/generated/macros.rs b/crates/biome_js_syntax/src/generated/macros.rs index 1ddeda95d8a8..760796f8858c 100644 --- a/crates/biome_js_syntax/src/generated/macros.rs +++ b/crates/biome_js_syntax/src/generated/macros.rs @@ -315,12 +315,12 @@ macro_rules! map_syntax_node { let $pattern = unsafe { $crate::JsImport::new_unchecked(node) }; $body } - $crate::JsSyntaxKind::JS_IMPORT_ASSERTION => { - let $pattern = unsafe { $crate::JsImportAssertion::new_unchecked(node) }; + $crate::JsSyntaxKind::JS_IMPORT_ATTRIBUTE => { + let $pattern = unsafe { $crate::JsImportAttribute::new_unchecked(node) }; $body } - $crate::JsSyntaxKind::JS_IMPORT_ASSERTION_ENTRY => { - let $pattern = unsafe { $crate::JsImportAssertionEntry::new_unchecked(node) }; + $crate::JsSyntaxKind::JS_IMPORT_ATTRIBUTE_ENTRY => { + let $pattern = unsafe { $crate::JsImportAttributeEntry::new_unchecked(node) }; $body } $crate::JsSyntaxKind::JS_IMPORT_BARE_CLAUSE => { @@ -1252,9 +1252,9 @@ macro_rules! map_syntax_node { let $pattern = unsafe { $crate::JsBogusExpression::new_unchecked(node) }; $body } - $crate::JsSyntaxKind::JS_BOGUS_IMPORT_ASSERTION_ENTRY => { + $crate::JsSyntaxKind::JS_BOGUS_IMPORT_ATTRIBUTE_ENTRY => { let $pattern = - unsafe { $crate::JsBogusImportAssertionEntry::new_unchecked(node) }; + unsafe { $crate::JsBogusImportAttributeEntry::new_unchecked(node) }; $body } $crate::JsSyntaxKind::JS_BOGUS_MEMBER => { @@ -1328,9 +1328,9 @@ macro_rules! map_syntax_node { unsafe { $crate::JsExportNamedSpecifierList::new_unchecked(node) }; $body } - $crate::JsSyntaxKind::JS_IMPORT_ASSERTION_ENTRY_LIST => { + $crate::JsSyntaxKind::JS_IMPORT_ATTRIBUTE_ENTRY_LIST => { let $pattern = - unsafe { $crate::JsImportAssertionEntryList::new_unchecked(node) }; + unsafe { $crate::JsImportAttributeEntryList::new_unchecked(node) }; $body } $crate::JsSyntaxKind::JS_METHOD_MODIFIER_LIST => { diff --git a/crates/biome_js_syntax/src/generated/nodes.rs b/crates/biome_js_syntax/src/generated/nodes.rs index 241e831ba045..2eddddd503c5 100644 --- a/crates/biome_js_syntax/src/generated/nodes.rs +++ b/crates/biome_js_syntax/src/generated/nodes.rs @@ -2121,7 +2121,7 @@ impl JsExportFromClause { export_as: self.export_as(), from_token: self.from_token(), source: self.source(), - assertion: self.assertion(), + attribute: self.attribute(), semicolon_token: self.semicolon_token(), } } @@ -2140,7 +2140,7 @@ impl JsExportFromClause { pub fn source(&self) -> SyntaxResult { support::required_node(&self.syntax, 4usize) } - pub fn assertion(&self) -> Option { + pub fn attribute(&self) -> Option { support::node(&self.syntax, 5usize) } pub fn semicolon_token(&self) -> Option { @@ -2162,7 +2162,7 @@ pub struct JsExportFromClauseFields { pub export_as: Option, pub from_token: SyntaxResult, pub source: SyntaxResult, - pub assertion: Option, + pub attribute: Option, pub semicolon_token: Option, } #[derive(Clone, PartialEq, Eq, Hash)] @@ -2242,7 +2242,7 @@ impl JsExportNamedFromClause { r_curly_token: self.r_curly_token(), from_token: self.from_token(), source: self.source(), - assertion: self.assertion(), + attribute: self.attribute(), semicolon_token: self.semicolon_token(), } } @@ -2264,7 +2264,7 @@ impl JsExportNamedFromClause { pub fn source(&self) -> SyntaxResult { support::required_node(&self.syntax, 5usize) } - pub fn assertion(&self) -> Option { + pub fn attribute(&self) -> Option { support::node(&self.syntax, 6usize) } pub fn semicolon_token(&self) -> Option { @@ -2287,7 +2287,7 @@ pub struct JsExportNamedFromClauseFields { pub r_curly_token: SyntaxResult, pub from_token: SyntaxResult, pub source: SyntaxResult, - pub assertion: Option, + pub attribute: Option, pub semicolon_token: Option, } #[derive(Clone, PartialEq, Eq, Hash)] @@ -3494,10 +3494,10 @@ pub struct JsImportFields { pub semicolon_token: Option, } #[derive(Clone, PartialEq, Eq, Hash)] -pub struct JsImportAssertion { +pub struct JsImportAttribute { pub(crate) syntax: SyntaxNode, } -impl JsImportAssertion { +impl JsImportAttribute { #[doc = r" Create an AstNode from a SyntaxNode without checking its kind"] #[doc = r""] #[doc = r" # Safety"] @@ -3507,11 +3507,11 @@ impl JsImportAssertion { pub const unsafe fn new_unchecked(syntax: SyntaxNode) -> Self { Self { syntax } } - pub fn as_fields(&self) -> JsImportAssertionFields { - JsImportAssertionFields { + pub fn as_fields(&self) -> JsImportAttributeFields { + JsImportAttributeFields { with_token: self.with_token(), l_curly_token: self.l_curly_token(), - assertions: self.assertions(), + attributes: self.attributes(), r_curly_token: self.r_curly_token(), } } @@ -3521,14 +3521,14 @@ impl JsImportAssertion { pub fn l_curly_token(&self) -> SyntaxResult { support::required_token(&self.syntax, 1usize) } - pub fn assertions(&self) -> JsImportAssertionEntryList { + pub fn attributes(&self) -> JsImportAttributeEntryList { support::list(&self.syntax, 2usize) } pub fn r_curly_token(&self) -> SyntaxResult { support::required_token(&self.syntax, 3usize) } } -impl Serialize for JsImportAssertion { +impl Serialize for JsImportAttribute { fn serialize(&self, serializer: S) -> Result where S: Serializer, @@ -3537,17 +3537,17 @@ impl Serialize for JsImportAssertion { } } #[derive(Serialize)] -pub struct JsImportAssertionFields { +pub struct JsImportAttributeFields { pub with_token: SyntaxResult, pub l_curly_token: SyntaxResult, - pub assertions: JsImportAssertionEntryList, + pub attributes: JsImportAttributeEntryList, pub r_curly_token: SyntaxResult, } #[derive(Clone, PartialEq, Eq, Hash)] -pub struct JsImportAssertionEntry { +pub struct JsImportAttributeEntry { pub(crate) syntax: SyntaxNode, } -impl JsImportAssertionEntry { +impl JsImportAttributeEntry { #[doc = r" Create an AstNode from a SyntaxNode without checking its kind"] #[doc = r""] #[doc = r" # Safety"] @@ -3557,8 +3557,8 @@ impl JsImportAssertionEntry { pub const unsafe fn new_unchecked(syntax: SyntaxNode) -> Self { Self { syntax } } - pub fn as_fields(&self) -> JsImportAssertionEntryFields { - JsImportAssertionEntryFields { + pub fn as_fields(&self) -> JsImportAttributeEntryFields { + JsImportAttributeEntryFields { key: self.key(), colon_token: self.colon_token(), value_token: self.value_token(), @@ -3574,7 +3574,7 @@ impl JsImportAssertionEntry { support::required_token(&self.syntax, 2usize) } } -impl Serialize for JsImportAssertionEntry { +impl Serialize for JsImportAttributeEntry { fn serialize(&self, serializer: S) -> Result where S: Serializer, @@ -3583,7 +3583,7 @@ impl Serialize for JsImportAssertionEntry { } } #[derive(Serialize)] -pub struct JsImportAssertionEntryFields { +pub struct JsImportAttributeEntryFields { pub key: SyntaxResult, pub colon_token: SyntaxResult, pub value_token: SyntaxResult, @@ -3605,13 +3605,13 @@ impl JsImportBareClause { pub fn as_fields(&self) -> JsImportBareClauseFields { JsImportBareClauseFields { source: self.source(), - assertion: self.assertion(), + attribute: self.attribute(), } } pub fn source(&self) -> SyntaxResult { support::required_node(&self.syntax, 0usize) } - pub fn assertion(&self) -> Option { + pub fn attribute(&self) -> Option { support::node(&self.syntax, 1usize) } } @@ -3626,7 +3626,7 @@ impl Serialize for JsImportBareClause { #[derive(Serialize)] pub struct JsImportBareClauseFields { pub source: SyntaxResult, - pub assertion: Option, + pub attribute: Option, } #[derive(Clone, PartialEq, Eq, Hash)] pub struct JsImportCallExpression { @@ -3689,7 +3689,7 @@ impl JsImportCombinedClause { specifier: self.specifier(), from_token: self.from_token(), source: self.source(), - assertion: self.assertion(), + attribute: self.attribute(), } } pub fn default_specifier(&self) -> SyntaxResult { @@ -3707,7 +3707,7 @@ impl JsImportCombinedClause { pub fn source(&self) -> SyntaxResult { support::required_node(&self.syntax, 4usize) } - pub fn assertion(&self) -> Option { + pub fn attribute(&self) -> Option { support::node(&self.syntax, 5usize) } } @@ -3726,7 +3726,7 @@ pub struct JsImportCombinedClauseFields { pub specifier: SyntaxResult, pub from_token: SyntaxResult, pub source: SyntaxResult, - pub assertion: Option, + pub attribute: Option, } #[derive(Clone, PartialEq, Eq, Hash)] pub struct JsImportDefaultClause { @@ -3748,7 +3748,7 @@ impl JsImportDefaultClause { default_specifier: self.default_specifier(), from_token: self.from_token(), source: self.source(), - assertion: self.assertion(), + attribute: self.attribute(), } } pub fn type_token(&self) -> Option { @@ -3763,7 +3763,7 @@ impl JsImportDefaultClause { pub fn source(&self) -> SyntaxResult { support::required_node(&self.syntax, 3usize) } - pub fn assertion(&self) -> Option { + pub fn attribute(&self) -> Option { support::node(&self.syntax, 4usize) } } @@ -3781,7 +3781,7 @@ pub struct JsImportDefaultClauseFields { pub default_specifier: SyntaxResult, pub from_token: SyntaxResult, pub source: SyntaxResult, - pub assertion: Option, + pub attribute: Option, } #[derive(Clone, PartialEq, Eq, Hash)] pub struct JsImportMetaExpression { @@ -3848,7 +3848,7 @@ impl JsImportNamedClause { named_specifiers: self.named_specifiers(), from_token: self.from_token(), source: self.source(), - assertion: self.assertion(), + attribute: self.attribute(), } } pub fn type_token(&self) -> Option { @@ -3863,7 +3863,7 @@ impl JsImportNamedClause { pub fn source(&self) -> SyntaxResult { support::required_node(&self.syntax, 3usize) } - pub fn assertion(&self) -> Option { + pub fn attribute(&self) -> Option { support::node(&self.syntax, 4usize) } } @@ -3881,7 +3881,7 @@ pub struct JsImportNamedClauseFields { pub named_specifiers: SyntaxResult, pub from_token: SyntaxResult, pub source: SyntaxResult, - pub assertion: Option, + pub attribute: Option, } #[derive(Clone, PartialEq, Eq, Hash)] pub struct JsImportNamespaceClause { @@ -3903,7 +3903,7 @@ impl JsImportNamespaceClause { namespace_specifier: self.namespace_specifier(), from_token: self.from_token(), source: self.source(), - assertion: self.assertion(), + attribute: self.attribute(), } } pub fn type_token(&self) -> Option { @@ -3918,7 +3918,7 @@ impl JsImportNamespaceClause { pub fn source(&self) -> SyntaxResult { support::required_node(&self.syntax, 3usize) } - pub fn assertion(&self) -> Option { + pub fn attribute(&self) -> Option { support::node(&self.syntax, 4usize) } } @@ -3936,7 +3936,7 @@ pub struct JsImportNamespaceClauseFields { pub namespace_specifier: SyntaxResult, pub from_token: SyntaxResult, pub source: SyntaxResult, - pub assertion: Option, + pub attribute: Option, } #[derive(Clone, PartialEq, Eq, Hash)] pub struct JsInExpression { @@ -14421,20 +14421,20 @@ impl AnyJsFunctionBody { } } #[derive(Clone, PartialEq, Eq, Hash, Serialize)] -pub enum AnyJsImportAssertionEntry { - JsBogusImportAssertionEntry(JsBogusImportAssertionEntry), - JsImportAssertionEntry(JsImportAssertionEntry), +pub enum AnyJsImportAttributeEntry { + JsBogusImportAttributeEntry(JsBogusImportAttributeEntry), + JsImportAttributeEntry(JsImportAttributeEntry), } -impl AnyJsImportAssertionEntry { - pub fn as_js_bogus_import_assertion_entry(&self) -> Option<&JsBogusImportAssertionEntry> { +impl AnyJsImportAttributeEntry { + pub fn as_js_bogus_import_attribute_entry(&self) -> Option<&JsBogusImportAttributeEntry> { match &self { - AnyJsImportAssertionEntry::JsBogusImportAssertionEntry(item) => Some(item), + AnyJsImportAttributeEntry::JsBogusImportAttributeEntry(item) => Some(item), _ => None, } } - pub fn as_js_import_assertion_entry(&self) -> Option<&JsImportAssertionEntry> { + pub fn as_js_import_attribute_entry(&self) -> Option<&JsImportAttributeEntry> { match &self { - AnyJsImportAssertionEntry::JsImportAssertionEntry(item) => Some(item), + AnyJsImportAttributeEntry::JsImportAttributeEntry(item) => Some(item), _ => None, } } @@ -18303,8 +18303,8 @@ impl std::fmt::Debug for JsExportFromClause { .field("from_token", &support::DebugSyntaxResult(self.from_token())) .field("source", &support::DebugSyntaxResult(self.source())) .field( - "assertion", - &support::DebugOptionalElement(self.assertion()), + "attribute", + &support::DebugOptionalElement(self.attribute()), ) .field( "semicolon_token", @@ -18417,8 +18417,8 @@ impl std::fmt::Debug for JsExportNamedFromClause { .field("from_token", &support::DebugSyntaxResult(self.from_token())) .field("source", &support::DebugSyntaxResult(self.source())) .field( - "assertion", - &support::DebugOptionalElement(self.assertion()), + "attribute", + &support::DebugOptionalElement(self.attribute()), ) .field( "semicolon_token", @@ -19559,12 +19559,12 @@ impl From for SyntaxElement { n.syntax.into() } } -impl AstNode for JsImportAssertion { +impl AstNode for JsImportAttribute { type Language = Language; const KIND_SET: SyntaxKindSet = - SyntaxKindSet::from_raw(RawSyntaxKind(JS_IMPORT_ASSERTION as u16)); + SyntaxKindSet::from_raw(RawSyntaxKind(JS_IMPORT_ATTRIBUTE as u16)); fn can_cast(kind: SyntaxKind) -> bool { - kind == JS_IMPORT_ASSERTION + kind == JS_IMPORT_ATTRIBUTE } fn cast(syntax: SyntaxNode) -> Option { if Self::can_cast(syntax.kind()) { @@ -19580,15 +19580,15 @@ impl AstNode for JsImportAssertion { self.syntax } } -impl std::fmt::Debug for JsImportAssertion { +impl std::fmt::Debug for JsImportAttribute { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - f.debug_struct("JsImportAssertion") + f.debug_struct("JsImportAttribute") .field("with_token", &support::DebugSyntaxResult(self.with_token())) .field( "l_curly_token", &support::DebugSyntaxResult(self.l_curly_token()), ) - .field("assertions", &self.assertions()) + .field("attributes", &self.attributes()) .field( "r_curly_token", &support::DebugSyntaxResult(self.r_curly_token()), @@ -19596,22 +19596,22 @@ impl std::fmt::Debug for JsImportAssertion { .finish() } } -impl From for SyntaxNode { - fn from(n: JsImportAssertion) -> SyntaxNode { +impl From for SyntaxNode { + fn from(n: JsImportAttribute) -> SyntaxNode { n.syntax } } -impl From for SyntaxElement { - fn from(n: JsImportAssertion) -> SyntaxElement { +impl From for SyntaxElement { + fn from(n: JsImportAttribute) -> SyntaxElement { n.syntax.into() } } -impl AstNode for JsImportAssertionEntry { +impl AstNode for JsImportAttributeEntry { type Language = Language; const KIND_SET: SyntaxKindSet = - SyntaxKindSet::from_raw(RawSyntaxKind(JS_IMPORT_ASSERTION_ENTRY as u16)); + SyntaxKindSet::from_raw(RawSyntaxKind(JS_IMPORT_ATTRIBUTE_ENTRY as u16)); fn can_cast(kind: SyntaxKind) -> bool { - kind == JS_IMPORT_ASSERTION_ENTRY + kind == JS_IMPORT_ATTRIBUTE_ENTRY } fn cast(syntax: SyntaxNode) -> Option { if Self::can_cast(syntax.kind()) { @@ -19627,9 +19627,9 @@ impl AstNode for JsImportAssertionEntry { self.syntax } } -impl std::fmt::Debug for JsImportAssertionEntry { +impl std::fmt::Debug for JsImportAttributeEntry { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - f.debug_struct("JsImportAssertionEntry") + f.debug_struct("JsImportAttributeEntry") .field("key", &support::DebugSyntaxResult(self.key())) .field( "colon_token", @@ -19642,13 +19642,13 @@ impl std::fmt::Debug for JsImportAssertionEntry { .finish() } } -impl From for SyntaxNode { - fn from(n: JsImportAssertionEntry) -> SyntaxNode { +impl From for SyntaxNode { + fn from(n: JsImportAttributeEntry) -> SyntaxNode { n.syntax } } -impl From for SyntaxElement { - fn from(n: JsImportAssertionEntry) -> SyntaxElement { +impl From for SyntaxElement { + fn from(n: JsImportAttributeEntry) -> SyntaxElement { n.syntax.into() } } @@ -19678,8 +19678,8 @@ impl std::fmt::Debug for JsImportBareClause { f.debug_struct("JsImportBareClause") .field("source", &support::DebugSyntaxResult(self.source())) .field( - "assertion", - &support::DebugOptionalElement(self.assertion()), + "attribute", + &support::DebugOptionalElement(self.attribute()), ) .finish() } @@ -19772,8 +19772,8 @@ impl std::fmt::Debug for JsImportCombinedClause { .field("from_token", &support::DebugSyntaxResult(self.from_token())) .field("source", &support::DebugSyntaxResult(self.source())) .field( - "assertion", - &support::DebugOptionalElement(self.assertion()), + "attribute", + &support::DebugOptionalElement(self.attribute()), ) .finish() } @@ -19823,8 +19823,8 @@ impl std::fmt::Debug for JsImportDefaultClause { .field("from_token", &support::DebugSyntaxResult(self.from_token())) .field("source", &support::DebugSyntaxResult(self.source())) .field( - "assertion", - &support::DebugOptionalElement(self.assertion()), + "attribute", + &support::DebugOptionalElement(self.attribute()), ) .finish() } @@ -19917,8 +19917,8 @@ impl std::fmt::Debug for JsImportNamedClause { .field("from_token", &support::DebugSyntaxResult(self.from_token())) .field("source", &support::DebugSyntaxResult(self.source())) .field( - "assertion", - &support::DebugOptionalElement(self.assertion()), + "attribute", + &support::DebugOptionalElement(self.attribute()), ) .finish() } @@ -19968,8 +19968,8 @@ impl std::fmt::Debug for JsImportNamespaceClause { .field("from_token", &support::DebugSyntaxResult(self.from_token())) .field("source", &support::DebugSyntaxResult(self.source())) .field( - "assertion", - &support::DebugOptionalElement(self.assertion()), + "attribute", + &support::DebugOptionalElement(self.attribute()), ) .finish() } @@ -32452,35 +32452,35 @@ impl From for SyntaxElement { node.into() } } -impl From for AnyJsImportAssertionEntry { - fn from(node: JsBogusImportAssertionEntry) -> AnyJsImportAssertionEntry { - AnyJsImportAssertionEntry::JsBogusImportAssertionEntry(node) +impl From for AnyJsImportAttributeEntry { + fn from(node: JsBogusImportAttributeEntry) -> AnyJsImportAttributeEntry { + AnyJsImportAttributeEntry::JsBogusImportAttributeEntry(node) } } -impl From for AnyJsImportAssertionEntry { - fn from(node: JsImportAssertionEntry) -> AnyJsImportAssertionEntry { - AnyJsImportAssertionEntry::JsImportAssertionEntry(node) +impl From for AnyJsImportAttributeEntry { + fn from(node: JsImportAttributeEntry) -> AnyJsImportAttributeEntry { + AnyJsImportAttributeEntry::JsImportAttributeEntry(node) } } -impl AstNode for AnyJsImportAssertionEntry { +impl AstNode for AnyJsImportAttributeEntry { type Language = Language; const KIND_SET: SyntaxKindSet = - JsBogusImportAssertionEntry::KIND_SET.union(JsImportAssertionEntry::KIND_SET); + JsBogusImportAttributeEntry::KIND_SET.union(JsImportAttributeEntry::KIND_SET); fn can_cast(kind: SyntaxKind) -> bool { matches!( kind, - JS_BOGUS_IMPORT_ASSERTION_ENTRY | JS_IMPORT_ASSERTION_ENTRY + JS_BOGUS_IMPORT_ATTRIBUTE_ENTRY | JS_IMPORT_ATTRIBUTE_ENTRY ) } fn cast(syntax: SyntaxNode) -> Option { let res = match syntax.kind() { - JS_BOGUS_IMPORT_ASSERTION_ENTRY => { - AnyJsImportAssertionEntry::JsBogusImportAssertionEntry( - JsBogusImportAssertionEntry { syntax }, + JS_BOGUS_IMPORT_ATTRIBUTE_ENTRY => { + AnyJsImportAttributeEntry::JsBogusImportAttributeEntry( + JsBogusImportAttributeEntry { syntax }, ) } - JS_IMPORT_ASSERTION_ENTRY => { - AnyJsImportAssertionEntry::JsImportAssertionEntry(JsImportAssertionEntry { syntax }) + JS_IMPORT_ATTRIBUTE_ENTRY => { + AnyJsImportAttributeEntry::JsImportAttributeEntry(JsImportAttributeEntry { syntax }) } _ => return None, }; @@ -32488,37 +32488,37 @@ impl AstNode for AnyJsImportAssertionEntry { } fn syntax(&self) -> &SyntaxNode { match self { - AnyJsImportAssertionEntry::JsBogusImportAssertionEntry(it) => &it.syntax, - AnyJsImportAssertionEntry::JsImportAssertionEntry(it) => &it.syntax, + AnyJsImportAttributeEntry::JsBogusImportAttributeEntry(it) => &it.syntax, + AnyJsImportAttributeEntry::JsImportAttributeEntry(it) => &it.syntax, } } fn into_syntax(self) -> SyntaxNode { match self { - AnyJsImportAssertionEntry::JsBogusImportAssertionEntry(it) => it.syntax, - AnyJsImportAssertionEntry::JsImportAssertionEntry(it) => it.syntax, + AnyJsImportAttributeEntry::JsBogusImportAttributeEntry(it) => it.syntax, + AnyJsImportAttributeEntry::JsImportAttributeEntry(it) => it.syntax, } } } -impl std::fmt::Debug for AnyJsImportAssertionEntry { +impl std::fmt::Debug for AnyJsImportAttributeEntry { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { match self { - AnyJsImportAssertionEntry::JsBogusImportAssertionEntry(it) => { + AnyJsImportAttributeEntry::JsBogusImportAttributeEntry(it) => { std::fmt::Debug::fmt(it, f) } - AnyJsImportAssertionEntry::JsImportAssertionEntry(it) => std::fmt::Debug::fmt(it, f), + AnyJsImportAttributeEntry::JsImportAttributeEntry(it) => std::fmt::Debug::fmt(it, f), } } } -impl From for SyntaxNode { - fn from(n: AnyJsImportAssertionEntry) -> SyntaxNode { +impl From for SyntaxNode { + fn from(n: AnyJsImportAttributeEntry) -> SyntaxNode { match n { - AnyJsImportAssertionEntry::JsBogusImportAssertionEntry(it) => it.into(), - AnyJsImportAssertionEntry::JsImportAssertionEntry(it) => it.into(), + AnyJsImportAttributeEntry::JsBogusImportAttributeEntry(it) => it.into(), + AnyJsImportAttributeEntry::JsImportAttributeEntry(it) => it.into(), } } } -impl From for SyntaxElement { - fn from(n: AnyJsImportAssertionEntry) -> SyntaxElement { +impl From for SyntaxElement { + fn from(n: AnyJsImportAttributeEntry) -> SyntaxElement { let node: SyntaxNode = n.into(); node.into() } @@ -37332,7 +37332,7 @@ impl std::fmt::Display for AnyJsFunctionBody { std::fmt::Display::fmt(self.syntax(), f) } } -impl std::fmt::Display for AnyJsImportAssertionEntry { +impl std::fmt::Display for AnyJsImportAttributeEntry { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { std::fmt::Display::fmt(self.syntax(), f) } @@ -37922,12 +37922,12 @@ impl std::fmt::Display for JsImport { std::fmt::Display::fmt(self.syntax(), f) } } -impl std::fmt::Display for JsImportAssertion { +impl std::fmt::Display for JsImportAttribute { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { std::fmt::Display::fmt(self.syntax(), f) } } -impl std::fmt::Display for JsImportAssertionEntry { +impl std::fmt::Display for JsImportAttributeEntry { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { std::fmt::Display::fmt(self.syntax(), f) } @@ -39227,10 +39227,10 @@ impl From for SyntaxElement { } } #[derive(Clone, PartialEq, Eq, Hash, Serialize)] -pub struct JsBogusImportAssertionEntry { +pub struct JsBogusImportAttributeEntry { syntax: SyntaxNode, } -impl JsBogusImportAssertionEntry { +impl JsBogusImportAttributeEntry { #[doc = r" Create an AstNode from a SyntaxNode without checking its kind"] #[doc = r""] #[doc = r" # Safety"] @@ -39244,12 +39244,12 @@ impl JsBogusImportAssertionEntry { support::elements(&self.syntax) } } -impl AstNode for JsBogusImportAssertionEntry { +impl AstNode for JsBogusImportAttributeEntry { type Language = Language; const KIND_SET: SyntaxKindSet = - SyntaxKindSet::from_raw(RawSyntaxKind(JS_BOGUS_IMPORT_ASSERTION_ENTRY as u16)); + SyntaxKindSet::from_raw(RawSyntaxKind(JS_BOGUS_IMPORT_ATTRIBUTE_ENTRY as u16)); fn can_cast(kind: SyntaxKind) -> bool { - kind == JS_BOGUS_IMPORT_ASSERTION_ENTRY + kind == JS_BOGUS_IMPORT_ATTRIBUTE_ENTRY } fn cast(syntax: SyntaxNode) -> Option { if Self::can_cast(syntax.kind()) { @@ -39265,20 +39265,20 @@ impl AstNode for JsBogusImportAssertionEntry { self.syntax } } -impl std::fmt::Debug for JsBogusImportAssertionEntry { +impl std::fmt::Debug for JsBogusImportAttributeEntry { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - f.debug_struct("JsBogusImportAssertionEntry") + f.debug_struct("JsBogusImportAttributeEntry") .field("items", &DebugSyntaxElementChildren(self.items())) .finish() } } -impl From for SyntaxNode { - fn from(n: JsBogusImportAssertionEntry) -> SyntaxNode { +impl From for SyntaxNode { + fn from(n: JsBogusImportAttributeEntry) -> SyntaxNode { n.syntax } } -impl From for SyntaxElement { - fn from(n: JsBogusImportAssertionEntry) -> SyntaxElement { +impl From for SyntaxElement { + fn from(n: JsBogusImportAttributeEntry) -> SyntaxElement { n.syntax.into() } } @@ -40466,10 +40466,10 @@ impl IntoIterator for &JsExportNamedSpecifierList { } } #[derive(Clone, Eq, PartialEq, Hash)] -pub struct JsImportAssertionEntryList { +pub struct JsImportAttributeEntryList { syntax_list: SyntaxList, } -impl JsImportAssertionEntryList { +impl JsImportAttributeEntryList { #[doc = r" Create an AstNode from a SyntaxNode without checking its kind"] #[doc = r""] #[doc = r" # Safety"] @@ -40482,16 +40482,16 @@ impl JsImportAssertionEntryList { } } } -impl AstNode for JsImportAssertionEntryList { +impl AstNode for JsImportAttributeEntryList { type Language = Language; const KIND_SET: SyntaxKindSet = - SyntaxKindSet::from_raw(RawSyntaxKind(JS_IMPORT_ASSERTION_ENTRY_LIST as u16)); + SyntaxKindSet::from_raw(RawSyntaxKind(JS_IMPORT_ATTRIBUTE_ENTRY_LIST as u16)); fn can_cast(kind: SyntaxKind) -> bool { - kind == JS_IMPORT_ASSERTION_ENTRY_LIST + kind == JS_IMPORT_ATTRIBUTE_ENTRY_LIST } - fn cast(syntax: SyntaxNode) -> Option { + fn cast(syntax: SyntaxNode) -> Option { if Self::can_cast(syntax.kind()) { - Some(JsImportAssertionEntryList { + Some(JsImportAttributeEntryList { syntax_list: syntax.into_list(), }) } else { @@ -40505,7 +40505,7 @@ impl AstNode for JsImportAssertionEntryList { self.syntax_list.into_node() } } -impl Serialize for JsImportAssertionEntryList { +impl Serialize for JsImportAttributeEntryList { fn serialize(&self, serializer: S) -> Result where S: Serializer, @@ -40517,9 +40517,9 @@ impl Serialize for JsImportAssertionEntryList { seq.end() } } -impl AstSeparatedList for JsImportAssertionEntryList { +impl AstSeparatedList for JsImportAttributeEntryList { type Language = Language; - type Node = AnyJsImportAssertionEntry; + type Node = AnyJsImportAttributeEntry; fn syntax_list(&self) -> &SyntaxList { &self.syntax_list } @@ -40527,22 +40527,22 @@ impl AstSeparatedList for JsImportAssertionEntryList { self.syntax_list } } -impl Debug for JsImportAssertionEntryList { +impl Debug for JsImportAttributeEntryList { fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result { - f.write_str("JsImportAssertionEntryList ")?; + f.write_str("JsImportAttributeEntryList ")?; f.debug_list().entries(self.elements()).finish() } } -impl IntoIterator for JsImportAssertionEntryList { - type Item = SyntaxResult; - type IntoIter = AstSeparatedListNodesIterator; +impl IntoIterator for JsImportAttributeEntryList { + type Item = SyntaxResult; + type IntoIter = AstSeparatedListNodesIterator; fn into_iter(self) -> Self::IntoIter { self.iter() } } -impl IntoIterator for &JsImportAssertionEntryList { - type Item = SyntaxResult; - type IntoIter = AstSeparatedListNodesIterator; +impl IntoIterator for &JsImportAttributeEntryList { + type Item = SyntaxResult; + type IntoIter = AstSeparatedListNodesIterator; fn into_iter(self) -> Self::IntoIter { self.iter() } diff --git a/crates/biome_js_syntax/src/generated/nodes_mut.rs b/crates/biome_js_syntax/src/generated/nodes_mut.rs index d13ffe2d37cd..e53641b072c5 100644 --- a/crates/biome_js_syntax/src/generated/nodes_mut.rs +++ b/crates/biome_js_syntax/src/generated/nodes_mut.rs @@ -999,7 +999,7 @@ impl JsExportFromClause { .splice_slots(4usize..=4usize, once(Some(element.into_syntax().into()))), ) } - pub fn with_assertion(self, element: Option) -> Self { + pub fn with_attribute(self, element: Option) -> Self { Self::unwrap_cast(self.syntax.splice_slots( 5usize..=5usize, once(element.map(|element| element.into_syntax().into())), @@ -1081,7 +1081,7 @@ impl JsExportNamedFromClause { .splice_slots(5usize..=5usize, once(Some(element.into_syntax().into()))), ) } - pub fn with_assertion(self, element: Option) -> Self { + pub fn with_attribute(self, element: Option) -> Self { Self::unwrap_cast(self.syntax.splice_slots( 6usize..=6usize, once(element.map(|element| element.into_syntax().into())), @@ -1758,7 +1758,7 @@ impl JsImport { ) } } -impl JsImportAssertion { +impl JsImportAttribute { pub fn with_with_token(self, element: SyntaxToken) -> Self { Self::unwrap_cast( self.syntax @@ -1771,7 +1771,7 @@ impl JsImportAssertion { .splice_slots(1usize..=1usize, once(Some(element.into()))), ) } - pub fn with_assertions(self, element: JsImportAssertionEntryList) -> Self { + pub fn with_attributes(self, element: JsImportAttributeEntryList) -> Self { Self::unwrap_cast( self.syntax .splice_slots(2usize..=2usize, once(Some(element.into_syntax().into()))), @@ -1784,7 +1784,7 @@ impl JsImportAssertion { ) } } -impl JsImportAssertionEntry { +impl JsImportAttributeEntry { pub fn with_key_token(self, element: SyntaxToken) -> Self { Self::unwrap_cast( self.syntax @@ -1811,7 +1811,7 @@ impl JsImportBareClause { .splice_slots(0usize..=0usize, once(Some(element.into_syntax().into()))), ) } - pub fn with_assertion(self, element: Option) -> Self { + pub fn with_attribute(self, element: Option) -> Self { Self::unwrap_cast(self.syntax.splice_slots( 1usize..=1usize, once(element.map(|element| element.into_syntax().into())), @@ -1863,7 +1863,7 @@ impl JsImportCombinedClause { .splice_slots(4usize..=4usize, once(Some(element.into_syntax().into()))), ) } - pub fn with_assertion(self, element: Option) -> Self { + pub fn with_attribute(self, element: Option) -> Self { Self::unwrap_cast(self.syntax.splice_slots( 5usize..=5usize, once(element.map(|element| element.into_syntax().into())), @@ -1895,7 +1895,7 @@ impl JsImportDefaultClause { .splice_slots(3usize..=3usize, once(Some(element.into_syntax().into()))), ) } - pub fn with_assertion(self, element: Option) -> Self { + pub fn with_attribute(self, element: Option) -> Self { Self::unwrap_cast(self.syntax.splice_slots( 4usize..=4usize, once(element.map(|element| element.into_syntax().into())), @@ -1947,7 +1947,7 @@ impl JsImportNamedClause { .splice_slots(3usize..=3usize, once(Some(element.into_syntax().into()))), ) } - pub fn with_assertion(self, element: Option) -> Self { + pub fn with_attribute(self, element: Option) -> Self { Self::unwrap_cast(self.syntax.splice_slots( 4usize..=4usize, once(element.map(|element| element.into_syntax().into())), @@ -1979,7 +1979,7 @@ impl JsImportNamespaceClause { .splice_slots(3usize..=3usize, once(Some(element.into_syntax().into()))), ) } - pub fn with_assertion(self, element: Option) -> Self { + pub fn with_attribute(self, element: Option) -> Self { Self::unwrap_cast(self.syntax.splice_slots( 4usize..=4usize, once(element.map(|element| element.into_syntax().into())), diff --git a/crates/biome_js_syntax/src/import_ext.rs b/crates/biome_js_syntax/src/import_ext.rs index f7bc740cb06a..fb39356041a1 100644 --- a/crates/biome_js_syntax/src/import_ext.rs +++ b/crates/biome_js_syntax/src/import_ext.rs @@ -1,7 +1,7 @@ use crate::{ inner_string_text, AnyJsBinding, AnyJsImportClause, AnyJsModuleSource, AnyJsNamedImportSpecifier, JsCallExpression, JsDefaultImportSpecifier, JsImport, - JsImportAssertion, JsImportCallExpression, JsModuleSource, JsNamedImportSpecifier, + JsImportAttribute, JsImportCallExpression, JsModuleSource, JsNamedImportSpecifier, JsNamespaceImportSpecifier, JsShorthandNamedImportSpecifier, JsSyntaxKind, JsSyntaxToken, }; use biome_rowan::{ @@ -75,7 +75,7 @@ impl AnyJsImportClause { }) } - /// Assertion of this import clause. + /// Attribute of this import clause. /// /// ``` /// use biome_js_factory::make; @@ -88,13 +88,13 @@ impl AnyJsImportClause { /// /// assert_eq!(clause.source().unwrap().as_js_module_source().unwrap().inner_string_text().unwrap().text(), "react"); /// ``` - pub fn assertion(&self) -> Option { + pub fn attribute(&self) -> Option { match self { - Self::JsImportBareClause(clause) => clause.assertion(), - Self::JsImportDefaultClause(clause) => clause.assertion(), - Self::JsImportNamedClause(clause) => clause.assertion(), - Self::JsImportNamespaceClause(clause) => clause.assertion(), - Self::JsImportCombinedClause(clause) => clause.assertion(), + Self::JsImportBareClause(clause) => clause.attribute(), + Self::JsImportDefaultClause(clause) => clause.attribute(), + Self::JsImportNamedClause(clause) => clause.attribute(), + Self::JsImportNamespaceClause(clause) => clause.attribute(), + Self::JsImportCombinedClause(clause) => clause.attribute(), } } } diff --git a/crates/biome_js_syntax/src/lib.rs b/crates/biome_js_syntax/src/lib.rs index fe5db8221d59..adbd584e6dd7 100644 --- a/crates/biome_js_syntax/src/lib.rs +++ b/crates/biome_js_syntax/src/lib.rs @@ -108,7 +108,7 @@ impl biome_rowan::SyntaxKind for JsSyntaxKind { | JS_BOGUS_BINDING | JS_BOGUS_MEMBER | JS_BOGUS_EXPRESSION - | JS_BOGUS_IMPORT_ASSERTION_ENTRY + | JS_BOGUS_IMPORT_ATTRIBUTE_ENTRY | JS_BOGUS_NAMED_IMPORT_SPECIFIER | JS_BOGUS_ASSIGNMENT | TS_BOGUS_TYPE @@ -125,7 +125,7 @@ impl biome_rowan::SyntaxKind for JsSyntaxKind { } kind if AnyJsAssignment::can_cast(*kind) => JS_BOGUS_ASSIGNMENT, kind if AnyJsNamedImportSpecifier::can_cast(*kind) => JS_BOGUS_NAMED_IMPORT_SPECIFIER, - kind if AnyJsImportAssertionEntry::can_cast(*kind) => JS_BOGUS_IMPORT_ASSERTION_ENTRY, + kind if AnyJsImportAttributeEntry::can_cast(*kind) => JS_BOGUS_IMPORT_ATTRIBUTE_ENTRY, kind if AnyJsParameter::can_cast(*kind) => JS_BOGUS_PARAMETER, kind if AnyTsType::can_cast(*kind) => TS_BOGUS_TYPE, diff --git a/xtask/codegen/js.ungram b/xtask/codegen/js.ungram index 5d96f46deca8..917a7796b272 100644 --- a/xtask/codegen/js.ungram +++ b/xtask/codegen/js.ungram @@ -44,7 +44,7 @@ JsBogusMember = SyntaxElement* JsBogusBinding = SyntaxElement* JsBogusAssignment = SyntaxElement* JsBogusParameter = SyntaxElement* -JsBogusImportAssertionEntry = SyntaxElement* +JsBogusImportAttributeEntry = SyntaxElement* JsBogusNamedImportSpecifier = SyntaxElement* TsBogusType = SyntaxElement* @@ -1237,7 +1237,7 @@ AnyJsImportClause = // import "abcd" assert ... JsImportBareClause = source: AnyJsModuleSource - assertion: JsImportAssertion? + attribute: JsImportAttribute? // import foo from "mod" // import type foo from "mod" @@ -1246,7 +1246,7 @@ JsImportDefaultClause = default_specifier: JsDefaultImportSpecifier 'from' source: AnyJsModuleSource - assertion: JsImportAssertion? + attribute: JsImportAttribute? // import * as foo from "mod"; // import type * as foo from "mod"; @@ -1255,7 +1255,7 @@ JsImportNamespaceClause = namespace_specifier: JsNamespaceImportSpecifier 'from' source: AnyJsModuleSource - assertion: JsImportAssertion? + attribute: JsImportAttribute? // import { a, b: c } from "d"; // ^^^^^^^^^^^^^^^^^^^^ @@ -1268,7 +1268,7 @@ JsImportNamedClause = named_specifiers: JsNamedImportSpecifiers 'from' source: AnyJsModuleSource - assertion: JsImportAssertion? + attribute: JsImportAttribute? // import c, { b } from "c" // ^^^^^^^^^^^^^^^^^ @@ -1282,7 +1282,7 @@ JsImportCombinedClause = specifier: AnyJsCombinedSpecifier 'from' source: AnyJsModuleSource - assertion: JsImportAssertion? + attribute: JsImportAttribute? AnyJsCombinedSpecifier = JsNamedImportSpecifiers | JsNamespaceImportSpecifier @@ -1328,23 +1328,23 @@ JsShorthandNamedImportSpecifier = 'type'? local_name: AnyJsBinding -// import a from "mod" assert { type: "json" } -// ^^^^^^^^^^^^^^^^^^^^^^^ -JsImportAssertion = +// import a from "mod" with { type: "json" } +// ^^^^^^^^^^^^^^^^^^^^^ +JsImportAttribute = 'with' '{' - assertions: JsImportAssertionEntryList + attributes: JsImportAttributeEntryList '}' -JsImportAssertionEntryList = (AnyJsImportAssertionEntry (',' AnyJsImportAssertionEntry)* ','?) +JsImportAttributeEntryList = (AnyJsImportAttributeEntry (',' AnyJsImportAttributeEntry)* ','?) -AnyJsImportAssertionEntry = - JsImportAssertionEntry - | JsBogusImportAssertionEntry +AnyJsImportAttributeEntry = + JsImportAttributeEntry + | JsBogusImportAttributeEntry -// import a from "mod" assert { type: "json" } -// ^^^^^^^^^^^^ -JsImportAssertionEntry = +// import a from "mod" with { type: "json" } +// ^^^^^^^^^^^^ +JsImportAttributeEntry = key: ('ident' | 'js_string_literal') ':' value: 'js_string_literal' @@ -1483,7 +1483,7 @@ JsExportFromClause = export_as: JsExportAsClause? 'from' source: AnyJsModuleSource - assertion: JsImportAssertion? + attribute: JsImportAttribute? ';'? // export { a } from "b"; @@ -1497,7 +1497,7 @@ JsExportNamedFromClause = '}' 'from' source: AnyJsModuleSource - assertion: JsImportAssertion? + attribute: JsImportAttribute? ';'? AnyJsModuleSource = diff --git a/xtask/codegen/src/js_kinds_src.rs b/xtask/codegen/src/js_kinds_src.rs index 09f05a304392..9102e0a5e6e0 100644 --- a/xtask/codegen/src/js_kinds_src.rs +++ b/xtask/codegen/src/js_kinds_src.rs @@ -356,9 +356,9 @@ pub const JS_KINDS_SRC: KindsSrc = KindsSrc { "JS_DEFAULT_IMPORT_SPECIFIER", "JS_NAMED_IMPORT_SPECIFIER", "JS_SHORTHAND_NAMED_IMPORT_SPECIFIER", - "JS_IMPORT_ASSERTION", - "JS_IMPORT_ASSERTION_ENTRY_LIST", - "JS_IMPORT_ASSERTION_ENTRY", + "JS_IMPORT_ATTRIBUTE", + "JS_IMPORT_ATTRIBUTE_ENTRY_LIST", + "JS_IMPORT_ATTRIBUTE_ENTRY", "JS_MODULE_SOURCE", "JS_EXPORT", "JS_EXPORT_NAMED_CLAUSE", @@ -519,7 +519,7 @@ pub const JS_KINDS_SRC: KindsSrc = KindsSrc { "JS_BOGUS_MEMBER", "JS_BOGUS_BINDING", "JS_BOGUS_PARAMETER", - "JS_BOGUS_IMPORT_ASSERTION_ENTRY", + "JS_BOGUS_IMPORT_ATTRIBUTE_ENTRY", "JS_BOGUS_NAMED_IMPORT_SPECIFIER", "JS_BOGUS_ASSIGNMENT", "TS_BOGUS_TYPE",