diff --git a/CHANGELOG.md b/CHANGELOG.md index de6a1174bd1d..cdd8f75aed52 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,7 +8,11 @@ ### Formatter - Fix an issue where formatting of JSX string literals property values were using incorrect quotes [#4054](https://github.com/rome/tools/issues/4054) - +- Changed import assertion grammar to the new import attribute assertion + ```diff + - import "module" assert {} + + import "module" with {} + ``` ### Linter #### Other changes @@ -26,6 +30,12 @@ the code action is not formatted. ### Parser - Allow module syntax in `cts` files +- Changed import assertion grammar to the new import attribute assertion + ```diff + - import "module" assert {} + + import "module" with {} + ``` + ### VSCode ### JavaScript APIs diff --git a/crates/rome_js_factory/src/generated/node_factory.rs b/crates/rome_js_factory/src/generated/node_factory.rs index 9e75d1008add..503cf1aa5aea 100644 --- a/crates/rome_js_factory/src/generated/node_factory.rs +++ b/crates/rome_js_factory/src/generated/node_factory.rs @@ -993,7 +993,7 @@ pub fn js_export_from_clause( source, type_token: None, export_as: None, - assertion: None, + attribute: None, semicolon_token: None, } } @@ -1003,7 +1003,7 @@ pub struct JsExportFromClauseBuilder { source: JsModuleSource, type_token: Option, export_as: Option, - assertion: Option, + attribute: Option, semicolon_token: Option, } impl JsExportFromClauseBuilder { @@ -1015,8 +1015,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 { @@ -1033,7 +1033,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)), @@ -1098,7 +1098,7 @@ pub fn js_export_named_from_clause( from_token, source, type_token: None, - assertion: None, + attribute: None, semicolon_token: None, } } @@ -1109,7 +1109,7 @@ pub struct JsExportNamedFromClauseBuilder { from_token: SyntaxToken, source: JsModuleSource, type_token: Option, - assertion: Option, + attribute: Option, semicolon_token: Option, } impl JsExportNamedFromClauseBuilder { @@ -1117,8 +1117,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 { @@ -1135,7 +1135,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)), @@ -1912,29 +1912,29 @@ impl JsImportBuilder { )) } } -pub fn js_import_assertion( - assert_token: SyntaxToken, +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(assert_token)), + 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)), @@ -1945,16 +1945,16 @@ pub fn js_import_assertion_entry( pub fn js_import_bare_clause(source: JsModuleSource) -> JsImportBareClauseBuilder { JsImportBareClauseBuilder { source, - assertion: None, + attribute: None, } } pub struct JsImportBareClauseBuilder { source: JsModuleSource, - 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 { @@ -1962,7 +1962,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())), ], )) @@ -1990,7 +1990,7 @@ pub fn js_import_default_clause( from_token, source, type_token: None, - assertion: None, + attribute: None, } } pub struct JsImportDefaultClauseBuilder { @@ -1998,15 +1998,15 @@ pub struct JsImportDefaultClauseBuilder { from_token: SyntaxToken, source: JsModuleSource, 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 { @@ -2017,7 +2017,7 @@ impl JsImportDefaultClauseBuilder { Some(SyntaxElement::Node(self.local_name.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())), ], )) @@ -2048,7 +2048,7 @@ pub fn js_import_named_clause( source, type_token: None, default_specifier: None, - assertion: None, + attribute: None, } } pub struct JsImportNamedClauseBuilder { @@ -2057,7 +2057,7 @@ pub struct JsImportNamedClauseBuilder { source: JsModuleSource, type_token: Option, default_specifier: Option, - assertion: Option, + attribute: Option, } impl JsImportNamedClauseBuilder { pub fn with_type_token(mut self, type_token: SyntaxToken) -> Self { @@ -2068,8 +2068,8 @@ impl JsImportNamedClauseBuilder { self.default_specifier = Some(default_specifier); 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 { @@ -2082,7 +2082,7 @@ impl JsImportNamedClauseBuilder { Some(SyntaxElement::Node(self.named_import.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())), ], )) @@ -2102,7 +2102,7 @@ pub fn js_import_namespace_clause( from_token, source, type_token: None, - assertion: None, + attribute: None, } } pub struct JsImportNamespaceClauseBuilder { @@ -2112,15 +2112,15 @@ pub struct JsImportNamespaceClauseBuilder { from_token: SyntaxToken, source: JsModuleSource, 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 { @@ -2133,7 +2133,7 @@ impl JsImportNamespaceClauseBuilder { Some(SyntaxElement::Node(self.local_name.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())), ], )) @@ -6572,9 +6572,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, @@ -6582,8 +6582,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()) @@ -7092,13 +7092,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/rome_js_factory/src/generated/syntax_factory.rs b/crates/rome_js_factory/src/generated/syntax_factory.rs index 295c124cc4f0..deeb9b953de0 100644 --- a/crates/rome_js_factory/src/generated/syntax_factory.rs +++ b/crates/rome_js_factory/src/generated/syntax_factory.rs @@ -16,7 +16,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 @@ -1631,7 +1631,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(); } @@ -1746,7 +1746,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(); } @@ -2750,12 +2750,12 @@ 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(); if let Some(element) = ¤t_element { - if element.kind() == T![assert] { + if element.kind() == T![with] { slots.mark_present(); current_element = elements.next(); } @@ -2769,7 +2769,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(); } @@ -2784,13 +2784,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(); @@ -2817,11 +2817,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(); @@ -2835,7 +2835,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(); } @@ -2908,7 +2908,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(); } @@ -2995,7 +2995,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(); } @@ -3056,7 +3056,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(); } @@ -9797,10 +9797,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/rome_js_formatter/src/comments.rs b/crates/rome_js_formatter/src/comments.rs index 9a3d004d16b3..a5b45442ec85 100644 --- a/crates/rome_js_formatter/src/comments.rs +++ b/crates/rome_js_formatter/src/comments.rs @@ -1099,7 +1099,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/rome_js_formatter/src/generated.rs b/crates/rome_js_formatter/src/generated.rs index 9d2a621cfa4b..3eb023aca75f 100644 --- a/crates/rome_js_formatter/src/generated.rs +++ b/crates/rome_js_formatter/src/generated.rs @@ -5969,41 +5969,41 @@ impl IntoFormat for rome_js_syntax::JsModuleSource { ) } } -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: &rome_js_syntax::JsImportAssertion, + node: &rome_js_syntax::JsImportAttribute, f: &mut JsFormatter, ) -> FormatResult<()> { - FormatNodeRule::::fmt(self, node, f) + FormatNodeRule::::fmt(self, node, f) } } -impl AsFormat for rome_js_syntax::JsImportAssertion { +impl AsFormat for rome_js_syntax::JsImportAttribute { type Format<'a> = FormatRefWithRule< 'a, - rome_js_syntax::JsImportAssertion, - crate::js::module::import_assertion::FormatJsImportAssertion, + rome_js_syntax::JsImportAttribute, + crate::js::module::import_attribute::FormatJsImportAttribute, >; fn format(&self) -> Self::Format<'_> { FormatRefWithRule::new( self, - crate::js::module::import_assertion::FormatJsImportAssertion::default(), + crate::js::module::import_attribute::FormatJsImportAttribute::default(), ) } } -impl IntoFormat for rome_js_syntax::JsImportAssertion { +impl IntoFormat for rome_js_syntax::JsImportAttribute { type Format = FormatOwnedWithRule< - rome_js_syntax::JsImportAssertion, - crate::js::module::import_assertion::FormatJsImportAssertion, + rome_js_syntax::JsImportAttribute, + crate::js::module::import_attribute::FormatJsImportAttribute, >; fn into_format(self) -> Self::Format { FormatOwnedWithRule::new( self, - crate::js::module::import_assertion::FormatJsImportAssertion::default(), + crate::js::module::import_attribute::FormatJsImportAttribute::default(), ) } } @@ -6223,41 +6223,41 @@ impl IntoFormat for rome_js_syntax::JsLiteralExportName { ) } } -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: &rome_js_syntax::JsImportAssertionEntry, + node: &rome_js_syntax::JsImportAttributeEntry, f: &mut JsFormatter, ) -> FormatResult<()> { - FormatNodeRule::::fmt(self, node, f) + FormatNodeRule::::fmt(self, node, f) } } -impl AsFormat for rome_js_syntax::JsImportAssertionEntry { +impl AsFormat for rome_js_syntax::JsImportAttributeEntry { type Format<'a> = FormatRefWithRule< 'a, - rome_js_syntax::JsImportAssertionEntry, - crate::js::module::import_assertion_entry::FormatJsImportAssertionEntry, + rome_js_syntax::JsImportAttributeEntry, + crate::js::module::import_attribute_entry::FormatJsImportAttributeEntry, >; fn format(&self) -> Self::Format<'_> { FormatRefWithRule::new( self, - crate::js::module::import_assertion_entry::FormatJsImportAssertionEntry::default(), + crate::js::module::import_attribute_entry::FormatJsImportAttributeEntry::default(), ) } } -impl IntoFormat for rome_js_syntax::JsImportAssertionEntry { +impl IntoFormat for rome_js_syntax::JsImportAttributeEntry { type Format = FormatOwnedWithRule< - rome_js_syntax::JsImportAssertionEntry, - crate::js::module::import_assertion_entry::FormatJsImportAssertionEntry, + rome_js_syntax::JsImportAttributeEntry, + crate::js::module::import_attribute_entry::FormatJsImportAttributeEntry, >; fn into_format(self) -> Self::Format { FormatOwnedWithRule::new( self, - crate::js::module::import_assertion_entry::FormatJsImportAssertionEntry::default(), + crate::js::module::import_attribute_entry::FormatJsImportAttributeEntry::default(), ) } } @@ -9906,23 +9906,23 @@ impl IntoFormat for rome_js_syntax::JsExportNamedSpecifierList FormatOwnedWithRule :: new (self , crate :: js :: lists :: export_named_specifier_list :: FormatJsExportNamedSpecifierList :: default ()) } } -impl AsFormat for rome_js_syntax::JsImportAssertionEntryList { +impl AsFormat for rome_js_syntax::JsImportAttributeEntryList { type Format<'a> = FormatRefWithRule< 'a, - rome_js_syntax::JsImportAssertionEntryList, - crate::js::lists::import_assertion_entry_list::FormatJsImportAssertionEntryList, + rome_js_syntax::JsImportAttributeEntryList, + crate::js::lists::import_attribute_entry_list::FormatJsImportAttributeEntryList, >; fn format(&self) -> Self::Format<'_> { - 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 rome_js_syntax::JsImportAssertionEntryList { +impl IntoFormat for rome_js_syntax::JsImportAttributeEntryList { type Format = FormatOwnedWithRule< - rome_js_syntax::JsImportAssertionEntryList, - crate::js::lists::import_assertion_entry_list::FormatJsImportAssertionEntryList, + rome_js_syntax::JsImportAttributeEntryList, + crate::js::lists::import_attribute_entry_list::FormatJsImportAttributeEntryList, >; fn into_format(self) -> Self::Format { - 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 rome_js_syntax::JsMethodModifierList { @@ -10798,36 +10798,36 @@ impl IntoFormat for rome_js_syntax::JsBogusParameter { ) } } -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: &rome_js_syntax::JsBogusImportAssertionEntry, + node: &rome_js_syntax::JsBogusImportAttributeEntry, f: &mut JsFormatter, ) -> FormatResult<()> { - FormatBogusNodeRule::::fmt(self, node, f) + FormatBogusNodeRule::::fmt(self, node, f) } } -impl AsFormat for rome_js_syntax::JsBogusImportAssertionEntry { +impl AsFormat for rome_js_syntax::JsBogusImportAttributeEntry { type Format<'a> = FormatRefWithRule< 'a, - rome_js_syntax::JsBogusImportAssertionEntry, - crate::js::bogus::bogus_import_assertion_entry::FormatJsBogusImportAssertionEntry, + rome_js_syntax::JsBogusImportAttributeEntry, + crate::js::bogus::bogus_import_attribute_entry::FormatJsBogusImportAttributeEntry, >; fn format(&self) -> Self::Format<'_> { - 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 rome_js_syntax::JsBogusImportAssertionEntry { +impl IntoFormat for rome_js_syntax::JsBogusImportAttributeEntry { type Format = FormatOwnedWithRule< - rome_js_syntax::JsBogusImportAssertionEntry, - crate::js::bogus::bogus_import_assertion_entry::FormatJsBogusImportAssertionEntry, + rome_js_syntax::JsBogusImportAttributeEntry, + crate::js::bogus::bogus_import_attribute_entry::FormatJsBogusImportAttributeEntry, >; fn into_format(self) -> Self::Format { - 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 @@ -11931,28 +11931,28 @@ impl IntoFormat for rome_js_syntax::AnyJsNamedImportSpecifier { ) } } -impl AsFormat for rome_js_syntax::AnyJsImportAssertionEntry { +impl AsFormat for rome_js_syntax::AnyJsImportAttributeEntry { type Format<'a> = FormatRefWithRule< 'a, - rome_js_syntax::AnyJsImportAssertionEntry, - crate::js::any::import_assertion_entry::FormatAnyJsImportAssertionEntry, + rome_js_syntax::AnyJsImportAttributeEntry, + crate::js::any::import_attribute_entry::FormatAnyJsImportAttributeEntry, >; fn format(&self) -> Self::Format<'_> { FormatRefWithRule::new( self, - crate::js::any::import_assertion_entry::FormatAnyJsImportAssertionEntry::default(), + crate::js::any::import_attribute_entry::FormatAnyJsImportAttributeEntry::default(), ) } } -impl IntoFormat for rome_js_syntax::AnyJsImportAssertionEntry { +impl IntoFormat for rome_js_syntax::AnyJsImportAttributeEntry { type Format = FormatOwnedWithRule< - rome_js_syntax::AnyJsImportAssertionEntry, - crate::js::any::import_assertion_entry::FormatAnyJsImportAssertionEntry, + rome_js_syntax::AnyJsImportAttributeEntry, + crate::js::any::import_attribute_entry::FormatAnyJsImportAttributeEntry, >; fn into_format(self) -> Self::Format { FormatOwnedWithRule::new( self, - crate::js::any::import_assertion_entry::FormatAnyJsImportAssertionEntry::default(), + crate::js::any::import_attribute_entry::FormatAnyJsImportAttributeEntry::default(), ) } } diff --git a/crates/rome_js_formatter/src/js/any/import_assertion_entry.rs b/crates/rome_js_formatter/src/js/any/import_assertion_entry.rs deleted file mode 100644 index b23bbf5aab80..000000000000 --- a/crates/rome_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 rome_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::JsImportAssertionEntry(node) => node.format().fmt(f), - AnyJsImportAssertionEntry::JsBogusImportAssertionEntry(node) => node.format().fmt(f), - } - } -} diff --git a/crates/rome_js_formatter/src/js/any/import_attribute_entry.rs b/crates/rome_js_formatter/src/js/any/import_attribute_entry.rs new file mode 100644 index 000000000000..1d5f2fbea439 --- /dev/null +++ b/crates/rome_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 rome_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::JsImportAttributeEntry(node) => node.format().fmt(f), + AnyJsImportAttributeEntry::JsBogusImportAttributeEntry(node) => node.format().fmt(f), + } + } +} diff --git a/crates/rome_js_formatter/src/js/any/mod.rs b/crates/rome_js_formatter/src/js/any/mod.rs index 7cb2f51235f7..d47b1e8d38d9 100644 --- a/crates/rome_js_formatter/src/js/any/mod.rs +++ b/crates/rome_js_formatter/src/js/any/mod.rs @@ -24,7 +24,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/rome_js_formatter/src/js/bogus/bogus_import_assertion_entry.rs b/crates/rome_js_formatter/src/js/bogus/bogus_import_assertion_entry.rs deleted file mode 100644 index 44b676bf68b0..000000000000 --- a/crates/rome_js_formatter/src/js/bogus/bogus_import_assertion_entry.rs +++ /dev/null @@ -1,7 +0,0 @@ -use crate::FormatBogusNodeRule; -use rome_js_syntax::JsBogusImportAssertionEntry; - -#[derive(Debug, Clone, Default)] -pub(crate) struct FormatJsBogusImportAssertionEntry; - -impl FormatBogusNodeRule for FormatJsBogusImportAssertionEntry {} diff --git a/crates/rome_js_formatter/src/js/bogus/bogus_import_attribute_entry.rs b/crates/rome_js_formatter/src/js/bogus/bogus_import_attribute_entry.rs new file mode 100644 index 000000000000..d8d2946b5bd4 --- /dev/null +++ b/crates/rome_js_formatter/src/js/bogus/bogus_import_attribute_entry.rs @@ -0,0 +1,5 @@ +use crate::FormatBogusNodeRule; +use rome_js_syntax::JsBogusImportAttributeEntry; +#[derive(Debug, Clone, Default)] +pub(crate) struct FormatJsBogusImportAttributeEntry; +impl FormatBogusNodeRule for FormatJsBogusImportAttributeEntry {} diff --git a/crates/rome_js_formatter/src/js/bogus/mod.rs b/crates/rome_js_formatter/src/js/bogus/mod.rs index 217dc033ce43..98c448f420c0 100644 --- a/crates/rome_js_formatter/src/js/bogus/mod.rs +++ b/crates/rome_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/rome_js_formatter/src/js/lists/import_assertion_entry_list.rs b/crates/rome_js_formatter/src/js/lists/import_attribute_entry_list.rs similarity index 66% rename from crates/rome_js_formatter/src/js/lists/import_assertion_entry_list.rs rename to crates/rome_js_formatter/src/js/lists/import_attribute_entry_list.rs index 48ce8e610f2f..ee8450e5ee61 100644 --- a/crates/rome_js_formatter/src/js/lists/import_assertion_entry_list.rs +++ b/crates/rome_js_formatter/src/js/lists/import_attribute_entry_list.rs @@ -1,14 +1,14 @@ use crate::context::trailing_comma::FormatTrailingComma; use crate::prelude::*; -use rome_js_syntax::JsImportAssertionEntryList; +use rome_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 = FormatTrailingComma::ES5.trailing_separator(f.options()); f.join_with(&soft_line_break_or_space()) diff --git a/crates/rome_js_formatter/src/js/lists/mod.rs b/crates/rome_js_formatter/src/js/lists/mod.rs index 7c78c81c7578..b289630aaf34 100644 --- a/crates/rome_js_formatter/src/js/lists/mod.rs +++ b/crates/rome_js_formatter/src/js/lists/mod.rs @@ -10,7 +10,7 @@ pub(crate) mod constructor_parameter_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/rome_js_formatter/src/js/module/export_from_clause.rs b/crates/rome_js_formatter/src/js/module/export_from_clause.rs index 2f4d4d7a01af..6a0412c4d1b1 100644 --- a/crates/rome_js_formatter/src/js/module/export_from_clause.rs +++ b/crates/rome_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, [space(), assertion.format()])?; + if let Some(attribute) = attribute { + write!(f, [space(), attribute.format()])?; } FormatStatementSemicolon::new(semicolon_token.as_ref()).fmt(f) diff --git a/crates/rome_js_formatter/src/js/module/export_named_from_clause.rs b/crates/rome_js_formatter/src/js/module/export_named_from_clause.rs index 13f1172afed8..d1048dbf75d5 100644 --- a/crates/rome_js_formatter/src/js/module/export_named_from_clause.rs +++ b/crates/rome_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(); @@ -64,8 +64,8 @@ impl FormatNodeRule for FormatJsExportNamedFromClause { ] ]?; - if let Some(assertion) = &assertion { - write!(f, [space(), assertion.format()])?; + if let Some(attribute) = &attribute { + write!(f, [space(), attribute.format()])?; } write!(f, [FormatStatementSemicolon::new(semicolon_token.as_ref())]) diff --git a/crates/rome_js_formatter/src/js/module/import_assertion.rs b/crates/rome_js_formatter/src/js/module/import_attribute.rs similarity index 61% rename from crates/rome_js_formatter/src/js/module/import_assertion.rs rename to crates/rome_js_formatter/src/js/module/import_attribute.rs index e27bf7654d61..6cac70b04aab 100644 --- a/crates/rome_js_formatter/src/js/module/import_assertion.rs +++ b/crates/rome_js_formatter/src/js/module/import_attribute.rs @@ -1,24 +1,21 @@ use crate::prelude::*; - use rome_formatter::write; -use rome_js_syntax::JsImportAssertion; -use rome_js_syntax::JsImportAssertionFields; - +use rome_js_syntax::{JsImportAttribute, JsImportAttributeFields}; +use rome_rowan::AstNode; #[derive(Debug, Clone, Default)] -pub(crate) struct FormatJsImportAssertion; - -impl FormatNodeRule for FormatJsImportAssertion { - fn fmt_fields(&self, node: &JsImportAssertion, f: &mut JsFormatter) -> FormatResult<()> { - let JsImportAssertionFields { - assert_token, +pub(crate) struct FormatJsImportAttribute; +impl FormatNodeRule for FormatJsImportAttribute { + fn fmt_fields(&self, node: &JsImportAttribute, f: &mut JsFormatter) -> FormatResult<()> { + let JsImportAttributeFields { + with_token, l_curly_token, - assertions, + attributes, r_curly_token, } = node.as_fields(); - write![f, [assert_token.format(), space(), l_curly_token.format()]]?; + write![f, [with_token.format(), space(), l_curly_token.format()]]?; - if assertions.is_empty() { + if attributes.is_empty() { let has_dangling = f.comments().has_dangling_comments(node.syntax()); write!( f, @@ -31,7 +28,7 @@ impl FormatNodeRule for FormatJsImportAssertion { } else { write!( f, - [group(&soft_space_or_block_indent(&assertions.format()))] + [group(&soft_space_or_block_indent(&attributes.format()))] )?; } @@ -40,7 +37,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/rome_js_formatter/src/js/module/import_assertion_entry.rs b/crates/rome_js_formatter/src/js/module/import_attribute_entry.rs similarity index 77% rename from crates/rome_js_formatter/src/js/module/import_assertion_entry.rs rename to crates/rome_js_formatter/src/js/module/import_attribute_entry.rs index d80b3689c4fc..903806a9387d 100644 --- a/crates/rome_js_formatter/src/js/module/import_assertion_entry.rs +++ b/crates/rome_js_formatter/src/js/module/import_attribute_entry.rs @@ -2,16 +2,14 @@ use crate::prelude::*; use rome_formatter::write; use crate::utils::{FormatLiteralStringToken, StringLiteralParentKind}; - -use rome_js_syntax::JsImportAssertionEntryFields; -use rome_js_syntax::{JsImportAssertionEntry, JsSyntaxKind}; +use rome_js_syntax::{JsImportAttributeEntry, JsImportAttributeEntryFields, 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 +52,7 @@ impl FormatNodeRule for FormatJsImportAssertionEntry { fn fmt_dangling_comments( &self, - _: &JsImportAssertionEntry, + _: &JsImportAttributeEntry, _: &mut JsFormatter, ) -> FormatResult<()> { // Handled inside `fmt_fields` diff --git a/crates/rome_js_formatter/src/js/module/import_bare_clause.rs b/crates/rome_js_formatter/src/js/module/import_bare_clause.rs index 41a4dbfb8780..794565305557 100644 --- a/crates/rome_js_formatter/src/js/module/import_bare_clause.rs +++ b/crates/rome_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, [space(), assertion.format()])?; + if let Some(attribute) = attribute { + write!(f, [space(), attribute.format()])?; } Ok(()) diff --git a/crates/rome_js_formatter/src/js/module/import_default_clause.rs b/crates/rome_js_formatter/src/js/module/import_default_clause.rs index cc2dae430631..21ad0b8a2845 100644 --- a/crates/rome_js_formatter/src/js/module/import_default_clause.rs +++ b/crates/rome_js_formatter/src/js/module/import_default_clause.rs @@ -14,7 +14,7 @@ impl FormatNodeRule for FormatJsImportDefaultClause { local_name, 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, [space(), assertion.format()])?; + if let Some(attribute) = attribute { + write!(f, [space(), attribute.format()])?; } Ok(()) diff --git a/crates/rome_js_formatter/src/js/module/import_named_clause.rs b/crates/rome_js_formatter/src/js/module/import_named_clause.rs index f782a61c3f3b..c6a530b4f45d 100644 --- a/crates/rome_js_formatter/src/js/module/import_named_clause.rs +++ b/crates/rome_js_formatter/src/js/module/import_named_clause.rs @@ -18,7 +18,7 @@ impl FormatNodeRule for FormatJsImportNamedClause { named_import, from_token, source, - assertion, + attribute, } = node.as_fields(); if let Some(type_token) = type_token { @@ -111,8 +111,8 @@ impl FormatNodeRule for FormatJsImportNamedClause { write![f, [space(), from_token.format(), space(), source.format(),]]?; - if let Some(assertion) = assertion { - write!(f, [space(), assertion.format()])?; + if let Some(attribute) = attribute { + write!(f, [space(), attribute.format()])?; } Ok(()) diff --git a/crates/rome_js_formatter/src/js/module/import_namespace_clause.rs b/crates/rome_js_formatter/src/js/module/import_namespace_clause.rs index 6b96bfb73adb..8e3687e848c5 100644 --- a/crates/rome_js_formatter/src/js/module/import_namespace_clause.rs +++ b/crates/rome_js_formatter/src/js/module/import_namespace_clause.rs @@ -16,7 +16,7 @@ impl FormatNodeRule for FormatJsImportNamespaceClause { local_name, from_token, source, - assertion, + attribute, } = node.as_fields(); if let Some(type_token) = type_token { @@ -38,8 +38,8 @@ impl FormatNodeRule for FormatJsImportNamespaceClause { ] ]?; - if let Some(assertion) = assertion { - write!(f, [space(), assertion.format()])?; + if let Some(attribute) = attribute { + write!(f, [space(), attribute.format()])?; } Ok(()) diff --git a/crates/rome_js_formatter/src/js/module/mod.rs b/crates/rome_js_formatter/src/js/module/mod.rs index bfe8e8a9a990..e568e01fa66a 100644 --- a/crates/rome_js_formatter/src/js/module/mod.rs +++ b/crates/rome_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_default_clause; pub(crate) mod import_named_clause; diff --git a/crates/rome_js_formatter/tests/specs/js/module/export/from_clause.js b/crates/rome_js_formatter/tests/specs/js/module/export/from_clause.js index 7235ae959b08..4ba8477f2785 100644 --- a/crates/rome_js_formatter/tests/specs/js/module/export/from_clause.js +++ b/crates/rome_js_formatter/tests/specs/js/module/export/from_clause.js @@ -2,4 +2,4 @@ export * from "hey" export * as something_bad_will_happen from "something_bad_might_not_happen" -export * as something_bad_will_happen from "something_bad_might_not_happen" assert { "type": "json", "type2": "json3"} \ No newline at end of file +export * as something_bad_will_happen from "something_bad_might_not_happen" with { "type": "json", "type2": "json3"} diff --git a/crates/rome_js_formatter/tests/specs/js/module/export/from_clause.js.snap b/crates/rome_js_formatter/tests/specs/js/module/export/from_clause.js.snap index 35e043d9a14a..632b900ba171 100644 --- a/crates/rome_js_formatter/tests/specs/js/module/export/from_clause.js.snap +++ b/crates/rome_js_formatter/tests/specs/js/module/export/from_clause.js.snap @@ -1,7 +1,6 @@ --- source: crates/rome_formatter_test/src/snapshot_builder.rs -info: - test_file: js/module/export/from_clause.js +info: js/module/export/from_clause.js --- # Input @@ -11,7 +10,8 @@ export * from "hey" export * as something_bad_will_happen from "something_bad_might_not_happen" -export * as something_bad_will_happen from "something_bad_might_not_happen" assert { "type": "json", "type2": "json3"} +export * as something_bad_will_happen from "something_bad_might_not_happen" with { "type": "json", "type2": "json3"} + ``` @@ -35,7 +35,7 @@ export * from "hey"; export * as something_bad_will_happen from "something_bad_might_not_happen"; -export * as something_bad_will_happen from "something_bad_might_not_happen" assert { +export * as something_bad_will_happen from "something_bad_might_not_happen" with { "type": "json", "type2": "json3", }; @@ -43,6 +43,7 @@ export * as something_bad_will_happen from "something_bad_might_not_happen" asse # Lines exceeding max width of 80 characters ``` - 5: export * as something_bad_will_happen from "something_bad_might_not_happen" assert { + 5: export * as something_bad_will_happen from "something_bad_might_not_happen" with { ``` + diff --git a/crates/rome_js_formatter/tests/specs/js/module/export/named_from_clause.js b/crates/rome_js_formatter/tests/specs/js/module/export/named_from_clause.js index a8f3ac2e077a..5ca9b6341c91 100644 --- a/crates/rome_js_formatter/tests/specs/js/module/export/named_from_clause.js +++ b/crates/rome_js_formatter/tests/specs/js/module/export/named_from_clause.js @@ -1,20 +1,20 @@ export {a, b as c -} from "fancy" assert { type: "json"} +} from "fancy" with { type: "json"} export { lorem_lorem_lorem_lorem_lorem_lorem_lorem_lorem_lorem, lorem_lorem_lorem_lorem_lorem_ as ipsum_ipsum_ipsum_ipsum_ipsum_ipsum_ -} from "fancy" assert { type: "json", "type2": "json", type23: "json", "type24": "json"} +} from "fancy" with { type: "json", "type2": "json", type23: "json", "type24": "json"} export { loooooooooooooooooooooooooooooooooooooooooooooooooong } from "loooooooooooooooooooooooooooooooooooooooooooooong" export { loooooooooooooooooooooooooooooooooooooooooooooooooong, } from "loooooooooooooooooooooooooooooooooooooooooooooong" -export { -// comment +export { +// comment loooooooooooooooooooooooooooooooooooooooooooooooooong } from "loooooooooooooooooooooooooooooooooooooooooooooong" -export { a as b } from "loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong" \ No newline at end of file +export { a as b } from "loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong" diff --git a/crates/rome_js_formatter/tests/specs/js/module/export/named_from_clause.js.snap b/crates/rome_js_formatter/tests/specs/js/module/export/named_from_clause.js.snap index 45a7454d39e9..2fa4013687ee 100644 --- a/crates/rome_js_formatter/tests/specs/js/module/export/named_from_clause.js.snap +++ b/crates/rome_js_formatter/tests/specs/js/module/export/named_from_clause.js.snap @@ -1,7 +1,6 @@ --- source: crates/rome_formatter_test/src/snapshot_builder.rs -info: - test_file: js/module/export/named_from_clause.js +info: js/module/export/named_from_clause.js --- # Input @@ -9,24 +8,25 @@ info: ```js export {a, b as c -} from "fancy" assert { type: "json"} +} from "fancy" with { type: "json"} export { lorem_lorem_lorem_lorem_lorem_lorem_lorem_lorem_lorem, lorem_lorem_lorem_lorem_lorem_ as ipsum_ipsum_ipsum_ipsum_ipsum_ipsum_ -} from "fancy" assert { type: "json", "type2": "json", type23: "json", "type24": "json"} +} from "fancy" with { type: "json", "type2": "json", type23: "json", "type24": "json"} export { loooooooooooooooooooooooooooooooooooooooooooooooooong } from "loooooooooooooooooooooooooooooooooooooooooooooong" export { loooooooooooooooooooooooooooooooooooooooooooooooooong, } from "loooooooooooooooooooooooooooooooooooooooooooooong" -export { -// comment +export { +// comment loooooooooooooooooooooooooooooooooooooooooooooooooong } from "loooooooooooooooooooooooooooooooooooooooooooooong" export { a as b } from "loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong" + ``` @@ -46,12 +46,12 @@ Semicolons: Always ----- ```js -export { a, b as c } from "fancy" assert { type: "json" }; +export { a, b as c } from "fancy" with { type: "json" }; export { lorem_lorem_lorem_lorem_lorem_lorem_lorem_lorem_lorem, lorem_lorem_lorem_lorem_lorem_ as ipsum_ipsum_ipsum_ipsum_ipsum_ipsum_, -} from "fancy" assert { +} from "fancy" with { type: "json", "type2": "json", type23: "json", diff --git a/crates/rome_js_formatter/tests/specs/js/module/import/bare_import.js b/crates/rome_js_formatter/tests/specs/js/module/import/bare_import.js index f424f1f08ebf..2caebe1531ae 100644 --- a/crates/rome_js_formatter/tests/specs/js/module/import/bare_import.js +++ b/crates/rome_js_formatter/tests/specs/js/module/import/bare_import.js @@ -1,16 +1,16 @@ import "very_long_import_very_long_import_very_long_import_very_long_import_very_long_import_very_long_import_very_long_import_"; -import "very_long_import_very_long_import_very_long_import_very_long_import_very_long_import_very_long" assert { type : "json"} -import "short" assert { +import "very_long_import_very_long_import_very_long_import_very_long_import_very_long_import_very_long" with { type : "json"} +import "short" with { type : "json" } -import "very_long_import_very_long_import_very" assert { +import "very_long_import_very_long_import_very" with { // something good is here "type": /****/ "json" } -import "very_long_import_very_long_import_very" assert { +import "very_long_import_very_long_import_very" with { // something good is here "type": /****/ "json", "type2" /****/ : "json", diff --git a/crates/rome_js_formatter/tests/specs/js/module/import/bare_import.js.snap b/crates/rome_js_formatter/tests/specs/js/module/import/bare_import.js.snap index c5ed0b49fe71..77eed8fbf869 100644 --- a/crates/rome_js_formatter/tests/specs/js/module/import/bare_import.js.snap +++ b/crates/rome_js_formatter/tests/specs/js/module/import/bare_import.js.snap @@ -8,18 +8,18 @@ info: ```js import "very_long_import_very_long_import_very_long_import_very_long_import_very_long_import_very_long_import_very_long_import_"; -import "very_long_import_very_long_import_very_long_import_very_long_import_very_long_import_very_long" assert { type : "json"} -import "short" assert { +import "very_long_import_very_long_import_very_long_import_very_long_import_very_long_import_very_long" with { type : "json"} +import "short" with { type : "json" } -import "very_long_import_very_long_import_very" assert { +import "very_long_import_very_long_import_very" with { // something good is here "type": /****/ "json" } -import "very_long_import_very_long_import_very" assert { +import "very_long_import_very_long_import_very" with { // something good is here "type": /****/ "json", "type2" /****/ : "json", @@ -51,17 +51,17 @@ Semicolons: Always ```js import "very_long_import_very_long_import_very_long_import_very_long_import_very_long_import_very_long_import_very_long_import_"; -import "very_long_import_very_long_import_very_long_import_very_long_import_very_long_import_very_long" assert { +import "very_long_import_very_long_import_very_long_import_very_long_import_very_long_import_very_long" with { type: "json", }; -import "short" assert { type: "json" }; +import "short" with { type: "json" }; -import "very_long_import_very_long_import_very" assert { +import "very_long_import_very_long_import_very" with { // something good is here "type": /****/ "json", }; -import "very_long_import_very_long_import_very" assert { +import "very_long_import_very_long_import_very" with { // something good is here "type": /****/ "json", "type2": /****/ "json", @@ -76,7 +76,7 @@ import "very_long_import_very_long_import_very" assert { # Lines exceeding max width of 80 characters ``` 1: import "very_long_import_very_long_import_very_long_import_very_long_import_very_long_import_very_long_import_very_long_import_"; - 2: import "very_long_import_very_long_import_very_long_import_very_long_import_very_long_import_very_long" assert { + 2: import "very_long_import_very_long_import_very_long_import_very_long_import_very_long_import_very_long" with { 20: "typetypetypetypetypetypetypetypetypetypetype": /****/ "typetypetypetypetypetypetypetypetypetypetypetypetypetype", ``` diff --git a/crates/rome_js_formatter/tests/specs/js/module/import/default_import.js b/crates/rome_js_formatter/tests/specs/js/module/import/default_import.js index 0e997493a03e..b5fc4d66ffd1 100644 --- a/crates/rome_js_formatter/tests/specs/js/module/import/default_import.js +++ b/crates/rome_js_formatter/tests/specs/js/module/import/default_import.js @@ -1,11 +1,11 @@ import hey from "hey" import hey from "hey"; -import "x" assert { type: "json" } -import "foo" assert { "type": "json" }; -import foo from "foo.json" assert { type: "json" }; -import foo from "foo.json" assert { +import "x" with { type: "json" } +import "foo" with { "type": "json" }; +import foo from "foo.json" with { type: "json" }; +import foo from "foo.json" with { type: "json" }; -import foo2 from "foo.json" assert { "type": "json", type: "html", "type": "js" }; +import foo2 from "foo.json" with { "type": "json", type: "html", "type": "js" }; import a, * as b from "foo" diff --git a/crates/rome_js_formatter/tests/specs/js/module/import/default_import.js.snap b/crates/rome_js_formatter/tests/specs/js/module/import/default_import.js.snap index ed3d6333c52b..ab38ec1538af 100644 --- a/crates/rome_js_formatter/tests/specs/js/module/import/default_import.js.snap +++ b/crates/rome_js_formatter/tests/specs/js/module/import/default_import.js.snap @@ -1,7 +1,6 @@ --- source: crates/rome_formatter_test/src/snapshot_builder.rs -info: - test_file: js/module/import/default_import.js +info: js/module/import/default_import.js --- # Input @@ -9,14 +8,14 @@ info: ```js import hey from "hey" import hey from "hey"; -import "x" assert { type: "json" } -import "foo" assert { "type": "json" }; -import foo from "foo.json" assert { type: "json" }; -import foo from "foo.json" assert { +import "x" with { type: "json" } +import "foo" with { "type": "json" }; +import foo from "foo.json" with { type: "json" }; +import foo from "foo.json" with { type: "json" }; -import foo2 from "foo.json" assert { "type": "json", type: "html", "type": "js" }; +import foo2 from "foo.json" with { "type": "json", type: "html", "type": "js" }; import a, * as b from "foo" ``` @@ -40,15 +39,11 @@ Semicolons: Always ```js import hey from "hey"; import hey from "hey"; -import "x" assert { type: "json" }; -import "foo" assert { "type": "json" }; -import foo from "foo.json" assert { type: "json" }; -import foo from "foo.json" assert { type: "json" }; -import foo2 from "foo.json" assert { - "type": "json", - type: "html", - "type": "js", -}; +import "x" with { type: "json" }; +import "foo" with { "type": "json" }; +import foo from "foo.json" with { type: "json" }; +import foo from "foo.json" with { type: "json" }; +import foo2 from "foo.json" with { "type": "json", type: "html", "type": "js" }; import a, * as b from "foo"; ``` diff --git a/crates/rome_js_formatter/tests/specs/js/module/import/import-assertions/bracket-spacing/dynamic-import.js b/crates/rome_js_formatter/tests/specs/js/module/import/import-assertions/bracket-spacing/dynamic-import.js new file mode 100644 index 000000000000..717b72d4a84f --- /dev/null +++ b/crates/rome_js_formatter/tests/specs/js/module/import/import-assertions/bracket-spacing/dynamic-import.js @@ -0,0 +1 @@ +import("./foo.json", { with: { type: "json" } }); diff --git a/crates/rome_js_formatter/tests/specs/js/module/import/import-assertions/bracket-spacing/dynamic-import.js.prettier-snap b/crates/rome_js_formatter/tests/specs/js/module/import/import-assertions/bracket-spacing/dynamic-import.js.prettier-snap new file mode 100644 index 000000000000..717b72d4a84f --- /dev/null +++ b/crates/rome_js_formatter/tests/specs/js/module/import/import-assertions/bracket-spacing/dynamic-import.js.prettier-snap @@ -0,0 +1 @@ +import("./foo.json", { with: { type: "json" } }); diff --git a/crates/rome_js_formatter/tests/specs/js/module/import/import-assertions/bracket-spacing/empty.js b/crates/rome_js_formatter/tests/specs/js/module/import/import-assertions/bracket-spacing/empty.js new file mode 100644 index 000000000000..fe2a9deb8714 --- /dev/null +++ b/crates/rome_js_formatter/tests/specs/js/module/import/import-assertions/bracket-spacing/empty.js @@ -0,0 +1 @@ +export * as bar from "bar.json" with { } diff --git a/crates/rome_js_formatter/tests/specs/js/module/import/import-assertions/bracket-spacing/empty.js.prettier-snap b/crates/rome_js_formatter/tests/specs/js/module/import/import-assertions/bracket-spacing/empty.js.prettier-snap new file mode 100644 index 000000000000..349c495478af --- /dev/null +++ b/crates/rome_js_formatter/tests/specs/js/module/import/import-assertions/bracket-spacing/empty.js.prettier-snap @@ -0,0 +1 @@ +export * as bar from "bar.json"; diff --git a/crates/rome_js_formatter/tests/specs/js/module/import/import-assertions/bracket-spacing/empty.js.snap b/crates/rome_js_formatter/tests/specs/js/module/import/import-assertions/bracket-spacing/empty.js.snap new file mode 100644 index 000000000000..e334e7c1fe57 --- /dev/null +++ b/crates/rome_js_formatter/tests/specs/js/module/import/import-assertions/bracket-spacing/empty.js.snap @@ -0,0 +1,73 @@ +--- +source: crates/rome_formatter_test/src/snapshot_builder.rs +info: js/import-withions/bracket-spacing/empty.js +--- + +# Input + +```js +export * as bar from "bar.json" with { } +``` + + +# Prettier differences + +```diff +--- Prettier ++++ Rome +@@ -1 +1,4 @@ + export * as bar from "bar.json"; ++with; ++{ ++} +``` + +# Output + +```js +export * as bar from "bar.json"; +with; +{ +} +``` + +# Errors +``` +empty.js:1:33 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + + × Expected a semicolon or an implicit semicolon after a statement, but found none + + > 1 │ export * as bar from "bar.json" with { } + │ ^^^^^^ + + i An explicit or implicit semicolon is expected here... + + > 1 │ export * as bar from "bar.json" with { } + │ ^^^^^^ + + i ...Which is required to end this statement + + > 1 │ export * as bar from "bar.json" with { } + │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +empty.js:1:40 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + + × Expected a semicolon or an implicit semicolon after a statement, but found none + + > 1 │ export * as bar from "bar.json" with { } + │ ^ + + i An explicit or implicit semicolon is expected here... + + > 1 │ export * as bar from "bar.json" with { } + │ ^ + + i ...Which is required to end this statement + + > 1 │ export * as bar from "bar.json" with { } + │ ^^^^^^^^ + + +``` + + diff --git a/crates/rome_js_formatter/tests/specs/js/module/import/import-assertions/bracket-spacing/re-export.js b/crates/rome_js_formatter/tests/specs/js/module/import/import-assertions/bracket-spacing/re-export.js new file mode 100644 index 000000000000..12b98b761f48 --- /dev/null +++ b/crates/rome_js_formatter/tests/specs/js/module/import/import-assertions/bracket-spacing/re-export.js @@ -0,0 +1 @@ +export { default as foo2 } from "foo.json" with { type: "json" }; diff --git a/crates/rome_js_formatter/tests/specs/js/module/import/import-assertions/bracket-spacing/re-export.js.prettier-snap b/crates/rome_js_formatter/tests/specs/js/module/import/import-assertions/bracket-spacing/re-export.js.prettier-snap new file mode 100644 index 000000000000..12b98b761f48 --- /dev/null +++ b/crates/rome_js_formatter/tests/specs/js/module/import/import-assertions/bracket-spacing/re-export.js.prettier-snap @@ -0,0 +1 @@ +export { default as foo2 } from "foo.json" with { type: "json" }; diff --git a/crates/rome_js_formatter/tests/specs/js/module/import/import-assertions/bracket-spacing/re-export.js.snap b/crates/rome_js_formatter/tests/specs/js/module/import/import-assertions/bracket-spacing/re-export.js.snap new file mode 100644 index 000000000000..80361e55862d --- /dev/null +++ b/crates/rome_js_formatter/tests/specs/js/module/import/import-assertions/bracket-spacing/re-export.js.snap @@ -0,0 +1,83 @@ +--- +source: crates/rome_formatter_test/src/snapshot_builder.rs +info: js/import-withions/bracket-spacing/re-export.js +--- + +# Input + +```js +export { default as foo2 } from "foo.json" with { type: "json" }; + +``` + + +# Prettier differences + +```diff +--- Prettier ++++ Rome +@@ -1 +1,5 @@ +-export { default as foo2 } from "foo.json" with { type: "json" }; ++export { default as foo2 } from "foo.json"; ++with; ++{ ++ type: "json"; ++} +``` + +# Output + +```js +export { default as foo2 } from "foo.json"; +with; +{ + type: "json"; +} +``` + +# Errors +``` +re-export.js:1:44 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + + × Expected a semicolon or an implicit semicolon after a statement, but found none + + > 1 │ export { default as foo2 } from "foo.json" with { type: "json" }; + │ ^^^^^^ + 2 │ + + i An explicit or implicit semicolon is expected here... + + > 1 │ export { default as foo2 } from "foo.json" with { type: "json" }; + │ ^^^^^^ + 2 │ + + i ...Which is required to end this statement + + > 1 │ export { default as foo2 } from "foo.json" with { type: "json" }; + │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + 2 │ + +re-export.js:1:51 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + + × Expected a semicolon or an implicit semicolon after a statement, but found none + + > 1 │ export { default as foo2 } from "foo.json" with { type: "json" }; + │ ^ + 2 │ + + i An explicit or implicit semicolon is expected here... + + > 1 │ export { default as foo2 } from "foo.json" with { type: "json" }; + │ ^ + 2 │ + + i ...Which is required to end this statement + + > 1 │ export { default as foo2 } from "foo.json" with { type: "json" }; + │ ^^^^^^^^ + 2 │ + + +``` + + diff --git a/crates/rome_js_formatter/tests/specs/js/module/import/import-assertions/bracket-spacing/static-import.js b/crates/rome_js_formatter/tests/specs/js/module/import/import-assertions/bracket-spacing/static-import.js new file mode 100644 index 000000000000..7770ae1f06b0 --- /dev/null +++ b/crates/rome_js_formatter/tests/specs/js/module/import/import-assertions/bracket-spacing/static-import.js @@ -0,0 +1 @@ +import json from "./foo.json" with { type: "json" }; diff --git a/crates/rome_js_formatter/tests/specs/js/module/import/import-assertions/bracket-spacing/static-import.js.prettier-snap b/crates/rome_js_formatter/tests/specs/js/module/import/import-assertions/bracket-spacing/static-import.js.prettier-snap new file mode 100644 index 000000000000..7770ae1f06b0 --- /dev/null +++ b/crates/rome_js_formatter/tests/specs/js/module/import/import-assertions/bracket-spacing/static-import.js.prettier-snap @@ -0,0 +1 @@ +import json from "./foo.json" with { type: "json" }; diff --git a/crates/rome_js_formatter/tests/specs/js/module/import/import-assertions/bracket-spacing/static-import.js.snap b/crates/rome_js_formatter/tests/specs/js/module/import/import-assertions/bracket-spacing/static-import.js.snap new file mode 100644 index 000000000000..252f22d2dd23 --- /dev/null +++ b/crates/rome_js_formatter/tests/specs/js/module/import/import-assertions/bracket-spacing/static-import.js.snap @@ -0,0 +1,83 @@ +--- +source: crates/rome_formatter_test/src/snapshot_builder.rs +info: js/import-withions/bracket-spacing/static-import.js +--- + +# Input + +```js +import json from "./foo.json" with { type: "json" }; + +``` + + +# Prettier differences + +```diff +--- Prettier ++++ Rome +@@ -1 +1,5 @@ +-import json from "./foo.json" with { type: "json" }; ++import json from "./foo.json"; ++with; ++{ ++ type: "json"; ++} +``` + +# Output + +```js +import json from "./foo.json"; +with; +{ + type: "json"; +} +``` + +# Errors +``` +static-import.js:1:31 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + + × Expected a semicolon or an implicit semicolon after a statement, but found none + + > 1 │ import json from "./foo.json" with { type: "json" }; + │ ^^^^^^ + 2 │ + + i An explicit or implicit semicolon is expected here... + + > 1 │ import json from "./foo.json" with { type: "json" }; + │ ^^^^^^ + 2 │ + + i ...Which is required to end this statement + + > 1 │ import json from "./foo.json" with { type: "json" }; + │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + 2 │ + +static-import.js:1:38 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + + × Expected a semicolon or an implicit semicolon after a statement, but found none + + > 1 │ import json from "./foo.json" with { type: "json" }; + │ ^ + 2 │ + + i An explicit or implicit semicolon is expected here... + + > 1 │ import json from "./foo.json" with { type: "json" }; + │ ^ + 2 │ + + i ...Which is required to end this statement + + > 1 │ import json from "./foo.json" with { type: "json" }; + │ ^^^^^^^^ + 2 │ + + +``` + + diff --git a/crates/rome_js_formatter/tests/specs/js/module/import/import-assertions/dynamic-import.js b/crates/rome_js_formatter/tests/specs/js/module/import/import-assertions/dynamic-import.js new file mode 100644 index 000000000000..717b72d4a84f --- /dev/null +++ b/crates/rome_js_formatter/tests/specs/js/module/import/import-assertions/dynamic-import.js @@ -0,0 +1 @@ +import("./foo.json", { with: { type: "json" } }); diff --git a/crates/rome_js_formatter/tests/specs/js/module/import/import-assertions/dynamic-import.js.prettier-snap b/crates/rome_js_formatter/tests/specs/js/module/import/import-assertions/dynamic-import.js.prettier-snap new file mode 100644 index 000000000000..717b72d4a84f --- /dev/null +++ b/crates/rome_js_formatter/tests/specs/js/module/import/import-assertions/dynamic-import.js.prettier-snap @@ -0,0 +1 @@ +import("./foo.json", { with: { type: "json" } }); diff --git a/crates/rome_js_formatter/tests/specs/js/module/import/import-assertions/empty.js b/crates/rome_js_formatter/tests/specs/js/module/import/import-assertions/empty.js new file mode 100644 index 000000000000..ab1ee6f33e4e --- /dev/null +++ b/crates/rome_js_formatter/tests/specs/js/module/import/import-assertions/empty.js @@ -0,0 +1,7 @@ +export * as foo from "foo.json" +export * as bar from "bar.json" with { } +export * as baz from "baz.json" with { /* comment */ } + +import * as foo from "foo.json" +import * as bar from "bar.json" with { } +import * as baz from "baz.json" with { /* comment */ } diff --git a/crates/rome_js_formatter/tests/specs/js/module/import/import-assertions/empty.js.prettier-snap b/crates/rome_js_formatter/tests/specs/js/module/import/import-assertions/empty.js.prettier-snap new file mode 100644 index 000000000000..6be0c7b7e068 --- /dev/null +++ b/crates/rome_js_formatter/tests/specs/js/module/import/import-assertions/empty.js.prettier-snap @@ -0,0 +1,7 @@ +export * as foo from "foo.json"; +export * as bar from "bar.json"; +export * as baz from "baz.json" /* comment */; + +import * as foo from "foo.json"; +import * as bar from "bar.json"; +import * as baz from "baz.json" /* comment */; diff --git a/crates/rome_js_formatter/tests/specs/js/module/import/import-assertions/empty.js.snap b/crates/rome_js_formatter/tests/specs/js/module/import/import-assertions/empty.js.snap new file mode 100644 index 000000000000..5cf5902228c7 --- /dev/null +++ b/crates/rome_js_formatter/tests/specs/js/module/import/import-assertions/empty.js.snap @@ -0,0 +1,283 @@ +--- +source: crates/rome_formatter_test/src/snapshot_builder.rs +info: js/import-withions/empty.js +--- + +# Input + +```js +export * as foo from "foo.json" +export * as bar from "bar.json" with { } +export * as baz from "baz.json" with { /* comment */ } + +import * as foo from "foo.json" +import * as bar from "bar.json" with { } +import * as baz from "baz.json" with { /* comment */ } +``` + + +# Prettier differences + +```diff +--- Prettier ++++ Rome +@@ -1,7 +1,21 @@ + export * as foo from "foo.json"; + export * as bar from "bar.json"; +-export * as baz from "baz.json" /* comment */; ++with; ++{ ++} ++export * as baz from "baz.json"; ++with; ++{ ++ /* comment */ ++} + + import * as foo from "foo.json"; + import * as bar from "bar.json"; +-import * as baz from "baz.json" /* comment */; ++with; ++{ ++} ++import * as baz from "baz.json"; ++with; ++{ ++ /* comment */ ++} +``` + +# Output + +```js +export * as foo from "foo.json"; +export * as bar from "bar.json"; +with; +{ +} +export * as baz from "baz.json"; +with; +{ + /* comment */ +} + +import * as foo from "foo.json"; +import * as bar from "bar.json"; +with; +{ +} +import * as baz from "baz.json"; +with; +{ + /* comment */ +} +``` + +# Errors +``` +empty.js:2:33 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + + × Expected a semicolon or an implicit semicolon after a statement, but found none + + 1 │ export * as foo from "foo.json" + > 2 │ export * as bar from "bar.json" with { } + │ ^^^^^^ + 3 │ export * as baz from "baz.json" with { /* comment */ } + 4 │ + + i An explicit or implicit semicolon is expected here... + + 1 │ export * as foo from "foo.json" + > 2 │ export * as bar from "bar.json" with { } + │ ^^^^^^ + 3 │ export * as baz from "baz.json" with { /* comment */ } + 4 │ + + i ...Which is required to end this statement + + 1 │ export * as foo from "foo.json" + > 2 │ export * as bar from "bar.json" with { } + │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + 3 │ export * as baz from "baz.json" with { /* comment */ } + 4 │ + +empty.js:2:40 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + + × Expected a semicolon or an implicit semicolon after a statement, but found none + + 1 │ export * as foo from "foo.json" + > 2 │ export * as bar from "bar.json" with { } + │ ^ + 3 │ export * as baz from "baz.json" with { /* comment */ } + 4 │ + + i An explicit or implicit semicolon is expected here... + + 1 │ export * as foo from "foo.json" + > 2 │ export * as bar from "bar.json" with { } + │ ^ + 3 │ export * as baz from "baz.json" with { /* comment */ } + 4 │ + + i ...Which is required to end this statement + + 1 │ export * as foo from "foo.json" + > 2 │ export * as bar from "bar.json" with { } + │ ^^^^^^^^ + 3 │ export * as baz from "baz.json" with { /* comment */ } + 4 │ + +empty.js:3:33 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + + × Expected a semicolon or an implicit semicolon after a statement, but found none + + 1 │ export * as foo from "foo.json" + 2 │ export * as bar from "bar.json" with { } + > 3 │ export * as baz from "baz.json" with { /* comment */ } + │ ^^^^^^ + 4 │ + 5 │ import * as foo from "foo.json" + + i An explicit or implicit semicolon is expected here... + + 1 │ export * as foo from "foo.json" + 2 │ export * as bar from "bar.json" with { } + > 3 │ export * as baz from "baz.json" with { /* comment */ } + │ ^^^^^^ + 4 │ + 5 │ import * as foo from "foo.json" + + i ...Which is required to end this statement + + 1 │ export * as foo from "foo.json" + 2 │ export * as bar from "bar.json" with { } + > 3 │ export * as baz from "baz.json" with { /* comment */ } + │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + 4 │ + 5 │ import * as foo from "foo.json" + +empty.js:3:40 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + + × Expected a semicolon or an implicit semicolon after a statement, but found none + + 1 │ export * as foo from "foo.json" + 2 │ export * as bar from "bar.json" with { } + > 3 │ export * as baz from "baz.json" with { /* comment */ } + │ ^ + 4 │ + 5 │ import * as foo from "foo.json" + + i An explicit or implicit semicolon is expected here... + + 1 │ export * as foo from "foo.json" + 2 │ export * as bar from "bar.json" with { } + > 3 │ export * as baz from "baz.json" with { /* comment */ } + │ ^ + 4 │ + 5 │ import * as foo from "foo.json" + + i ...Which is required to end this statement + + 1 │ export * as foo from "foo.json" + 2 │ export * as bar from "bar.json" with { } + > 3 │ export * as baz from "baz.json" with { /* comment */ } + │ ^^^^^^^^ + 4 │ + 5 │ import * as foo from "foo.json" + +empty.js:6:33 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + + × Expected a semicolon or an implicit semicolon after a statement, but found none + + 5 │ import * as foo from "foo.json" + > 6 │ import * as bar from "bar.json" with { } + │ ^^^^^^ + 7 │ import * as baz from "baz.json" with { /* comment */ } + + i An explicit or implicit semicolon is expected here... + + 5 │ import * as foo from "foo.json" + > 6 │ import * as bar from "bar.json" with { } + │ ^^^^^^ + 7 │ import * as baz from "baz.json" with { /* comment */ } + + i ...Which is required to end this statement + + 5 │ import * as foo from "foo.json" + > 6 │ import * as bar from "bar.json" with { } + │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + 7 │ import * as baz from "baz.json" with { /* comment */ } + +empty.js:6:40 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + + × Expected a semicolon or an implicit semicolon after a statement, but found none + + 5 │ import * as foo from "foo.json" + > 6 │ import * as bar from "bar.json" with { } + │ ^ + 7 │ import * as baz from "baz.json" with { /* comment */ } + + i An explicit or implicit semicolon is expected here... + + 5 │ import * as foo from "foo.json" + > 6 │ import * as bar from "bar.json" with { } + │ ^ + 7 │ import * as baz from "baz.json" with { /* comment */ } + + i ...Which is required to end this statement + + 5 │ import * as foo from "foo.json" + > 6 │ import * as bar from "bar.json" with { } + │ ^^^^^^^^ + 7 │ import * as baz from "baz.json" with { /* comment */ } + +empty.js:7:33 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + + × Expected a semicolon or an implicit semicolon after a statement, but found none + + 5 │ import * as foo from "foo.json" + 6 │ import * as bar from "bar.json" with { } + > 7 │ import * as baz from "baz.json" with { /* comment */ } + │ ^^^^^^ + + i An explicit or implicit semicolon is expected here... + + 5 │ import * as foo from "foo.json" + 6 │ import * as bar from "bar.json" with { } + > 7 │ import * as baz from "baz.json" with { /* comment */ } + │ ^^^^^^ + + i ...Which is required to end this statement + + 5 │ import * as foo from "foo.json" + 6 │ import * as bar from "bar.json" with { } + > 7 │ import * as baz from "baz.json" with { /* comment */ } + │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +empty.js:7:40 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + + × Expected a semicolon or an implicit semicolon after a statement, but found none + + 5 │ import * as foo from "foo.json" + 6 │ import * as bar from "bar.json" with { } + > 7 │ import * as baz from "baz.json" with { /* comment */ } + │ ^ + + i An explicit or implicit semicolon is expected here... + + 5 │ import * as foo from "foo.json" + 6 │ import * as bar from "bar.json" with { } + > 7 │ import * as baz from "baz.json" with { /* comment */ } + │ ^ + + i ...Which is required to end this statement + + 5 │ import * as foo from "foo.json" + 6 │ import * as bar from "bar.json" with { } + > 7 │ import * as baz from "baz.json" with { /* comment */ } + │ ^^^^^^^^ + + +``` + + diff --git a/crates/rome_js_formatter/tests/specs/js/module/import/import-assertions/multi-types.js b/crates/rome_js_formatter/tests/specs/js/module/import/import-assertions/multi-types.js new file mode 100644 index 000000000000..0f0e7115f307 --- /dev/null +++ b/crates/rome_js_formatter/tests/specs/js/module/import/import-assertions/multi-types.js @@ -0,0 +1 @@ +import json from "./foo.json" with { type: "json", type: "bar" }; diff --git a/crates/rome_js_formatter/tests/specs/js/module/import/import-assertions/multi-types.js.prettier-snap b/crates/rome_js_formatter/tests/specs/js/module/import/import-assertions/multi-types.js.prettier-snap new file mode 100644 index 000000000000..0f0e7115f307 --- /dev/null +++ b/crates/rome_js_formatter/tests/specs/js/module/import/import-assertions/multi-types.js.prettier-snap @@ -0,0 +1 @@ +import json from "./foo.json" with { type: "json", type: "bar" }; diff --git a/crates/rome_js_formatter/tests/specs/js/module/import/import-assertions/multi-types.js.snap b/crates/rome_js_formatter/tests/specs/js/module/import/import-assertions/multi-types.js.snap new file mode 100644 index 000000000000..ce9ed9c85599 --- /dev/null +++ b/crates/rome_js_formatter/tests/specs/js/module/import/import-assertions/multi-types.js.snap @@ -0,0 +1,105 @@ +--- +source: crates/rome_formatter_test/src/snapshot_builder.rs +info: js/import-withions/multi-types.js +--- + +# Input + +```js +import json from "./foo.json" with { type: "json", type: "bar" }; + +``` + + +# Prettier differences + +```diff +--- Prettier ++++ Rome +@@ -1 +1,6 @@ +-import json from "./foo.json" with { type: "json", type: "bar" }; ++import json from "./foo.json"; ++with; ++{ ++ type: "json", type; ++ : "bar" ++} +``` + +# Output + +```js +import json from "./foo.json"; +with; +{ + type: "json", type; + : "bar" +} +``` + +# Errors +``` +multi-types.js:1:31 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + + × Expected a semicolon or an implicit semicolon after a statement, but found none + + > 1 │ import json from "./foo.json" with { type: "json", type: "bar" }; + │ ^^^^^^ + 2 │ + + i An explicit or implicit semicolon is expected here... + + > 1 │ import json from "./foo.json" with { type: "json", type: "bar" }; + │ ^^^^^^ + 2 │ + + i ...Which is required to end this statement + + > 1 │ import json from "./foo.json" with { type: "json", type: "bar" }; + │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + 2 │ + +multi-types.js:1:38 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + + × Expected a semicolon or an implicit semicolon after a statement, but found none + + > 1 │ import json from "./foo.json" with { type: "json", type: "bar" }; + │ ^ + 2 │ + + i An explicit or implicit semicolon is expected here... + + > 1 │ import json from "./foo.json" with { type: "json", type: "bar" }; + │ ^ + 2 │ + + i ...Which is required to end this statement + + > 1 │ import json from "./foo.json" with { type: "json", type: "bar" }; + │ ^^^^^^^^ + 2 │ + +multi-types.js:1:58 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + + × Expected a semicolon or an implicit semicolon after a statement, but found none + + > 1 │ import json from "./foo.json" with { type: "json", type: "bar" }; + │ ^ + 2 │ + + i An explicit or implicit semicolon is expected here... + + > 1 │ import json from "./foo.json" with { type: "json", type: "bar" }; + │ ^ + 2 │ + + i ...Which is required to end this statement + + > 1 │ import json from "./foo.json" with { type: "json", type: "bar" }; + │ ^^^^^^^^^^^^^ + 2 │ + + +``` + + diff --git a/crates/rome_js_formatter/tests/specs/js/module/import/import-assertions/non-type.js b/crates/rome_js_formatter/tests/specs/js/module/import/import-assertions/non-type.js new file mode 100644 index 000000000000..1858e49c2022 --- /dev/null +++ b/crates/rome_js_formatter/tests/specs/js/module/import/import-assertions/non-type.js @@ -0,0 +1 @@ +import foo from "foo.json" with { lazy: "true" }; diff --git a/crates/rome_js_formatter/tests/specs/js/module/import/import-assertions/non-type.js.prettier-snap b/crates/rome_js_formatter/tests/specs/js/module/import/import-assertions/non-type.js.prettier-snap new file mode 100644 index 000000000000..1858e49c2022 --- /dev/null +++ b/crates/rome_js_formatter/tests/specs/js/module/import/import-assertions/non-type.js.prettier-snap @@ -0,0 +1 @@ +import foo from "foo.json" with { lazy: "true" }; diff --git a/crates/rome_js_formatter/tests/specs/js/module/import/import-assertions/non-type.js.snap b/crates/rome_js_formatter/tests/specs/js/module/import/import-assertions/non-type.js.snap new file mode 100644 index 000000000000..50ff1f13e384 --- /dev/null +++ b/crates/rome_js_formatter/tests/specs/js/module/import/import-assertions/non-type.js.snap @@ -0,0 +1,83 @@ +--- +source: crates/rome_formatter_test/src/snapshot_builder.rs +info: js/import-withions/non-type.js +--- + +# Input + +```js +import foo from "foo.json" with { lazy: "true" }; + +``` + + +# Prettier differences + +```diff +--- Prettier ++++ Rome +@@ -1 +1,5 @@ +-import foo from "foo.json" with { lazy: "true" }; ++import foo from "foo.json"; ++with; ++{ ++ lazy: "true"; ++} +``` + +# Output + +```js +import foo from "foo.json"; +with; +{ + lazy: "true"; +} +``` + +# Errors +``` +non-type.js:1:28 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + + × Expected a semicolon or an implicit semicolon after a statement, but found none + + > 1 │ import foo from "foo.json" with { lazy: "true" }; + │ ^^^^^^ + 2 │ + + i An explicit or implicit semicolon is expected here... + + > 1 │ import foo from "foo.json" with { lazy: "true" }; + │ ^^^^^^ + 2 │ + + i ...Which is required to end this statement + + > 1 │ import foo from "foo.json" with { lazy: "true" }; + │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^ + 2 │ + +non-type.js:1:35 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + + × Expected a semicolon or an implicit semicolon after a statement, but found none + + > 1 │ import foo from "foo.json" with { lazy: "true" }; + │ ^ + 2 │ + + i An explicit or implicit semicolon is expected here... + + > 1 │ import foo from "foo.json" with { lazy: "true" }; + │ ^ + 2 │ + + i ...Which is required to end this statement + + > 1 │ import foo from "foo.json" with { lazy: "true" }; + │ ^^^^^^^^ + 2 │ + + +``` + + diff --git a/crates/rome_js_formatter/tests/specs/js/module/import/import-assertions/not-import-assertions.js b/crates/rome_js_formatter/tests/specs/js/module/import/import-assertions/not-import-assertions.js new file mode 100644 index 000000000000..c3624b9699d9 --- /dev/null +++ b/crates/rome_js_formatter/tests/specs/js/module/import/import-assertions/not-import-assertions.js @@ -0,0 +1,2 @@ +import "x" +with ({type: 'json'}); diff --git a/crates/rome_js_formatter/tests/specs/js/module/import/import-assertions/not-import-assertions.js.prettier-snap b/crates/rome_js_formatter/tests/specs/js/module/import/import-assertions/not-import-assertions.js.prettier-snap new file mode 100644 index 000000000000..253720d1d429 --- /dev/null +++ b/crates/rome_js_formatter/tests/specs/js/module/import/import-assertions/not-import-assertions.js.prettier-snap @@ -0,0 +1,2 @@ +import "x"; +with({ type: "json" }); diff --git a/crates/rome_js_formatter/tests/specs/js/module/import/import-assertions/re-export.js b/crates/rome_js_formatter/tests/specs/js/module/import/import-assertions/re-export.js new file mode 100644 index 000000000000..8b7f8a81728d --- /dev/null +++ b/crates/rome_js_formatter/tests/specs/js/module/import/import-assertions/re-export.js @@ -0,0 +1,3 @@ +export { default as foo2 } from "foo.json" with { type: "json" }; +export * from "foo.json" with { type: "json" }; +export * as foo3 from "foo.json" with { type: "json" }; diff --git a/crates/rome_js_formatter/tests/specs/js/module/import/import-assertions/re-export.js.prettier-snap b/crates/rome_js_formatter/tests/specs/js/module/import/import-assertions/re-export.js.prettier-snap new file mode 100644 index 000000000000..8b7f8a81728d --- /dev/null +++ b/crates/rome_js_formatter/tests/specs/js/module/import/import-assertions/re-export.js.prettier-snap @@ -0,0 +1,3 @@ +export { default as foo2 } from "foo.json" with { type: "json" }; +export * from "foo.json" with { type: "json" }; +export * as foo3 from "foo.json" with { type: "json" }; diff --git a/crates/rome_js_formatter/tests/specs/js/module/import/import-assertions/re-export.js.snap b/crates/rome_js_formatter/tests/specs/js/module/import/import-assertions/re-export.js.snap new file mode 100644 index 000000000000..d2b29d85a17a --- /dev/null +++ b/crates/rome_js_formatter/tests/specs/js/module/import/import-assertions/re-export.js.snap @@ -0,0 +1,217 @@ +--- +source: crates/rome_formatter_test/src/snapshot_builder.rs +info: js/import-withions/re-export.js +--- + +# Input + +```js +export { default as foo2 } from "foo.json" with { type: "json" }; +export * from "foo.json" with { type: "json" }; +export * as foo3 from "foo.json" with { type: "json" }; + +``` + + +# Prettier differences + +```diff +--- Prettier ++++ Rome +@@ -1,3 +1,15 @@ +-export { default as foo2 } from "foo.json" with { type: "json" }; +-export * from "foo.json" with { type: "json" }; +-export * as foo3 from "foo.json" with { type: "json" }; ++export { default as foo2 } from "foo.json"; ++with; ++{ ++ type: "json"; ++} ++export * from "foo.json"; ++with; ++{ ++ type: "json"; ++} ++export * as foo3 from "foo.json"; ++with; ++{ ++ type: "json"; ++} +``` + +# Output + +```js +export { default as foo2 } from "foo.json"; +with; +{ + type: "json"; +} +export * from "foo.json"; +with; +{ + type: "json"; +} +export * as foo3 from "foo.json"; +with; +{ + type: "json"; +} +``` + +# Errors +``` +re-export.js:1:44 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + + × Expected a semicolon or an implicit semicolon after a statement, but found none + + > 1 │ export { default as foo2 } from "foo.json" with { type: "json" }; + │ ^^^^^^ + 2 │ export * from "foo.json" with { type: "json" }; + 3 │ export * as foo3 from "foo.json" with { type: "json" }; + + i An explicit or implicit semicolon is expected here... + + > 1 │ export { default as foo2 } from "foo.json" with { type: "json" }; + │ ^^^^^^ + 2 │ export * from "foo.json" with { type: "json" }; + 3 │ export * as foo3 from "foo.json" with { type: "json" }; + + i ...Which is required to end this statement + + > 1 │ export { default as foo2 } from "foo.json" with { type: "json" }; + │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + 2 │ export * from "foo.json" with { type: "json" }; + 3 │ export * as foo3 from "foo.json" with { type: "json" }; + +re-export.js:1:51 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + + × Expected a semicolon or an implicit semicolon after a statement, but found none + + > 1 │ export { default as foo2 } from "foo.json" with { type: "json" }; + │ ^ + 2 │ export * from "foo.json" with { type: "json" }; + 3 │ export * as foo3 from "foo.json" with { type: "json" }; + + i An explicit or implicit semicolon is expected here... + + > 1 │ export { default as foo2 } from "foo.json" with { type: "json" }; + │ ^ + 2 │ export * from "foo.json" with { type: "json" }; + 3 │ export * as foo3 from "foo.json" with { type: "json" }; + + i ...Which is required to end this statement + + > 1 │ export { default as foo2 } from "foo.json" with { type: "json" }; + │ ^^^^^^^^ + 2 │ export * from "foo.json" with { type: "json" }; + 3 │ export * as foo3 from "foo.json" with { type: "json" }; + +re-export.js:2:26 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + + × Expected a semicolon or an implicit semicolon after a statement, but found none + + 1 │ export { default as foo2 } from "foo.json" with { type: "json" }; + > 2 │ export * from "foo.json" with { type: "json" }; + │ ^^^^^^ + 3 │ export * as foo3 from "foo.json" with { type: "json" }; + 4 │ + + i An explicit or implicit semicolon is expected here... + + 1 │ export { default as foo2 } from "foo.json" with { type: "json" }; + > 2 │ export * from "foo.json" with { type: "json" }; + │ ^^^^^^ + 3 │ export * as foo3 from "foo.json" with { type: "json" }; + 4 │ + + i ...Which is required to end this statement + + 1 │ export { default as foo2 } from "foo.json" with { type: "json" }; + > 2 │ export * from "foo.json" with { type: "json" }; + │ ^^^^^^^^^^^^^^^^^^^^^^^^ + 3 │ export * as foo3 from "foo.json" with { type: "json" }; + 4 │ + +re-export.js:2:33 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + + × Expected a semicolon or an implicit semicolon after a statement, but found none + + 1 │ export { default as foo2 } from "foo.json" with { type: "json" }; + > 2 │ export * from "foo.json" with { type: "json" }; + │ ^ + 3 │ export * as foo3 from "foo.json" with { type: "json" }; + 4 │ + + i An explicit or implicit semicolon is expected here... + + 1 │ export { default as foo2 } from "foo.json" with { type: "json" }; + > 2 │ export * from "foo.json" with { type: "json" }; + │ ^ + 3 │ export * as foo3 from "foo.json" with { type: "json" }; + 4 │ + + i ...Which is required to end this statement + + 1 │ export { default as foo2 } from "foo.json" with { type: "json" }; + > 2 │ export * from "foo.json" with { type: "json" }; + │ ^^^^^^^^ + 3 │ export * as foo3 from "foo.json" with { type: "json" }; + 4 │ + +re-export.js:3:34 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + + × Expected a semicolon or an implicit semicolon after a statement, but found none + + 1 │ export { default as foo2 } from "foo.json" with { type: "json" }; + 2 │ export * from "foo.json" with { type: "json" }; + > 3 │ export * as foo3 from "foo.json" with { type: "json" }; + │ ^^^^^^ + 4 │ + + i An explicit or implicit semicolon is expected here... + + 1 │ export { default as foo2 } from "foo.json" with { type: "json" }; + 2 │ export * from "foo.json" with { type: "json" }; + > 3 │ export * as foo3 from "foo.json" with { type: "json" }; + │ ^^^^^^ + 4 │ + + i ...Which is required to end this statement + + 1 │ export { default as foo2 } from "foo.json" with { type: "json" }; + 2 │ export * from "foo.json" with { type: "json" }; + > 3 │ export * as foo3 from "foo.json" with { type: "json" }; + │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + 4 │ + +re-export.js:3:41 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + + × Expected a semicolon or an implicit semicolon after a statement, but found none + + 1 │ export { default as foo2 } from "foo.json" with { type: "json" }; + 2 │ export * from "foo.json" with { type: "json" }; + > 3 │ export * as foo3 from "foo.json" with { type: "json" }; + │ ^ + 4 │ + + i An explicit or implicit semicolon is expected here... + + 1 │ export { default as foo2 } from "foo.json" with { type: "json" }; + 2 │ export * from "foo.json" with { type: "json" }; + > 3 │ export * as foo3 from "foo.json" with { type: "json" }; + │ ^ + 4 │ + + i ...Which is required to end this statement + + 1 │ export { default as foo2 } from "foo.json" with { type: "json" }; + 2 │ export * from "foo.json" with { type: "json" }; + > 3 │ export * as foo3 from "foo.json" with { type: "json" }; + │ ^^^^^^^^ + 4 │ + + +``` + + diff --git a/crates/rome_js_formatter/tests/specs/js/module/import/import-assertions/static-import.js b/crates/rome_js_formatter/tests/specs/js/module/import/import-assertions/static-import.js new file mode 100644 index 000000000000..7770ae1f06b0 --- /dev/null +++ b/crates/rome_js_formatter/tests/specs/js/module/import/import-assertions/static-import.js @@ -0,0 +1 @@ +import json from "./foo.json" with { type: "json" }; diff --git a/crates/rome_js_formatter/tests/specs/js/module/import/import-assertions/static-import.js.prettier-snap b/crates/rome_js_formatter/tests/specs/js/module/import/import-assertions/static-import.js.prettier-snap new file mode 100644 index 000000000000..7770ae1f06b0 --- /dev/null +++ b/crates/rome_js_formatter/tests/specs/js/module/import/import-assertions/static-import.js.prettier-snap @@ -0,0 +1 @@ +import json from "./foo.json" with { type: "json" }; diff --git a/crates/rome_js_formatter/tests/specs/js/module/import/import-assertions/static-import.js.snap b/crates/rome_js_formatter/tests/specs/js/module/import/import-assertions/static-import.js.snap new file mode 100644 index 000000000000..370914e6b024 --- /dev/null +++ b/crates/rome_js_formatter/tests/specs/js/module/import/import-assertions/static-import.js.snap @@ -0,0 +1,83 @@ +--- +source: crates/rome_formatter_test/src/snapshot_builder.rs +info: js/import-withions/static-import.js +--- + +# Input + +```js +import json from "./foo.json" with { type: "json" }; + +``` + + +# Prettier differences + +```diff +--- Prettier ++++ Rome +@@ -1 +1,5 @@ +-import json from "./foo.json" with { type: "json" }; ++import json from "./foo.json"; ++with; ++{ ++ type: "json"; ++} +``` + +# Output + +```js +import json from "./foo.json"; +with; +{ + type: "json"; +} +``` + +# Errors +``` +static-import.js:1:31 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + + × Expected a semicolon or an implicit semicolon after a statement, but found none + + > 1 │ import json from "./foo.json" with { type: "json" }; + │ ^^^^^^ + 2 │ + + i An explicit or implicit semicolon is expected here... + + > 1 │ import json from "./foo.json" with { type: "json" }; + │ ^^^^^^ + 2 │ + + i ...Which is required to end this statement + + > 1 │ import json from "./foo.json" with { type: "json" }; + │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + 2 │ + +static-import.js:1:38 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + + × Expected a semicolon or an implicit semicolon after a statement, but found none + + > 1 │ import json from "./foo.json" with { type: "json" }; + │ ^ + 2 │ + + i An explicit or implicit semicolon is expected here... + + > 1 │ import json from "./foo.json" with { type: "json" }; + │ ^ + 2 │ + + i ...Which is required to end this statement + + > 1 │ import json from "./foo.json" with { type: "json" }; + │ ^^^^^^^^ + 2 │ + + +``` + + diff --git a/crates/rome_js_formatter/tests/specs/js/module/import/import-assertions/without-from.js b/crates/rome_js_formatter/tests/specs/js/module/import/import-assertions/without-from.js new file mode 100644 index 000000000000..5009c441a73c --- /dev/null +++ b/crates/rome_js_formatter/tests/specs/js/module/import/import-assertions/without-from.js @@ -0,0 +1 @@ +import "foo" with { type: "json" } diff --git a/crates/rome_js_formatter/tests/specs/js/module/import/import-assertions/without-from.js.prettier-snap b/crates/rome_js_formatter/tests/specs/js/module/import/import-assertions/without-from.js.prettier-snap new file mode 100644 index 000000000000..97676575506c --- /dev/null +++ b/crates/rome_js_formatter/tests/specs/js/module/import/import-assertions/without-from.js.prettier-snap @@ -0,0 +1 @@ +import "foo" with { type: "json" }; diff --git a/crates/rome_js_formatter/tests/specs/js/module/import/import-assertions/without-from.js.snap b/crates/rome_js_formatter/tests/specs/js/module/import/import-assertions/without-from.js.snap new file mode 100644 index 000000000000..cc6e08f41021 --- /dev/null +++ b/crates/rome_js_formatter/tests/specs/js/module/import/import-assertions/without-from.js.snap @@ -0,0 +1,83 @@ +--- +source: crates/rome_formatter_test/src/snapshot_builder.rs +info: js/import-withions/without-from.js +--- + +# Input + +```js +import "foo" with { type: "json" } + +``` + + +# Prettier differences + +```diff +--- Prettier ++++ Rome +@@ -1 +1,5 @@ +-import "foo" with { type: "json" }; ++import "foo"; ++with; ++{ ++ type: "json"; ++} +``` + +# Output + +```js +import "foo"; +with; +{ + type: "json"; +} +``` + +# Errors +``` +without-from.js:1:14 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + + × Expected a semicolon or an implicit semicolon after a statement, but found none + + > 1 │ import "foo" with { type: "json" } + │ ^^^^^^ + 2 │ + + i An explicit or implicit semicolon is expected here... + + > 1 │ import "foo" with { type: "json" } + │ ^^^^^^ + 2 │ + + i ...Which is required to end this statement + + > 1 │ import "foo" with { type: "json" } + │ ^^^^^^^^^^^^^ + 2 │ + +without-from.js:1:21 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + + × Expected a semicolon or an implicit semicolon after a statement, but found none + + > 1 │ import "foo" with { type: "json" } + │ ^ + 2 │ + + i An explicit or implicit semicolon is expected here... + + > 1 │ import "foo" with { type: "json" } + │ ^ + 2 │ + + i ...Which is required to end this statement + + > 1 │ import "foo" with { type: "json" } + │ ^^^^^^^^ + 2 │ + + +``` + + diff --git a/crates/rome_js_formatter/tests/specs/js/module/import/import_specifiers.js b/crates/rome_js_formatter/tests/specs/js/module/import/import_specifiers.js index d2223d44ec36..63dd4b790e5f 100644 --- a/crates/rome_js_formatter/tests/specs/js/module/import/import_specifiers.js +++ b/crates/rome_js_formatter/tests/specs/js/module/import/import_specifiers.js @@ -3,7 +3,7 @@ import { hey } from "hey"; import { apple, banana } from "fruits"; -import {test} from "foo.json" assert { for: "for" } +import {test} from "foo.json" with { for: "for" } import { // some funky comment loooooooooooooooooooong as moreeeeeeloooooooooooooooooooong, loooooooooooooooooooong2 as moreeeeeeloooooooooooooooooooong2, @@ -23,8 +23,8 @@ import { loooooooooooooooooooooooooooooooooooooooooooooooooong } from "loooooooo import { loooooooooooooooooooooooooooooooooooooooooooooooooong, } from "loooooooooooooooooooooooooooooooooooooooooooooong" -import { -// comment +import { +// comment loooooooooooooooooooooooooooooooooooooooooooooooooong } from "loooooooooooooooooooooooooooooooooooooooooooooong" import { a as b } from "loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong" diff --git a/crates/rome_js_formatter/tests/specs/js/module/import/import_specifiers.js.snap b/crates/rome_js_formatter/tests/specs/js/module/import/import_specifiers.js.snap index bcee5d43f1fe..bcf28af51b5d 100644 --- a/crates/rome_js_formatter/tests/specs/js/module/import/import_specifiers.js.snap +++ b/crates/rome_js_formatter/tests/specs/js/module/import/import_specifiers.js.snap @@ -12,7 +12,7 @@ import { hey } from "hey"; import { apple, banana } from "fruits"; -import {test} from "foo.json" assert { for: "for" } +import {test} from "foo.json" with { for: "for" } import { // some funky comment loooooooooooooooooooong as moreeeeeeloooooooooooooooooooong, loooooooooooooooooooong2 as moreeeeeeloooooooooooooooooooong2, @@ -32,8 +32,8 @@ import { loooooooooooooooooooooooooooooooooooooooooooooooooong } from "loooooooo import { loooooooooooooooooooooooooooooooooooooooooooooooooong, } from "loooooooooooooooooooooooooooooooooooooooooooooong" -import { -// comment +import { +// comment loooooooooooooooooooooooooooooooooooooooooooooooooong } from "loooooooooooooooooooooooooooooooooooooooooooooong" import { a as b } from "loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong" @@ -62,7 +62,7 @@ Semicolons: Always import { hey } from "hey"; import { hey } from "hey"; import { apple, banana } from "fruits"; -import { test } from "foo.json" assert { for: "for" }; +import { test } from "foo.json" with { for: "for" }; import { // some funky comment loooooooooooooooooooong as moreeeeeeloooooooooooooooooooong, diff --git a/crates/rome_js_formatter/tests/specs/js/module/string/string.js b/crates/rome_js_formatter/tests/specs/js/module/string/string.js index ec8d585be940..d7d32efdb956 100644 --- a/crates/rome_js_formatter/tests/specs/js/module/string/string.js +++ b/crates/rome_js_formatter/tests/specs/js/module/string/string.js @@ -1,13 +1,13 @@ import hey from "hey" import hey from "hey"; -import "x" assert { type: "json" } -import "foo" assert { "type": "json" }; -import foo from "foo.json" assert { type: "json" }; -import foo from "foo.json" assert { +import "x" with { type: "json" } +import "foo" with { "type": "json" }; +import foo from "foo.json" with { type: "json" }; +import foo from "foo.json" with { type: "json" }; -import foo2 from "foo.json" assert { "type": "json", type: "html", "type": "js" }; +import foo2 from "foo.json" with { "type": "json", type: "html", "type": "js" }; import a, * as b from "foo" const foo = {}; @@ -42,7 +42,7 @@ export * from "hey" export * as something_bad_will_happen from "something_bad_might_not_happen" -export * as something_bad_will_happen from "something_bad_might_not_happen" assert { "type": "json", "type2": "json3"} +export * as something_bad_will_happen from "something_bad_might_not_happen" with { "type": "json", "type2": "json3"} // this one should switch to use single quotes @@ -55,4 +55,4 @@ export * as something_bad_will_happen from "something_bad_might_not_happen" asse ("content \\' \\' "); // you should remove the escape -("content \'\' ") \ No newline at end of file +("content \'\' ") diff --git a/crates/rome_js_formatter/tests/specs/js/module/string/string.js.snap b/crates/rome_js_formatter/tests/specs/js/module/string/string.js.snap index 52251cb5e7f7..d56e29b4dd65 100644 --- a/crates/rome_js_formatter/tests/specs/js/module/string/string.js.snap +++ b/crates/rome_js_formatter/tests/specs/js/module/string/string.js.snap @@ -1,7 +1,6 @@ --- source: crates/rome_formatter_test/src/snapshot_builder.rs -info: - test_file: js/module/string/string.js +info: js/module/string/string.js --- # Input @@ -9,14 +8,14 @@ info: ```js import hey from "hey" import hey from "hey"; -import "x" assert { type: "json" } -import "foo" assert { "type": "json" }; -import foo from "foo.json" assert { type: "json" }; -import foo from "foo.json" assert { +import "x" with { type: "json" } +import "foo" with { "type": "json" }; +import foo from "foo.json" with { type: "json" }; +import foo from "foo.json" with { type: "json" }; -import foo2 from "foo.json" assert { "type": "json", type: "html", "type": "js" }; +import foo2 from "foo.json" with { "type": "json", type: "html", "type": "js" }; import a, * as b from "foo" const foo = {}; @@ -51,7 +50,7 @@ export * from "hey" export * as something_bad_will_happen from "something_bad_might_not_happen" -export * as something_bad_will_happen from "something_bad_might_not_happen" assert { "type": "json", "type2": "json3"} +export * as something_bad_will_happen from "something_bad_might_not_happen" with { "type": "json", "type2": "json3"} // this one should switch to use single quotes @@ -65,6 +64,7 @@ export * as something_bad_will_happen from "something_bad_might_not_happen" asse // you should remove the escape ("content \'\' ") + ``` @@ -86,15 +86,11 @@ Semicolons: Always ```js import hey from "hey"; import hey from "hey"; -import "x" assert { type: "json" }; -import "foo" assert { "type": "json" }; -import foo from "foo.json" assert { type: "json" }; -import foo from "foo.json" assert { type: "json" }; -import foo2 from "foo.json" assert { - "type": "json", - type: "html", - "type": "js", -}; +import "x" with { type: "json" }; +import "foo" with { "type": "json" }; +import foo from "foo.json" with { type: "json" }; +import foo from "foo.json" with { type: "json" }; +import foo2 from "foo.json" with { "type": "json", type: "html", "type": "js" }; import a, * as b from "foo"; const foo = {}; @@ -131,7 +127,7 @@ export * from "hey"; export * as something_bad_will_happen from "something_bad_might_not_happen"; -export * as something_bad_will_happen from "something_bad_might_not_happen" assert { +export * as something_bad_will_happen from "something_bad_might_not_happen" with { "type": "json", "type2": "json3", }; @@ -151,7 +147,7 @@ export * as something_bad_will_happen from "something_bad_might_not_happen" asse # Lines exceeding max width of 80 characters ``` - 48: export * as something_bad_will_happen from "something_bad_might_not_happen" assert { + 44: export * as something_bad_will_happen from "something_bad_might_not_happen" with { ``` ## Output 2 @@ -168,15 +164,11 @@ Semicolons: Always ```js import hey from 'hey'; import hey from 'hey'; -import 'x' assert { type: 'json' }; -import 'foo' assert { 'type': 'json' }; -import foo from 'foo.json' assert { type: 'json' }; -import foo from 'foo.json' assert { type: 'json' }; -import foo2 from 'foo.json' assert { - 'type': 'json', - type: "html", - "type": "js", -}; +import 'x' with { type: 'json' }; +import 'foo' with { 'type': 'json' }; +import foo from 'foo.json' with { type: 'json' }; +import foo from 'foo.json' with { type: 'json' }; +import foo2 from 'foo.json' with { 'type': 'json', type: "html", "type": "js" }; import a, * as b from 'foo'; const foo = {}; @@ -213,7 +205,7 @@ export * from 'hey'; export * as something_bad_will_happen from 'something_bad_might_not_happen'; -export * as something_bad_will_happen from 'something_bad_might_not_happen' assert { +export * as something_bad_will_happen from 'something_bad_might_not_happen' with { 'type': 'json', 'type2': 'json3', }; @@ -233,7 +225,7 @@ export * as something_bad_will_happen from 'something_bad_might_not_happen' asse # Lines exceeding max width of 80 characters ``` - 48: export * as something_bad_will_happen from 'something_bad_might_not_happen' assert { + 44: export * as something_bad_will_happen from 'something_bad_might_not_happen' with { ``` ## Output 3 @@ -250,15 +242,11 @@ Semicolons: Always ```js import hey from "hey"; import hey from "hey"; -import "x" assert { type: "json" }; -import "foo" assert { "type": "json" }; -import foo from "foo.json" assert { type: "json" }; -import foo from "foo.json" assert { type: "json" }; -import foo2 from "foo.json" assert { - "type": "json", - type: "html", - "type": "js", -}; +import "x" with { type: "json" }; +import "foo" with { "type": "json" }; +import foo from "foo.json" with { type: "json" }; +import foo from "foo.json" with { type: "json" }; +import foo2 from "foo.json" with { "type": "json", type: "html", "type": "js" }; import a, * as b from "foo"; const foo = {}; @@ -295,7 +283,7 @@ export * from "hey"; export * as something_bad_will_happen from "something_bad_might_not_happen"; -export * as something_bad_will_happen from "something_bad_might_not_happen" assert { +export * as something_bad_will_happen from "something_bad_might_not_happen" with { "type": "json", "type2": "json3", }; @@ -315,7 +303,7 @@ export * as something_bad_will_happen from "something_bad_might_not_happen" asse # Lines exceeding max width of 80 characters ``` - 48: export * as something_bad_will_happen from "something_bad_might_not_happen" assert { + 44: export * as something_bad_will_happen from "something_bad_might_not_happen" with { ``` diff --git a/crates/rome_js_formatter/tests/specs/prettier/js/babel-plugins/import-assertions-static.js.snap b/crates/rome_js_formatter/tests/specs/prettier/js/babel-plugins/import-assertions-static.js.snap new file mode 100644 index 000000000000..552316c799b9 --- /dev/null +++ b/crates/rome_js_formatter/tests/specs/prettier/js/babel-plugins/import-assertions-static.js.snap @@ -0,0 +1,83 @@ +--- +source: crates/rome_formatter_test/src/snapshot_builder.rs +info: js/babel-plugins/import-assertions-static.js +--- + +# Input + +```js +import json from "./foo.json" assert { type: "json" }; + +``` + + +# Prettier differences + +```diff +--- Prettier ++++ Rome +@@ -1 +1,5 @@ +-import json from "./foo.json" assert { type: "json" }; ++import json from "./foo.json"; ++assert; ++{ ++ type: "json"; ++} +``` + +# Output + +```js +import json from "./foo.json"; +assert; +{ + type: "json"; +} +``` + +# Errors +``` +import-assertions-static.js:1:31 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + + × Expected a semicolon or an implicit semicolon after a statement, but found none + + > 1 │ import json from "./foo.json" assert { type: "json" }; + │ ^^^^^^ + 2 │ + + i An explicit or implicit semicolon is expected here... + + > 1 │ import json from "./foo.json" assert { type: "json" }; + │ ^^^^^^ + 2 │ + + i ...Which is required to end this statement + + > 1 │ import json from "./foo.json" assert { type: "json" }; + │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + 2 │ + +import-assertions-static.js:1:38 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + + × Expected a semicolon or an implicit semicolon after a statement, but found none + + > 1 │ import json from "./foo.json" assert { type: "json" }; + │ ^ + 2 │ + + i An explicit or implicit semicolon is expected here... + + > 1 │ import json from "./foo.json" assert { type: "json" }; + │ ^ + 2 │ + + i ...Which is required to end this statement + + > 1 │ import json from "./foo.json" assert { type: "json" }; + │ ^^^^^^^^ + 2 │ + + +``` + + diff --git a/crates/rome_js_formatter/tests/specs/prettier/js/import-assertions/bracket-spacing/empty.js.snap b/crates/rome_js_formatter/tests/specs/prettier/js/import-assertions/bracket-spacing/empty.js.snap index 816b3af8455f..7b3df90eab51 100644 --- a/crates/rome_js_formatter/tests/specs/prettier/js/import-assertions/bracket-spacing/empty.js.snap +++ b/crates/rome_js_formatter/tests/specs/prettier/js/import-assertions/bracket-spacing/empty.js.snap @@ -1,7 +1,6 @@ --- source: crates/rome_formatter_test/src/snapshot_builder.rs -info: - test_file: js/import-assertions/bracket-spacing/empty.js +info: js/import-assertions/bracket-spacing/empty.js --- # Input @@ -16,15 +15,59 @@ export * as bar from "bar.json" assert { } ```diff --- Prettier +++ Rome -@@ -1 +1 @@ --export * as bar from "bar.json"; -+export * as bar from "bar.json" assert {}; +@@ -1 +1,4 @@ + export * as bar from "bar.json"; ++assert; ++{ ++} ``` # Output ```js -export * as bar from "bar.json" assert {}; +export * as bar from "bar.json"; +assert; +{ +} +``` + +# Errors +``` +empty.js:1:33 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + + × Expected a semicolon or an implicit semicolon after a statement, but found none + + > 1 │ export * as bar from "bar.json" assert { } + │ ^^^^^^ + + i An explicit or implicit semicolon is expected here... + + > 1 │ export * as bar from "bar.json" assert { } + │ ^^^^^^ + + i ...Which is required to end this statement + + > 1 │ export * as bar from "bar.json" assert { } + │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +empty.js:1:40 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + + × Expected a semicolon or an implicit semicolon after a statement, but found none + + > 1 │ export * as bar from "bar.json" assert { } + │ ^ + + i An explicit or implicit semicolon is expected here... + + > 1 │ export * as bar from "bar.json" assert { } + │ ^ + + i ...Which is required to end this statement + + > 1 │ export * as bar from "bar.json" assert { } + │ ^^^^^^^^ + + ``` diff --git a/crates/rome_js_formatter/tests/specs/prettier/js/import-assertions/bracket-spacing/re-export.js.snap b/crates/rome_js_formatter/tests/specs/prettier/js/import-assertions/bracket-spacing/re-export.js.snap new file mode 100644 index 000000000000..039a961ae29a --- /dev/null +++ b/crates/rome_js_formatter/tests/specs/prettier/js/import-assertions/bracket-spacing/re-export.js.snap @@ -0,0 +1,83 @@ +--- +source: crates/rome_formatter_test/src/snapshot_builder.rs +info: js/import-assertions/bracket-spacing/re-export.js +--- + +# Input + +```js +export { default as foo2 } from "foo.json" assert { type: "json" }; + +``` + + +# Prettier differences + +```diff +--- Prettier ++++ Rome +@@ -1 +1,5 @@ +-export { default as foo2 } from "foo.json" assert { type: "json" }; ++export { default as foo2 } from "foo.json"; ++assert; ++{ ++ type: "json"; ++} +``` + +# Output + +```js +export { default as foo2 } from "foo.json"; +assert; +{ + type: "json"; +} +``` + +# Errors +``` +re-export.js:1:44 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + + × Expected a semicolon or an implicit semicolon after a statement, but found none + + > 1 │ export { default as foo2 } from "foo.json" assert { type: "json" }; + │ ^^^^^^ + 2 │ + + i An explicit or implicit semicolon is expected here... + + > 1 │ export { default as foo2 } from "foo.json" assert { type: "json" }; + │ ^^^^^^ + 2 │ + + i ...Which is required to end this statement + + > 1 │ export { default as foo2 } from "foo.json" assert { type: "json" }; + │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + 2 │ + +re-export.js:1:51 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + + × Expected a semicolon or an implicit semicolon after a statement, but found none + + > 1 │ export { default as foo2 } from "foo.json" assert { type: "json" }; + │ ^ + 2 │ + + i An explicit or implicit semicolon is expected here... + + > 1 │ export { default as foo2 } from "foo.json" assert { type: "json" }; + │ ^ + 2 │ + + i ...Which is required to end this statement + + > 1 │ export { default as foo2 } from "foo.json" assert { type: "json" }; + │ ^^^^^^^^ + 2 │ + + +``` + + diff --git a/crates/rome_js_formatter/tests/specs/prettier/js/import-assertions/bracket-spacing/static-import.js.snap b/crates/rome_js_formatter/tests/specs/prettier/js/import-assertions/bracket-spacing/static-import.js.snap new file mode 100644 index 000000000000..6e053afb9882 --- /dev/null +++ b/crates/rome_js_formatter/tests/specs/prettier/js/import-assertions/bracket-spacing/static-import.js.snap @@ -0,0 +1,83 @@ +--- +source: crates/rome_formatter_test/src/snapshot_builder.rs +info: js/import-assertions/bracket-spacing/static-import.js +--- + +# Input + +```js +import json from "./foo.json" assert { type: "json" }; + +``` + + +# Prettier differences + +```diff +--- Prettier ++++ Rome +@@ -1 +1,5 @@ +-import json from "./foo.json" assert { type: "json" }; ++import json from "./foo.json"; ++assert; ++{ ++ type: "json"; ++} +``` + +# Output + +```js +import json from "./foo.json"; +assert; +{ + type: "json"; +} +``` + +# Errors +``` +static-import.js:1:31 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + + × Expected a semicolon or an implicit semicolon after a statement, but found none + + > 1 │ import json from "./foo.json" assert { type: "json" }; + │ ^^^^^^ + 2 │ + + i An explicit or implicit semicolon is expected here... + + > 1 │ import json from "./foo.json" assert { type: "json" }; + │ ^^^^^^ + 2 │ + + i ...Which is required to end this statement + + > 1 │ import json from "./foo.json" assert { type: "json" }; + │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + 2 │ + +static-import.js:1:38 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + + × Expected a semicolon or an implicit semicolon after a statement, but found none + + > 1 │ import json from "./foo.json" assert { type: "json" }; + │ ^ + 2 │ + + i An explicit or implicit semicolon is expected here... + + > 1 │ import json from "./foo.json" assert { type: "json" }; + │ ^ + 2 │ + + i ...Which is required to end this statement + + > 1 │ import json from "./foo.json" assert { type: "json" }; + │ ^^^^^^^^ + 2 │ + + +``` + + diff --git a/crates/rome_js_formatter/tests/specs/prettier/js/import-assertions/empty.js.snap b/crates/rome_js_formatter/tests/specs/prettier/js/import-assertions/empty.js.snap index c9f1904fec92..6ed789791a36 100644 --- a/crates/rome_js_formatter/tests/specs/prettier/js/import-assertions/empty.js.snap +++ b/crates/rome_js_formatter/tests/specs/prettier/js/import-assertions/empty.js.snap @@ -1,7 +1,6 @@ --- source: crates/rome_formatter_test/src/snapshot_builder.rs -info: - test_file: js/import-assertions/empty.js +info: js/import-assertions/empty.js --- # Input @@ -22,30 +21,263 @@ import * as baz from "baz.json" assert { /* comment */ } ```diff --- Prettier +++ Rome -@@ -1,7 +1,7 @@ +@@ -1,7 +1,21 @@ export * as foo from "foo.json"; --export * as bar from "bar.json"; + export * as bar from "bar.json"; -export * as baz from "baz.json" /* comment */; -+export * as bar from "bar.json" assert {}; -+export * as baz from "baz.json" assert { /* comment */ }; ++assert; ++{ ++} ++export * as baz from "baz.json"; ++assert; ++{ ++ /* comment */ ++} import * as foo from "foo.json"; --import * as bar from "bar.json"; + import * as bar from "bar.json"; -import * as baz from "baz.json" /* comment */; -+import * as bar from "bar.json" assert {}; -+import * as baz from "baz.json" assert { /* comment */ }; ++assert; ++{ ++} ++import * as baz from "baz.json"; ++assert; ++{ ++ /* comment */ ++} ``` # Output ```js export * as foo from "foo.json"; -export * as bar from "bar.json" assert {}; -export * as baz from "baz.json" assert { /* comment */ }; +export * as bar from "bar.json"; +assert; +{ +} +export * as baz from "baz.json"; +assert; +{ + /* comment */ +} import * as foo from "foo.json"; -import * as bar from "bar.json" assert {}; -import * as baz from "baz.json" assert { /* comment */ }; +import * as bar from "bar.json"; +assert; +{ +} +import * as baz from "baz.json"; +assert; +{ + /* comment */ +} +``` + +# Errors +``` +empty.js:2:33 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + + × Expected a semicolon or an implicit semicolon after a statement, but found none + + 1 │ export * as foo from "foo.json" + > 2 │ export * as bar from "bar.json" assert { } + │ ^^^^^^ + 3 │ export * as baz from "baz.json" assert { /* comment */ } + 4 │ + + i An explicit or implicit semicolon is expected here... + + 1 │ export * as foo from "foo.json" + > 2 │ export * as bar from "bar.json" assert { } + │ ^^^^^^ + 3 │ export * as baz from "baz.json" assert { /* comment */ } + 4 │ + + i ...Which is required to end this statement + + 1 │ export * as foo from "foo.json" + > 2 │ export * as bar from "bar.json" assert { } + │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + 3 │ export * as baz from "baz.json" assert { /* comment */ } + 4 │ + +empty.js:2:40 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + + × Expected a semicolon or an implicit semicolon after a statement, but found none + + 1 │ export * as foo from "foo.json" + > 2 │ export * as bar from "bar.json" assert { } + │ ^ + 3 │ export * as baz from "baz.json" assert { /* comment */ } + 4 │ + + i An explicit or implicit semicolon is expected here... + + 1 │ export * as foo from "foo.json" + > 2 │ export * as bar from "bar.json" assert { } + │ ^ + 3 │ export * as baz from "baz.json" assert { /* comment */ } + 4 │ + + i ...Which is required to end this statement + + 1 │ export * as foo from "foo.json" + > 2 │ export * as bar from "bar.json" assert { } + │ ^^^^^^^^ + 3 │ export * as baz from "baz.json" assert { /* comment */ } + 4 │ + +empty.js:3:33 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + + × Expected a semicolon or an implicit semicolon after a statement, but found none + + 1 │ export * as foo from "foo.json" + 2 │ export * as bar from "bar.json" assert { } + > 3 │ export * as baz from "baz.json" assert { /* comment */ } + │ ^^^^^^ + 4 │ + 5 │ import * as foo from "foo.json" + + i An explicit or implicit semicolon is expected here... + + 1 │ export * as foo from "foo.json" + 2 │ export * as bar from "bar.json" assert { } + > 3 │ export * as baz from "baz.json" assert { /* comment */ } + │ ^^^^^^ + 4 │ + 5 │ import * as foo from "foo.json" + + i ...Which is required to end this statement + + 1 │ export * as foo from "foo.json" + 2 │ export * as bar from "bar.json" assert { } + > 3 │ export * as baz from "baz.json" assert { /* comment */ } + │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + 4 │ + 5 │ import * as foo from "foo.json" + +empty.js:3:40 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + + × Expected a semicolon or an implicit semicolon after a statement, but found none + + 1 │ export * as foo from "foo.json" + 2 │ export * as bar from "bar.json" assert { } + > 3 │ export * as baz from "baz.json" assert { /* comment */ } + │ ^ + 4 │ + 5 │ import * as foo from "foo.json" + + i An explicit or implicit semicolon is expected here... + + 1 │ export * as foo from "foo.json" + 2 │ export * as bar from "bar.json" assert { } + > 3 │ export * as baz from "baz.json" assert { /* comment */ } + │ ^ + 4 │ + 5 │ import * as foo from "foo.json" + + i ...Which is required to end this statement + + 1 │ export * as foo from "foo.json" + 2 │ export * as bar from "bar.json" assert { } + > 3 │ export * as baz from "baz.json" assert { /* comment */ } + │ ^^^^^^^^ + 4 │ + 5 │ import * as foo from "foo.json" + +empty.js:6:33 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + + × Expected a semicolon or an implicit semicolon after a statement, but found none + + 5 │ import * as foo from "foo.json" + > 6 │ import * as bar from "bar.json" assert { } + │ ^^^^^^ + 7 │ import * as baz from "baz.json" assert { /* comment */ } + + i An explicit or implicit semicolon is expected here... + + 5 │ import * as foo from "foo.json" + > 6 │ import * as bar from "bar.json" assert { } + │ ^^^^^^ + 7 │ import * as baz from "baz.json" assert { /* comment */ } + + i ...Which is required to end this statement + + 5 │ import * as foo from "foo.json" + > 6 │ import * as bar from "bar.json" assert { } + │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + 7 │ import * as baz from "baz.json" assert { /* comment */ } + +empty.js:6:40 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + + × Expected a semicolon or an implicit semicolon after a statement, but found none + + 5 │ import * as foo from "foo.json" + > 6 │ import * as bar from "bar.json" assert { } + │ ^ + 7 │ import * as baz from "baz.json" assert { /* comment */ } + + i An explicit or implicit semicolon is expected here... + + 5 │ import * as foo from "foo.json" + > 6 │ import * as bar from "bar.json" assert { } + │ ^ + 7 │ import * as baz from "baz.json" assert { /* comment */ } + + i ...Which is required to end this statement + + 5 │ import * as foo from "foo.json" + > 6 │ import * as bar from "bar.json" assert { } + │ ^^^^^^^^ + 7 │ import * as baz from "baz.json" assert { /* comment */ } + +empty.js:7:33 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + + × Expected a semicolon or an implicit semicolon after a statement, but found none + + 5 │ import * as foo from "foo.json" + 6 │ import * as bar from "bar.json" assert { } + > 7 │ import * as baz from "baz.json" assert { /* comment */ } + │ ^^^^^^ + + i An explicit or implicit semicolon is expected here... + + 5 │ import * as foo from "foo.json" + 6 │ import * as bar from "bar.json" assert { } + > 7 │ import * as baz from "baz.json" assert { /* comment */ } + │ ^^^^^^ + + i ...Which is required to end this statement + + 5 │ import * as foo from "foo.json" + 6 │ import * as bar from "bar.json" assert { } + > 7 │ import * as baz from "baz.json" assert { /* comment */ } + │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +empty.js:7:40 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + + × Expected a semicolon or an implicit semicolon after a statement, but found none + + 5 │ import * as foo from "foo.json" + 6 │ import * as bar from "bar.json" assert { } + > 7 │ import * as baz from "baz.json" assert { /* comment */ } + │ ^ + + i An explicit or implicit semicolon is expected here... + + 5 │ import * as foo from "foo.json" + 6 │ import * as bar from "bar.json" assert { } + > 7 │ import * as baz from "baz.json" assert { /* comment */ } + │ ^ + + i ...Which is required to end this statement + + 5 │ import * as foo from "foo.json" + 6 │ import * as bar from "bar.json" assert { } + > 7 │ import * as baz from "baz.json" assert { /* comment */ } + │ ^^^^^^^^ + + ``` diff --git a/crates/rome_js_formatter/tests/specs/prettier/js/import-assertions/multi-types.js.snap b/crates/rome_js_formatter/tests/specs/prettier/js/import-assertions/multi-types.js.snap new file mode 100644 index 000000000000..f88b287dd7ef --- /dev/null +++ b/crates/rome_js_formatter/tests/specs/prettier/js/import-assertions/multi-types.js.snap @@ -0,0 +1,105 @@ +--- +source: crates/rome_formatter_test/src/snapshot_builder.rs +info: js/import-assertions/multi-types.js +--- + +# Input + +```js +import json from "./foo.json" assert { type: "json", type: "bar" }; + +``` + + +# Prettier differences + +```diff +--- Prettier ++++ Rome +@@ -1 +1,6 @@ +-import json from "./foo.json" assert { type: "json", type: "bar" }; ++import json from "./foo.json"; ++assert; ++{ ++ type: "json", type; ++ : "bar" ++} +``` + +# Output + +```js +import json from "./foo.json"; +assert; +{ + type: "json", type; + : "bar" +} +``` + +# Errors +``` +multi-types.js:1:31 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + + × Expected a semicolon or an implicit semicolon after a statement, but found none + + > 1 │ import json from "./foo.json" assert { type: "json", type: "bar" }; + │ ^^^^^^ + 2 │ + + i An explicit or implicit semicolon is expected here... + + > 1 │ import json from "./foo.json" assert { type: "json", type: "bar" }; + │ ^^^^^^ + 2 │ + + i ...Which is required to end this statement + + > 1 │ import json from "./foo.json" assert { type: "json", type: "bar" }; + │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + 2 │ + +multi-types.js:1:38 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + + × Expected a semicolon or an implicit semicolon after a statement, but found none + + > 1 │ import json from "./foo.json" assert { type: "json", type: "bar" }; + │ ^ + 2 │ + + i An explicit or implicit semicolon is expected here... + + > 1 │ import json from "./foo.json" assert { type: "json", type: "bar" }; + │ ^ + 2 │ + + i ...Which is required to end this statement + + > 1 │ import json from "./foo.json" assert { type: "json", type: "bar" }; + │ ^^^^^^^^ + 2 │ + +multi-types.js:1:58 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + + × Expected a semicolon or an implicit semicolon after a statement, but found none + + > 1 │ import json from "./foo.json" assert { type: "json", type: "bar" }; + │ ^ + 2 │ + + i An explicit or implicit semicolon is expected here... + + > 1 │ import json from "./foo.json" assert { type: "json", type: "bar" }; + │ ^ + 2 │ + + i ...Which is required to end this statement + + > 1 │ import json from "./foo.json" assert { type: "json", type: "bar" }; + │ ^^^^^^^^^^^^^ + 2 │ + + +``` + + diff --git a/crates/rome_js_formatter/tests/specs/prettier/js/import-assertions/non-type.js.snap b/crates/rome_js_formatter/tests/specs/prettier/js/import-assertions/non-type.js.snap new file mode 100644 index 000000000000..2a0e200e7fa3 --- /dev/null +++ b/crates/rome_js_formatter/tests/specs/prettier/js/import-assertions/non-type.js.snap @@ -0,0 +1,83 @@ +--- +source: crates/rome_formatter_test/src/snapshot_builder.rs +info: js/import-assertions/non-type.js +--- + +# Input + +```js +import foo from "foo.json" assert { lazy: "true" }; + +``` + + +# Prettier differences + +```diff +--- Prettier ++++ Rome +@@ -1 +1,5 @@ +-import foo from "foo.json" assert { lazy: "true" }; ++import foo from "foo.json"; ++assert; ++{ ++ lazy: "true"; ++} +``` + +# Output + +```js +import foo from "foo.json"; +assert; +{ + lazy: "true"; +} +``` + +# Errors +``` +non-type.js:1:28 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + + × Expected a semicolon or an implicit semicolon after a statement, but found none + + > 1 │ import foo from "foo.json" assert { lazy: "true" }; + │ ^^^^^^ + 2 │ + + i An explicit or implicit semicolon is expected here... + + > 1 │ import foo from "foo.json" assert { lazy: "true" }; + │ ^^^^^^ + 2 │ + + i ...Which is required to end this statement + + > 1 │ import foo from "foo.json" assert { lazy: "true" }; + │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^ + 2 │ + +non-type.js:1:35 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + + × Expected a semicolon or an implicit semicolon after a statement, but found none + + > 1 │ import foo from "foo.json" assert { lazy: "true" }; + │ ^ + 2 │ + + i An explicit or implicit semicolon is expected here... + + > 1 │ import foo from "foo.json" assert { lazy: "true" }; + │ ^ + 2 │ + + i ...Which is required to end this statement + + > 1 │ import foo from "foo.json" assert { lazy: "true" }; + │ ^^^^^^^^ + 2 │ + + +``` + + diff --git a/crates/rome_js_formatter/tests/specs/prettier/js/import-assertions/re-export.js.snap b/crates/rome_js_formatter/tests/specs/prettier/js/import-assertions/re-export.js.snap new file mode 100644 index 000000000000..b8ecf6f7b523 --- /dev/null +++ b/crates/rome_js_formatter/tests/specs/prettier/js/import-assertions/re-export.js.snap @@ -0,0 +1,217 @@ +--- +source: crates/rome_formatter_test/src/snapshot_builder.rs +info: js/import-assertions/re-export.js +--- + +# Input + +```js +export { default as foo2 } from "foo.json" assert { type: "json" }; +export * from "foo.json" assert { type: "json" }; +export * as foo3 from "foo.json" assert { type: "json" }; + +``` + + +# Prettier differences + +```diff +--- Prettier ++++ Rome +@@ -1,3 +1,15 @@ +-export { default as foo2 } from "foo.json" assert { type: "json" }; +-export * from "foo.json" assert { type: "json" }; +-export * as foo3 from "foo.json" assert { type: "json" }; ++export { default as foo2 } from "foo.json"; ++assert; ++{ ++ type: "json"; ++} ++export * from "foo.json"; ++assert; ++{ ++ type: "json"; ++} ++export * as foo3 from "foo.json"; ++assert; ++{ ++ type: "json"; ++} +``` + +# Output + +```js +export { default as foo2 } from "foo.json"; +assert; +{ + type: "json"; +} +export * from "foo.json"; +assert; +{ + type: "json"; +} +export * as foo3 from "foo.json"; +assert; +{ + type: "json"; +} +``` + +# Errors +``` +re-export.js:1:44 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + + × Expected a semicolon or an implicit semicolon after a statement, but found none + + > 1 │ export { default as foo2 } from "foo.json" assert { type: "json" }; + │ ^^^^^^ + 2 │ export * from "foo.json" assert { type: "json" }; + 3 │ export * as foo3 from "foo.json" assert { type: "json" }; + + i An explicit or implicit semicolon is expected here... + + > 1 │ export { default as foo2 } from "foo.json" assert { type: "json" }; + │ ^^^^^^ + 2 │ export * from "foo.json" assert { type: "json" }; + 3 │ export * as foo3 from "foo.json" assert { type: "json" }; + + i ...Which is required to end this statement + + > 1 │ export { default as foo2 } from "foo.json" assert { type: "json" }; + │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + 2 │ export * from "foo.json" assert { type: "json" }; + 3 │ export * as foo3 from "foo.json" assert { type: "json" }; + +re-export.js:1:51 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + + × Expected a semicolon or an implicit semicolon after a statement, but found none + + > 1 │ export { default as foo2 } from "foo.json" assert { type: "json" }; + │ ^ + 2 │ export * from "foo.json" assert { type: "json" }; + 3 │ export * as foo3 from "foo.json" assert { type: "json" }; + + i An explicit or implicit semicolon is expected here... + + > 1 │ export { default as foo2 } from "foo.json" assert { type: "json" }; + │ ^ + 2 │ export * from "foo.json" assert { type: "json" }; + 3 │ export * as foo3 from "foo.json" assert { type: "json" }; + + i ...Which is required to end this statement + + > 1 │ export { default as foo2 } from "foo.json" assert { type: "json" }; + │ ^^^^^^^^ + 2 │ export * from "foo.json" assert { type: "json" }; + 3 │ export * as foo3 from "foo.json" assert { type: "json" }; + +re-export.js:2:26 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + + × Expected a semicolon or an implicit semicolon after a statement, but found none + + 1 │ export { default as foo2 } from "foo.json" assert { type: "json" }; + > 2 │ export * from "foo.json" assert { type: "json" }; + │ ^^^^^^ + 3 │ export * as foo3 from "foo.json" assert { type: "json" }; + 4 │ + + i An explicit or implicit semicolon is expected here... + + 1 │ export { default as foo2 } from "foo.json" assert { type: "json" }; + > 2 │ export * from "foo.json" assert { type: "json" }; + │ ^^^^^^ + 3 │ export * as foo3 from "foo.json" assert { type: "json" }; + 4 │ + + i ...Which is required to end this statement + + 1 │ export { default as foo2 } from "foo.json" assert { type: "json" }; + > 2 │ export * from "foo.json" assert { type: "json" }; + │ ^^^^^^^^^^^^^^^^^^^^^^^^ + 3 │ export * as foo3 from "foo.json" assert { type: "json" }; + 4 │ + +re-export.js:2:33 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + + × Expected a semicolon or an implicit semicolon after a statement, but found none + + 1 │ export { default as foo2 } from "foo.json" assert { type: "json" }; + > 2 │ export * from "foo.json" assert { type: "json" }; + │ ^ + 3 │ export * as foo3 from "foo.json" assert { type: "json" }; + 4 │ + + i An explicit or implicit semicolon is expected here... + + 1 │ export { default as foo2 } from "foo.json" assert { type: "json" }; + > 2 │ export * from "foo.json" assert { type: "json" }; + │ ^ + 3 │ export * as foo3 from "foo.json" assert { type: "json" }; + 4 │ + + i ...Which is required to end this statement + + 1 │ export { default as foo2 } from "foo.json" assert { type: "json" }; + > 2 │ export * from "foo.json" assert { type: "json" }; + │ ^^^^^^^^ + 3 │ export * as foo3 from "foo.json" assert { type: "json" }; + 4 │ + +re-export.js:3:34 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + + × Expected a semicolon or an implicit semicolon after a statement, but found none + + 1 │ export { default as foo2 } from "foo.json" assert { type: "json" }; + 2 │ export * from "foo.json" assert { type: "json" }; + > 3 │ export * as foo3 from "foo.json" assert { type: "json" }; + │ ^^^^^^ + 4 │ + + i An explicit or implicit semicolon is expected here... + + 1 │ export { default as foo2 } from "foo.json" assert { type: "json" }; + 2 │ export * from "foo.json" assert { type: "json" }; + > 3 │ export * as foo3 from "foo.json" assert { type: "json" }; + │ ^^^^^^ + 4 │ + + i ...Which is required to end this statement + + 1 │ export { default as foo2 } from "foo.json" assert { type: "json" }; + 2 │ export * from "foo.json" assert { type: "json" }; + > 3 │ export * as foo3 from "foo.json" assert { type: "json" }; + │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + 4 │ + +re-export.js:3:41 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + + × Expected a semicolon or an implicit semicolon after a statement, but found none + + 1 │ export { default as foo2 } from "foo.json" assert { type: "json" }; + 2 │ export * from "foo.json" assert { type: "json" }; + > 3 │ export * as foo3 from "foo.json" assert { type: "json" }; + │ ^ + 4 │ + + i An explicit or implicit semicolon is expected here... + + 1 │ export { default as foo2 } from "foo.json" assert { type: "json" }; + 2 │ export * from "foo.json" assert { type: "json" }; + > 3 │ export * as foo3 from "foo.json" assert { type: "json" }; + │ ^ + 4 │ + + i ...Which is required to end this statement + + 1 │ export { default as foo2 } from "foo.json" assert { type: "json" }; + 2 │ export * from "foo.json" assert { type: "json" }; + > 3 │ export * as foo3 from "foo.json" assert { type: "json" }; + │ ^^^^^^^^ + 4 │ + + +``` + + diff --git a/crates/rome_js_formatter/tests/specs/prettier/js/import-assertions/static-import.js.snap b/crates/rome_js_formatter/tests/specs/prettier/js/import-assertions/static-import.js.snap new file mode 100644 index 000000000000..5a017fd1e756 --- /dev/null +++ b/crates/rome_js_formatter/tests/specs/prettier/js/import-assertions/static-import.js.snap @@ -0,0 +1,83 @@ +--- +source: crates/rome_formatter_test/src/snapshot_builder.rs +info: js/import-assertions/static-import.js +--- + +# Input + +```js +import json from "./foo.json" assert { type: "json" }; + +``` + + +# Prettier differences + +```diff +--- Prettier ++++ Rome +@@ -1 +1,5 @@ +-import json from "./foo.json" assert { type: "json" }; ++import json from "./foo.json"; ++assert; ++{ ++ type: "json"; ++} +``` + +# Output + +```js +import json from "./foo.json"; +assert; +{ + type: "json"; +} +``` + +# Errors +``` +static-import.js:1:31 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + + × Expected a semicolon or an implicit semicolon after a statement, but found none + + > 1 │ import json from "./foo.json" assert { type: "json" }; + │ ^^^^^^ + 2 │ + + i An explicit or implicit semicolon is expected here... + + > 1 │ import json from "./foo.json" assert { type: "json" }; + │ ^^^^^^ + 2 │ + + i ...Which is required to end this statement + + > 1 │ import json from "./foo.json" assert { type: "json" }; + │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + 2 │ + +static-import.js:1:38 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + + × Expected a semicolon or an implicit semicolon after a statement, but found none + + > 1 │ import json from "./foo.json" assert { type: "json" }; + │ ^ + 2 │ + + i An explicit or implicit semicolon is expected here... + + > 1 │ import json from "./foo.json" assert { type: "json" }; + │ ^ + 2 │ + + i ...Which is required to end this statement + + > 1 │ import json from "./foo.json" assert { type: "json" }; + │ ^^^^^^^^ + 2 │ + + +``` + + diff --git a/crates/rome_js_formatter/tests/specs/prettier/js/import-assertions/without-from.js.snap b/crates/rome_js_formatter/tests/specs/prettier/js/import-assertions/without-from.js.snap new file mode 100644 index 000000000000..9a4cb8a6caeb --- /dev/null +++ b/crates/rome_js_formatter/tests/specs/prettier/js/import-assertions/without-from.js.snap @@ -0,0 +1,83 @@ +--- +source: crates/rome_formatter_test/src/snapshot_builder.rs +info: js/import-assertions/without-from.js +--- + +# Input + +```js +import "foo" assert { type: "json" } + +``` + + +# Prettier differences + +```diff +--- Prettier ++++ Rome +@@ -1 +1,5 @@ +-import "foo" assert { type: "json" }; ++import "foo"; ++assert; ++{ ++ type: "json"; ++} +``` + +# Output + +```js +import "foo"; +assert; +{ + type: "json"; +} +``` + +# Errors +``` +without-from.js:1:14 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + + × Expected a semicolon or an implicit semicolon after a statement, but found none + + > 1 │ import "foo" assert { type: "json" } + │ ^^^^^^ + 2 │ + + i An explicit or implicit semicolon is expected here... + + > 1 │ import "foo" assert { type: "json" } + │ ^^^^^^ + 2 │ + + i ...Which is required to end this statement + + > 1 │ import "foo" assert { type: "json" } + │ ^^^^^^^^^^^^^ + 2 │ + +without-from.js:1:21 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + + × Expected a semicolon or an implicit semicolon after a statement, but found none + + > 1 │ import "foo" assert { type: "json" } + │ ^ + 2 │ + + i An explicit or implicit semicolon is expected here... + + > 1 │ import "foo" assert { type: "json" } + │ ^ + 2 │ + + i ...Which is required to end this statement + + > 1 │ import "foo" assert { type: "json" } + │ ^^^^^^^^ + 2 │ + + +``` + + diff --git a/crates/rome_js_parser/src/lexer/mod.rs b/crates/rome_js_parser/src/lexer/mod.rs index ddd48030a9bb..698b794bc4b5 100644 --- a/crates/rome_js_parser/src/lexer/mod.rs +++ b/crates/rome_js_parser/src/lexer/mod.rs @@ -1060,7 +1060,6 @@ impl<'src> Lexer<'src> { b"accessor" => ACCESSOR_KW, b"as" => AS_KW, b"asserts" => ASSERTS_KW, - b"assert" => ASSERT_KW, b"any" => ANY_KW, b"async" => ASYNC_KW, b"await" => AWAIT_KW, diff --git a/crates/rome_js_parser/src/lexer/tests.rs b/crates/rome_js_parser/src/lexer/tests.rs index 856dea7d765d..99a68ee6c76f 100644 --- a/crates/rome_js_parser/src/lexer/tests.rs +++ b/crates/rome_js_parser/src/lexer/tests.rs @@ -1311,7 +1311,6 @@ fn keywords() { "abstract", "as", "asserts", - "assert", "any", "async", "await", diff --git a/crates/rome_js_parser/src/syntax/module.rs b/crates/rome_js_parser/src/syntax/module.rs index b5de1a2be7bc..7f91997f0ad1 100644 --- a/crates/rome_js_parser/src/syntax/module.rs +++ b/crates/rome_js_parser/src/syntax/module.rs @@ -248,14 +248,14 @@ fn parse_import_default_or_named_clause_rest( p.expect(T![from]); parse_module_source(p).or_add_diagnostic(p, expected_module_source); - parse_import_assertion(p).ok(); + parse_import_attributes(p).ok(); named_clause.complete(p, JS_IMPORT_NAMED_CLAUSE) } _ => { p.expect(T![from]); parse_module_source(p).or_add_diagnostic(p, expected_module_source); - parse_import_assertion(p).ok(); + parse_import_attributes(p).ok(); m.complete(p, JS_IMPORT_DEFAULT_CLAUSE) } @@ -268,7 +268,7 @@ fn parse_import_default_or_named_clause_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_attributes(p).ok(); m.complete(p, JS_IMPORT_BARE_CLAUSE) }) } @@ -282,7 +282,7 @@ fn parse_import_namespace_clause_rest(p: &mut JsParser, m: Marker) -> CompletedM parse_binding(p).or_add_diagnostic(p, expected_binding); p.expect(T![from]); parse_module_source(p).or_add_diagnostic(p, expected_module_source); - parse_import_assertion(p).ok(); + parse_import_attributes(p).ok(); m.complete(p, JS_IMPORT_NAMESPACE_CLAUSE) } @@ -298,7 +298,7 @@ fn parse_import_named_clause_rest(p: &mut JsParser, m: Marker) -> CompletedMarke parse_named_import(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_attributes(p).ok(); m.complete(p, JS_IMPORT_NAMED_CLAUSE) } @@ -445,51 +445,51 @@ fn parse_any_named_import_specifier(p: &mut JsParser) -> ParsedSyntax { } } -// test import_assertion -// import "x" assert { type: "json" } -// import "foo" assert { "type": "json" }; -// import foo from "foo.json" assert { type: "json" }; -// import {test} from "foo.json" assert { for: "for" } -// import foo_json from "foo.json" assert { type: "json", hasOwnProperty: "true" }; -// import "x" assert +// test import_attribute +// import "x" with { type: "json" } +// import "foo" with { "type": "json" }; +// import foo from "foo.json" with { type: "json" }; +// import {test} from "foo.json" with { for: "for" } +// import foo_json from "foo.json" with { type: "json", hasOwnProperty: "true" }; +// import "x" with // { type: "json" } -// test_err import_assertion_err -// import "foo" assert { type, "json" }; -// import "bar" \u{61}ssert { type: "json" }; -// import { foo } assert { type: "json" }; +// test_err import_attribute_err +// import "foo" with { type, "json" }; +// import "bar" \u{61}ith { type: "json" }; +// import { foo } with { type: "json" }; // import "lorem" // assert { type: "json" } -// import foo2 from "foo.json" assert { "type": "json", type: "html", "type": "js" }; -// import "x" assert; -// import ipsum from "ipsum.json" assert { type: "json", lazy: true, startAtLine: 1 }; -// import { a } from "a.json" assert -fn parse_import_assertion(p: &mut JsParser) -> ParsedSyntax { - if !p.at(T![assert]) || p.has_preceding_line_break() { +// import foo2 from "foo.json" with { "type": "json", type: "html", "type": "js" }; +// import "x" with; +// import ipsum from "ipsum.json" with { type: "json", lazy: true, startAtLine: 1 }; +// import { a } from "a.json" with +fn parse_import_attributes(p: &mut JsParser) -> ParsedSyntax { + if !p.at(T![with]) || p.has_preceding_line_break() { return Absent; } let m = p.start(); - p.expect(T![assert]); + p.expect(T![with]); p.expect(T!['{']); - ImportAssertionList::default().parse_list(p); + ImportAttributeList::default().parse_list(p); p.expect(T!['}']); - Present(m.complete(p, JS_IMPORT_ASSERTION)) + Present(m.complete(p, JS_IMPORT_ATTRIBUTE)) } #[derive(Default)] -struct ImportAssertionList { +struct ImportAttributeList { assertion_keys: HashMap, } -impl ParseSeparatedList for ImportAssertionList { +impl ParseSeparatedList for ImportAttributeList { 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) @@ -503,7 +503,7 @@ impl ParseSeparatedList for ImportAssertionList { parsed_element.or_recover( p, &ParseRecovery::new( - JS_BOGUS_IMPORT_ASSERTION_ENTRY, + JS_BOGUS_IMPORT_ATTRIBUTE_ENTRY, STMT_RECOVERY_SET.union(token_set![T![,], T!['}']]), ) .enable_recovery_on_line_break(), @@ -572,7 +572,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); @@ -917,7 +917,7 @@ where // export * from "a"; // export * as c from "b"; // export * as default from "b" -// export * from "mod" assert { type: "json" } +// export * from "mod" with { type: "json" } // export type * from "types"; // export type * as types from "types"; // @@ -944,7 +944,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_attributes(p).ok(); semi(p, TextRange::new(start, p.cur_range().end())); Present(m.complete(p, JS_EXPORT_FROM_CLAUSE)) @@ -956,7 +956,7 @@ fn parse_export_from_clause(p: &mut JsParser) -> ParsedSyntax { // export { as } from "mod"; // export { default as "b" } from "mod"; // export { "a" as b } from "mod"; -// export { a } from "mod" assert { type: "json" } +// export { a } from "mod" with { type: "json" } // export { "a" } from "./mod"; // export { // "a" @@ -990,7 +990,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_attributes(p).ok(); semi(p, TextRange::new(start, p.cur_range().start())); diff --git a/crates/rome_js_parser/test_data/inline/err/export_decl_not_top_level.rast b/crates/rome_js_parser/test_data/inline/err/export_decl_not_top_level.rast index c613ee0c8449..51226d99efa7 100644 --- a/crates/rome_js_parser/test_data/inline/err/export_decl_not_top_level.rast +++ b/crates/rome_js_parser/test_data/inline/err/export_decl_not_top_level.rast @@ -25,7 +25,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/rome_js_parser/test_data/inline/err/export_from_clause_err.rast b/crates/rome_js_parser/test_data/inline/err/export_from_clause_err.rast index ea0c7d0e6f05..344b8189d4b7 100644 --- a/crates/rome_js_parser/test_data/inline/err/export_from_clause_err.rast +++ b/crates/rome_js_parser/test_data/inline/err/export_from_clause_err.rast @@ -10,7 +10,7 @@ JsModule { export_as: missing (optional), from_token: missing (required), source: missing (required), - assertion: missing (optional), + attribute: missing (optional), semicolon_token: SEMICOLON@8..9 ";" [] [], }, }, @@ -22,7 +22,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), }, }, @@ -47,7 +47,7 @@ JsModule { source: JsModuleSource { value_token: JS_STRING_LITERAL@42..48 "\"test\"" [] [], }, - assertion: missing (optional), + attribute: missing (optional), semicolon_token: SEMICOLON@48..49 ";" [] [], }, }, @@ -61,7 +61,7 @@ JsModule { source: JsModuleSource { value_token: JS_STRING_LITERAL@62..68 "\"test\"" [] [], }, - assertion: missing (optional), + attribute: missing (optional), semicolon_token: SEMICOLON@68..69 ";" [] [], }, }, @@ -73,7 +73,7 @@ JsModule { export_as: missing (optional), from_token: missing (required), source: missing (required), - assertion: missing (optional), + attribute: missing (optional), semicolon_token: SEMICOLON@83..84 ";" [] [], }, }, @@ -85,7 +85,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 ";" [] [], }, }, @@ -102,7 +102,7 @@ JsModule { }, from_token: missing (required), source: missing (required), - assertion: missing (optional), + attribute: missing (optional), semicolon_token: SEMICOLON@126..127 ";" [] [], }, }, @@ -119,7 +119,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/rome_js_parser/test_data/inline/err/export_named_from_clause_err.rast b/crates/rome_js_parser/test_data/inline/err/export_named_from_clause_err.rast index c24db2b93632..753d99100744 100644 --- a/crates/rome_js_parser/test_data/inline/err/export_named_from_clause_err.rast +++ b/crates/rome_js_parser/test_data/inline/err/export_named_from_clause_err.rast @@ -24,7 +24,7 @@ JsModule { source: JsModuleSource { value_token: JS_STRING_LITERAL@21..26 "\"mod\"" [] [], }, - assertion: missing (optional), + attribute: missing (optional), semicolon_token: SEMICOLON@26..27 ";" [] [], }, }, @@ -98,7 +98,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/rome_js_parser/test_data/inline/err/import_as_identifier_err.rast b/crates/rome_js_parser/test_data/inline/err/import_as_identifier_err.rast index 365bcf2eaf7b..acedab4580b0 100644 --- a/crates/rome_js_parser/test_data/inline/err/import_as_identifier_err.rast +++ b/crates/rome_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/rome_js_parser/test_data/inline/err/import_assertion_err.rast b/crates/rome_js_parser/test_data/inline/err/import_assertion_err.rast index 19b10e254f91..4a54ee3c286d 100644 --- a/crates/rome_js_parser/test_data/inline/err/import_assertion_err.rast +++ b/crates/rome_js_parser/test_data/inline/err/import_assertion_err.rast @@ -8,53 +8,77 @@ JsModule { source: JsModuleSource { value_token: JS_STRING_LITERAL@7..13 "\"foo\"" [] [Whitespace(" ")], }, - assertion: JsImportAssertion { - assert_token: ASSERT_KW@13..20 "assert" [] [Whitespace(" ")], - l_curly_token: L_CURLY@20..22 "{" [] [Whitespace(" ")], - assertions: JsImportAssertionEntryList [ - JsImportAssertionEntry { - key: IDENT@22..26 "type" [] [], - colon_token: missing (required), - value_token: missing (required), + attribute: missing (optional), + }, + semicolon_token: missing (optional), + }, + JsExpressionStatement { + expression: JsIdentifierExpression { + name: JsReferenceIdentifier { + value_token: IDENT@13..20 "assert" [] [Whitespace(" ")], + }, + }, + semicolon_token: missing (optional), + }, + JsBlockStatement { + l_curly_token: L_CURLY@20..22 "{" [] [Whitespace(" ")], + statements: JsStatementList [ + JsExpressionStatement { + expression: JsSequenceExpression { + left: JsIdentifierExpression { + name: JsReferenceIdentifier { + value_token: IDENT@22..26 "type" [] [], + }, }, - COMMA@26..28 "," [] [Whitespace(" ")], - JsImportAssertionEntry { - key: JS_STRING_LITERAL@28..35 "\"json\"" [] [Whitespace(" ")], - colon_token: missing (required), - value_token: missing (required), + comma_token: COMMA@26..28 "," [] [Whitespace(" ")], + right: JsStringLiteralExpression { + value_token: JS_STRING_LITERAL@28..35 "\"json\"" [] [Whitespace(" ")], }, - ], - r_curly_token: R_CURLY@35..36 "}" [] [], + }, + semicolon_token: missing (optional), }, - }, + ], + r_curly_token: R_CURLY@35..36 "}" [] [], + }, + JsEmptyStatement { semicolon_token: SEMICOLON@36..37 ";" [] [], }, - JsBogusStatement { - items: [ - IMPORT_KW@37..45 "import" [Newline("\n")] [Whitespace(" ")], - JsBogus { - items: [ - JsModuleSource { - value_token: JS_STRING_LITERAL@45..51 "\"bar\"" [] [Whitespace(" ")], - }, - JsBogus { - items: [ - ERROR_TOKEN@51..63 "\\u{61}ssert" [] [Whitespace(" ")], - L_CURLY@63..65 "{" [] [Whitespace(" ")], - JsImportAssertionEntryList [ - JsImportAssertionEntry { - key: IDENT@65..69 "type" [] [], - colon_token: COLON@69..71 ":" [] [Whitespace(" ")], - value_token: JS_STRING_LITERAL@71..78 "\"json\"" [] [Whitespace(" ")], - }, - ], - R_CURLY@78..79 "}" [] [], - ], + JsImport { + import_token: IMPORT_KW@37..45 "import" [Newline("\n")] [Whitespace(" ")], + import_clause: JsImportBareClause { + source: JsModuleSource { + value_token: JS_STRING_LITERAL@45..51 "\"bar\"" [] [Whitespace(" ")], + }, + attribute: missing (optional), + }, + semicolon_token: missing (optional), + }, + JsExpressionStatement { + expression: JsIdentifierExpression { + name: JsReferenceIdentifier { + value_token: IDENT@51..63 "\\u{61}ssert" [] [Whitespace(" ")], + }, + }, + semicolon_token: missing (optional), + }, + JsBlockStatement { + l_curly_token: L_CURLY@63..65 "{" [] [Whitespace(" ")], + statements: JsStatementList [ + JsLabeledStatement { + label_token: IDENT@65..69 "type" [] [], + colon_token: COLON@69..71 ":" [] [Whitespace(" ")], + body: JsExpressionStatement { + expression: JsStringLiteralExpression { + value_token: JS_STRING_LITERAL@71..78 "\"json\"" [] [Whitespace(" ")], }, - ], + semicolon_token: missing (optional), + }, }, - SEMICOLON@79..80 ";" [] [], ], + r_curly_token: R_CURLY@78..79 "}" [] [], + }, + JsEmptyStatement { + semicolon_token: SEMICOLON@79..80 ";" [] [], }, JsImport { import_token: IMPORT_KW@80..88 "import" [Newline("\n")] [Whitespace(" ")], @@ -75,19 +99,35 @@ JsModule { }, from_token: missing (required), source: missing (required), - assertion: JsImportAssertion { - assert_token: ASSERT_KW@96..103 "assert" [] [Whitespace(" ")], - l_curly_token: L_CURLY@103..105 "{" [] [Whitespace(" ")], - assertions: JsImportAssertionEntryList [ - JsImportAssertionEntry { - key: IDENT@105..109 "type" [] [], - colon_token: COLON@109..111 ":" [] [Whitespace(" ")], + attribute: missing (optional), + }, + semicolon_token: missing (optional), + }, + JsExpressionStatement { + expression: JsIdentifierExpression { + name: JsReferenceIdentifier { + value_token: IDENT@96..103 "assert" [] [Whitespace(" ")], + }, + }, + semicolon_token: missing (optional), + }, + JsBlockStatement { + l_curly_token: L_CURLY@103..105 "{" [] [Whitespace(" ")], + statements: JsStatementList [ + JsLabeledStatement { + label_token: IDENT@105..109 "type" [] [], + colon_token: COLON@109..111 ":" [] [Whitespace(" ")], + body: JsExpressionStatement { + expression: JsStringLiteralExpression { value_token: JS_STRING_LITERAL@111..118 "\"json\"" [] [Whitespace(" ")], }, - ], - r_curly_token: R_CURLY@118..119 "}" [] [], + semicolon_token: missing (optional), + }, }, - }, + ], + r_curly_token: R_CURLY@118..119 "}" [] [], + }, + JsEmptyStatement { semicolon_token: SEMICOLON@119..120 ";" [] [], }, JsImport { @@ -96,7 +136,7 @@ JsModule { source: JsModuleSource { value_token: JS_STRING_LITERAL@128..135 "\"lorem\"" [] [], }, - assertion: missing (optional), + attribute: missing (optional), }, semicolon_token: missing (optional), }, @@ -135,35 +175,60 @@ JsModule { source: JsModuleSource { value_token: JS_STRING_LITERAL@177..188 "\"foo.json\"" [] [Whitespace(" ")], }, - assertion: JsImportAssertion { - assert_token: ASSERT_KW@188..195 "assert" [] [Whitespace(" ")], - l_curly_token: L_CURLY@195..197 "{" [] [Whitespace(" ")], - assertions: JsImportAssertionEntryList [ - JsImportAssertionEntry { - key: JS_STRING_LITERAL@197..203 "\"type\"" [] [], - colon_token: COLON@203..205 ":" [] [Whitespace(" ")], - value_token: JS_STRING_LITERAL@205..211 "\"json\"" [] [], - }, + attribute: missing (optional), + }, + semicolon_token: missing (optional), + }, + JsExpressionStatement { + expression: JsIdentifierExpression { + name: JsReferenceIdentifier { + value_token: IDENT@188..195 "assert" [] [Whitespace(" ")], + }, + }, + semicolon_token: missing (optional), + }, + JsBlockStatement { + l_curly_token: L_CURLY@195..197 "{" [] [Whitespace(" ")], + statements: JsStatementList [ + JsExpressionStatement { + expression: JsStringLiteralExpression { + value_token: JS_STRING_LITERAL@197..203 "\"type\"" [] [], + }, + semicolon_token: missing (optional), + }, + JsBogusStatement { + items: [ + COLON@203..205 ":" [] [Whitespace(" ")], + JS_STRING_LITERAL@205..211 "\"json\"" [] [], COMMA@211..213 "," [] [Whitespace(" ")], - JsBogusImportAssertionEntry { - items: [ - IDENT@213..217 "type" [] [], - COLON@217..219 ":" [] [Whitespace(" ")], - JS_STRING_LITERAL@219..225 "\"html\"" [] [], - ], - }, - COMMA@225..227 "," [] [Whitespace(" ")], - JsBogusImportAssertionEntry { - items: [ - JS_STRING_LITERAL@227..233 "\"type\"" [] [], - COLON@233..235 ":" [] [Whitespace(" ")], - JS_STRING_LITERAL@235..240 "\"js\"" [] [Whitespace(" ")], - ], + ], + }, + JsLabeledStatement { + label_token: IDENT@213..217 "type" [] [], + colon_token: COLON@217..219 ":" [] [Whitespace(" ")], + body: JsExpressionStatement { + expression: JsSequenceExpression { + left: JsStringLiteralExpression { + value_token: JS_STRING_LITERAL@219..225 "\"html\"" [] [], + }, + comma_token: COMMA@225..227 "," [] [Whitespace(" ")], + right: JsStringLiteralExpression { + value_token: JS_STRING_LITERAL@227..233 "\"type\"" [] [], + }, }, + semicolon_token: missing (optional), + }, + }, + JsBogusStatement { + items: [ + COLON@233..235 ":" [] [Whitespace(" ")], + JS_STRING_LITERAL@235..240 "\"js\"" [] [Whitespace(" ")], ], - r_curly_token: R_CURLY@240..241 "}" [] [], }, - }, + ], + r_curly_token: R_CURLY@240..241 "}" [] [], + }, + JsEmptyStatement { semicolon_token: SEMICOLON@241..242 ";" [] [], }, JsImport { @@ -172,11 +237,14 @@ JsModule { source: JsModuleSource { value_token: JS_STRING_LITERAL@250..254 "\"x\"" [] [Whitespace(" ")], }, - assertion: JsImportAssertion { - assert_token: ASSERT_KW@254..260 "assert" [] [], - l_curly_token: missing (required), - assertions: JsImportAssertionEntryList [], - r_curly_token: missing (required), + attribute: missing (optional), + }, + semicolon_token: missing (optional), + }, + JsExpressionStatement { + expression: JsIdentifierExpression { + name: JsReferenceIdentifier { + value_token: IDENT@254..260 "assert" [] [], }, }, semicolon_token: SEMICOLON@260..261 ";" [] [], @@ -192,43 +260,53 @@ JsModule { source: JsModuleSource { value_token: JS_STRING_LITERAL@280..293 "\"ipsum.json\"" [] [Whitespace(" ")], }, - assertion: JsImportAssertion { - assert_token: ASSERT_KW@293..300 "assert" [] [Whitespace(" ")], - l_curly_token: L_CURLY@300..302 "{" [] [Whitespace(" ")], - assertions: JsImportAssertionEntryList [ - JsImportAssertionEntry { - key: IDENT@302..306 "type" [] [], - colon_token: COLON@306..308 ":" [] [Whitespace(" ")], - value_token: JS_STRING_LITERAL@308..314 "\"json\"" [] [], - }, - COMMA@314..316 "," [] [Whitespace(" ")], - JsImportAssertionEntry { - key: IDENT@316..320 "lazy" [] [], - colon_token: COLON@320..322 ":" [] [Whitespace(" ")], - value_token: missing (required), - }, - missing separator, - JsImportAssertionEntry { - key: IDENT@322..326 "true" [] [], - colon_token: missing (required), - value_token: missing (required), + attribute: missing (optional), + }, + semicolon_token: missing (optional), + }, + JsExpressionStatement { + expression: JsIdentifierExpression { + name: JsReferenceIdentifier { + value_token: IDENT@293..300 "assert" [] [Whitespace(" ")], + }, + }, + semicolon_token: missing (optional), + }, + JsBlockStatement { + l_curly_token: L_CURLY@300..302 "{" [] [Whitespace(" ")], + statements: JsStatementList [ + JsLabeledStatement { + label_token: IDENT@302..306 "type" [] [], + colon_token: COLON@306..308 ":" [] [Whitespace(" ")], + body: JsExpressionStatement { + expression: JsSequenceExpression { + left: JsStringLiteralExpression { + value_token: JS_STRING_LITERAL@308..314 "\"json\"" [] [], + }, + comma_token: COMMA@314..316 "," [] [Whitespace(" ")], + right: JsIdentifierExpression { + name: JsReferenceIdentifier { + value_token: IDENT@316..320 "lazy" [] [], + }, + }, }, + semicolon_token: missing (optional), + }, + }, + JsBogusStatement { + items: [ + COLON@320..322 ":" [] [Whitespace(" ")], + TRUE_KW@322..326 "true" [] [], COMMA@326..328 "," [] [Whitespace(" ")], - JsImportAssertionEntry { - key: IDENT@328..339 "startAtLine" [] [], - colon_token: COLON@339..341 ":" [] [Whitespace(" ")], - value_token: missing (required), - }, - missing separator, - JsBogusImportAssertionEntry { - items: [ - JS_NUMBER_LITERAL@341..343 "1" [] [Whitespace(" ")], - ], - }, + IDENT@328..339 "startAtLine" [] [], + COLON@339..341 ":" [] [Whitespace(" ")], + JS_NUMBER_LITERAL@341..343 "1" [] [Whitespace(" ")], ], - r_curly_token: R_CURLY@343..344 "}" [] [], }, - }, + ], + r_curly_token: R_CURLY@343..344 "}" [] [], + }, + JsEmptyStatement { semicolon_token: SEMICOLON@344..345 ";" [] [], }, JsImport { @@ -252,11 +330,14 @@ JsModule { source: JsModuleSource { value_token: JS_STRING_LITERAL@364..373 "\"a.json\"" [] [Whitespace(" ")], }, - assertion: JsImportAssertion { - assert_token: ASSERT_KW@373..379 "assert" [] [], - l_curly_token: missing (required), - assertions: JsImportAssertionEntryList [], - r_curly_token: missing (required), + attribute: missing (optional), + }, + semicolon_token: missing (optional), + }, + JsExpressionStatement { + expression: JsIdentifierExpression { + name: JsReferenceIdentifier { + value_token: IDENT@373..379 "assert" [] [], }, }, semicolon_token: missing (optional), @@ -269,44 +350,61 @@ JsModule { 0: (empty) 1: JS_DIRECTIVE_LIST@0..0 2: JS_MODULE_ITEM_LIST@0..379 - 0: JS_IMPORT@0..37 + 0: JS_IMPORT@0..13 0: IMPORT_KW@0..7 "import" [] [Whitespace(" ")] - 1: JS_IMPORT_BARE_CLAUSE@7..36 + 1: JS_IMPORT_BARE_CLAUSE@7..13 0: JS_MODULE_SOURCE@7..13 0: JS_STRING_LITERAL@7..13 "\"foo\"" [] [Whitespace(" ")] - 1: JS_IMPORT_ASSERTION@13..36 - 0: ASSERT_KW@13..20 "assert" [] [Whitespace(" ")] - 1: L_CURLY@20..22 "{" [] [Whitespace(" ")] - 2: JS_IMPORT_ASSERTION_ENTRY_LIST@22..35 - 0: JS_IMPORT_ASSERTION_ENTRY@22..26 - 0: IDENT@22..26 "type" [] [] - 1: (empty) - 2: (empty) + 1: (empty) + 2: (empty) + 1: JS_EXPRESSION_STATEMENT@13..20 + 0: JS_IDENTIFIER_EXPRESSION@13..20 + 0: JS_REFERENCE_IDENTIFIER@13..20 + 0: IDENT@13..20 "assert" [] [Whitespace(" ")] + 1: (empty) + 2: JS_BLOCK_STATEMENT@20..36 + 0: L_CURLY@20..22 "{" [] [Whitespace(" ")] + 1: JS_STATEMENT_LIST@22..35 + 0: JS_EXPRESSION_STATEMENT@22..35 + 0: JS_SEQUENCE_EXPRESSION@22..35 + 0: JS_IDENTIFIER_EXPRESSION@22..26 + 0: JS_REFERENCE_IDENTIFIER@22..26 + 0: IDENT@22..26 "type" [] [] 1: COMMA@26..28 "," [] [Whitespace(" ")] - 2: JS_IMPORT_ASSERTION_ENTRY@28..35 + 2: JS_STRING_LITERAL_EXPRESSION@28..35 0: JS_STRING_LITERAL@28..35 "\"json\"" [] [Whitespace(" ")] - 1: (empty) - 2: (empty) - 3: R_CURLY@35..36 "}" [] [] - 2: SEMICOLON@36..37 ";" [] [] - 1: JS_BOGUS_STATEMENT@37..80 + 1: (empty) + 2: R_CURLY@35..36 "}" [] [] + 3: JS_EMPTY_STATEMENT@36..37 + 0: SEMICOLON@36..37 ";" [] [] + 4: JS_IMPORT@37..51 0: IMPORT_KW@37..45 "import" [Newline("\n")] [Whitespace(" ")] - 1: JS_BOGUS@45..79 + 1: JS_IMPORT_BARE_CLAUSE@45..51 0: JS_MODULE_SOURCE@45..51 0: JS_STRING_LITERAL@45..51 "\"bar\"" [] [Whitespace(" ")] - 1: JS_BOGUS@51..79 - 0: ERROR_TOKEN@51..63 "\\u{61}ssert" [] [Whitespace(" ")] - 1: L_CURLY@63..65 "{" [] [Whitespace(" ")] - 2: JS_IMPORT_ASSERTION_ENTRY_LIST@65..78 - 0: JS_IMPORT_ASSERTION_ENTRY@65..78 - 0: IDENT@65..69 "type" [] [] - 1: COLON@69..71 ":" [] [Whitespace(" ")] - 2: JS_STRING_LITERAL@71..78 "\"json\"" [] [Whitespace(" ")] - 3: R_CURLY@78..79 "}" [] [] - 2: SEMICOLON@79..80 ";" [] [] - 2: JS_IMPORT@80..120 + 1: (empty) + 2: (empty) + 5: JS_EXPRESSION_STATEMENT@51..63 + 0: JS_IDENTIFIER_EXPRESSION@51..63 + 0: JS_REFERENCE_IDENTIFIER@51..63 + 0: IDENT@51..63 "\\u{61}ssert" [] [Whitespace(" ")] + 1: (empty) + 6: JS_BLOCK_STATEMENT@63..79 + 0: L_CURLY@63..65 "{" [] [Whitespace(" ")] + 1: JS_STATEMENT_LIST@65..78 + 0: JS_LABELED_STATEMENT@65..78 + 0: IDENT@65..69 "type" [] [] + 1: COLON@69..71 ":" [] [Whitespace(" ")] + 2: JS_EXPRESSION_STATEMENT@71..78 + 0: JS_STRING_LITERAL_EXPRESSION@71..78 + 0: JS_STRING_LITERAL@71..78 "\"json\"" [] [Whitespace(" ")] + 1: (empty) + 2: R_CURLY@78..79 "}" [] [] + 7: JS_EMPTY_STATEMENT@79..80 + 0: SEMICOLON@79..80 ";" [] [] + 8: JS_IMPORT@80..96 0: IMPORT_KW@80..88 "import" [Newline("\n")] [Whitespace(" ")] - 1: JS_IMPORT_NAMED_CLAUSE@88..119 + 1: JS_IMPORT_NAMED_CLAUSE@88..96 0: (empty) 1: (empty) 2: JS_NAMED_IMPORT_SPECIFIERS@88..96 @@ -319,29 +417,39 @@ JsModule { 2: R_CURLY@94..96 "}" [] [Whitespace(" ")] 3: (empty) 4: (empty) - 5: JS_IMPORT_ASSERTION@96..119 - 0: ASSERT_KW@96..103 "assert" [] [Whitespace(" ")] - 1: L_CURLY@103..105 "{" [] [Whitespace(" ")] - 2: JS_IMPORT_ASSERTION_ENTRY_LIST@105..118 - 0: JS_IMPORT_ASSERTION_ENTRY@105..118 - 0: IDENT@105..109 "type" [] [] - 1: COLON@109..111 ":" [] [Whitespace(" ")] - 2: JS_STRING_LITERAL@111..118 "\"json\"" [] [Whitespace(" ")] - 3: R_CURLY@118..119 "}" [] [] - 2: SEMICOLON@119..120 ";" [] [] - 3: JS_IMPORT@120..135 + 5: (empty) + 2: (empty) + 9: JS_EXPRESSION_STATEMENT@96..103 + 0: JS_IDENTIFIER_EXPRESSION@96..103 + 0: JS_REFERENCE_IDENTIFIER@96..103 + 0: IDENT@96..103 "assert" [] [Whitespace(" ")] + 1: (empty) + 10: JS_BLOCK_STATEMENT@103..119 + 0: L_CURLY@103..105 "{" [] [Whitespace(" ")] + 1: JS_STATEMENT_LIST@105..118 + 0: JS_LABELED_STATEMENT@105..118 + 0: IDENT@105..109 "type" [] [] + 1: COLON@109..111 ":" [] [Whitespace(" ")] + 2: JS_EXPRESSION_STATEMENT@111..118 + 0: JS_STRING_LITERAL_EXPRESSION@111..118 + 0: JS_STRING_LITERAL@111..118 "\"json\"" [] [Whitespace(" ")] + 1: (empty) + 2: R_CURLY@118..119 "}" [] [] + 11: JS_EMPTY_STATEMENT@119..120 + 0: SEMICOLON@119..120 ";" [] [] + 12: JS_IMPORT@120..135 0: IMPORT_KW@120..128 "import" [Newline("\n")] [Whitespace(" ")] 1: JS_IMPORT_BARE_CLAUSE@128..135 0: JS_MODULE_SOURCE@128..135 0: JS_STRING_LITERAL@128..135 "\"lorem\"" [] [] 1: (empty) 2: (empty) - 4: JS_EXPRESSION_STATEMENT@135..143 + 13: JS_EXPRESSION_STATEMENT@135..143 0: JS_IDENTIFIER_EXPRESSION@135..143 0: JS_REFERENCE_IDENTIFIER@135..143 0: IDENT@135..143 "assert" [Newline("\n")] [Whitespace(" ")] 1: (empty) - 5: JS_BLOCK_STATEMENT@143..159 + 14: JS_BLOCK_STATEMENT@143..159 0: L_CURLY@143..145 "{" [] [Whitespace(" ")] 1: JS_STATEMENT_LIST@145..158 0: JS_LABELED_STATEMENT@145..158 @@ -352,86 +460,106 @@ JsModule { 0: JS_STRING_LITERAL@151..158 "\"json\"" [] [Whitespace(" ")] 1: (empty) 2: R_CURLY@158..159 "}" [] [] - 6: JS_IMPORT@159..242 + 15: JS_IMPORT@159..188 0: IMPORT_KW@159..167 "import" [Newline("\n")] [Whitespace(" ")] - 1: JS_IMPORT_DEFAULT_CLAUSE@167..241 + 1: JS_IMPORT_DEFAULT_CLAUSE@167..188 0: (empty) 1: JS_IDENTIFIER_BINDING@167..172 0: IDENT@167..172 "foo2" [] [Whitespace(" ")] 2: FROM_KW@172..177 "from" [] [Whitespace(" ")] 3: JS_MODULE_SOURCE@177..188 0: JS_STRING_LITERAL@177..188 "\"foo.json\"" [] [Whitespace(" ")] - 4: JS_IMPORT_ASSERTION@188..241 - 0: ASSERT_KW@188..195 "assert" [] [Whitespace(" ")] - 1: L_CURLY@195..197 "{" [] [Whitespace(" ")] - 2: JS_IMPORT_ASSERTION_ENTRY_LIST@197..240 - 0: JS_IMPORT_ASSERTION_ENTRY@197..211 - 0: JS_STRING_LITERAL@197..203 "\"type\"" [] [] - 1: COLON@203..205 ":" [] [Whitespace(" ")] - 2: JS_STRING_LITERAL@205..211 "\"json\"" [] [] - 1: COMMA@211..213 "," [] [Whitespace(" ")] - 2: JS_BOGUS_IMPORT_ASSERTION_ENTRY@213..225 - 0: IDENT@213..217 "type" [] [] - 1: COLON@217..219 ":" [] [Whitespace(" ")] - 2: JS_STRING_LITERAL@219..225 "\"html\"" [] [] - 3: COMMA@225..227 "," [] [Whitespace(" ")] - 4: JS_BOGUS_IMPORT_ASSERTION_ENTRY@227..240 - 0: JS_STRING_LITERAL@227..233 "\"type\"" [] [] - 1: COLON@233..235 ":" [] [Whitespace(" ")] - 2: JS_STRING_LITERAL@235..240 "\"js\"" [] [Whitespace(" ")] - 3: R_CURLY@240..241 "}" [] [] - 2: SEMICOLON@241..242 ";" [] [] - 7: JS_IMPORT@242..261 + 4: (empty) + 2: (empty) + 16: JS_EXPRESSION_STATEMENT@188..195 + 0: JS_IDENTIFIER_EXPRESSION@188..195 + 0: JS_REFERENCE_IDENTIFIER@188..195 + 0: IDENT@188..195 "assert" [] [Whitespace(" ")] + 1: (empty) + 17: JS_BLOCK_STATEMENT@195..241 + 0: L_CURLY@195..197 "{" [] [Whitespace(" ")] + 1: JS_STATEMENT_LIST@197..240 + 0: JS_EXPRESSION_STATEMENT@197..203 + 0: JS_STRING_LITERAL_EXPRESSION@197..203 + 0: JS_STRING_LITERAL@197..203 "\"type\"" [] [] + 1: (empty) + 1: JS_BOGUS_STATEMENT@203..213 + 0: COLON@203..205 ":" [] [Whitespace(" ")] + 1: JS_STRING_LITERAL@205..211 "\"json\"" [] [] + 2: COMMA@211..213 "," [] [Whitespace(" ")] + 2: JS_LABELED_STATEMENT@213..233 + 0: IDENT@213..217 "type" [] [] + 1: COLON@217..219 ":" [] [Whitespace(" ")] + 2: JS_EXPRESSION_STATEMENT@219..233 + 0: JS_SEQUENCE_EXPRESSION@219..233 + 0: JS_STRING_LITERAL_EXPRESSION@219..225 + 0: JS_STRING_LITERAL@219..225 "\"html\"" [] [] + 1: COMMA@225..227 "," [] [Whitespace(" ")] + 2: JS_STRING_LITERAL_EXPRESSION@227..233 + 0: JS_STRING_LITERAL@227..233 "\"type\"" [] [] + 1: (empty) + 3: JS_BOGUS_STATEMENT@233..240 + 0: COLON@233..235 ":" [] [Whitespace(" ")] + 1: JS_STRING_LITERAL@235..240 "\"js\"" [] [Whitespace(" ")] + 2: R_CURLY@240..241 "}" [] [] + 18: JS_EMPTY_STATEMENT@241..242 + 0: SEMICOLON@241..242 ";" [] [] + 19: JS_IMPORT@242..254 0: IMPORT_KW@242..250 "import" [Newline("\n")] [Whitespace(" ")] - 1: JS_IMPORT_BARE_CLAUSE@250..260 + 1: JS_IMPORT_BARE_CLAUSE@250..254 0: JS_MODULE_SOURCE@250..254 0: JS_STRING_LITERAL@250..254 "\"x\"" [] [Whitespace(" ")] - 1: JS_IMPORT_ASSERTION@254..260 - 0: ASSERT_KW@254..260 "assert" [] [] - 1: (empty) - 2: JS_IMPORT_ASSERTION_ENTRY_LIST@260..260 - 3: (empty) - 2: SEMICOLON@260..261 ";" [] [] - 8: JS_IMPORT@261..345 + 1: (empty) + 2: (empty) + 20: JS_EXPRESSION_STATEMENT@254..261 + 0: JS_IDENTIFIER_EXPRESSION@254..260 + 0: JS_REFERENCE_IDENTIFIER@254..260 + 0: IDENT@254..260 "assert" [] [] + 1: SEMICOLON@260..261 ";" [] [] + 21: JS_IMPORT@261..293 0: IMPORT_KW@261..269 "import" [Newline("\n")] [Whitespace(" ")] - 1: JS_IMPORT_DEFAULT_CLAUSE@269..344 + 1: JS_IMPORT_DEFAULT_CLAUSE@269..293 0: (empty) 1: JS_IDENTIFIER_BINDING@269..275 0: IDENT@269..275 "ipsum" [] [Whitespace(" ")] 2: FROM_KW@275..280 "from" [] [Whitespace(" ")] 3: JS_MODULE_SOURCE@280..293 0: JS_STRING_LITERAL@280..293 "\"ipsum.json\"" [] [Whitespace(" ")] - 4: JS_IMPORT_ASSERTION@293..344 - 0: ASSERT_KW@293..300 "assert" [] [Whitespace(" ")] - 1: L_CURLY@300..302 "{" [] [Whitespace(" ")] - 2: JS_IMPORT_ASSERTION_ENTRY_LIST@302..343 - 0: JS_IMPORT_ASSERTION_ENTRY@302..314 - 0: IDENT@302..306 "type" [] [] - 1: COLON@306..308 ":" [] [Whitespace(" ")] - 2: JS_STRING_LITERAL@308..314 "\"json\"" [] [] - 1: COMMA@314..316 "," [] [Whitespace(" ")] - 2: JS_IMPORT_ASSERTION_ENTRY@316..322 - 0: IDENT@316..320 "lazy" [] [] - 1: COLON@320..322 ":" [] [Whitespace(" ")] - 2: (empty) - 3: (empty) - 4: JS_IMPORT_ASSERTION_ENTRY@322..326 - 0: IDENT@322..326 "true" [] [] - 1: (empty) - 2: (empty) - 5: COMMA@326..328 "," [] [Whitespace(" ")] - 6: JS_IMPORT_ASSERTION_ENTRY@328..341 - 0: IDENT@328..339 "startAtLine" [] [] - 1: COLON@339..341 ":" [] [Whitespace(" ")] - 2: (empty) - 7: (empty) - 8: JS_BOGUS_IMPORT_ASSERTION_ENTRY@341..343 - 0: JS_NUMBER_LITERAL@341..343 "1" [] [Whitespace(" ")] - 3: R_CURLY@343..344 "}" [] [] - 2: SEMICOLON@344..345 ";" [] [] - 9: JS_IMPORT@345..379 + 4: (empty) + 2: (empty) + 22: JS_EXPRESSION_STATEMENT@293..300 + 0: JS_IDENTIFIER_EXPRESSION@293..300 + 0: JS_REFERENCE_IDENTIFIER@293..300 + 0: IDENT@293..300 "assert" [] [Whitespace(" ")] + 1: (empty) + 23: JS_BLOCK_STATEMENT@300..344 + 0: L_CURLY@300..302 "{" [] [Whitespace(" ")] + 1: JS_STATEMENT_LIST@302..343 + 0: JS_LABELED_STATEMENT@302..320 + 0: IDENT@302..306 "type" [] [] + 1: COLON@306..308 ":" [] [Whitespace(" ")] + 2: JS_EXPRESSION_STATEMENT@308..320 + 0: JS_SEQUENCE_EXPRESSION@308..320 + 0: JS_STRING_LITERAL_EXPRESSION@308..314 + 0: JS_STRING_LITERAL@308..314 "\"json\"" [] [] + 1: COMMA@314..316 "," [] [Whitespace(" ")] + 2: JS_IDENTIFIER_EXPRESSION@316..320 + 0: JS_REFERENCE_IDENTIFIER@316..320 + 0: IDENT@316..320 "lazy" [] [] + 1: (empty) + 1: JS_BOGUS_STATEMENT@320..343 + 0: COLON@320..322 ":" [] [Whitespace(" ")] + 1: TRUE_KW@322..326 "true" [] [] + 2: COMMA@326..328 "," [] [Whitespace(" ")] + 3: IDENT@328..339 "startAtLine" [] [] + 4: COLON@339..341 ":" [] [Whitespace(" ")] + 5: JS_NUMBER_LITERAL@341..343 "1" [] [Whitespace(" ")] + 2: R_CURLY@343..344 "}" [] [] + 24: JS_EMPTY_STATEMENT@344..345 + 0: SEMICOLON@344..345 ";" [] [] + 25: JS_IMPORT@345..373 0: IMPORT_KW@345..353 "import" [Newline("\n")] [Whitespace(" ")] - 1: JS_IMPORT_NAMED_CLAUSE@353..379 + 1: JS_IMPORT_NAMED_CLAUSE@353..373 0: (empty) 1: (empty) 2: JS_NAMED_IMPORT_SPECIFIERS@353..359 @@ -445,41 +573,66 @@ JsModule { 3: FROM_KW@359..364 "from" [] [Whitespace(" ")] 4: JS_MODULE_SOURCE@364..373 0: JS_STRING_LITERAL@364..373 "\"a.json\"" [] [Whitespace(" ")] - 5: JS_IMPORT_ASSERTION@373..379 - 0: ASSERT_KW@373..379 "assert" [] [] - 1: (empty) - 2: JS_IMPORT_ASSERTION_ENTRY_LIST@379..379 - 3: (empty) + 5: (empty) 2: (empty) + 26: JS_EXPRESSION_STATEMENT@373..379 + 0: JS_IDENTIFIER_EXPRESSION@373..379 + 0: JS_REFERENCE_IDENTIFIER@373..379 + 0: IDENT@373..379 "assert" [] [] + 1: (empty) 3: EOF@379..380 "" [Newline("\n")] [] -- -import_assertion_err.js:1:27 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ +import_assertion_err.js:1:14 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ - × expected `:` but instead found `,` + × Expected a semicolon or an implicit semicolon after a statement, but found none > 1 │ import "foo" assert { type, "json" }; - │ ^ + │ ^^^^^^ 2 │ import "bar" \u{61}ssert { type: "json" }; 3 │ import { foo } assert { type: "json" }; - i Remove , + i An explicit or implicit semicolon is expected here... + + > 1 │ import "foo" assert { type, "json" }; + │ ^^^^^^ + 2 │ import "bar" \u{61}ssert { type: "json" }; + 3 │ import { foo } assert { type: "json" }; + + i ...Which is required to end this statement + + > 1 │ import "foo" assert { type, "json" }; + │ ^^^^^^^^^^^^^ + 2 │ import "bar" \u{61}ssert { type: "json" }; + 3 │ import { foo } assert { type: "json" }; -- -import_assertion_err.js:1:36 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ +import_assertion_err.js:1:21 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ - × expected `:` but instead found `}` + × Expected a semicolon or an implicit semicolon after a statement, but found none > 1 │ import "foo" assert { type, "json" }; - │ ^ + │ ^ 2 │ import "bar" \u{61}ssert { type: "json" }; 3 │ import { foo } assert { type: "json" }; - i Remove } + i An explicit or implicit semicolon is expected here... + + > 1 │ import "foo" assert { type, "json" }; + │ ^ + 2 │ import "bar" \u{61}ssert { type: "json" }; + 3 │ import { foo } assert { type: "json" }; + + i ...Which is required to end this statement + + > 1 │ import "foo" assert { type, "json" }; + │ ^^^^^^^^ + 2 │ import "bar" \u{61}ssert { type: "json" }; + 3 │ import { foo } assert { type: "json" }; -- import_assertion_err.js:2:14 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ - × 'assert' keyword cannot contain escape character. + × Expected a semicolon or an implicit semicolon after a statement, but found none 1 │ import "foo" assert { type, "json" }; > 2 │ import "bar" \u{61}ssert { type: "json" }; @@ -487,6 +640,49 @@ import_assertion_err.js:2:14 parse ━━━━━━━━━━━━━━━ 3 │ import { foo } assert { type: "json" }; 4 │ import "lorem" + i An explicit or implicit semicolon is expected here... + + 1 │ import "foo" assert { type, "json" }; + > 2 │ import "bar" \u{61}ssert { type: "json" }; + │ ^^^^^^^^^^^ + 3 │ import { foo } assert { type: "json" }; + 4 │ import "lorem" + + i ...Which is required to end this statement + + 1 │ import "foo" assert { type, "json" }; + > 2 │ import "bar" \u{61}ssert { type: "json" }; + │ ^^^^^^^^^^^^^ + 3 │ import { foo } assert { type: "json" }; + 4 │ import "lorem" + +-- +import_assertion_err.js:2:26 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + + × Expected a semicolon or an implicit semicolon after a statement, but found none + + 1 │ import "foo" assert { type, "json" }; + > 2 │ import "bar" \u{61}ssert { type: "json" }; + │ ^ + 3 │ import { foo } assert { type: "json" }; + 4 │ import "lorem" + + i An explicit or implicit semicolon is expected here... + + 1 │ import "foo" assert { type, "json" }; + > 2 │ import "bar" \u{61}ssert { type: "json" }; + │ ^ + 3 │ import { foo } assert { type: "json" }; + 4 │ import "lorem" + + i ...Which is required to end this statement + + 1 │ import "foo" assert { type, "json" }; + > 2 │ import "bar" \u{61}ssert { type: "json" }; + │ ^^^^^^^^^^^^^ + 3 │ import { foo } assert { type: "json" }; + 4 │ import "lorem" + -- import_assertion_err.js:3:16 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ @@ -501,6 +697,36 @@ import_assertion_err.js:3:16 parse ━━━━━━━━━━━━━━━ i Remove assert +-- +import_assertion_err.js:3:23 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + + × Expected a semicolon or an implicit semicolon after a statement, but found none + + 1 │ import "foo" assert { type, "json" }; + 2 │ import "bar" \u{61}ssert { type: "json" }; + > 3 │ import { foo } assert { type: "json" }; + │ ^ + 4 │ import "lorem" + 5 │ assert { type: "json" } + + i An explicit or implicit semicolon is expected here... + + 1 │ import "foo" assert { type, "json" }; + 2 │ import "bar" \u{61}ssert { type: "json" }; + > 3 │ import { foo } assert { type: "json" }; + │ ^ + 4 │ import "lorem" + 5 │ assert { type: "json" } + + i ...Which is required to end this statement + + 1 │ import "foo" assert { type, "json" }; + 2 │ import "bar" \u{61}ssert { type: "json" }; + > 3 │ import { foo } assert { type: "json" }; + │ ^^^^^^^^ + 4 │ import "lorem" + 5 │ assert { type: "json" } + -- import_assertion_err.js:5:8 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ @@ -532,107 +758,271 @@ import_assertion_err.js:5:8 parse ━━━━━━━━━━━━━━━ 7 │ import "x" assert; -- -import_assertion_err.js:6:38 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ +import_assertion_err.js:6:29 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + + × Expected a semicolon or an implicit semicolon after a statement, but found none + + 4 │ import "lorem" + 5 │ assert { type: "json" } + > 6 │ import foo2 from "foo.json" assert { "type": "json", type: "html", "type": "js" }; + │ ^^^^^^ + 7 │ import "x" assert; + 8 │ import ipsum from "ipsum.json" assert { type: "json", lazy: true, startAtLine: 1 }; + + i An explicit or implicit semicolon is expected here... + + 4 │ import "lorem" + 5 │ assert { type: "json" } + > 6 │ import foo2 from "foo.json" assert { "type": "json", type: "html", "type": "js" }; + │ ^^^^^^ + 7 │ import "x" assert; + 8 │ import ipsum from "ipsum.json" assert { type: "json", lazy: true, startAtLine: 1 }; + + i ...Which is required to end this statement + + 4 │ import "lorem" + 5 │ assert { type: "json" } + > 6 │ import foo2 from "foo.json" assert { "type": "json", type: "html", "type": "js" }; + │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + 7 │ import "x" assert; + 8 │ import ipsum from "ipsum.json" assert { type: "json", lazy: true, startAtLine: 1 }; + +-- +import_assertion_err.js:6:36 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + + × Expected a semicolon or an implicit semicolon after a statement, but found none + + 4 │ import "lorem" + 5 │ assert { type: "json" } + > 6 │ import foo2 from "foo.json" assert { "type": "json", type: "html", "type": "js" }; + │ ^ + 7 │ import "x" assert; + 8 │ import ipsum from "ipsum.json" assert { type: "json", lazy: true, startAtLine: 1 }; + + i An explicit or implicit semicolon is expected here... + + 4 │ import "lorem" + 5 │ assert { type: "json" } + > 6 │ import foo2 from "foo.json" assert { "type": "json", type: "html", "type": "js" }; + │ ^ + 7 │ import "x" assert; + 8 │ import ipsum from "ipsum.json" assert { type: "json", lazy: true, startAtLine: 1 }; + + i ...Which is required to end this statement + + 4 │ import "lorem" + 5 │ assert { type: "json" } + > 6 │ import foo2 from "foo.json" assert { "type": "json", type: "html", "type": "js" }; + │ ^^^^^^^^ + 7 │ import "x" assert; + 8 │ import ipsum from "ipsum.json" assert { type: "json", lazy: true, startAtLine: 1 }; + +-- +import_assertion_err.js:6:44 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + + × Expected a semicolon or an implicit semicolon after a statement, but found none + + 4 │ import "lorem" + 5 │ assert { type: "json" } + > 6 │ import foo2 from "foo.json" assert { "type": "json", type: "html", "type": "js" }; + │ ^ + 7 │ import "x" assert; + 8 │ import ipsum from "ipsum.json" assert { type: "json", lazy: true, startAtLine: 1 }; + + i An explicit or implicit semicolon is expected here... + + 4 │ import "lorem" + 5 │ assert { type: "json" } + > 6 │ import foo2 from "foo.json" assert { "type": "json", type: "html", "type": "js" }; + │ ^ + 7 │ import "x" assert; + 8 │ import ipsum from "ipsum.json" assert { type: "json", lazy: true, startAtLine: 1 }; + + i ...Which is required to end this statement + + 4 │ import "lorem" + 5 │ assert { type: "json" } + > 6 │ import foo2 from "foo.json" assert { "type": "json", type: "html", "type": "js" }; + │ ^^^^^^^ + 7 │ import "x" assert; + 8 │ import ipsum from "ipsum.json" assert { type: "json", lazy: true, startAtLine: 1 }; + +-- +import_assertion_err.js:6:74 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ - × Duplicate assertion keys are not allowed + × Expected a semicolon or an implicit semicolon after a statement, but found none 4 │ import "lorem" 5 │ assert { type: "json" } > 6 │ import foo2 from "foo.json" assert { "type": "json", type: "html", "type": "js" }; - │ ^^^^^^ + │ ^ 7 │ import "x" assert; 8 │ import ipsum from "ipsum.json" assert { type: "json", lazy: true, startAtLine: 1 }; - i First use of the key `type` + i An explicit or implicit semicolon is expected here... 4 │ import "lorem" 5 │ assert { type: "json" } > 6 │ import foo2 from "foo.json" assert { "type": "json", type: "html", "type": "js" }; - │ ^^^^^^ + │ ^ 7 │ import "x" assert; 8 │ import ipsum from "ipsum.json" assert { type: "json", lazy: true, startAtLine: 1 }; - i second use here + i ...Which is required to end this statement 4 │ import "lorem" 5 │ assert { type: "json" } > 6 │ import foo2 from "foo.json" assert { "type": "json", type: "html", "type": "js" }; - │ ^^^^ + │ ^^^^^^^^^^^^^^^ 7 │ import "x" assert; 8 │ import ipsum from "ipsum.json" assert { type: "json", lazy: true, startAtLine: 1 }; -- -import_assertion_err.js:7:18 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ +import_assertion_err.js:7:12 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ - × expected `{` but instead found `;` + × Expected a semicolon or an implicit semicolon after a statement, but found none 5 │ assert { type: "json" } 6 │ import foo2 from "foo.json" assert { "type": "json", type: "html", "type": "js" }; > 7 │ import "x" assert; - │ ^ + │ ^^^^^^ 8 │ import ipsum from "ipsum.json" assert { type: "json", lazy: true, startAtLine: 1 }; 9 │ import { a } from "a.json" assert - i Remove ; + i An explicit or implicit semicolon is expected here... + + 5 │ assert { type: "json" } + 6 │ import foo2 from "foo.json" assert { "type": "json", type: "html", "type": "js" }; + > 7 │ import "x" assert; + │ ^^^^^^ + 8 │ import ipsum from "ipsum.json" assert { type: "json", lazy: true, startAtLine: 1 }; + 9 │ import { a } from "a.json" assert + + i ...Which is required to end this statement + + 5 │ assert { type: "json" } + 6 │ import foo2 from "foo.json" assert { "type": "json", type: "html", "type": "js" }; + > 7 │ import "x" assert; + │ ^^^^^^^^^^^ + 8 │ import ipsum from "ipsum.json" assert { type: "json", lazy: true, startAtLine: 1 }; + 9 │ import { a } from "a.json" assert -- -import_assertion_err.js:8:61 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ +import_assertion_err.js:8:32 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ - × expected `string literal` but instead found `true` + × Expected a semicolon or an implicit semicolon after a statement, but found none + + 6 │ import foo2 from "foo.json" assert { "type": "json", type: "html", "type": "js" }; + 7 │ import "x" assert; + > 8 │ import ipsum from "ipsum.json" assert { type: "json", lazy: true, startAtLine: 1 }; + │ ^^^^^^ + 9 │ import { a } from "a.json" assert + 10 │ + + i An explicit or implicit semicolon is expected here... 6 │ import foo2 from "foo.json" assert { "type": "json", type: "html", "type": "js" }; 7 │ import "x" assert; > 8 │ import ipsum from "ipsum.json" assert { type: "json", lazy: true, startAtLine: 1 }; - │ ^^^^ + │ ^^^^^^ 9 │ import { a } from "a.json" assert 10 │ - i Remove true + i ...Which is required to end this statement + + 6 │ import foo2 from "foo.json" assert { "type": "json", type: "html", "type": "js" }; + 7 │ import "x" assert; + > 8 │ import ipsum from "ipsum.json" assert { type: "json", lazy: true, startAtLine: 1 }; + │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + 9 │ import { a } from "a.json" assert + 10 │ -- -import_assertion_err.js:8:65 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ +import_assertion_err.js:8:39 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ - × expected `:` but instead found `,` + × Expected a semicolon or an implicit semicolon after a statement, but found none + + 6 │ import foo2 from "foo.json" assert { "type": "json", type: "html", "type": "js" }; + 7 │ import "x" assert; + > 8 │ import ipsum from "ipsum.json" assert { type: "json", lazy: true, startAtLine: 1 }; + │ ^ + 9 │ import { a } from "a.json" assert + 10 │ + + i An explicit or implicit semicolon is expected here... 6 │ import foo2 from "foo.json" assert { "type": "json", type: "html", "type": "js" }; 7 │ import "x" assert; > 8 │ import ipsum from "ipsum.json" assert { type: "json", lazy: true, startAtLine: 1 }; - │ ^ + │ ^ 9 │ import { a } from "a.json" assert 10 │ - i Remove , + i ...Which is required to end this statement + + 6 │ import foo2 from "foo.json" assert { "type": "json", type: "html", "type": "js" }; + 7 │ import "x" assert; + > 8 │ import ipsum from "ipsum.json" assert { type: "json", lazy: true, startAtLine: 1 }; + │ ^^^^^^^^ + 9 │ import { a } from "a.json" assert + 10 │ -- -import_assertion_err.js:8:80 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ +import_assertion_err.js:8:59 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ - × expected `string literal` but instead found `1` + × Expected a semicolon or an implicit semicolon after a statement, but found none 6 │ import foo2 from "foo.json" assert { "type": "json", type: "html", "type": "js" }; 7 │ import "x" assert; > 8 │ import ipsum from "ipsum.json" assert { type: "json", lazy: true, startAtLine: 1 }; - │ ^ + │ ^ 9 │ import { a } from "a.json" assert 10 │ - i Remove 1 + i An explicit or implicit semicolon is expected here... + + 6 │ import foo2 from "foo.json" assert { "type": "json", type: "html", "type": "js" }; + 7 │ import "x" assert; + > 8 │ import ipsum from "ipsum.json" assert { type: "json", lazy: true, startAtLine: 1 }; + │ ^ + 9 │ import { a } from "a.json" assert + 10 │ + + i ...Which is required to end this statement + + 6 │ import foo2 from "foo.json" assert { "type": "json", type: "html", "type": "js" }; + 7 │ import "x" assert; + > 8 │ import ipsum from "ipsum.json" assert { type: "json", lazy: true, startAtLine: 1 }; + │ ^^^^^^^^^^^^^ + 9 │ import { a } from "a.json" assert + 10 │ -- -import_assertion_err.js:10:1 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ +import_assertion_err.js:9:28 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ - × expected `{` but instead the file ends + × Expected a semicolon or an implicit semicolon after a statement, but found none + 7 │ import "x" assert; 8 │ import ipsum from "ipsum.json" assert { type: "json", lazy: true, startAtLine: 1 }; - 9 │ import { a } from "a.json" assert - > 10 │ - │ + > 9 │ import { a } from "a.json" assert + │ ^^^^^^ + 10 │ - i the file ends here + i An explicit or implicit semicolon is expected here... + 7 │ import "x" assert; 8 │ import ipsum from "ipsum.json" assert { type: "json", lazy: true, startAtLine: 1 }; - 9 │ import { a } from "a.json" assert - > 10 │ - │ + > 9 │ import { a } from "a.json" assert + │ ^^^^^^ + 10 │ + + i ...Which is required to end this statement + + 7 │ import "x" assert; + 8 │ import ipsum from "ipsum.json" assert { type: "json", lazy: true, startAtLine: 1 }; + > 9 │ import { a } from "a.json" assert + │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^ + 10 │ -- import "foo" assert { type, "json" }; diff --git a/crates/rome_js_parser/test_data/inline/err/import_attribute_err.js b/crates/rome_js_parser/test_data/inline/err/import_attribute_err.js new file mode 100644 index 000000000000..7fbec80fc903 --- /dev/null +++ b/crates/rome_js_parser/test_data/inline/err/import_attribute_err.js @@ -0,0 +1,9 @@ +import "foo" with { type, "json" }; +import "bar" \u{61}ith { type: "json" }; +import { foo } with { type: "json" }; +import "lorem" +assert { type: "json" } +import foo2 from "foo.json" with { "type": "json", type: "html", "type": "js" }; +import "x" with; +import ipsum from "ipsum.json" with { type: "json", lazy: true, startAtLine: 1 }; +import { a } from "a.json" with diff --git a/crates/rome_js_parser/test_data/inline/err/import_attribute_err.rast b/crates/rome_js_parser/test_data/inline/err/import_attribute_err.rast new file mode 100644 index 000000000000..28317c62d639 --- /dev/null +++ b/crates/rome_js_parser/test_data/inline/err/import_attribute_err.rast @@ -0,0 +1,709 @@ +JsModule { + interpreter_token: missing (optional), + directives: JsDirectiveList [], + items: JsModuleItemList [ + JsImport { + import_token: IMPORT_KW@0..7 "import" [] [Whitespace(" ")], + import_clause: JsImportBareClause { + source: JsModuleSource { + value_token: JS_STRING_LITERAL@7..13 "\"foo\"" [] [Whitespace(" ")], + }, + attribute: JsImportAttribute { + with_token: WITH_KW@13..18 "with" [] [Whitespace(" ")], + l_curly_token: L_CURLY@18..20 "{" [] [Whitespace(" ")], + attributes: JsImportAttributeEntryList [ + JsImportAttributeEntry { + key: IDENT@20..24 "type" [] [], + colon_token: missing (required), + value_token: missing (required), + }, + COMMA@24..26 "," [] [Whitespace(" ")], + JsImportAttributeEntry { + key: JS_STRING_LITERAL@26..33 "\"json\"" [] [Whitespace(" ")], + colon_token: missing (required), + value_token: missing (required), + }, + ], + r_curly_token: R_CURLY@33..34 "}" [] [], + }, + }, + semicolon_token: SEMICOLON@34..35 ";" [] [], + }, + JsImport { + import_token: IMPORT_KW@35..43 "import" [Newline("\n")] [Whitespace(" ")], + import_clause: JsImportBareClause { + source: JsModuleSource { + value_token: JS_STRING_LITERAL@43..49 "\"bar\"" [] [Whitespace(" ")], + }, + attribute: missing (optional), + }, + semicolon_token: missing (optional), + }, + JsExpressionStatement { + expression: JsIdentifierExpression { + name: JsReferenceIdentifier { + value_token: IDENT@49..59 "\\u{61}ith" [] [Whitespace(" ")], + }, + }, + semicolon_token: missing (optional), + }, + JsBlockStatement { + l_curly_token: L_CURLY@59..61 "{" [] [Whitespace(" ")], + statements: JsStatementList [ + JsLabeledStatement { + label_token: IDENT@61..65 "type" [] [], + colon_token: COLON@65..67 ":" [] [Whitespace(" ")], + body: JsExpressionStatement { + expression: JsStringLiteralExpression { + value_token: JS_STRING_LITERAL@67..74 "\"json\"" [] [Whitespace(" ")], + }, + semicolon_token: missing (optional), + }, + }, + ], + r_curly_token: R_CURLY@74..75 "}" [] [], + }, + JsEmptyStatement { + semicolon_token: SEMICOLON@75..76 ";" [] [], + }, + JsImport { + import_token: IMPORT_KW@76..84 "import" [Newline("\n")] [Whitespace(" ")], + import_clause: JsImportNamedClause { + type_token: missing (optional), + default_specifier: missing (optional), + named_import: JsNamedImportSpecifiers { + l_curly_token: L_CURLY@84..86 "{" [] [Whitespace(" ")], + specifiers: JsNamedImportSpecifierList [ + JsShorthandNamedImportSpecifier { + type_token: missing (optional), + local_name: JsIdentifierBinding { + name_token: IDENT@86..90 "foo" [] [Whitespace(" ")], + }, + }, + ], + r_curly_token: R_CURLY@90..92 "}" [] [Whitespace(" ")], + }, + from_token: missing (required), + source: missing (required), + attribute: JsImportAttribute { + with_token: WITH_KW@92..97 "with" [] [Whitespace(" ")], + l_curly_token: L_CURLY@97..99 "{" [] [Whitespace(" ")], + attributes: JsImportAttributeEntryList [ + JsImportAttributeEntry { + key: IDENT@99..103 "type" [] [], + colon_token: COLON@103..105 ":" [] [Whitespace(" ")], + value_token: JS_STRING_LITERAL@105..112 "\"json\"" [] [Whitespace(" ")], + }, + ], + r_curly_token: R_CURLY@112..113 "}" [] [], + }, + }, + semicolon_token: SEMICOLON@113..114 ";" [] [], + }, + JsImport { + import_token: IMPORT_KW@114..122 "import" [Newline("\n")] [Whitespace(" ")], + import_clause: JsImportBareClause { + source: JsModuleSource { + value_token: JS_STRING_LITERAL@122..129 "\"lorem\"" [] [], + }, + attribute: missing (optional), + }, + semicolon_token: missing (optional), + }, + JsExpressionStatement { + expression: JsIdentifierExpression { + name: JsReferenceIdentifier { + value_token: IDENT@129..137 "assert" [Newline("\n")] [Whitespace(" ")], + }, + }, + semicolon_token: missing (optional), + }, + JsBlockStatement { + l_curly_token: L_CURLY@137..139 "{" [] [Whitespace(" ")], + statements: JsStatementList [ + JsLabeledStatement { + label_token: IDENT@139..143 "type" [] [], + colon_token: COLON@143..145 ":" [] [Whitespace(" ")], + body: JsExpressionStatement { + expression: JsStringLiteralExpression { + value_token: JS_STRING_LITERAL@145..152 "\"json\"" [] [Whitespace(" ")], + }, + semicolon_token: missing (optional), + }, + }, + ], + r_curly_token: R_CURLY@152..153 "}" [] [], + }, + JsImport { + import_token: IMPORT_KW@153..161 "import" [Newline("\n")] [Whitespace(" ")], + import_clause: JsImportDefaultClause { + type_token: missing (optional), + local_name: JsIdentifierBinding { + name_token: IDENT@161..166 "foo2" [] [Whitespace(" ")], + }, + from_token: FROM_KW@166..171 "from" [] [Whitespace(" ")], + source: JsModuleSource { + value_token: JS_STRING_LITERAL@171..182 "\"foo.json\"" [] [Whitespace(" ")], + }, + attribute: JsImportAttribute { + with_token: WITH_KW@182..187 "with" [] [Whitespace(" ")], + l_curly_token: L_CURLY@187..189 "{" [] [Whitespace(" ")], + attributes: JsImportAttributeEntryList [ + JsImportAttributeEntry { + key: JS_STRING_LITERAL@189..195 "\"type\"" [] [], + colon_token: COLON@195..197 ":" [] [Whitespace(" ")], + value_token: JS_STRING_LITERAL@197..203 "\"json\"" [] [], + }, + COMMA@203..205 "," [] [Whitespace(" ")], + JsBogusImportAttributeEntry { + items: [ + IDENT@205..209 "type" [] [], + COLON@209..211 ":" [] [Whitespace(" ")], + JS_STRING_LITERAL@211..217 "\"html\"" [] [], + ], + }, + COMMA@217..219 "," [] [Whitespace(" ")], + JsBogusImportAttributeEntry { + items: [ + JS_STRING_LITERAL@219..225 "\"type\"" [] [], + COLON@225..227 ":" [] [Whitespace(" ")], + JS_STRING_LITERAL@227..232 "\"js\"" [] [Whitespace(" ")], + ], + }, + ], + r_curly_token: R_CURLY@232..233 "}" [] [], + }, + }, + semicolon_token: SEMICOLON@233..234 ";" [] [], + }, + JsImport { + import_token: IMPORT_KW@234..242 "import" [Newline("\n")] [Whitespace(" ")], + import_clause: JsImportBareClause { + source: JsModuleSource { + value_token: JS_STRING_LITERAL@242..246 "\"x\"" [] [Whitespace(" ")], + }, + attribute: JsImportAttribute { + with_token: WITH_KW@246..250 "with" [] [], + l_curly_token: missing (required), + attributes: JsImportAttributeEntryList [], + r_curly_token: missing (required), + }, + }, + semicolon_token: SEMICOLON@250..251 ";" [] [], + }, + JsImport { + import_token: IMPORT_KW@251..259 "import" [Newline("\n")] [Whitespace(" ")], + import_clause: JsImportDefaultClause { + type_token: missing (optional), + local_name: JsIdentifierBinding { + name_token: IDENT@259..265 "ipsum" [] [Whitespace(" ")], + }, + from_token: FROM_KW@265..270 "from" [] [Whitespace(" ")], + source: JsModuleSource { + value_token: JS_STRING_LITERAL@270..283 "\"ipsum.json\"" [] [Whitespace(" ")], + }, + attribute: JsImportAttribute { + with_token: WITH_KW@283..288 "with" [] [Whitespace(" ")], + l_curly_token: L_CURLY@288..290 "{" [] [Whitespace(" ")], + attributes: JsImportAttributeEntryList [ + JsImportAttributeEntry { + key: IDENT@290..294 "type" [] [], + colon_token: COLON@294..296 ":" [] [Whitespace(" ")], + value_token: JS_STRING_LITERAL@296..302 "\"json\"" [] [], + }, + COMMA@302..304 "," [] [Whitespace(" ")], + JsImportAttributeEntry { + key: IDENT@304..308 "lazy" [] [], + colon_token: COLON@308..310 ":" [] [Whitespace(" ")], + value_token: missing (required), + }, + missing separator, + JsImportAttributeEntry { + key: IDENT@310..314 "true" [] [], + colon_token: missing (required), + value_token: missing (required), + }, + COMMA@314..316 "," [] [Whitespace(" ")], + JsImportAttributeEntry { + key: IDENT@316..327 "startAtLine" [] [], + colon_token: COLON@327..329 ":" [] [Whitespace(" ")], + value_token: missing (required), + }, + missing separator, + JsBogusImportAttributeEntry { + items: [ + JS_NUMBER_LITERAL@329..331 "1" [] [Whitespace(" ")], + ], + }, + ], + r_curly_token: R_CURLY@331..332 "}" [] [], + }, + }, + semicolon_token: SEMICOLON@332..333 ";" [] [], + }, + JsImport { + import_token: IMPORT_KW@333..341 "import" [Newline("\n")] [Whitespace(" ")], + import_clause: JsImportNamedClause { + type_token: missing (optional), + default_specifier: missing (optional), + named_import: JsNamedImportSpecifiers { + l_curly_token: L_CURLY@341..343 "{" [] [Whitespace(" ")], + specifiers: JsNamedImportSpecifierList [ + JsShorthandNamedImportSpecifier { + type_token: missing (optional), + local_name: JsIdentifierBinding { + name_token: IDENT@343..345 "a" [] [Whitespace(" ")], + }, + }, + ], + r_curly_token: R_CURLY@345..347 "}" [] [Whitespace(" ")], + }, + from_token: FROM_KW@347..352 "from" [] [Whitespace(" ")], + source: JsModuleSource { + value_token: JS_STRING_LITERAL@352..361 "\"a.json\"" [] [Whitespace(" ")], + }, + attribute: JsImportAttribute { + with_token: WITH_KW@361..365 "with" [] [], + l_curly_token: missing (required), + attributes: JsImportAttributeEntryList [], + r_curly_token: missing (required), + }, + }, + semicolon_token: missing (optional), + }, + ], + eof_token: EOF@365..366 "" [Newline("\n")] [], +} + +0: JS_MODULE@0..366 + 0: (empty) + 1: JS_DIRECTIVE_LIST@0..0 + 2: JS_MODULE_ITEM_LIST@0..365 + 0: JS_IMPORT@0..35 + 0: IMPORT_KW@0..7 "import" [] [Whitespace(" ")] + 1: JS_IMPORT_BARE_CLAUSE@7..34 + 0: JS_MODULE_SOURCE@7..13 + 0: JS_STRING_LITERAL@7..13 "\"foo\"" [] [Whitespace(" ")] + 1: JS_IMPORT_ATTRIBUTE@13..34 + 0: WITH_KW@13..18 "with" [] [Whitespace(" ")] + 1: L_CURLY@18..20 "{" [] [Whitespace(" ")] + 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_ATTRIBUTE_ENTRY@26..33 + 0: JS_STRING_LITERAL@26..33 "\"json\"" [] [Whitespace(" ")] + 1: (empty) + 2: (empty) + 3: R_CURLY@33..34 "}" [] [] + 2: SEMICOLON@34..35 ";" [] [] + 1: JS_IMPORT@35..49 + 0: IMPORT_KW@35..43 "import" [Newline("\n")] [Whitespace(" ")] + 1: JS_IMPORT_BARE_CLAUSE@43..49 + 0: JS_MODULE_SOURCE@43..49 + 0: JS_STRING_LITERAL@43..49 "\"bar\"" [] [Whitespace(" ")] + 1: (empty) + 2: (empty) + 2: JS_EXPRESSION_STATEMENT@49..59 + 0: JS_IDENTIFIER_EXPRESSION@49..59 + 0: JS_REFERENCE_IDENTIFIER@49..59 + 0: IDENT@49..59 "\\u{61}ith" [] [Whitespace(" ")] + 1: (empty) + 3: JS_BLOCK_STATEMENT@59..75 + 0: L_CURLY@59..61 "{" [] [Whitespace(" ")] + 1: JS_STATEMENT_LIST@61..74 + 0: JS_LABELED_STATEMENT@61..74 + 0: IDENT@61..65 "type" [] [] + 1: COLON@65..67 ":" [] [Whitespace(" ")] + 2: JS_EXPRESSION_STATEMENT@67..74 + 0: JS_STRING_LITERAL_EXPRESSION@67..74 + 0: JS_STRING_LITERAL@67..74 "\"json\"" [] [Whitespace(" ")] + 1: (empty) + 2: R_CURLY@74..75 "}" [] [] + 4: JS_EMPTY_STATEMENT@75..76 + 0: SEMICOLON@75..76 ";" [] [] + 5: JS_IMPORT@76..114 + 0: IMPORT_KW@76..84 "import" [Newline("\n")] [Whitespace(" ")] + 1: JS_IMPORT_NAMED_CLAUSE@84..113 + 0: (empty) + 1: (empty) + 2: JS_NAMED_IMPORT_SPECIFIERS@84..92 + 0: L_CURLY@84..86 "{" [] [Whitespace(" ")] + 1: JS_NAMED_IMPORT_SPECIFIER_LIST@86..90 + 0: JS_SHORTHAND_NAMED_IMPORT_SPECIFIER@86..90 + 0: (empty) + 1: JS_IDENTIFIER_BINDING@86..90 + 0: IDENT@86..90 "foo" [] [Whitespace(" ")] + 2: R_CURLY@90..92 "}" [] [Whitespace(" ")] + 3: (empty) + 4: (empty) + 5: JS_IMPORT_ATTRIBUTE@92..113 + 0: WITH_KW@92..97 "with" [] [Whitespace(" ")] + 1: L_CURLY@97..99 "{" [] [Whitespace(" ")] + 2: JS_IMPORT_ATTRIBUTE_ENTRY_LIST@99..112 + 0: JS_IMPORT_ATTRIBUTE_ENTRY@99..112 + 0: IDENT@99..103 "type" [] [] + 1: COLON@103..105 ":" [] [Whitespace(" ")] + 2: JS_STRING_LITERAL@105..112 "\"json\"" [] [Whitespace(" ")] + 3: R_CURLY@112..113 "}" [] [] + 2: SEMICOLON@113..114 ";" [] [] + 6: JS_IMPORT@114..129 + 0: IMPORT_KW@114..122 "import" [Newline("\n")] [Whitespace(" ")] + 1: JS_IMPORT_BARE_CLAUSE@122..129 + 0: JS_MODULE_SOURCE@122..129 + 0: JS_STRING_LITERAL@122..129 "\"lorem\"" [] [] + 1: (empty) + 2: (empty) + 7: JS_EXPRESSION_STATEMENT@129..137 + 0: JS_IDENTIFIER_EXPRESSION@129..137 + 0: JS_REFERENCE_IDENTIFIER@129..137 + 0: IDENT@129..137 "assert" [Newline("\n")] [Whitespace(" ")] + 1: (empty) + 8: JS_BLOCK_STATEMENT@137..153 + 0: L_CURLY@137..139 "{" [] [Whitespace(" ")] + 1: JS_STATEMENT_LIST@139..152 + 0: JS_LABELED_STATEMENT@139..152 + 0: IDENT@139..143 "type" [] [] + 1: COLON@143..145 ":" [] [Whitespace(" ")] + 2: JS_EXPRESSION_STATEMENT@145..152 + 0: JS_STRING_LITERAL_EXPRESSION@145..152 + 0: JS_STRING_LITERAL@145..152 "\"json\"" [] [Whitespace(" ")] + 1: (empty) + 2: R_CURLY@152..153 "}" [] [] + 9: JS_IMPORT@153..234 + 0: IMPORT_KW@153..161 "import" [Newline("\n")] [Whitespace(" ")] + 1: JS_IMPORT_DEFAULT_CLAUSE@161..233 + 0: (empty) + 1: JS_IDENTIFIER_BINDING@161..166 + 0: IDENT@161..166 "foo2" [] [Whitespace(" ")] + 2: FROM_KW@166..171 "from" [] [Whitespace(" ")] + 3: JS_MODULE_SOURCE@171..182 + 0: JS_STRING_LITERAL@171..182 "\"foo.json\"" [] [Whitespace(" ")] + 4: JS_IMPORT_ATTRIBUTE@182..233 + 0: WITH_KW@182..187 "with" [] [Whitespace(" ")] + 1: L_CURLY@187..189 "{" [] [Whitespace(" ")] + 2: JS_IMPORT_ATTRIBUTE_ENTRY_LIST@189..232 + 0: JS_IMPORT_ATTRIBUTE_ENTRY@189..203 + 0: JS_STRING_LITERAL@189..195 "\"type\"" [] [] + 1: COLON@195..197 ":" [] [Whitespace(" ")] + 2: JS_STRING_LITERAL@197..203 "\"json\"" [] [] + 1: COMMA@203..205 "," [] [Whitespace(" ")] + 2: JS_BOGUS_IMPORT_ATTRIBUTE_ENTRY@205..217 + 0: IDENT@205..209 "type" [] [] + 1: COLON@209..211 ":" [] [Whitespace(" ")] + 2: JS_STRING_LITERAL@211..217 "\"html\"" [] [] + 3: COMMA@217..219 "," [] [Whitespace(" ")] + 4: JS_BOGUS_IMPORT_ATTRIBUTE_ENTRY@219..232 + 0: JS_STRING_LITERAL@219..225 "\"type\"" [] [] + 1: COLON@225..227 ":" [] [Whitespace(" ")] + 2: JS_STRING_LITERAL@227..232 "\"js\"" [] [Whitespace(" ")] + 3: R_CURLY@232..233 "}" [] [] + 2: SEMICOLON@233..234 ";" [] [] + 10: JS_IMPORT@234..251 + 0: IMPORT_KW@234..242 "import" [Newline("\n")] [Whitespace(" ")] + 1: JS_IMPORT_BARE_CLAUSE@242..250 + 0: JS_MODULE_SOURCE@242..246 + 0: JS_STRING_LITERAL@242..246 "\"x\"" [] [Whitespace(" ")] + 1: JS_IMPORT_ATTRIBUTE@246..250 + 0: WITH_KW@246..250 "with" [] [] + 1: (empty) + 2: JS_IMPORT_ATTRIBUTE_ENTRY_LIST@250..250 + 3: (empty) + 2: SEMICOLON@250..251 ";" [] [] + 11: JS_IMPORT@251..333 + 0: IMPORT_KW@251..259 "import" [Newline("\n")] [Whitespace(" ")] + 1: JS_IMPORT_DEFAULT_CLAUSE@259..332 + 0: (empty) + 1: JS_IDENTIFIER_BINDING@259..265 + 0: IDENT@259..265 "ipsum" [] [Whitespace(" ")] + 2: FROM_KW@265..270 "from" [] [Whitespace(" ")] + 3: JS_MODULE_SOURCE@270..283 + 0: JS_STRING_LITERAL@270..283 "\"ipsum.json\"" [] [Whitespace(" ")] + 4: JS_IMPORT_ATTRIBUTE@283..332 + 0: WITH_KW@283..288 "with" [] [Whitespace(" ")] + 1: L_CURLY@288..290 "{" [] [Whitespace(" ")] + 2: JS_IMPORT_ATTRIBUTE_ENTRY_LIST@290..331 + 0: JS_IMPORT_ATTRIBUTE_ENTRY@290..302 + 0: IDENT@290..294 "type" [] [] + 1: COLON@294..296 ":" [] [Whitespace(" ")] + 2: JS_STRING_LITERAL@296..302 "\"json\"" [] [] + 1: COMMA@302..304 "," [] [Whitespace(" ")] + 2: JS_IMPORT_ATTRIBUTE_ENTRY@304..310 + 0: IDENT@304..308 "lazy" [] [] + 1: COLON@308..310 ":" [] [Whitespace(" ")] + 2: (empty) + 3: (empty) + 4: JS_IMPORT_ATTRIBUTE_ENTRY@310..314 + 0: IDENT@310..314 "true" [] [] + 1: (empty) + 2: (empty) + 5: COMMA@314..316 "," [] [Whitespace(" ")] + 6: JS_IMPORT_ATTRIBUTE_ENTRY@316..329 + 0: IDENT@316..327 "startAtLine" [] [] + 1: COLON@327..329 ":" [] [Whitespace(" ")] + 2: (empty) + 7: (empty) + 8: JS_BOGUS_IMPORT_ATTRIBUTE_ENTRY@329..331 + 0: JS_NUMBER_LITERAL@329..331 "1" [] [Whitespace(" ")] + 3: R_CURLY@331..332 "}" [] [] + 2: SEMICOLON@332..333 ";" [] [] + 12: JS_IMPORT@333..365 + 0: IMPORT_KW@333..341 "import" [Newline("\n")] [Whitespace(" ")] + 1: JS_IMPORT_NAMED_CLAUSE@341..365 + 0: (empty) + 1: (empty) + 2: JS_NAMED_IMPORT_SPECIFIERS@341..347 + 0: L_CURLY@341..343 "{" [] [Whitespace(" ")] + 1: JS_NAMED_IMPORT_SPECIFIER_LIST@343..345 + 0: JS_SHORTHAND_NAMED_IMPORT_SPECIFIER@343..345 + 0: (empty) + 1: JS_IDENTIFIER_BINDING@343..345 + 0: IDENT@343..345 "a" [] [Whitespace(" ")] + 2: R_CURLY@345..347 "}" [] [Whitespace(" ")] + 3: FROM_KW@347..352 "from" [] [Whitespace(" ")] + 4: JS_MODULE_SOURCE@352..361 + 0: JS_STRING_LITERAL@352..361 "\"a.json\"" [] [Whitespace(" ")] + 5: JS_IMPORT_ATTRIBUTE@361..365 + 0: WITH_KW@361..365 "with" [] [] + 1: (empty) + 2: JS_IMPORT_ATTRIBUTE_ENTRY_LIST@365..365 + 3: (empty) + 2: (empty) + 3: EOF@365..366 "" [Newline("\n")] [] +-- +import_attribute_err.js:1:25 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + + × expected `:` but instead found `,` + + > 1 │ import "foo" with { type, "json" }; + │ ^ + 2 │ import "bar" \u{61}ith { type: "json" }; + 3 │ import { foo } with { type: "json" }; + + i Remove , + +-- +import_attribute_err.js:1:34 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + + × expected `:` but instead found `}` + + > 1 │ import "foo" with { type, "json" }; + │ ^ + 2 │ import "bar" \u{61}ith { type: "json" }; + 3 │ import { foo } with { type: "json" }; + + i Remove } + +-- +import_attribute_err.js:2:14 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + + × Expected a semicolon or an implicit semicolon after a statement, but found none + + 1 │ import "foo" with { type, "json" }; + > 2 │ import "bar" \u{61}ith { type: "json" }; + │ ^^^^^^^^^ + 3 │ import { foo } with { type: "json" }; + 4 │ import "lorem" + + i An explicit or implicit semicolon is expected here... + + 1 │ import "foo" with { type, "json" }; + > 2 │ import "bar" \u{61}ith { type: "json" }; + │ ^^^^^^^^^ + 3 │ import { foo } with { type: "json" }; + 4 │ import "lorem" + + i ...Which is required to end this statement + + 1 │ import "foo" with { type, "json" }; + > 2 │ import "bar" \u{61}ith { type: "json" }; + │ ^^^^^^^^^^^^^ + 3 │ import { foo } with { type: "json" }; + 4 │ import "lorem" + +-- +import_attribute_err.js:2:24 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + + × Expected a semicolon or an implicit semicolon after a statement, but found none + + 1 │ import "foo" with { type, "json" }; + > 2 │ import "bar" \u{61}ith { type: "json" }; + │ ^ + 3 │ import { foo } with { type: "json" }; + 4 │ import "lorem" + + i An explicit or implicit semicolon is expected here... + + 1 │ import "foo" with { type, "json" }; + > 2 │ import "bar" \u{61}ith { type: "json" }; + │ ^ + 3 │ import { foo } with { type: "json" }; + 4 │ import "lorem" + + i ...Which is required to end this statement + + 1 │ import "foo" with { type, "json" }; + > 2 │ import "bar" \u{61}ith { type: "json" }; + │ ^^^^^^^^^^^ + 3 │ import { foo } with { type: "json" }; + 4 │ import "lorem" + +-- +import_attribute_err.js:3:16 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + + × expected `from` but instead found `with` + + 1 │ import "foo" with { type, "json" }; + 2 │ import "bar" \u{61}ith { type: "json" }; + > 3 │ import { foo } with { type: "json" }; + │ ^^^^ + 4 │ import "lorem" + 5 │ assert { type: "json" } + + i Remove with + +-- +import_attribute_err.js:5:8 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + + × Expected a semicolon or an implicit semicolon after a statement, but found none + + 3 │ import { foo } with { type: "json" }; + 4 │ import "lorem" + > 5 │ assert { type: "json" } + │ ^ + 6 │ import foo2 from "foo.json" with { "type": "json", type: "html", "type": "js" }; + 7 │ import "x" with; + + i An explicit or implicit semicolon is expected here... + + 3 │ import { foo } with { type: "json" }; + 4 │ import "lorem" + > 5 │ assert { type: "json" } + │ ^ + 6 │ import foo2 from "foo.json" with { "type": "json", type: "html", "type": "js" }; + 7 │ import "x" with; + + i ...Which is required to end this statement + + 3 │ import { foo } with { type: "json" }; + 4 │ import "lorem" + > 5 │ assert { type: "json" } + │ ^^^^^^^^ + 6 │ import foo2 from "foo.json" with { "type": "json", type: "html", "type": "js" }; + 7 │ import "x" with; + +-- +import_attribute_err.js:6:36 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + + × Duplicate assertion keys are not allowed + + 4 │ import "lorem" + 5 │ assert { type: "json" } + > 6 │ import foo2 from "foo.json" with { "type": "json", type: "html", "type": "js" }; + │ ^^^^^^ + 7 │ import "x" with; + 8 │ import ipsum from "ipsum.json" with { type: "json", lazy: true, startAtLine: 1 }; + + i First use of the key `type` + + 4 │ import "lorem" + 5 │ assert { type: "json" } + > 6 │ import foo2 from "foo.json" with { "type": "json", type: "html", "type": "js" }; + │ ^^^^^^ + 7 │ import "x" with; + 8 │ import ipsum from "ipsum.json" with { type: "json", lazy: true, startAtLine: 1 }; + + i second use here + + 4 │ import "lorem" + 5 │ assert { type: "json" } + > 6 │ import foo2 from "foo.json" with { "type": "json", type: "html", "type": "js" }; + │ ^^^^ + 7 │ import "x" with; + 8 │ import ipsum from "ipsum.json" with { type: "json", lazy: true, startAtLine: 1 }; + +-- +import_attribute_err.js:7:16 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + + × expected `{` but instead found `;` + + 5 │ assert { type: "json" } + 6 │ import foo2 from "foo.json" with { "type": "json", type: "html", "type": "js" }; + > 7 │ import "x" with; + │ ^ + 8 │ import ipsum from "ipsum.json" with { type: "json", lazy: true, startAtLine: 1 }; + 9 │ import { a } from "a.json" with + + i Remove ; + +-- +import_attribute_err.js:8:59 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + + × expected `string literal` but instead found `true` + + 6 │ import foo2 from "foo.json" with { "type": "json", type: "html", "type": "js" }; + 7 │ import "x" with; + > 8 │ import ipsum from "ipsum.json" with { type: "json", lazy: true, startAtLine: 1 }; + │ ^^^^ + 9 │ import { a } from "a.json" with + 10 │ + + i Remove true + +-- +import_attribute_err.js:8:63 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + + × expected `:` but instead found `,` + + 6 │ import foo2 from "foo.json" with { "type": "json", type: "html", "type": "js" }; + 7 │ import "x" with; + > 8 │ import ipsum from "ipsum.json" with { type: "json", lazy: true, startAtLine: 1 }; + │ ^ + 9 │ import { a } from "a.json" with + 10 │ + + i Remove , + +-- +import_attribute_err.js:8:78 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + + × expected `string literal` but instead found `1` + + 6 │ import foo2 from "foo.json" with { "type": "json", type: "html", "type": "js" }; + 7 │ import "x" with; + > 8 │ import ipsum from "ipsum.json" with { type: "json", lazy: true, startAtLine: 1 }; + │ ^ + 9 │ import { a } from "a.json" with + 10 │ + + i Remove 1 + +-- +import_attribute_err.js:10:1 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + + × expected `{` but instead the file ends + + 8 │ import ipsum from "ipsum.json" with { type: "json", lazy: true, startAtLine: 1 }; + 9 │ import { a } from "a.json" with + > 10 │ + │ + + i the file ends here + + 8 │ import ipsum from "ipsum.json" with { type: "json", lazy: true, startAtLine: 1 }; + 9 │ import { a } from "a.json" with + > 10 │ + │ + +-- +import "foo" with { type, "json" }; +import "bar" \u{61}ith { type: "json" }; +import { foo } with { type: "json" }; +import "lorem" +assert { type: "json" } +import foo2 from "foo.json" with { "type": "json", type: "html", "type": "js" }; +import "x" with; +import ipsum from "ipsum.json" with { type: "json", lazy: true, startAtLine: 1 }; +import { a } from "a.json" with diff --git a/crates/rome_js_parser/test_data/inline/err/import_decl_not_top_level.rast b/crates/rome_js_parser/test_data/inline/err/import_decl_not_top_level.rast index ef6d49bd8a84..eb841f5163d6 100644 --- a/crates/rome_js_parser/test_data/inline/err/import_decl_not_top_level.rast +++ b/crates/rome_js_parser/test_data/inline/err/import_decl_not_top_level.rast @@ -17,7 +17,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/rome_js_parser/test_data/inline/err/import_err.rast b/crates/rome_js_parser/test_data/inline/err/import_err.rast index e8a0259cc1d5..21d6892f09ae 100644 --- a/crates/rome_js_parser/test_data/inline/err/import_err.rast +++ b/crates/rome_js_parser/test_data/inline/err/import_err.rast @@ -16,7 +16,7 @@ JsModule { local_name: missing (required), from_token: missing (required), source: missing (required), - assertion: missing (optional), + attribute: missing (optional), }, semicolon_token: SEMICOLON@16..17 ";" [] [], }, @@ -31,7 +31,7 @@ JsModule { }, from_token: missing (required), source: missing (required), - assertion: missing (optional), + attribute: missing (optional), }, semicolon_token: missing (optional), }, @@ -111,7 +111,7 @@ JsModule { source: JsModuleSource { value_token: JS_STRING_LITERAL@80..83 "\"c\"" [] [], }, - assertion: missing (optional), + attribute: missing (optional), }, semicolon_token: SEMICOLON@83..84 ";" [] [], }, @@ -143,7 +143,7 @@ JsModule { source: JsModuleSource { value_token: JS_STRING_LITERAL@108..111 "\"c\"" [] [], }, - assertion: missing (optional), + attribute: missing (optional), }, semicolon_token: SEMICOLON@111..112 ";" [] [], }, @@ -170,7 +170,7 @@ JsModule { source: JsModuleSource { value_token: JS_STRING_LITERAL@137..140 "\"c\"" [] [], }, - assertion: missing (optional), + attribute: missing (optional), }, semicolon_token: SEMICOLON@140..141 ";" [] [], }, @@ -197,7 +197,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 ";" [] [], }, @@ -262,7 +262,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/rome_js_parser/test_data/inline/err/ts_named_import_specifier_error.rast b/crates/rome_js_parser/test_data/inline/err/ts_named_import_specifier_error.rast index 3300c6c939d2..8cb239d76dbd 100644 --- a/crates/rome_js_parser/test_data/inline/err/ts_named_import_specifier_error.rast +++ b/crates/rome_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 ";" [] [], }, @@ -52,7 +52,7 @@ JsModule { source: JsModuleSource { value_token: JS_STRING_LITERAL@62..69 "\"./mod\"" [] [], }, - assertion: missing (optional), + attribute: missing (optional), }, semicolon_token: SEMICOLON@69..70 ";" [] [], }, @@ -79,7 +79,7 @@ JsModule { source: JsModuleSource { value_token: JS_STRING_LITERAL@102..109 "\"./mod\"" [] [], }, - assertion: missing (optional), + attribute: missing (optional), }, semicolon_token: SEMICOLON@109..110 ";" [] [], }, @@ -106,7 +106,7 @@ JsModule { source: JsModuleSource { value_token: JS_STRING_LITERAL@147..154 "\"./mod\"" [] [], }, - assertion: missing (optional), + attribute: missing (optional), }, semicolon_token: SEMICOLON@154..155 ";" [] [], }, @@ -122,7 +122,7 @@ JsModule { }, from_token: missing (required), source: missing (required), - assertion: missing (optional), + attribute: missing (optional), }, semicolon_token: missing (optional), }, diff --git a/crates/rome_js_parser/test_data/inline/ok/export_from_clause.js b/crates/rome_js_parser/test_data/inline/ok/export_from_clause.js index 970c5b41dd09..8365c3bf7f7e 100644 --- a/crates/rome_js_parser/test_data/inline/ok/export_from_clause.js +++ b/crates/rome_js_parser/test_data/inline/ok/export_from_clause.js @@ -4,6 +4,6 @@ export { default as a } from "b"; export * from "a"; export * as c from "b"; export * as default from "b" -export * from "mod" assert { type: "json" } +export * from "mod" with { type: "json" } export type * from "types"; export type * as types from "types"; diff --git a/crates/rome_js_parser/test_data/inline/ok/export_from_clause.rast b/crates/rome_js_parser/test_data/inline/ok/export_from_clause.rast index b10f7e596ed8..7ea73d804781 100644 --- a/crates/rome_js_parser/test_data/inline/ok/export_from_clause.rast +++ b/crates/rome_js_parser/test_data/inline/ok/export_from_clause.rast @@ -26,7 +26,7 @@ JsModule { source: JsModuleSource { value_token: JS_STRING_LITERAL@33..36 "\"b\"" [] [], }, - assertion: missing (optional), + attribute: missing (optional), semicolon_token: SEMICOLON@36..37 ";" [] [], }, }, @@ -54,7 +54,7 @@ JsModule { source: JsModuleSource { value_token: JS_STRING_LITERAL@67..70 "\"b\"" [] [], }, - assertion: missing (optional), + attribute: missing (optional), semicolon_token: SEMICOLON@70..71 ";" [] [], }, }, @@ -68,7 +68,7 @@ JsModule { source: JsModuleSource { value_token: JS_STRING_LITERAL@86..89 "\"a\"" [] [], }, - assertion: missing (optional), + attribute: missing (optional), semicolon_token: SEMICOLON@89..90 ";" [] [], }, }, @@ -87,7 +87,7 @@ JsModule { source: JsModuleSource { value_token: JS_STRING_LITERAL@110..113 "\"b\"" [] [], }, - assertion: missing (optional), + attribute: missing (optional), semicolon_token: SEMICOLON@113..114 ";" [] [], }, }, @@ -106,7 +106,7 @@ JsModule { source: JsModuleSource { value_token: JS_STRING_LITERAL@140..143 "\"b\"" [] [], }, - assertion: missing (optional), + attribute: missing (optional), semicolon_token: missing (optional), }, }, @@ -120,62 +120,62 @@ JsModule { source: JsModuleSource { value_token: JS_STRING_LITERAL@158..164 "\"mod\"" [] [Whitespace(" ")], }, - assertion: JsImportAssertion { - assert_token: ASSERT_KW@164..171 "assert" [] [Whitespace(" ")], - l_curly_token: L_CURLY@171..173 "{" [] [Whitespace(" ")], - assertions: JsImportAssertionEntryList [ - JsImportAssertionEntry { - key: IDENT@173..177 "type" [] [], - colon_token: COLON@177..179 ":" [] [Whitespace(" ")], - value_token: JS_STRING_LITERAL@179..186 "\"json\"" [] [Whitespace(" ")], + attribute: JsImportAttribute { + with_token: WITH_KW@164..169 "with" [] [Whitespace(" ")], + l_curly_token: L_CURLY@169..171 "{" [] [Whitespace(" ")], + attributes: JsImportAttributeEntryList [ + JsImportAttributeEntry { + key: IDENT@171..175 "type" [] [], + colon_token: COLON@175..177 ":" [] [Whitespace(" ")], + value_token: JS_STRING_LITERAL@177..184 "\"json\"" [] [Whitespace(" ")], }, ], - r_curly_token: R_CURLY@186..187 "}" [] [], + r_curly_token: R_CURLY@184..185 "}" [] [], }, semicolon_token: missing (optional), }, }, JsExport { - export_token: EXPORT_KW@187..195 "export" [Newline("\n")] [Whitespace(" ")], + export_token: EXPORT_KW@185..193 "export" [Newline("\n")] [Whitespace(" ")], export_clause: JsExportFromClause { - type_token: TYPE_KW@195..200 "type" [] [Whitespace(" ")], - star_token: STAR@200..202 "*" [] [Whitespace(" ")], + type_token: TYPE_KW@193..198 "type" [] [Whitespace(" ")], + star_token: STAR@198..200 "*" [] [Whitespace(" ")], export_as: missing (optional), - from_token: FROM_KW@202..207 "from" [] [Whitespace(" ")], + from_token: FROM_KW@200..205 "from" [] [Whitespace(" ")], source: JsModuleSource { - value_token: JS_STRING_LITERAL@207..214 "\"types\"" [] [], + value_token: JS_STRING_LITERAL@205..212 "\"types\"" [] [], }, - assertion: missing (optional), - semicolon_token: SEMICOLON@214..215 ";" [] [], + attribute: missing (optional), + semicolon_token: SEMICOLON@212..213 ";" [] [], }, }, JsExport { - export_token: EXPORT_KW@215..223 "export" [Newline("\n")] [Whitespace(" ")], + export_token: EXPORT_KW@213..221 "export" [Newline("\n")] [Whitespace(" ")], export_clause: JsExportFromClause { - type_token: TYPE_KW@223..228 "type" [] [Whitespace(" ")], - star_token: STAR@228..230 "*" [] [Whitespace(" ")], + type_token: TYPE_KW@221..226 "type" [] [Whitespace(" ")], + star_token: STAR@226..228 "*" [] [Whitespace(" ")], export_as: JsExportAsClause { - as_token: AS_KW@230..233 "as" [] [Whitespace(" ")], + as_token: AS_KW@228..231 "as" [] [Whitespace(" ")], exported_name: JsLiteralExportName { - value: IDENT@233..239 "types" [] [Whitespace(" ")], + value: IDENT@231..237 "types" [] [Whitespace(" ")], }, }, - from_token: FROM_KW@239..244 "from" [] [Whitespace(" ")], + from_token: FROM_KW@237..242 "from" [] [Whitespace(" ")], source: JsModuleSource { - value_token: JS_STRING_LITERAL@244..251 "\"types\"" [] [], + value_token: JS_STRING_LITERAL@242..249 "\"types\"" [] [], }, - assertion: missing (optional), - semicolon_token: SEMICOLON@251..252 ";" [] [], + attribute: missing (optional), + semicolon_token: SEMICOLON@249..250 ";" [] [], }, }, ], - eof_token: EOF@252..253 "" [Newline("\n")] [], + eof_token: EOF@250..251 "" [Newline("\n")] [], } -0: JS_MODULE@0..253 +0: JS_MODULE@0..251 0: (empty) 1: JS_DIRECTIVE_LIST@0..0 - 2: JS_MODULE_ITEM_LIST@0..252 + 2: JS_MODULE_ITEM_LIST@0..250 0: JS_EXPORT@0..37 0: EXPORT_KW@0..7 "export" [] [Whitespace(" ")] 1: JS_EXPORT_NAMED_FROM_CLAUSE@7..37 @@ -255,48 +255,48 @@ JsModule { 0: JS_STRING_LITERAL@140..143 "\"b\"" [] [] 5: (empty) 6: (empty) - 5: JS_EXPORT@143..187 + 5: JS_EXPORT@143..185 0: EXPORT_KW@143..151 "export" [Newline("\n")] [Whitespace(" ")] - 1: JS_EXPORT_FROM_CLAUSE@151..187 + 1: JS_EXPORT_FROM_CLAUSE@151..185 0: (empty) 1: STAR@151..153 "*" [] [Whitespace(" ")] 2: (empty) 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..187 - 0: ASSERT_KW@164..171 "assert" [] [Whitespace(" ")] - 1: L_CURLY@171..173 "{" [] [Whitespace(" ")] - 2: JS_IMPORT_ASSERTION_ENTRY_LIST@173..186 - 0: JS_IMPORT_ASSERTION_ENTRY@173..186 - 0: IDENT@173..177 "type" [] [] - 1: COLON@177..179 ":" [] [Whitespace(" ")] - 2: JS_STRING_LITERAL@179..186 "\"json\"" [] [Whitespace(" ")] - 3: R_CURLY@186..187 "}" [] [] + 5: JS_IMPORT_ATTRIBUTE@164..185 + 0: WITH_KW@164..169 "with" [] [Whitespace(" ")] + 1: L_CURLY@169..171 "{" [] [Whitespace(" ")] + 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(" ")] + 3: R_CURLY@184..185 "}" [] [] 6: (empty) - 6: JS_EXPORT@187..215 - 0: EXPORT_KW@187..195 "export" [Newline("\n")] [Whitespace(" ")] - 1: JS_EXPORT_FROM_CLAUSE@195..215 - 0: TYPE_KW@195..200 "type" [] [Whitespace(" ")] - 1: STAR@200..202 "*" [] [Whitespace(" ")] + 6: JS_EXPORT@185..213 + 0: EXPORT_KW@185..193 "export" [Newline("\n")] [Whitespace(" ")] + 1: JS_EXPORT_FROM_CLAUSE@193..213 + 0: TYPE_KW@193..198 "type" [] [Whitespace(" ")] + 1: STAR@198..200 "*" [] [Whitespace(" ")] 2: (empty) - 3: FROM_KW@202..207 "from" [] [Whitespace(" ")] - 4: JS_MODULE_SOURCE@207..214 - 0: JS_STRING_LITERAL@207..214 "\"types\"" [] [] + 3: FROM_KW@200..205 "from" [] [Whitespace(" ")] + 4: JS_MODULE_SOURCE@205..212 + 0: JS_STRING_LITERAL@205..212 "\"types\"" [] [] 5: (empty) - 6: SEMICOLON@214..215 ";" [] [] - 7: JS_EXPORT@215..252 - 0: EXPORT_KW@215..223 "export" [Newline("\n")] [Whitespace(" ")] - 1: JS_EXPORT_FROM_CLAUSE@223..252 - 0: TYPE_KW@223..228 "type" [] [Whitespace(" ")] - 1: STAR@228..230 "*" [] [Whitespace(" ")] - 2: JS_EXPORT_AS_CLAUSE@230..239 - 0: AS_KW@230..233 "as" [] [Whitespace(" ")] - 1: JS_LITERAL_EXPORT_NAME@233..239 - 0: IDENT@233..239 "types" [] [Whitespace(" ")] - 3: FROM_KW@239..244 "from" [] [Whitespace(" ")] - 4: JS_MODULE_SOURCE@244..251 - 0: JS_STRING_LITERAL@244..251 "\"types\"" [] [] + 6: SEMICOLON@212..213 ";" [] [] + 7: JS_EXPORT@213..250 + 0: EXPORT_KW@213..221 "export" [Newline("\n")] [Whitespace(" ")] + 1: JS_EXPORT_FROM_CLAUSE@221..250 + 0: TYPE_KW@221..226 "type" [] [Whitespace(" ")] + 1: STAR@226..228 "*" [] [Whitespace(" ")] + 2: JS_EXPORT_AS_CLAUSE@228..237 + 0: AS_KW@228..231 "as" [] [Whitespace(" ")] + 1: JS_LITERAL_EXPORT_NAME@231..237 + 0: IDENT@231..237 "types" [] [Whitespace(" ")] + 3: FROM_KW@237..242 "from" [] [Whitespace(" ")] + 4: JS_MODULE_SOURCE@242..249 + 0: JS_STRING_LITERAL@242..249 "\"types\"" [] [] 5: (empty) - 6: SEMICOLON@251..252 ";" [] [] - 3: EOF@252..253 "" [Newline("\n")] [] + 6: SEMICOLON@249..250 ";" [] [] + 3: EOF@250..251 "" [Newline("\n")] [] diff --git a/crates/rome_js_parser/test_data/inline/ok/export_named_from_clause.js b/crates/rome_js_parser/test_data/inline/ok/export_named_from_clause.js index 9b350448e328..c223f8df7287 100644 --- a/crates/rome_js_parser/test_data/inline/ok/export_named_from_clause.js +++ b/crates/rome_js_parser/test_data/inline/ok/export_named_from_clause.js @@ -3,7 +3,7 @@ export { a as z, b as "y", c as default } from "mod" export { as } from "mod"; export { default as "b" } from "mod"; export { "a" as b } from "mod"; -export { a } from "mod" assert { type: "json" } +export { a } from "mod" with { type: "json" } export { "a" } from "./mod"; export { "a" diff --git a/crates/rome_js_parser/test_data/inline/ok/export_named_from_clause.rast b/crates/rome_js_parser/test_data/inline/ok/export_named_from_clause.rast index b2a2619bc231..6eef9d2a393b 100644 --- a/crates/rome_js_parser/test_data/inline/ok/export_named_from_clause.rast +++ b/crates/rome_js_parser/test_data/inline/ok/export_named_from_clause.rast @@ -29,7 +29,7 @@ JsModule { source: JsModuleSource { value_token: JS_STRING_LITERAL@27..32 "\"mod\"" [] [], }, - assertion: missing (optional), + attribute: missing (optional), semicolon_token: SEMICOLON@32..33 ";" [] [], }, }, @@ -83,7 +83,7 @@ JsModule { source: JsModuleSource { value_token: JS_STRING_LITERAL@81..86 "\"mod\"" [] [], }, - assertion: missing (optional), + attribute: missing (optional), semicolon_token: missing (optional), }, }, @@ -106,7 +106,7 @@ JsModule { source: JsModuleSource { value_token: JS_STRING_LITERAL@106..111 "\"mod\"" [] [], }, - assertion: missing (optional), + attribute: missing (optional), semicolon_token: SEMICOLON@111..112 ";" [] [], }, }, @@ -134,7 +134,7 @@ JsModule { source: JsModuleSource { value_token: JS_STRING_LITERAL@144..149 "\"mod\"" [] [], }, - assertion: missing (optional), + attribute: missing (optional), semicolon_token: SEMICOLON@149..150 ";" [] [], }, }, @@ -162,7 +162,7 @@ JsModule { source: JsModuleSource { value_token: JS_STRING_LITERAL@176..181 "\"mod\"" [] [], }, - assertion: missing (optional), + attribute: missing (optional), semicolon_token: SEMICOLON@181..182 ";" [] [], }, }, @@ -185,75 +185,75 @@ JsModule { source: JsModuleSource { value_token: JS_STRING_LITERAL@201..207 "\"mod\"" [] [Whitespace(" ")], }, - assertion: JsImportAssertion { - assert_token: ASSERT_KW@207..214 "assert" [] [Whitespace(" ")], - l_curly_token: L_CURLY@214..216 "{" [] [Whitespace(" ")], - assertions: JsImportAssertionEntryList [ - JsImportAssertionEntry { - key: IDENT@216..220 "type" [] [], - colon_token: COLON@220..222 ":" [] [Whitespace(" ")], - value_token: JS_STRING_LITERAL@222..229 "\"json\"" [] [Whitespace(" ")], + attribute: JsImportAttribute { + with_token: WITH_KW@207..212 "with" [] [Whitespace(" ")], + l_curly_token: L_CURLY@212..214 "{" [] [Whitespace(" ")], + attributes: JsImportAttributeEntryList [ + JsImportAttributeEntry { + key: IDENT@214..218 "type" [] [], + colon_token: COLON@218..220 ":" [] [Whitespace(" ")], + value_token: JS_STRING_LITERAL@220..227 "\"json\"" [] [Whitespace(" ")], }, ], - r_curly_token: R_CURLY@229..230 "}" [] [], + r_curly_token: R_CURLY@227..228 "}" [] [], }, semicolon_token: missing (optional), }, }, JsExport { - export_token: EXPORT_KW@230..238 "export" [Newline("\n")] [Whitespace(" ")], + export_token: EXPORT_KW@228..236 "export" [Newline("\n")] [Whitespace(" ")], export_clause: JsExportNamedFromClause { type_token: missing (optional), - l_curly_token: L_CURLY@238..240 "{" [] [Whitespace(" ")], + l_curly_token: L_CURLY@236..238 "{" [] [Whitespace(" ")], specifiers: JsExportNamedFromSpecifierList [ JsExportNamedFromSpecifier { type_token: missing (optional), source_name: JsLiteralExportName { - value: JS_STRING_LITERAL@240..244 "\"a\"" [] [Whitespace(" ")], + value: JS_STRING_LITERAL@238..242 "\"a\"" [] [Whitespace(" ")], }, export_as: missing (optional), }, ], - r_curly_token: R_CURLY@244..246 "}" [] [Whitespace(" ")], - from_token: FROM_KW@246..251 "from" [] [Whitespace(" ")], + r_curly_token: R_CURLY@242..244 "}" [] [Whitespace(" ")], + from_token: FROM_KW@244..249 "from" [] [Whitespace(" ")], source: JsModuleSource { - value_token: JS_STRING_LITERAL@251..258 "\"./mod\"" [] [], + value_token: JS_STRING_LITERAL@249..256 "\"./mod\"" [] [], }, - assertion: missing (optional), - semicolon_token: SEMICOLON@258..259 ";" [] [], + attribute: missing (optional), + semicolon_token: SEMICOLON@256..257 ";" [] [], }, }, JsExport { - export_token: EXPORT_KW@259..267 "export" [Newline("\n")] [Whitespace(" ")], + export_token: EXPORT_KW@257..265 "export" [Newline("\n")] [Whitespace(" ")], export_clause: JsExportNamedFromClause { type_token: missing (optional), - l_curly_token: L_CURLY@267..268 "{" [] [], + l_curly_token: L_CURLY@265..266 "{" [] [], specifiers: JsExportNamedFromSpecifierList [ JsExportNamedFromSpecifier { type_token: missing (optional), source_name: JsLiteralExportName { - value: JS_STRING_LITERAL@268..277 "\"a\"" [Newline("\n"), Whitespace(" ")] [], + value: JS_STRING_LITERAL@266..275 "\"a\"" [Newline("\n"), Whitespace(" ")] [], }, export_as: missing (optional), }, ], - r_curly_token: R_CURLY@277..280 "}" [Newline("\n")] [Whitespace(" ")], - from_token: FROM_KW@280..285 "from" [] [Whitespace(" ")], + r_curly_token: R_CURLY@275..278 "}" [Newline("\n")] [Whitespace(" ")], + from_token: FROM_KW@278..283 "from" [] [Whitespace(" ")], source: JsModuleSource { - value_token: JS_STRING_LITERAL@285..292 "\"./mod\"" [] [], + value_token: JS_STRING_LITERAL@283..290 "\"./mod\"" [] [], }, - assertion: missing (optional), - semicolon_token: SEMICOLON@292..293 ";" [] [], + attribute: missing (optional), + semicolon_token: SEMICOLON@290..291 ";" [] [], }, }, ], - eof_token: EOF@293..294 "" [Newline("\n")] [], + eof_token: EOF@291..292 "" [Newline("\n")] [], } -0: JS_MODULE@0..294 +0: JS_MODULE@0..292 0: (empty) 1: JS_DIRECTIVE_LIST@0..0 - 2: JS_MODULE_ITEM_LIST@0..293 + 2: JS_MODULE_ITEM_LIST@0..291 0: JS_EXPORT@0..33 0: EXPORT_KW@0..7 "export" [] [Whitespace(" ")] 1: JS_EXPORT_NAMED_FROM_CLAUSE@7..33 @@ -372,9 +372,9 @@ JsModule { 0: JS_STRING_LITERAL@176..181 "\"mod\"" [] [] 6: (empty) 7: SEMICOLON@181..182 ";" [] [] - 5: JS_EXPORT@182..230 + 5: JS_EXPORT@182..228 0: EXPORT_KW@182..190 "export" [Newline("\n")] [Whitespace(" ")] - 1: JS_EXPORT_NAMED_FROM_CLAUSE@190..230 + 1: JS_EXPORT_NAMED_FROM_CLAUSE@190..228 0: (empty) 1: L_CURLY@190..192 "{" [] [Whitespace(" ")] 2: JS_EXPORT_NAMED_FROM_SPECIFIER_LIST@192..194 @@ -387,48 +387,48 @@ 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..230 - 0: ASSERT_KW@207..214 "assert" [] [Whitespace(" ")] - 1: L_CURLY@214..216 "{" [] [Whitespace(" ")] - 2: JS_IMPORT_ASSERTION_ENTRY_LIST@216..229 - 0: JS_IMPORT_ASSERTION_ENTRY@216..229 - 0: IDENT@216..220 "type" [] [] - 1: COLON@220..222 ":" [] [Whitespace(" ")] - 2: JS_STRING_LITERAL@222..229 "\"json\"" [] [Whitespace(" ")] - 3: R_CURLY@229..230 "}" [] [] + 6: JS_IMPORT_ATTRIBUTE@207..228 + 0: WITH_KW@207..212 "with" [] [Whitespace(" ")] + 1: L_CURLY@212..214 "{" [] [Whitespace(" ")] + 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(" ")] + 3: R_CURLY@227..228 "}" [] [] 7: (empty) - 6: JS_EXPORT@230..259 - 0: EXPORT_KW@230..238 "export" [Newline("\n")] [Whitespace(" ")] - 1: JS_EXPORT_NAMED_FROM_CLAUSE@238..259 + 6: JS_EXPORT@228..257 + 0: EXPORT_KW@228..236 "export" [Newline("\n")] [Whitespace(" ")] + 1: JS_EXPORT_NAMED_FROM_CLAUSE@236..257 0: (empty) - 1: L_CURLY@238..240 "{" [] [Whitespace(" ")] - 2: JS_EXPORT_NAMED_FROM_SPECIFIER_LIST@240..244 - 0: JS_EXPORT_NAMED_FROM_SPECIFIER@240..244 + 1: L_CURLY@236..238 "{" [] [Whitespace(" ")] + 2: JS_EXPORT_NAMED_FROM_SPECIFIER_LIST@238..242 + 0: JS_EXPORT_NAMED_FROM_SPECIFIER@238..242 0: (empty) - 1: JS_LITERAL_EXPORT_NAME@240..244 - 0: JS_STRING_LITERAL@240..244 "\"a\"" [] [Whitespace(" ")] + 1: JS_LITERAL_EXPORT_NAME@238..242 + 0: JS_STRING_LITERAL@238..242 "\"a\"" [] [Whitespace(" ")] 2: (empty) - 3: R_CURLY@244..246 "}" [] [Whitespace(" ")] - 4: FROM_KW@246..251 "from" [] [Whitespace(" ")] - 5: JS_MODULE_SOURCE@251..258 - 0: JS_STRING_LITERAL@251..258 "\"./mod\"" [] [] + 3: R_CURLY@242..244 "}" [] [Whitespace(" ")] + 4: FROM_KW@244..249 "from" [] [Whitespace(" ")] + 5: JS_MODULE_SOURCE@249..256 + 0: JS_STRING_LITERAL@249..256 "\"./mod\"" [] [] 6: (empty) - 7: SEMICOLON@258..259 ";" [] [] - 7: JS_EXPORT@259..293 - 0: EXPORT_KW@259..267 "export" [Newline("\n")] [Whitespace(" ")] - 1: JS_EXPORT_NAMED_FROM_CLAUSE@267..293 + 7: SEMICOLON@256..257 ";" [] [] + 7: JS_EXPORT@257..291 + 0: EXPORT_KW@257..265 "export" [Newline("\n")] [Whitespace(" ")] + 1: JS_EXPORT_NAMED_FROM_CLAUSE@265..291 0: (empty) - 1: L_CURLY@267..268 "{" [] [] - 2: JS_EXPORT_NAMED_FROM_SPECIFIER_LIST@268..277 - 0: JS_EXPORT_NAMED_FROM_SPECIFIER@268..277 + 1: L_CURLY@265..266 "{" [] [] + 2: JS_EXPORT_NAMED_FROM_SPECIFIER_LIST@266..275 + 0: JS_EXPORT_NAMED_FROM_SPECIFIER@266..275 0: (empty) - 1: JS_LITERAL_EXPORT_NAME@268..277 - 0: JS_STRING_LITERAL@268..277 "\"a\"" [Newline("\n"), Whitespace(" ")] [] + 1: JS_LITERAL_EXPORT_NAME@266..275 + 0: JS_STRING_LITERAL@266..275 "\"a\"" [Newline("\n"), Whitespace(" ")] [] 2: (empty) - 3: R_CURLY@277..280 "}" [Newline("\n")] [Whitespace(" ")] - 4: FROM_KW@280..285 "from" [] [Whitespace(" ")] - 5: JS_MODULE_SOURCE@285..292 - 0: JS_STRING_LITERAL@285..292 "\"./mod\"" [] [] + 3: R_CURLY@275..278 "}" [Newline("\n")] [Whitespace(" ")] + 4: FROM_KW@278..283 "from" [] [Whitespace(" ")] + 5: JS_MODULE_SOURCE@283..290 + 0: JS_STRING_LITERAL@283..290 "\"./mod\"" [] [] 6: (empty) - 7: SEMICOLON@292..293 ";" [] [] - 3: EOF@293..294 "" [Newline("\n")] [] + 7: SEMICOLON@290..291 ";" [] [] + 3: EOF@291..292 "" [Newline("\n")] [] diff --git a/crates/rome_js_parser/test_data/inline/ok/import_as_as_as_identifier.rast b/crates/rome_js_parser/test_data/inline/ok/import_as_as_as_identifier.rast index cf72e03e1510..5276275f704e 100644 --- a/crates/rome_js_parser/test_data/inline/ok/import_as_as_as_identifier.rast +++ b/crates/rome_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/rome_js_parser/test_data/inline/ok/import_as_identifier.rast b/crates/rome_js_parser/test_data/inline/ok/import_as_identifier.rast index a16685b319e8..d21f27365b41 100644 --- a/crates/rome_js_parser/test_data/inline/ok/import_as_identifier.rast +++ b/crates/rome_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/rome_js_parser/test_data/inline/ok/import_assertion.js b/crates/rome_js_parser/test_data/inline/ok/import_assertion.js deleted file mode 100644 index e7c0ce4a164c..000000000000 --- a/crates/rome_js_parser/test_data/inline/ok/import_assertion.js +++ /dev/null @@ -1,7 +0,0 @@ -import "x" assert { type: "json" } -import "foo" assert { "type": "json" }; -import foo from "foo.json" assert { type: "json" }; -import {test} from "foo.json" assert { for: "for" } -import foo_json from "foo.json" assert { type: "json", hasOwnProperty: "true" }; -import "x" assert -{ type: "json" } diff --git a/crates/rome_js_parser/test_data/inline/ok/import_assertion.rast b/crates/rome_js_parser/test_data/inline/ok/import_assertion.rast deleted file mode 100644 index 1d14678c8e35..000000000000 --- a/crates/rome_js_parser/test_data/inline/ok/import_assertion.rast +++ /dev/null @@ -1,284 +0,0 @@ -JsModule { - interpreter_token: missing (optional), - directives: JsDirectiveList [], - items: JsModuleItemList [ - JsImport { - import_token: IMPORT_KW@0..7 "import" [] [Whitespace(" ")], - import_clause: JsImportBareClause { - source: JsModuleSource { - value_token: JS_STRING_LITERAL@7..11 "\"x\"" [] [Whitespace(" ")], - }, - assertion: JsImportAssertion { - assert_token: ASSERT_KW@11..18 "assert" [] [Whitespace(" ")], - l_curly_token: L_CURLY@18..20 "{" [] [Whitespace(" ")], - assertions: JsImportAssertionEntryList [ - JsImportAssertionEntry { - key: IDENT@20..24 "type" [] [], - colon_token: COLON@24..26 ":" [] [Whitespace(" ")], - value_token: JS_STRING_LITERAL@26..33 "\"json\"" [] [Whitespace(" ")], - }, - ], - r_curly_token: R_CURLY@33..34 "}" [] [], - }, - }, - semicolon_token: missing (optional), - }, - JsImport { - import_token: IMPORT_KW@34..42 "import" [Newline("\n")] [Whitespace(" ")], - import_clause: JsImportBareClause { - source: JsModuleSource { - value_token: JS_STRING_LITERAL@42..48 "\"foo\"" [] [Whitespace(" ")], - }, - assertion: JsImportAssertion { - assert_token: ASSERT_KW@48..55 "assert" [] [Whitespace(" ")], - l_curly_token: L_CURLY@55..57 "{" [] [Whitespace(" ")], - assertions: JsImportAssertionEntryList [ - JsImportAssertionEntry { - key: JS_STRING_LITERAL@57..63 "\"type\"" [] [], - colon_token: COLON@63..65 ":" [] [Whitespace(" ")], - value_token: JS_STRING_LITERAL@65..72 "\"json\"" [] [Whitespace(" ")], - }, - ], - r_curly_token: R_CURLY@72..73 "}" [] [], - }, - }, - semicolon_token: SEMICOLON@73..74 ";" [] [], - }, - JsImport { - import_token: IMPORT_KW@74..82 "import" [Newline("\n")] [Whitespace(" ")], - import_clause: JsImportDefaultClause { - type_token: missing (optional), - local_name: JsIdentifierBinding { - name_token: IDENT@82..86 "foo" [] [Whitespace(" ")], - }, - from_token: FROM_KW@86..91 "from" [] [Whitespace(" ")], - source: JsModuleSource { - value_token: JS_STRING_LITERAL@91..102 "\"foo.json\"" [] [Whitespace(" ")], - }, - assertion: JsImportAssertion { - assert_token: ASSERT_KW@102..109 "assert" [] [Whitespace(" ")], - l_curly_token: L_CURLY@109..111 "{" [] [Whitespace(" ")], - assertions: JsImportAssertionEntryList [ - JsImportAssertionEntry { - key: IDENT@111..115 "type" [] [], - colon_token: COLON@115..117 ":" [] [Whitespace(" ")], - value_token: JS_STRING_LITERAL@117..124 "\"json\"" [] [Whitespace(" ")], - }, - ], - r_curly_token: R_CURLY@124..125 "}" [] [], - }, - }, - semicolon_token: SEMICOLON@125..126 ";" [] [], - }, - JsImport { - import_token: IMPORT_KW@126..134 "import" [Newline("\n")] [Whitespace(" ")], - import_clause: JsImportNamedClause { - type_token: missing (optional), - default_specifier: missing (optional), - named_import: JsNamedImportSpecifiers { - l_curly_token: L_CURLY@134..135 "{" [] [], - specifiers: JsNamedImportSpecifierList [ - JsShorthandNamedImportSpecifier { - type_token: missing (optional), - local_name: JsIdentifierBinding { - name_token: IDENT@135..139 "test" [] [], - }, - }, - ], - r_curly_token: R_CURLY@139..141 "}" [] [Whitespace(" ")], - }, - from_token: FROM_KW@141..146 "from" [] [Whitespace(" ")], - source: JsModuleSource { - value_token: JS_STRING_LITERAL@146..157 "\"foo.json\"" [] [Whitespace(" ")], - }, - assertion: JsImportAssertion { - assert_token: ASSERT_KW@157..164 "assert" [] [Whitespace(" ")], - l_curly_token: L_CURLY@164..166 "{" [] [Whitespace(" ")], - assertions: JsImportAssertionEntryList [ - JsImportAssertionEntry { - key: IDENT@166..169 "for" [] [], - colon_token: COLON@169..171 ":" [] [Whitespace(" ")], - value_token: JS_STRING_LITERAL@171..177 "\"for\"" [] [Whitespace(" ")], - }, - ], - r_curly_token: R_CURLY@177..178 "}" [] [], - }, - }, - semicolon_token: missing (optional), - }, - JsImport { - import_token: IMPORT_KW@178..186 "import" [Newline("\n")] [Whitespace(" ")], - import_clause: JsImportDefaultClause { - type_token: missing (optional), - local_name: JsIdentifierBinding { - name_token: IDENT@186..195 "foo_json" [] [Whitespace(" ")], - }, - from_token: FROM_KW@195..200 "from" [] [Whitespace(" ")], - source: JsModuleSource { - value_token: JS_STRING_LITERAL@200..211 "\"foo.json\"" [] [Whitespace(" ")], - }, - assertion: JsImportAssertion { - assert_token: ASSERT_KW@211..218 "assert" [] [Whitespace(" ")], - l_curly_token: L_CURLY@218..220 "{" [] [Whitespace(" ")], - assertions: JsImportAssertionEntryList [ - JsImportAssertionEntry { - key: IDENT@220..224 "type" [] [], - colon_token: COLON@224..226 ":" [] [Whitespace(" ")], - value_token: JS_STRING_LITERAL@226..232 "\"json\"" [] [], - }, - COMMA@232..234 "," [] [Whitespace(" ")], - JsImportAssertionEntry { - key: IDENT@234..248 "hasOwnProperty" [] [], - colon_token: COLON@248..250 ":" [] [Whitespace(" ")], - value_token: JS_STRING_LITERAL@250..257 "\"true\"" [] [Whitespace(" ")], - }, - ], - r_curly_token: R_CURLY@257..258 "}" [] [], - }, - }, - semicolon_token: SEMICOLON@258..259 ";" [] [], - }, - JsImport { - import_token: IMPORT_KW@259..267 "import" [Newline("\n")] [Whitespace(" ")], - import_clause: JsImportBareClause { - source: JsModuleSource { - value_token: JS_STRING_LITERAL@267..271 "\"x\"" [] [Whitespace(" ")], - }, - assertion: JsImportAssertion { - assert_token: ASSERT_KW@271..277 "assert" [] [], - l_curly_token: L_CURLY@277..280 "{" [Newline("\n")] [Whitespace(" ")], - assertions: JsImportAssertionEntryList [ - JsImportAssertionEntry { - key: IDENT@280..284 "type" [] [], - colon_token: COLON@284..286 ":" [] [Whitespace(" ")], - value_token: JS_STRING_LITERAL@286..293 "\"json\"" [] [Whitespace(" ")], - }, - ], - r_curly_token: R_CURLY@293..294 "}" [] [], - }, - }, - semicolon_token: missing (optional), - }, - ], - eof_token: EOF@294..295 "" [Newline("\n")] [], -} - -0: JS_MODULE@0..295 - 0: (empty) - 1: JS_DIRECTIVE_LIST@0..0 - 2: JS_MODULE_ITEM_LIST@0..294 - 0: JS_IMPORT@0..34 - 0: IMPORT_KW@0..7 "import" [] [Whitespace(" ")] - 1: JS_IMPORT_BARE_CLAUSE@7..34 - 0: JS_MODULE_SOURCE@7..11 - 0: JS_STRING_LITERAL@7..11 "\"x\"" [] [Whitespace(" ")] - 1: JS_IMPORT_ASSERTION@11..34 - 0: ASSERT_KW@11..18 "assert" [] [Whitespace(" ")] - 1: L_CURLY@18..20 "{" [] [Whitespace(" ")] - 2: JS_IMPORT_ASSERTION_ENTRY_LIST@20..33 - 0: JS_IMPORT_ASSERTION_ENTRY@20..33 - 0: IDENT@20..24 "type" [] [] - 1: COLON@24..26 ":" [] [Whitespace(" ")] - 2: JS_STRING_LITERAL@26..33 "\"json\"" [] [Whitespace(" ")] - 3: R_CURLY@33..34 "}" [] [] - 2: (empty) - 1: JS_IMPORT@34..74 - 0: IMPORT_KW@34..42 "import" [Newline("\n")] [Whitespace(" ")] - 1: JS_IMPORT_BARE_CLAUSE@42..73 - 0: JS_MODULE_SOURCE@42..48 - 0: JS_STRING_LITERAL@42..48 "\"foo\"" [] [Whitespace(" ")] - 1: JS_IMPORT_ASSERTION@48..73 - 0: ASSERT_KW@48..55 "assert" [] [Whitespace(" ")] - 1: L_CURLY@55..57 "{" [] [Whitespace(" ")] - 2: JS_IMPORT_ASSERTION_ENTRY_LIST@57..72 - 0: JS_IMPORT_ASSERTION_ENTRY@57..72 - 0: JS_STRING_LITERAL@57..63 "\"type\"" [] [] - 1: COLON@63..65 ":" [] [Whitespace(" ")] - 2: JS_STRING_LITERAL@65..72 "\"json\"" [] [Whitespace(" ")] - 3: R_CURLY@72..73 "}" [] [] - 2: SEMICOLON@73..74 ";" [] [] - 2: JS_IMPORT@74..126 - 0: IMPORT_KW@74..82 "import" [Newline("\n")] [Whitespace(" ")] - 1: JS_IMPORT_DEFAULT_CLAUSE@82..125 - 0: (empty) - 1: JS_IDENTIFIER_BINDING@82..86 - 0: IDENT@82..86 "foo" [] [Whitespace(" ")] - 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..125 - 0: ASSERT_KW@102..109 "assert" [] [Whitespace(" ")] - 1: L_CURLY@109..111 "{" [] [Whitespace(" ")] - 2: JS_IMPORT_ASSERTION_ENTRY_LIST@111..124 - 0: JS_IMPORT_ASSERTION_ENTRY@111..124 - 0: IDENT@111..115 "type" [] [] - 1: COLON@115..117 ":" [] [Whitespace(" ")] - 2: JS_STRING_LITERAL@117..124 "\"json\"" [] [Whitespace(" ")] - 3: R_CURLY@124..125 "}" [] [] - 2: SEMICOLON@125..126 ";" [] [] - 3: JS_IMPORT@126..178 - 0: IMPORT_KW@126..134 "import" [Newline("\n")] [Whitespace(" ")] - 1: JS_IMPORT_NAMED_CLAUSE@134..178 - 0: (empty) - 1: (empty) - 2: JS_NAMED_IMPORT_SPECIFIERS@134..141 - 0: L_CURLY@134..135 "{" [] [] - 1: JS_NAMED_IMPORT_SPECIFIER_LIST@135..139 - 0: JS_SHORTHAND_NAMED_IMPORT_SPECIFIER@135..139 - 0: (empty) - 1: JS_IDENTIFIER_BINDING@135..139 - 0: IDENT@135..139 "test" [] [] - 2: R_CURLY@139..141 "}" [] [Whitespace(" ")] - 3: FROM_KW@141..146 "from" [] [Whitespace(" ")] - 4: JS_MODULE_SOURCE@146..157 - 0: JS_STRING_LITERAL@146..157 "\"foo.json\"" [] [Whitespace(" ")] - 5: JS_IMPORT_ASSERTION@157..178 - 0: ASSERT_KW@157..164 "assert" [] [Whitespace(" ")] - 1: L_CURLY@164..166 "{" [] [Whitespace(" ")] - 2: JS_IMPORT_ASSERTION_ENTRY_LIST@166..177 - 0: JS_IMPORT_ASSERTION_ENTRY@166..177 - 0: IDENT@166..169 "for" [] [] - 1: COLON@169..171 ":" [] [Whitespace(" ")] - 2: JS_STRING_LITERAL@171..177 "\"for\"" [] [Whitespace(" ")] - 3: R_CURLY@177..178 "}" [] [] - 2: (empty) - 4: JS_IMPORT@178..259 - 0: IMPORT_KW@178..186 "import" [Newline("\n")] [Whitespace(" ")] - 1: JS_IMPORT_DEFAULT_CLAUSE@186..258 - 0: (empty) - 1: JS_IDENTIFIER_BINDING@186..195 - 0: IDENT@186..195 "foo_json" [] [Whitespace(" ")] - 2: FROM_KW@195..200 "from" [] [Whitespace(" ")] - 3: JS_MODULE_SOURCE@200..211 - 0: JS_STRING_LITERAL@200..211 "\"foo.json\"" [] [Whitespace(" ")] - 4: JS_IMPORT_ASSERTION@211..258 - 0: ASSERT_KW@211..218 "assert" [] [Whitespace(" ")] - 1: L_CURLY@218..220 "{" [] [Whitespace(" ")] - 2: JS_IMPORT_ASSERTION_ENTRY_LIST@220..257 - 0: JS_IMPORT_ASSERTION_ENTRY@220..232 - 0: IDENT@220..224 "type" [] [] - 1: COLON@224..226 ":" [] [Whitespace(" ")] - 2: JS_STRING_LITERAL@226..232 "\"json\"" [] [] - 1: COMMA@232..234 "," [] [Whitespace(" ")] - 2: JS_IMPORT_ASSERTION_ENTRY@234..257 - 0: IDENT@234..248 "hasOwnProperty" [] [] - 1: COLON@248..250 ":" [] [Whitespace(" ")] - 2: JS_STRING_LITERAL@250..257 "\"true\"" [] [Whitespace(" ")] - 3: R_CURLY@257..258 "}" [] [] - 2: SEMICOLON@258..259 ";" [] [] - 5: JS_IMPORT@259..294 - 0: IMPORT_KW@259..267 "import" [Newline("\n")] [Whitespace(" ")] - 1: JS_IMPORT_BARE_CLAUSE@267..294 - 0: JS_MODULE_SOURCE@267..271 - 0: JS_STRING_LITERAL@267..271 "\"x\"" [] [Whitespace(" ")] - 1: JS_IMPORT_ASSERTION@271..294 - 0: ASSERT_KW@271..277 "assert" [] [] - 1: L_CURLY@277..280 "{" [Newline("\n")] [Whitespace(" ")] - 2: JS_IMPORT_ASSERTION_ENTRY_LIST@280..293 - 0: JS_IMPORT_ASSERTION_ENTRY@280..293 - 0: IDENT@280..284 "type" [] [] - 1: COLON@284..286 ":" [] [Whitespace(" ")] - 2: JS_STRING_LITERAL@286..293 "\"json\"" [] [Whitespace(" ")] - 3: R_CURLY@293..294 "}" [] [] - 2: (empty) - 3: EOF@294..295 "" [Newline("\n")] [] diff --git a/crates/rome_js_parser/test_data/inline/ok/import_attribute.js b/crates/rome_js_parser/test_data/inline/ok/import_attribute.js new file mode 100644 index 000000000000..9e396ebdb732 --- /dev/null +++ b/crates/rome_js_parser/test_data/inline/ok/import_attribute.js @@ -0,0 +1,7 @@ +import "x" with { type: "json" } +import "foo" with { "type": "json" }; +import foo from "foo.json" with { type: "json" }; +import {test} from "foo.json" with { for: "for" } +import foo_json from "foo.json" with { type: "json", hasOwnProperty: "true" }; +import "x" with +{ type: "json" } diff --git a/crates/rome_js_parser/test_data/inline/ok/import_attribute.rast b/crates/rome_js_parser/test_data/inline/ok/import_attribute.rast new file mode 100644 index 000000000000..e013b80e4405 --- /dev/null +++ b/crates/rome_js_parser/test_data/inline/ok/import_attribute.rast @@ -0,0 +1,284 @@ +JsModule { + interpreter_token: missing (optional), + directives: JsDirectiveList [], + items: JsModuleItemList [ + JsImport { + import_token: IMPORT_KW@0..7 "import" [] [Whitespace(" ")], + import_clause: JsImportBareClause { + source: JsModuleSource { + value_token: JS_STRING_LITERAL@7..11 "\"x\"" [] [Whitespace(" ")], + }, + attribute: JsImportAttribute { + with_token: WITH_KW@11..16 "with" [] [Whitespace(" ")], + l_curly_token: L_CURLY@16..18 "{" [] [Whitespace(" ")], + attributes: JsImportAttributeEntryList [ + JsImportAttributeEntry { + key: IDENT@18..22 "type" [] [], + colon_token: COLON@22..24 ":" [] [Whitespace(" ")], + value_token: JS_STRING_LITERAL@24..31 "\"json\"" [] [Whitespace(" ")], + }, + ], + r_curly_token: R_CURLY@31..32 "}" [] [], + }, + }, + semicolon_token: missing (optional), + }, + JsImport { + import_token: IMPORT_KW@32..40 "import" [Newline("\n")] [Whitespace(" ")], + import_clause: JsImportBareClause { + source: JsModuleSource { + value_token: JS_STRING_LITERAL@40..46 "\"foo\"" [] [Whitespace(" ")], + }, + attribute: JsImportAttribute { + with_token: WITH_KW@46..51 "with" [] [Whitespace(" ")], + l_curly_token: L_CURLY@51..53 "{" [] [Whitespace(" ")], + 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(" ")], + }, + ], + r_curly_token: R_CURLY@68..69 "}" [] [], + }, + }, + semicolon_token: SEMICOLON@69..70 ";" [] [], + }, + JsImport { + import_token: IMPORT_KW@70..78 "import" [Newline("\n")] [Whitespace(" ")], + import_clause: JsImportDefaultClause { + type_token: missing (optional), + local_name: JsIdentifierBinding { + name_token: IDENT@78..82 "foo" [] [Whitespace(" ")], + }, + from_token: FROM_KW@82..87 "from" [] [Whitespace(" ")], + source: JsModuleSource { + value_token: JS_STRING_LITERAL@87..98 "\"foo.json\"" [] [Whitespace(" ")], + }, + attribute: JsImportAttribute { + with_token: WITH_KW@98..103 "with" [] [Whitespace(" ")], + l_curly_token: L_CURLY@103..105 "{" [] [Whitespace(" ")], + attributes: JsImportAttributeEntryList [ + JsImportAttributeEntry { + key: IDENT@105..109 "type" [] [], + colon_token: COLON@109..111 ":" [] [Whitespace(" ")], + value_token: JS_STRING_LITERAL@111..118 "\"json\"" [] [Whitespace(" ")], + }, + ], + r_curly_token: R_CURLY@118..119 "}" [] [], + }, + }, + semicolon_token: SEMICOLON@119..120 ";" [] [], + }, + JsImport { + import_token: IMPORT_KW@120..128 "import" [Newline("\n")] [Whitespace(" ")], + import_clause: JsImportNamedClause { + type_token: missing (optional), + default_specifier: missing (optional), + named_import: JsNamedImportSpecifiers { + l_curly_token: L_CURLY@128..129 "{" [] [], + specifiers: JsNamedImportSpecifierList [ + JsShorthandNamedImportSpecifier { + type_token: missing (optional), + local_name: JsIdentifierBinding { + name_token: IDENT@129..133 "test" [] [], + }, + }, + ], + r_curly_token: R_CURLY@133..135 "}" [] [Whitespace(" ")], + }, + from_token: FROM_KW@135..140 "from" [] [Whitespace(" ")], + source: JsModuleSource { + value_token: JS_STRING_LITERAL@140..151 "\"foo.json\"" [] [Whitespace(" ")], + }, + attribute: JsImportAttribute { + with_token: WITH_KW@151..156 "with" [] [Whitespace(" ")], + l_curly_token: L_CURLY@156..158 "{" [] [Whitespace(" ")], + attributes: JsImportAttributeEntryList [ + JsImportAttributeEntry { + key: IDENT@158..161 "for" [] [], + colon_token: COLON@161..163 ":" [] [Whitespace(" ")], + value_token: JS_STRING_LITERAL@163..169 "\"for\"" [] [Whitespace(" ")], + }, + ], + r_curly_token: R_CURLY@169..170 "}" [] [], + }, + }, + semicolon_token: missing (optional), + }, + JsImport { + import_token: IMPORT_KW@170..178 "import" [Newline("\n")] [Whitespace(" ")], + import_clause: JsImportDefaultClause { + type_token: missing (optional), + local_name: JsIdentifierBinding { + name_token: IDENT@178..187 "foo_json" [] [Whitespace(" ")], + }, + from_token: FROM_KW@187..192 "from" [] [Whitespace(" ")], + source: JsModuleSource { + value_token: JS_STRING_LITERAL@192..203 "\"foo.json\"" [] [Whitespace(" ")], + }, + attribute: JsImportAttribute { + with_token: WITH_KW@203..208 "with" [] [Whitespace(" ")], + l_curly_token: L_CURLY@208..210 "{" [] [Whitespace(" ")], + 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(" ")], + JsImportAttributeEntry { + key: IDENT@224..238 "hasOwnProperty" [] [], + colon_token: COLON@238..240 ":" [] [Whitespace(" ")], + value_token: JS_STRING_LITERAL@240..247 "\"true\"" [] [Whitespace(" ")], + }, + ], + r_curly_token: R_CURLY@247..248 "}" [] [], + }, + }, + semicolon_token: SEMICOLON@248..249 ";" [] [], + }, + JsImport { + import_token: IMPORT_KW@249..257 "import" [Newline("\n")] [Whitespace(" ")], + import_clause: JsImportBareClause { + source: JsModuleSource { + value_token: JS_STRING_LITERAL@257..261 "\"x\"" [] [Whitespace(" ")], + }, + attribute: JsImportAttribute { + with_token: WITH_KW@261..265 "with" [] [], + l_curly_token: L_CURLY@265..268 "{" [Newline("\n")] [Whitespace(" ")], + attributes: JsImportAttributeEntryList [ + JsImportAttributeEntry { + key: IDENT@268..272 "type" [] [], + colon_token: COLON@272..274 ":" [] [Whitespace(" ")], + value_token: JS_STRING_LITERAL@274..281 "\"json\"" [] [Whitespace(" ")], + }, + ], + r_curly_token: R_CURLY@281..282 "}" [] [], + }, + }, + semicolon_token: missing (optional), + }, + ], + eof_token: EOF@282..283 "" [Newline("\n")] [], +} + +0: JS_MODULE@0..283 + 0: (empty) + 1: JS_DIRECTIVE_LIST@0..0 + 2: JS_MODULE_ITEM_LIST@0..282 + 0: JS_IMPORT@0..32 + 0: IMPORT_KW@0..7 "import" [] [Whitespace(" ")] + 1: JS_IMPORT_BARE_CLAUSE@7..32 + 0: JS_MODULE_SOURCE@7..11 + 0: JS_STRING_LITERAL@7..11 "\"x\"" [] [Whitespace(" ")] + 1: JS_IMPORT_ATTRIBUTE@11..32 + 0: WITH_KW@11..16 "with" [] [Whitespace(" ")] + 1: L_CURLY@16..18 "{" [] [Whitespace(" ")] + 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(" ")] + 3: R_CURLY@31..32 "}" [] [] + 2: (empty) + 1: JS_IMPORT@32..70 + 0: IMPORT_KW@32..40 "import" [Newline("\n")] [Whitespace(" ")] + 1: JS_IMPORT_BARE_CLAUSE@40..69 + 0: JS_MODULE_SOURCE@40..46 + 0: JS_STRING_LITERAL@40..46 "\"foo\"" [] [Whitespace(" ")] + 1: JS_IMPORT_ATTRIBUTE@46..69 + 0: WITH_KW@46..51 "with" [] [Whitespace(" ")] + 1: L_CURLY@51..53 "{" [] [Whitespace(" ")] + 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(" ")] + 3: R_CURLY@68..69 "}" [] [] + 2: SEMICOLON@69..70 ";" [] [] + 2: JS_IMPORT@70..120 + 0: IMPORT_KW@70..78 "import" [Newline("\n")] [Whitespace(" ")] + 1: JS_IMPORT_DEFAULT_CLAUSE@78..119 + 0: (empty) + 1: JS_IDENTIFIER_BINDING@78..82 + 0: IDENT@78..82 "foo" [] [Whitespace(" ")] + 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_ATTRIBUTE@98..119 + 0: WITH_KW@98..103 "with" [] [Whitespace(" ")] + 1: L_CURLY@103..105 "{" [] [Whitespace(" ")] + 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(" ")] + 3: R_CURLY@118..119 "}" [] [] + 2: SEMICOLON@119..120 ";" [] [] + 3: JS_IMPORT@120..170 + 0: IMPORT_KW@120..128 "import" [Newline("\n")] [Whitespace(" ")] + 1: JS_IMPORT_NAMED_CLAUSE@128..170 + 0: (empty) + 1: (empty) + 2: JS_NAMED_IMPORT_SPECIFIERS@128..135 + 0: L_CURLY@128..129 "{" [] [] + 1: JS_NAMED_IMPORT_SPECIFIER_LIST@129..133 + 0: JS_SHORTHAND_NAMED_IMPORT_SPECIFIER@129..133 + 0: (empty) + 1: JS_IDENTIFIER_BINDING@129..133 + 0: IDENT@129..133 "test" [] [] + 2: R_CURLY@133..135 "}" [] [Whitespace(" ")] + 3: FROM_KW@135..140 "from" [] [Whitespace(" ")] + 4: JS_MODULE_SOURCE@140..151 + 0: JS_STRING_LITERAL@140..151 "\"foo.json\"" [] [Whitespace(" ")] + 5: JS_IMPORT_ATTRIBUTE@151..170 + 0: WITH_KW@151..156 "with" [] [Whitespace(" ")] + 1: L_CURLY@156..158 "{" [] [Whitespace(" ")] + 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(" ")] + 3: R_CURLY@169..170 "}" [] [] + 2: (empty) + 4: JS_IMPORT@170..249 + 0: IMPORT_KW@170..178 "import" [Newline("\n")] [Whitespace(" ")] + 1: JS_IMPORT_DEFAULT_CLAUSE@178..248 + 0: (empty) + 1: JS_IDENTIFIER_BINDING@178..187 + 0: IDENT@178..187 "foo_json" [] [Whitespace(" ")] + 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_ATTRIBUTE@203..248 + 0: WITH_KW@203..208 "with" [] [Whitespace(" ")] + 1: L_CURLY@208..210 "{" [] [Whitespace(" ")] + 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_ATTRIBUTE_ENTRY@224..247 + 0: IDENT@224..238 "hasOwnProperty" [] [] + 1: COLON@238..240 ":" [] [Whitespace(" ")] + 2: JS_STRING_LITERAL@240..247 "\"true\"" [] [Whitespace(" ")] + 3: R_CURLY@247..248 "}" [] [] + 2: SEMICOLON@248..249 ";" [] [] + 5: JS_IMPORT@249..282 + 0: IMPORT_KW@249..257 "import" [Newline("\n")] [Whitespace(" ")] + 1: JS_IMPORT_BARE_CLAUSE@257..282 + 0: JS_MODULE_SOURCE@257..261 + 0: JS_STRING_LITERAL@257..261 "\"x\"" [] [Whitespace(" ")] + 1: JS_IMPORT_ATTRIBUTE@261..282 + 0: WITH_KW@261..265 "with" [] [] + 1: L_CURLY@265..268 "{" [Newline("\n")] [Whitespace(" ")] + 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(" ")] + 3: R_CURLY@281..282 "}" [] [] + 2: (empty) + 3: EOF@282..283 "" [Newline("\n")] [] diff --git a/crates/rome_js_parser/test_data/inline/ok/import_bare_clause.rast b/crates/rome_js_parser/test_data/inline/ok/import_bare_clause.rast index dcc825107461..28197e17e16a 100644 --- a/crates/rome_js_parser/test_data/inline/ok/import_bare_clause.rast +++ b/crates/rome_js_parser/test_data/inline/ok/import_bare_clause.rast @@ -8,7 +8,7 @@ JsModule { source: JsModuleSource { value_token: JS_STRING_LITERAL@7..13 "\"test\"" [] [], }, - assertion: missing (optional), + attribute: missing (optional), }, semicolon_token: SEMICOLON@13..14 ";" [] [], }, @@ -18,7 +18,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/rome_js_parser/test_data/inline/ok/import_decl.rast b/crates/rome_js_parser/test_data/inline/ok/import_decl.rast index 4bad1615e1e2..aa58c059192f 100644 --- a/crates/rome_js_parser/test_data/inline/ok/import_decl.rast +++ b/crates/rome_js_parser/test_data/inline/ok/import_decl.rast @@ -15,7 +15,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/rome_js_parser/test_data/inline/ok/import_default_clause.rast b/crates/rome_js_parser/test_data/inline/ok/import_default_clause.rast index e062bf4264fd..eb6f1a65b4ab 100644 --- a/crates/rome_js_parser/test_data/inline/ok/import_default_clause.rast +++ b/crates/rome_js_parser/test_data/inline/ok/import_default_clause.rast @@ -13,7 +13,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/rome_js_parser/test_data/inline/ok/import_named_clause.rast b/crates/rome_js_parser/test_data/inline/ok/import_named_clause.rast index f54b7c55ffe1..f61ca77cc7bf 100644 --- a/crates/rome_js_parser/test_data/inline/ok/import_named_clause.rast +++ b/crates/rome_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 ";" [] [], }, @@ -56,7 +56,7 @@ JsModule { source: JsModuleSource { value_token: JS_STRING_LITERAL@45..48 "\"b\"" [] [], }, - assertion: missing (optional), + attribute: missing (optional), }, semicolon_token: SEMICOLON@48..49 ";" [] [], }, @@ -86,7 +86,7 @@ JsModule { source: JsModuleSource { value_token: JS_STRING_LITERAL@71..74 "\"b\"" [] [], }, - assertion: missing (optional), + attribute: missing (optional), }, semicolon_token: SEMICOLON@74..75 ";" [] [], }, @@ -111,7 +111,7 @@ JsModule { source: JsModuleSource { value_token: JS_STRING_LITERAL@102..105 "\"c\"" [] [], }, - assertion: missing (optional), + attribute: missing (optional), }, semicolon_token: SEMICOLON@105..106 ";" [] [], }, @@ -162,7 +162,7 @@ JsModule { source: JsModuleSource { value_token: JS_STRING_LITERAL@158..161 "\"b\"" [] [], }, - assertion: missing (optional), + attribute: missing (optional), }, semicolon_token: SEMICOLON@161..162 ";" [] [], }, diff --git a/crates/rome_js_parser/test_data/inline/ok/module.rast b/crates/rome_js_parser/test_data/inline/ok/module.rast index b449a3e981a6..fcf3c19d6450 100644 --- a/crates/rome_js_parser/test_data/inline/ok/module.rast +++ b/crates/rome_js_parser/test_data/inline/ok/module.rast @@ -13,7 +13,7 @@ JsModule { source: JsModuleSource { value_token: JS_STRING_LITERAL@14..17 "\"b\"" [] [], }, - assertion: missing (optional), + attribute: missing (optional), }, semicolon_token: SEMICOLON@17..18 ";" [] [], }, @@ -72,7 +72,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/rome_js_parser/test_data/inline/ok/ts_export_named_from_specifier_with_type.rast b/crates/rome_js_parser/test_data/inline/ok/ts_export_named_from_specifier_with_type.rast index c0024e271bb5..a4d455a3c731 100644 --- a/crates/rome_js_parser/test_data/inline/ok/ts_export_named_from_specifier_with_type.rast +++ b/crates/rome_js_parser/test_data/inline/ok/ts_export_named_from_specifier_with_type.rast @@ -21,7 +21,7 @@ JsModule { source: JsModuleSource { value_token: JS_STRING_LITERAL@23..26 "\"a\"" [] [], }, - assertion: missing (optional), + attribute: missing (optional), semicolon_token: missing (optional), }, }, @@ -44,7 +44,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/rome_js_parser/test_data/inline/ok/ts_export_type_named_from.rast b/crates/rome_js_parser/test_data/inline/ok/ts_export_type_named_from.rast index d775627d6b8a..c44f0f8cd204 100644 --- a/crates/rome_js_parser/test_data/inline/ok/ts_export_type_named_from.rast +++ b/crates/rome_js_parser/test_data/inline/ok/ts_export_type_named_from.rast @@ -21,7 +21,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/rome_js_parser/test_data/inline/ok/ts_import_clause_types.rast b/crates/rome_js_parser/test_data/inline/ok/ts_import_clause_types.rast index cc5887a5623d..92f576466bc4 100644 --- a/crates/rome_js_parser/test_data/inline/ok/ts_import_clause_types.rast +++ b/crates/rome_js_parser/test_data/inline/ok/ts_import_clause_types.rast @@ -13,7 +13,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")], }, @@ -28,7 +28,7 @@ JsModule { source: JsModuleSource { value_token: JS_STRING_LITERAL@61..68 "\"./mod\"" [] [], }, - assertion: missing (optional), + attribute: missing (optional), }, semicolon_token: SEMICOLON@68..69 ";" [] [], }, @@ -45,7 +45,7 @@ JsModule { source: JsModuleSource { value_token: JS_STRING_LITERAL@97..104 "\"./mod\"" [] [], }, - assertion: missing (optional), + attribute: missing (optional), }, semicolon_token: SEMICOLON@104..105 ";" [] [], }, @@ -70,7 +70,7 @@ JsModule { source: JsModuleSource { value_token: JS_STRING_LITERAL@132..137 "\"mod\"" [] [], }, - assertion: missing (optional), + attribute: missing (optional), }, semicolon_token: SEMICOLON@137..138 ";" [] [], }, diff --git a/crates/rome_js_parser/test_data/inline/ok/ts_named_import_specifier_with_type.rast b/crates/rome_js_parser/test_data/inline/ok/ts_named_import_specifier_with_type.rast index 9efa5619dfbf..7fc72c659404 100644 --- a/crates/rome_js_parser/test_data/inline/ok/ts_named_import_specifier_with_type.rast +++ b/crates/rome_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 ";" [] [], }, @@ -59,7 +59,7 @@ JsModule { source: JsModuleSource { value_token: JS_STRING_LITERAL@69..76 "\"./mod\"" [] [], }, - assertion: missing (optional), + attribute: missing (optional), }, semicolon_token: missing (optional), }, @@ -88,7 +88,7 @@ JsModule { source: JsModuleSource { value_token: JS_STRING_LITERAL@104..111 "\"./mod\"" [] [], }, - assertion: missing (optional), + attribute: missing (optional), }, semicolon_token: SEMICOLON@111..112 ";" [] [], }, @@ -117,7 +117,7 @@ JsModule { source: JsModuleSource { value_token: JS_STRING_LITERAL@143..150 "\"./mod\"" [] [], }, - assertion: missing (optional), + attribute: missing (optional), }, semicolon_token: missing (optional), }, @@ -146,7 +146,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/rome_js_syntax/src/generated/kind.rs b/crates/rome_js_syntax/src/generated/kind.rs index f5c94bc90ce0..506843bff85c 100644 --- a/crates/rome_js_syntax/src/generated/kind.rs +++ b/crates/rome_js_syntax/src/generated/kind.rs @@ -119,7 +119,6 @@ pub enum JsSyntaxKind { AS_KW, SATISFIES_KW, ASSERTS_KW, - ASSERT_KW, ANY_KW, ASYNC_KW, AWAIT_KW, @@ -343,9 +342,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, @@ -498,7 +497,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, @@ -549,7 +548,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 | TS_UNION_TYPE_VARIANT_LIST @@ -622,7 +621,6 @@ impl JsSyntaxKind { "as" => AS_KW, "satisfies" => SATISFIES_KW, "asserts" => ASSERTS_KW, - "assert" => ASSERT_KW, "any" => ANY_KW, "async" => ASYNC_KW, "await" => AWAIT_KW, @@ -768,7 +766,6 @@ impl JsSyntaxKind { AS_KW => "as", SATISFIES_KW => "satisfies", ASSERTS_KW => "asserts", - ASSERT_KW => "assert", ANY_KW => "any", ASYNC_KW => "async", AWAIT_KW => "await", @@ -807,4 +804,4 @@ impl JsSyntaxKind { } #[doc = r" Utility macro for creating a SyntaxKind through simple macro syntax"] #[macro_export] -macro_rules ! T { [;] => { $ crate :: JsSyntaxKind :: SEMICOLON } ; [,] => { $ crate :: JsSyntaxKind :: COMMA } ; ['('] => { $ crate :: JsSyntaxKind :: L_PAREN } ; [')'] => { $ crate :: JsSyntaxKind :: R_PAREN } ; ['{'] => { $ crate :: JsSyntaxKind :: L_CURLY } ; ['}'] => { $ crate :: JsSyntaxKind :: R_CURLY } ; ['['] => { $ crate :: JsSyntaxKind :: L_BRACK } ; [']'] => { $ crate :: JsSyntaxKind :: R_BRACK } ; [<] => { $ crate :: JsSyntaxKind :: L_ANGLE } ; [>] => { $ crate :: JsSyntaxKind :: R_ANGLE } ; [~] => { $ crate :: JsSyntaxKind :: TILDE } ; [?] => { $ crate :: JsSyntaxKind :: QUESTION } ; [??] => { $ crate :: JsSyntaxKind :: QUESTION2 } ; [?.] => { $ crate :: JsSyntaxKind :: QUESTIONDOT } ; [&] => { $ crate :: JsSyntaxKind :: AMP } ; [|] => { $ crate :: JsSyntaxKind :: PIPE } ; [+] => { $ crate :: JsSyntaxKind :: PLUS } ; [++] => { $ crate :: JsSyntaxKind :: PLUS2 } ; [*] => { $ crate :: JsSyntaxKind :: STAR } ; [**] => { $ crate :: JsSyntaxKind :: STAR2 } ; [/] => { $ crate :: JsSyntaxKind :: SLASH } ; [^] => { $ crate :: JsSyntaxKind :: CARET } ; [%] => { $ crate :: JsSyntaxKind :: PERCENT } ; [.] => { $ crate :: JsSyntaxKind :: DOT } ; [...] => { $ crate :: JsSyntaxKind :: DOT3 } ; [:] => { $ crate :: JsSyntaxKind :: COLON } ; [=] => { $ crate :: JsSyntaxKind :: EQ } ; [==] => { $ crate :: JsSyntaxKind :: EQ2 } ; [===] => { $ crate :: JsSyntaxKind :: EQ3 } ; [=>] => { $ crate :: JsSyntaxKind :: FAT_ARROW } ; [!] => { $ crate :: JsSyntaxKind :: BANG } ; [!=] => { $ crate :: JsSyntaxKind :: NEQ } ; [!==] => { $ crate :: JsSyntaxKind :: NEQ2 } ; [-] => { $ crate :: JsSyntaxKind :: MINUS } ; [--] => { $ crate :: JsSyntaxKind :: MINUS2 } ; [<=] => { $ crate :: JsSyntaxKind :: LTEQ } ; [>=] => { $ crate :: JsSyntaxKind :: GTEQ } ; [+=] => { $ crate :: JsSyntaxKind :: PLUSEQ } ; [-=] => { $ crate :: JsSyntaxKind :: MINUSEQ } ; [|=] => { $ crate :: JsSyntaxKind :: PIPEEQ } ; [&=] => { $ crate :: JsSyntaxKind :: AMPEQ } ; [^=] => { $ crate :: JsSyntaxKind :: CARETEQ } ; [/=] => { $ crate :: JsSyntaxKind :: SLASHEQ } ; [*=] => { $ crate :: JsSyntaxKind :: STAREQ } ; [%=] => { $ crate :: JsSyntaxKind :: PERCENTEQ } ; [&&] => { $ crate :: JsSyntaxKind :: AMP2 } ; [||] => { $ crate :: JsSyntaxKind :: PIPE2 } ; [<<] => { $ crate :: JsSyntaxKind :: SHL } ; [>>] => { $ crate :: JsSyntaxKind :: SHR } ; [>>>] => { $ crate :: JsSyntaxKind :: USHR } ; [<<=] => { $ crate :: JsSyntaxKind :: SHLEQ } ; [>>=] => { $ crate :: JsSyntaxKind :: SHREQ } ; [>>>=] => { $ crate :: JsSyntaxKind :: USHREQ } ; [&&=] => { $ crate :: JsSyntaxKind :: AMP2EQ } ; [||=] => { $ crate :: JsSyntaxKind :: PIPE2EQ } ; [**=] => { $ crate :: JsSyntaxKind :: STAR2EQ } ; [??=] => { $ crate :: JsSyntaxKind :: QUESTION2EQ } ; [@] => { $ crate :: JsSyntaxKind :: AT } ; ['`'] => { $ crate :: JsSyntaxKind :: BACKTICK } ; [break] => { $ crate :: JsSyntaxKind :: BREAK_KW } ; [case] => { $ crate :: JsSyntaxKind :: CASE_KW } ; [catch] => { $ crate :: JsSyntaxKind :: CATCH_KW } ; [class] => { $ crate :: JsSyntaxKind :: CLASS_KW } ; [const] => { $ crate :: JsSyntaxKind :: CONST_KW } ; [continue] => { $ crate :: JsSyntaxKind :: CONTINUE_KW } ; [debugger] => { $ crate :: JsSyntaxKind :: DEBUGGER_KW } ; [default] => { $ crate :: JsSyntaxKind :: DEFAULT_KW } ; [delete] => { $ crate :: JsSyntaxKind :: DELETE_KW } ; [do] => { $ crate :: JsSyntaxKind :: DO_KW } ; [else] => { $ crate :: JsSyntaxKind :: ELSE_KW } ; [enum] => { $ crate :: JsSyntaxKind :: ENUM_KW } ; [export] => { $ crate :: JsSyntaxKind :: EXPORT_KW } ; [extends] => { $ crate :: JsSyntaxKind :: EXTENDS_KW } ; [false] => { $ crate :: JsSyntaxKind :: FALSE_KW } ; [finally] => { $ crate :: JsSyntaxKind :: FINALLY_KW } ; [for] => { $ crate :: JsSyntaxKind :: FOR_KW } ; [function] => { $ crate :: JsSyntaxKind :: FUNCTION_KW } ; [if] => { $ crate :: JsSyntaxKind :: IF_KW } ; [in] => { $ crate :: JsSyntaxKind :: IN_KW } ; [instanceof] => { $ crate :: JsSyntaxKind :: INSTANCEOF_KW } ; [import] => { $ crate :: JsSyntaxKind :: IMPORT_KW } ; [new] => { $ crate :: JsSyntaxKind :: NEW_KW } ; [null] => { $ crate :: JsSyntaxKind :: NULL_KW } ; [return] => { $ crate :: JsSyntaxKind :: RETURN_KW } ; [super] => { $ crate :: JsSyntaxKind :: SUPER_KW } ; [switch] => { $ crate :: JsSyntaxKind :: SWITCH_KW } ; [this] => { $ crate :: JsSyntaxKind :: THIS_KW } ; [throw] => { $ crate :: JsSyntaxKind :: THROW_KW } ; [try] => { $ crate :: JsSyntaxKind :: TRY_KW } ; [true] => { $ crate :: JsSyntaxKind :: TRUE_KW } ; [typeof] => { $ crate :: JsSyntaxKind :: TYPEOF_KW } ; [var] => { $ crate :: JsSyntaxKind :: VAR_KW } ; [void] => { $ crate :: JsSyntaxKind :: VOID_KW } ; [while] => { $ crate :: JsSyntaxKind :: WHILE_KW } ; [with] => { $ crate :: JsSyntaxKind :: WITH_KW } ; [implements] => { $ crate :: JsSyntaxKind :: IMPLEMENTS_KW } ; [interface] => { $ crate :: JsSyntaxKind :: INTERFACE_KW } ; [let] => { $ crate :: JsSyntaxKind :: LET_KW } ; [package] => { $ crate :: JsSyntaxKind :: PACKAGE_KW } ; [private] => { $ crate :: JsSyntaxKind :: PRIVATE_KW } ; [protected] => { $ crate :: JsSyntaxKind :: PROTECTED_KW } ; [public] => { $ crate :: JsSyntaxKind :: PUBLIC_KW } ; [static] => { $ crate :: JsSyntaxKind :: STATIC_KW } ; [yield] => { $ crate :: JsSyntaxKind :: YIELD_KW } ; [abstract] => { $ crate :: JsSyntaxKind :: ABSTRACT_KW } ; [accessor] => { $ crate :: JsSyntaxKind :: ACCESSOR_KW } ; [as] => { $ crate :: JsSyntaxKind :: AS_KW } ; [satisfies] => { $ crate :: JsSyntaxKind :: SATISFIES_KW } ; [asserts] => { $ crate :: JsSyntaxKind :: ASSERTS_KW } ; [assert] => { $ crate :: JsSyntaxKind :: ASSERT_KW } ; [any] => { $ crate :: JsSyntaxKind :: ANY_KW } ; [async] => { $ crate :: JsSyntaxKind :: ASYNC_KW } ; [await] => { $ crate :: JsSyntaxKind :: AWAIT_KW } ; [boolean] => { $ crate :: JsSyntaxKind :: BOOLEAN_KW } ; [constructor] => { $ crate :: JsSyntaxKind :: CONSTRUCTOR_KW } ; [declare] => { $ crate :: JsSyntaxKind :: DECLARE_KW } ; [get] => { $ crate :: JsSyntaxKind :: GET_KW } ; [infer] => { $ crate :: JsSyntaxKind :: INFER_KW } ; [is] => { $ crate :: JsSyntaxKind :: IS_KW } ; [keyof] => { $ crate :: JsSyntaxKind :: KEYOF_KW } ; [module] => { $ crate :: JsSyntaxKind :: MODULE_KW } ; [namespace] => { $ crate :: JsSyntaxKind :: NAMESPACE_KW } ; [never] => { $ crate :: JsSyntaxKind :: NEVER_KW } ; [readonly] => { $ crate :: JsSyntaxKind :: READONLY_KW } ; [require] => { $ crate :: JsSyntaxKind :: REQUIRE_KW } ; [number] => { $ crate :: JsSyntaxKind :: NUMBER_KW } ; [object] => { $ crate :: JsSyntaxKind :: OBJECT_KW } ; [set] => { $ crate :: JsSyntaxKind :: SET_KW } ; [string] => { $ crate :: JsSyntaxKind :: STRING_KW } ; [symbol] => { $ crate :: JsSyntaxKind :: SYMBOL_KW } ; [type] => { $ crate :: JsSyntaxKind :: TYPE_KW } ; [undefined] => { $ crate :: JsSyntaxKind :: UNDEFINED_KW } ; [unique] => { $ crate :: JsSyntaxKind :: UNIQUE_KW } ; [unknown] => { $ crate :: JsSyntaxKind :: UNKNOWN_KW } ; [from] => { $ crate :: JsSyntaxKind :: FROM_KW } ; [global] => { $ crate :: JsSyntaxKind :: GLOBAL_KW } ; [bigint] => { $ crate :: JsSyntaxKind :: BIGINT_KW } ; [override] => { $ crate :: JsSyntaxKind :: OVERRIDE_KW } ; [of] => { $ crate :: JsSyntaxKind :: OF_KW } ; [out] => { $ crate :: JsSyntaxKind :: OUT_KW } ; [ident] => { $ crate :: JsSyntaxKind :: IDENT } ; [EOF] => { $ crate :: JsSyntaxKind :: EOF } ; [#] => { $ crate :: JsSyntaxKind :: HASH } ; } +macro_rules ! T { [;] => { $ crate :: JsSyntaxKind :: SEMICOLON } ; [,] => { $ crate :: JsSyntaxKind :: COMMA } ; ['('] => { $ crate :: JsSyntaxKind :: L_PAREN } ; [')'] => { $ crate :: JsSyntaxKind :: R_PAREN } ; ['{'] => { $ crate :: JsSyntaxKind :: L_CURLY } ; ['}'] => { $ crate :: JsSyntaxKind :: R_CURLY } ; ['['] => { $ crate :: JsSyntaxKind :: L_BRACK } ; [']'] => { $ crate :: JsSyntaxKind :: R_BRACK } ; [<] => { $ crate :: JsSyntaxKind :: L_ANGLE } ; [>] => { $ crate :: JsSyntaxKind :: R_ANGLE } ; [~] => { $ crate :: JsSyntaxKind :: TILDE } ; [?] => { $ crate :: JsSyntaxKind :: QUESTION } ; [??] => { $ crate :: JsSyntaxKind :: QUESTION2 } ; [?.] => { $ crate :: JsSyntaxKind :: QUESTIONDOT } ; [&] => { $ crate :: JsSyntaxKind :: AMP } ; [|] => { $ crate :: JsSyntaxKind :: PIPE } ; [+] => { $ crate :: JsSyntaxKind :: PLUS } ; [++] => { $ crate :: JsSyntaxKind :: PLUS2 } ; [*] => { $ crate :: JsSyntaxKind :: STAR } ; [**] => { $ crate :: JsSyntaxKind :: STAR2 } ; [/] => { $ crate :: JsSyntaxKind :: SLASH } ; [^] => { $ crate :: JsSyntaxKind :: CARET } ; [%] => { $ crate :: JsSyntaxKind :: PERCENT } ; [.] => { $ crate :: JsSyntaxKind :: DOT } ; [...] => { $ crate :: JsSyntaxKind :: DOT3 } ; [:] => { $ crate :: JsSyntaxKind :: COLON } ; [=] => { $ crate :: JsSyntaxKind :: EQ } ; [==] => { $ crate :: JsSyntaxKind :: EQ2 } ; [===] => { $ crate :: JsSyntaxKind :: EQ3 } ; [=>] => { $ crate :: JsSyntaxKind :: FAT_ARROW } ; [!] => { $ crate :: JsSyntaxKind :: BANG } ; [!=] => { $ crate :: JsSyntaxKind :: NEQ } ; [!==] => { $ crate :: JsSyntaxKind :: NEQ2 } ; [-] => { $ crate :: JsSyntaxKind :: MINUS } ; [--] => { $ crate :: JsSyntaxKind :: MINUS2 } ; [<=] => { $ crate :: JsSyntaxKind :: LTEQ } ; [>=] => { $ crate :: JsSyntaxKind :: GTEQ } ; [+=] => { $ crate :: JsSyntaxKind :: PLUSEQ } ; [-=] => { $ crate :: JsSyntaxKind :: MINUSEQ } ; [|=] => { $ crate :: JsSyntaxKind :: PIPEEQ } ; [&=] => { $ crate :: JsSyntaxKind :: AMPEQ } ; [^=] => { $ crate :: JsSyntaxKind :: CARETEQ } ; [/=] => { $ crate :: JsSyntaxKind :: SLASHEQ } ; [*=] => { $ crate :: JsSyntaxKind :: STAREQ } ; [%=] => { $ crate :: JsSyntaxKind :: PERCENTEQ } ; [&&] => { $ crate :: JsSyntaxKind :: AMP2 } ; [||] => { $ crate :: JsSyntaxKind :: PIPE2 } ; [<<] => { $ crate :: JsSyntaxKind :: SHL } ; [>>] => { $ crate :: JsSyntaxKind :: SHR } ; [>>>] => { $ crate :: JsSyntaxKind :: USHR } ; [<<=] => { $ crate :: JsSyntaxKind :: SHLEQ } ; [>>=] => { $ crate :: JsSyntaxKind :: SHREQ } ; [>>>=] => { $ crate :: JsSyntaxKind :: USHREQ } ; [&&=] => { $ crate :: JsSyntaxKind :: AMP2EQ } ; [||=] => { $ crate :: JsSyntaxKind :: PIPE2EQ } ; [**=] => { $ crate :: JsSyntaxKind :: STAR2EQ } ; [??=] => { $ crate :: JsSyntaxKind :: QUESTION2EQ } ; [@] => { $ crate :: JsSyntaxKind :: AT } ; ['`'] => { $ crate :: JsSyntaxKind :: BACKTICK } ; [break] => { $ crate :: JsSyntaxKind :: BREAK_KW } ; [case] => { $ crate :: JsSyntaxKind :: CASE_KW } ; [catch] => { $ crate :: JsSyntaxKind :: CATCH_KW } ; [class] => { $ crate :: JsSyntaxKind :: CLASS_KW } ; [const] => { $ crate :: JsSyntaxKind :: CONST_KW } ; [continue] => { $ crate :: JsSyntaxKind :: CONTINUE_KW } ; [debugger] => { $ crate :: JsSyntaxKind :: DEBUGGER_KW } ; [default] => { $ crate :: JsSyntaxKind :: DEFAULT_KW } ; [delete] => { $ crate :: JsSyntaxKind :: DELETE_KW } ; [do] => { $ crate :: JsSyntaxKind :: DO_KW } ; [else] => { $ crate :: JsSyntaxKind :: ELSE_KW } ; [enum] => { $ crate :: JsSyntaxKind :: ENUM_KW } ; [export] => { $ crate :: JsSyntaxKind :: EXPORT_KW } ; [extends] => { $ crate :: JsSyntaxKind :: EXTENDS_KW } ; [false] => { $ crate :: JsSyntaxKind :: FALSE_KW } ; [finally] => { $ crate :: JsSyntaxKind :: FINALLY_KW } ; [for] => { $ crate :: JsSyntaxKind :: FOR_KW } ; [function] => { $ crate :: JsSyntaxKind :: FUNCTION_KW } ; [if] => { $ crate :: JsSyntaxKind :: IF_KW } ; [in] => { $ crate :: JsSyntaxKind :: IN_KW } ; [instanceof] => { $ crate :: JsSyntaxKind :: INSTANCEOF_KW } ; [import] => { $ crate :: JsSyntaxKind :: IMPORT_KW } ; [new] => { $ crate :: JsSyntaxKind :: NEW_KW } ; [null] => { $ crate :: JsSyntaxKind :: NULL_KW } ; [return] => { $ crate :: JsSyntaxKind :: RETURN_KW } ; [super] => { $ crate :: JsSyntaxKind :: SUPER_KW } ; [switch] => { $ crate :: JsSyntaxKind :: SWITCH_KW } ; [this] => { $ crate :: JsSyntaxKind :: THIS_KW } ; [throw] => { $ crate :: JsSyntaxKind :: THROW_KW } ; [try] => { $ crate :: JsSyntaxKind :: TRY_KW } ; [true] => { $ crate :: JsSyntaxKind :: TRUE_KW } ; [typeof] => { $ crate :: JsSyntaxKind :: TYPEOF_KW } ; [var] => { $ crate :: JsSyntaxKind :: VAR_KW } ; [void] => { $ crate :: JsSyntaxKind :: VOID_KW } ; [while] => { $ crate :: JsSyntaxKind :: WHILE_KW } ; [with] => { $ crate :: JsSyntaxKind :: WITH_KW } ; [implements] => { $ crate :: JsSyntaxKind :: IMPLEMENTS_KW } ; [interface] => { $ crate :: JsSyntaxKind :: INTERFACE_KW } ; [let] => { $ crate :: JsSyntaxKind :: LET_KW } ; [package] => { $ crate :: JsSyntaxKind :: PACKAGE_KW } ; [private] => { $ crate :: JsSyntaxKind :: PRIVATE_KW } ; [protected] => { $ crate :: JsSyntaxKind :: PROTECTED_KW } ; [public] => { $ crate :: JsSyntaxKind :: PUBLIC_KW } ; [static] => { $ crate :: JsSyntaxKind :: STATIC_KW } ; [yield] => { $ crate :: JsSyntaxKind :: YIELD_KW } ; [abstract] => { $ crate :: JsSyntaxKind :: ABSTRACT_KW } ; [accessor] => { $ crate :: JsSyntaxKind :: ACCESSOR_KW } ; [as] => { $ crate :: JsSyntaxKind :: AS_KW } ; [satisfies] => { $ crate :: JsSyntaxKind :: SATISFIES_KW } ; [asserts] => { $ crate :: JsSyntaxKind :: ASSERTS_KW } ; [any] => { $ crate :: JsSyntaxKind :: ANY_KW } ; [async] => { $ crate :: JsSyntaxKind :: ASYNC_KW } ; [await] => { $ crate :: JsSyntaxKind :: AWAIT_KW } ; [boolean] => { $ crate :: JsSyntaxKind :: BOOLEAN_KW } ; [constructor] => { $ crate :: JsSyntaxKind :: CONSTRUCTOR_KW } ; [declare] => { $ crate :: JsSyntaxKind :: DECLARE_KW } ; [get] => { $ crate :: JsSyntaxKind :: GET_KW } ; [infer] => { $ crate :: JsSyntaxKind :: INFER_KW } ; [is] => { $ crate :: JsSyntaxKind :: IS_KW } ; [keyof] => { $ crate :: JsSyntaxKind :: KEYOF_KW } ; [module] => { $ crate :: JsSyntaxKind :: MODULE_KW } ; [namespace] => { $ crate :: JsSyntaxKind :: NAMESPACE_KW } ; [never] => { $ crate :: JsSyntaxKind :: NEVER_KW } ; [readonly] => { $ crate :: JsSyntaxKind :: READONLY_KW } ; [require] => { $ crate :: JsSyntaxKind :: REQUIRE_KW } ; [number] => { $ crate :: JsSyntaxKind :: NUMBER_KW } ; [object] => { $ crate :: JsSyntaxKind :: OBJECT_KW } ; [set] => { $ crate :: JsSyntaxKind :: SET_KW } ; [string] => { $ crate :: JsSyntaxKind :: STRING_KW } ; [symbol] => { $ crate :: JsSyntaxKind :: SYMBOL_KW } ; [type] => { $ crate :: JsSyntaxKind :: TYPE_KW } ; [undefined] => { $ crate :: JsSyntaxKind :: UNDEFINED_KW } ; [unique] => { $ crate :: JsSyntaxKind :: UNIQUE_KW } ; [unknown] => { $ crate :: JsSyntaxKind :: UNKNOWN_KW } ; [from] => { $ crate :: JsSyntaxKind :: FROM_KW } ; [global] => { $ crate :: JsSyntaxKind :: GLOBAL_KW } ; [bigint] => { $ crate :: JsSyntaxKind :: BIGINT_KW } ; [override] => { $ crate :: JsSyntaxKind :: OVERRIDE_KW } ; [of] => { $ crate :: JsSyntaxKind :: OF_KW } ; [out] => { $ crate :: JsSyntaxKind :: OUT_KW } ; [ident] => { $ crate :: JsSyntaxKind :: IDENT } ; [EOF] => { $ crate :: JsSyntaxKind :: EOF } ; [#] => { $ crate :: JsSyntaxKind :: HASH } ; } diff --git a/crates/rome_js_syntax/src/generated/macros.rs b/crates/rome_js_syntax/src/generated/macros.rs index 93e9cf37be2a..85e6e9daad12 100644 --- a/crates/rome_js_syntax/src/generated/macros.rs +++ b/crates/rome_js_syntax/src/generated/macros.rs @@ -310,12 +310,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 => { @@ -1235,9 +1235,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 => { @@ -1307,9 +1307,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/rome_js_syntax/src/generated/nodes.rs b/crates/rome_js_syntax/src/generated/nodes.rs index b59b233ba63b..14b1a2781838 100644 --- a/crates/rome_js_syntax/src/generated/nodes.rs +++ b/crates/rome_js_syntax/src/generated/nodes.rs @@ -1965,7 +1965,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(), } } @@ -1980,7 +1980,7 @@ impl JsExportFromClause { pub fn source(&self) -> SyntaxResult { support::required_node(&self.syntax, 4usize) } - pub fn assertion(&self) -> Option { support::node(&self.syntax, 5usize) } + pub fn attribute(&self) -> Option { support::node(&self.syntax, 5usize) } pub fn semicolon_token(&self) -> Option { support::token(&self.syntax, 6usize) } } #[cfg(feature = "serde")] @@ -1999,7 +1999,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)] @@ -2070,7 +2070,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(), } } @@ -2090,7 +2090,7 @@ impl JsExportNamedFromClause { pub fn source(&self) -> SyntaxResult { support::required_node(&self.syntax, 5usize) } - pub fn assertion(&self) -> Option { support::node(&self.syntax, 6usize) } + pub fn attribute(&self) -> Option { support::node(&self.syntax, 6usize) } pub fn semicolon_token(&self) -> Option { support::token(&self.syntax, 7usize) } } #[cfg(feature = "serde")] @@ -2110,7 +2110,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)] @@ -3230,10 +3230,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"] @@ -3241,27 +3241,27 @@ impl JsImportAssertion { #[doc = r" or a match on [SyntaxNode::kind]"] #[inline] pub const unsafe fn new_unchecked(syntax: SyntaxNode) -> Self { Self { syntax } } - pub fn as_fields(&self) -> JsImportAssertionFields { - JsImportAssertionFields { - assert_token: self.assert_token(), + 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(), } } - pub fn assert_token(&self) -> SyntaxResult { + pub fn with_token(&self) -> SyntaxResult { support::required_token(&self.syntax, 0usize) } pub fn l_curly_token(&self) -> SyntaxResult { support::required_token(&self.syntax, 1usize) } - pub fn assertions(&self) -> JsImportAssertionEntryList { support::list(&self.syntax, 2usize) } + pub fn attributes(&self) -> JsImportAttributeEntryList { support::list(&self.syntax, 2usize) } pub fn r_curly_token(&self) -> SyntaxResult { support::required_token(&self.syntax, 3usize) } } #[cfg(feature = "serde")] -impl Serialize for JsImportAssertion { +impl Serialize for JsImportAttribute { fn serialize(&self, serializer: S) -> Result where S: Serializer, @@ -3270,17 +3270,17 @@ impl Serialize for JsImportAssertion { } } #[cfg_attr(feature = "serde", derive(Serialize))] -pub struct JsImportAssertionFields { - pub assert_token: SyntaxResult, +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"] @@ -3288,8 +3288,8 @@ impl JsImportAssertionEntry { #[doc = r" or a match on [SyntaxNode::kind]"] #[inline] 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(), @@ -3304,7 +3304,7 @@ impl JsImportAssertionEntry { } } #[cfg(feature = "serde")] -impl Serialize for JsImportAssertionEntry { +impl Serialize for JsImportAttributeEntry { fn serialize(&self, serializer: S) -> Result where S: Serializer, @@ -3313,7 +3313,7 @@ impl Serialize for JsImportAssertionEntry { } } #[cfg_attr(feature = "serde", derive(Serialize))] -pub struct JsImportAssertionEntryFields { +pub struct JsImportAttributeEntryFields { pub key: SyntaxResult, pub colon_token: SyntaxResult, pub value_token: SyntaxResult, @@ -3333,13 +3333,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 { support::node(&self.syntax, 1usize) } + pub fn attribute(&self) -> Option { support::node(&self.syntax, 1usize) } } #[cfg(feature = "serde")] impl Serialize for JsImportBareClause { @@ -3353,7 +3353,7 @@ impl Serialize for JsImportBareClause { #[cfg_attr(feature = "serde", derive(Serialize))] pub struct JsImportBareClauseFields { pub source: SyntaxResult, - pub assertion: Option, + pub attribute: Option, } #[derive(Clone, PartialEq, Eq, Hash)] pub struct JsImportCallExpression { @@ -3412,7 +3412,7 @@ impl JsImportDefaultClause { local_name: self.local_name(), from_token: self.from_token(), source: self.source(), - assertion: self.assertion(), + attribute: self.attribute(), } } pub fn type_token(&self) -> Option { support::token(&self.syntax, 0usize) } @@ -3425,7 +3425,7 @@ impl JsImportDefaultClause { pub fn source(&self) -> SyntaxResult { support::required_node(&self.syntax, 3usize) } - pub fn assertion(&self) -> Option { support::node(&self.syntax, 4usize) } + pub fn attribute(&self) -> Option { support::node(&self.syntax, 4usize) } } #[cfg(feature = "serde")] impl Serialize for JsImportDefaultClause { @@ -3442,7 +3442,7 @@ pub struct JsImportDefaultClauseFields { pub local_name: SyntaxResult, pub from_token: SyntaxResult, pub source: SyntaxResult, - pub assertion: Option, + pub attribute: Option, } #[derive(Clone, PartialEq, Eq, Hash)] pub struct JsImportMetaExpression { @@ -3507,7 +3507,7 @@ impl JsImportNamedClause { named_import: self.named_import(), from_token: self.from_token(), source: self.source(), - assertion: self.assertion(), + attribute: self.attribute(), } } pub fn type_token(&self) -> Option { support::token(&self.syntax, 0usize) } @@ -3523,7 +3523,7 @@ impl JsImportNamedClause { pub fn source(&self) -> SyntaxResult { support::required_node(&self.syntax, 4usize) } - pub fn assertion(&self) -> Option { support::node(&self.syntax, 5usize) } + pub fn attribute(&self) -> Option { support::node(&self.syntax, 5usize) } } #[cfg(feature = "serde")] impl Serialize for JsImportNamedClause { @@ -3541,7 +3541,7 @@ pub struct JsImportNamedClauseFields { pub named_import: SyntaxResult, pub from_token: SyntaxResult, pub source: SyntaxResult, - pub assertion: Option, + pub attribute: Option, } #[derive(Clone, PartialEq, Eq, Hash)] pub struct JsImportNamespaceClause { @@ -3563,7 +3563,7 @@ impl JsImportNamespaceClause { local_name: self.local_name(), from_token: self.from_token(), source: self.source(), - assertion: self.assertion(), + attribute: self.attribute(), } } pub fn type_token(&self) -> Option { support::token(&self.syntax, 0usize) } @@ -3582,7 +3582,7 @@ impl JsImportNamespaceClause { pub fn source(&self) -> SyntaxResult { support::required_node(&self.syntax, 5usize) } - pub fn assertion(&self) -> Option { support::node(&self.syntax, 6usize) } + pub fn attribute(&self) -> Option { support::node(&self.syntax, 6usize) } } #[cfg(feature = "serde")] impl Serialize for JsImportNamespaceClause { @@ -3601,7 +3601,7 @@ pub struct JsImportNamespaceClauseFields { pub local_name: SyntaxResult, pub from_token: SyntaxResult, pub source: SyntaxResult, - pub assertion: Option, + pub attribute: Option, } #[derive(Clone, PartialEq, Eq, Hash)] pub struct JsInExpression { @@ -13424,20 +13424,20 @@ impl AnyJsFunctionBody { } #[derive(Clone, PartialEq, Eq, Hash)] #[cfg_attr(feature = "serde", derive(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, } } @@ -16765,8 +16765,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", @@ -16859,8 +16859,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", @@ -17762,11 +17762,11 @@ impl From for SyntaxNode { impl From for SyntaxElement { fn from(n: JsImport) -> 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)); - fn can_cast(kind: SyntaxKind) -> bool { kind == JS_IMPORT_ASSERTION } + SyntaxKindSet::from_raw(RawSyntaxKind(JS_IMPORT_ATTRIBUTE as u16)); + fn can_cast(kind: SyntaxKind) -> bool { kind == JS_IMPORT_ATTRIBUTE } fn cast(syntax: SyntaxNode) -> Option { if Self::can_cast(syntax.kind()) { Some(Self { syntax }) @@ -17777,18 +17777,15 @@ impl AstNode for JsImportAssertion { fn syntax(&self) -> &SyntaxNode { &self.syntax } fn into_syntax(self) -> SyntaxNode { 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") - .field( - "assert_token", - &support::DebugSyntaxResult(self.assert_token()), - ) + 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()), @@ -17796,17 +17793,17 @@ impl std::fmt::Debug for JsImportAssertion { .finish() } } -impl From for SyntaxNode { - fn from(n: JsImportAssertion) -> SyntaxNode { n.syntax } +impl From for SyntaxNode { + fn from(n: JsImportAttribute) -> SyntaxNode { n.syntax } } -impl From for SyntaxElement { - fn from(n: JsImportAssertion) -> SyntaxElement { n.syntax.into() } +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)); - fn can_cast(kind: SyntaxKind) -> bool { kind == JS_IMPORT_ASSERTION_ENTRY } + SyntaxKindSet::from_raw(RawSyntaxKind(JS_IMPORT_ATTRIBUTE_ENTRY as u16)); + fn can_cast(kind: SyntaxKind) -> bool { kind == JS_IMPORT_ATTRIBUTE_ENTRY } fn cast(syntax: SyntaxNode) -> Option { if Self::can_cast(syntax.kind()) { Some(Self { syntax }) @@ -17817,9 +17814,9 @@ impl AstNode for JsImportAssertionEntry { fn syntax(&self) -> &SyntaxNode { &self.syntax } fn into_syntax(self) -> SyntaxNode { 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", @@ -17832,11 +17829,11 @@ impl std::fmt::Debug for JsImportAssertionEntry { .finish() } } -impl From for SyntaxNode { - fn from(n: JsImportAssertionEntry) -> SyntaxNode { n.syntax } +impl From for SyntaxNode { + fn from(n: JsImportAttributeEntry) -> SyntaxNode { n.syntax } } -impl From for SyntaxElement { - fn from(n: JsImportAssertionEntry) -> SyntaxElement { n.syntax.into() } +impl From for SyntaxElement { + fn from(n: JsImportAttributeEntry) -> SyntaxElement { n.syntax.into() } } impl AstNode for JsImportBareClause { type Language = Language; @@ -17858,8 +17855,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() } @@ -17928,8 +17925,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() } @@ -18006,8 +18003,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() } @@ -18046,8 +18043,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() } @@ -28123,35 +28120,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, }; @@ -28159,37 +28156,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() } @@ -32556,7 +32553,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) } @@ -33131,12 +33128,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) } @@ -34370,10 +34367,10 @@ impl From for SyntaxElement { } #[derive(Clone, PartialEq, Eq, Hash)] #[cfg_attr(feature = "serde", derive(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"] @@ -34383,11 +34380,11 @@ impl JsBogusImportAssertionEntry { pub const unsafe fn new_unchecked(syntax: SyntaxNode) -> Self { Self { syntax } } pub fn items(&self) -> SyntaxElementChildren { 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)); - fn can_cast(kind: SyntaxKind) -> bool { kind == JS_BOGUS_IMPORT_ASSERTION_ENTRY } + SyntaxKindSet::from_raw(RawSyntaxKind(JS_BOGUS_IMPORT_ATTRIBUTE_ENTRY as u16)); + fn can_cast(kind: SyntaxKind) -> bool { kind == JS_BOGUS_IMPORT_ATTRIBUTE_ENTRY } fn cast(syntax: SyntaxNode) -> Option { if Self::can_cast(syntax.kind()) { Some(Self { syntax }) @@ -34398,18 +34395,18 @@ impl AstNode for JsBogusImportAssertionEntry { fn syntax(&self) -> &SyntaxNode { &self.syntax } fn into_syntax(self) -> SyntaxNode { 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 { n.syntax } +impl From for SyntaxNode { + fn from(n: JsBogusImportAttributeEntry) -> SyntaxNode { n.syntax } } -impl From for SyntaxElement { - fn from(n: JsBogusImportAssertionEntry) -> SyntaxElement { n.syntax.into() } +impl From for SyntaxElement { + fn from(n: JsBogusImportAttributeEntry) -> SyntaxElement { n.syntax.into() } } #[derive(Clone, PartialEq, Eq, Hash)] #[cfg_attr(feature = "serde", derive(Serialize))] @@ -35318,10 +35315,10 @@ impl IntoIterator for &JsExportNamedSpecifierList { fn into_iter(self) -> Self::IntoIter { self.iter() } } #[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"] @@ -35334,14 +35331,14 @@ 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)); - fn can_cast(kind: SyntaxKind) -> bool { kind == JS_IMPORT_ASSERTION_ENTRY_LIST } - fn cast(syntax: SyntaxNode) -> Option { + SyntaxKindSet::from_raw(RawSyntaxKind(JS_IMPORT_ATTRIBUTE_ENTRY_LIST as u16)); + fn can_cast(kind: SyntaxKind) -> bool { kind == JS_IMPORT_ATTRIBUTE_ENTRY_LIST } + fn cast(syntax: SyntaxNode) -> Option { if Self::can_cast(syntax.kind()) { - Some(JsImportAssertionEntryList { + Some(JsImportAttributeEntryList { syntax_list: syntax.into_list(), }) } else { @@ -35352,7 +35349,7 @@ impl AstNode for JsImportAssertionEntryList { fn into_syntax(self) -> SyntaxNode { self.syntax_list.into_node() } } #[cfg(feature = "serde")] -impl Serialize for JsImportAssertionEntryList { +impl Serialize for JsImportAttributeEntryList { fn serialize(&self, serializer: S) -> Result where S: Serializer, @@ -35364,26 +35361,26 @@ 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 } fn into_syntax_list(self) -> SyntaxList { 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() } } #[derive(Clone, Eq, PartialEq, Hash)] diff --git a/crates/rome_js_syntax/src/generated/nodes_mut.rs b/crates/rome_js_syntax/src/generated/nodes_mut.rs index 1d441a2d0d95..a2bc844730e6 100644 --- a/crates/rome_js_syntax/src/generated/nodes_mut.rs +++ b/crates/rome_js_syntax/src/generated/nodes_mut.rs @@ -979,7 +979,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())), @@ -1061,7 +1061,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())), @@ -1726,8 +1726,8 @@ impl JsImport { ) } } -impl JsImportAssertion { - pub fn with_assert_token(self, element: SyntaxToken) -> Self { +impl JsImportAttribute { + pub fn with_with_token(self, element: SyntaxToken) -> Self { Self::unwrap_cast( self.syntax .splice_slots(0usize..=0usize, once(Some(element.into()))), @@ -1739,7 +1739,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()))), @@ -1752,7 +1752,7 @@ impl JsImportAssertion { ) } } -impl JsImportAssertionEntry { +impl JsImportAttributeEntry { pub fn with_key_token(self, element: SyntaxToken) -> Self { Self::unwrap_cast( self.syntax @@ -1779,7 +1779,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())), @@ -1825,7 +1825,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())), @@ -1883,7 +1883,7 @@ impl JsImportNamedClause { .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())), @@ -1927,7 +1927,7 @@ impl JsImportNamespaceClause { .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())), diff --git a/crates/rome_js_syntax/src/lib.rs b/crates/rome_js_syntax/src/lib.rs index df477d39b90d..c091393a1e4e 100644 --- a/crates/rome_js_syntax/src/lib.rs +++ b/crates/rome_js_syntax/src/lib.rs @@ -98,7 +98,7 @@ impl rome_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 @@ -115,7 +115,7 @@ impl rome_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 bd177c94f814..820962562561 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* @@ -1221,7 +1221,7 @@ AnyJsImportClause = // import "abcd" assert ... JsImportBareClause = source: JsModuleSource - assertion: JsImportAssertion? + attribute: JsImportAttribute? // import foo from "mod" // import type foo from "mod" @@ -1230,7 +1230,7 @@ JsImportDefaultClause = local_name: AnyJsBinding 'from' source: JsModuleSource - assertion: JsImportAssertion? + attribute: JsImportAttribute? // import * as foo from "mod"; // import type * as foo from "mod"; @@ -1241,7 +1241,7 @@ JsImportNamespaceClause = local_name: AnyJsBinding 'from' source: JsModuleSource - assertion: JsImportAssertion? + attribute: JsImportAttribute? // import { a, b: c } from "d" // ^^^^^^^^^^^^^^^^^^^^ @@ -1260,7 +1260,7 @@ JsImportNamedClause = named_import: AnyJsNamedImport 'from' source: JsModuleSource - assertion: JsImportAssertion? + attribute: JsImportAttribute? // import a, { b, c } from "d"; // ^^ @@ -1311,21 +1311,21 @@ JsShorthandNamedImportSpecifier = // import a from "mod" assert { type: "json" } // ^^^^^^^^^^^^^^^^^^^^^^^ -JsImportAssertion = - 'assert' +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" } +// import a from "mod" with { type: "json" } // ^^^^^^^^^^^^ -JsImportAssertionEntry = +JsImportAttributeEntry = key: ('ident' | 'js_string_literal') ':' value: 'js_string_literal' @@ -1462,7 +1462,7 @@ JsExportFromClause = export_as: JsExportAsClause? 'from' source: JsModuleSource - assertion: JsImportAssertion? + attribute: JsImportAttribute? ';'? // export { a } from "b"; @@ -1476,7 +1476,7 @@ JsExportNamedFromClause = '}' 'from' source: JsModuleSource - assertion: JsImportAssertion? + attribute: JsImportAttribute? ';'? JsExportNamedFromSpecifierList = (JsExportNamedFromSpecifier (',' JsExportNamedFromSpecifier)* ','?) diff --git a/xtask/codegen/src/kinds_src.rs b/xtask/codegen/src/kinds_src.rs index 5654634c1aac..c62cb903688f 100644 --- a/xtask/codegen/src/kinds_src.rs +++ b/xtask/codegen/src/kinds_src.rs @@ -132,7 +132,6 @@ pub const JS_KINDS_SRC: KindsSrc = KindsSrc { "as", "satisfies", "asserts", - "assert", "any", "async", "await", @@ -362,9 +361,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", @@ -520,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",