diff --git a/CHANGELOG.md b/CHANGELOG.md index 20b8719573b..52a62836ef0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -18,8 +18,18 @@ was defined [#4479](https://github.com/rome/tools/issues/4479) ### Editors ### Formatter + +#### Other changes + +- Revert [#4359](https://github.com/rome/tools/issues/4359) + ### Linter ### Parser + +#### Other changes + +- Revert [#4359](https://github.com/rome/tools/issues/4359) + ### 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 a9e2259fe78..81fb1783951 100644 --- a/crates/rome_js_factory/src/generated/node_factory.rs +++ b/crates/rome_js_factory/src/generated/node_factory.rs @@ -1019,7 +1019,7 @@ pub fn js_export_from_clause( source, type_token: None, export_as: None, - attribute: None, + assertion: None, semicolon_token: None, } } @@ -1029,7 +1029,7 @@ pub struct JsExportFromClauseBuilder { source: JsModuleSource, type_token: Option, export_as: Option, - attribute: Option, + assertion: Option, semicolon_token: Option, } impl JsExportFromClauseBuilder { @@ -1041,8 +1041,8 @@ impl JsExportFromClauseBuilder { self.export_as = Some(export_as); self } - pub fn with_attribute(mut self, attribute: JsImportAttribute) -> Self { - self.attribute = Some(attribute); + pub fn with_assertion(mut self, assertion: JsImportAssertion) -> Self { + self.assertion = Some(assertion); self } pub fn with_semicolon_token(mut self, semicolon_token: SyntaxToken) -> Self { @@ -1059,7 +1059,7 @@ impl JsExportFromClauseBuilder { .map(|token| SyntaxElement::Node(token.into_syntax())), Some(SyntaxElement::Token(self.from_token)), Some(SyntaxElement::Node(self.source.into_syntax())), - self.attribute + self.assertion .map(|token| SyntaxElement::Node(token.into_syntax())), self.semicolon_token .map(|token| SyntaxElement::Token(token)), @@ -1124,7 +1124,7 @@ pub fn js_export_named_from_clause( from_token, source, type_token: None, - attribute: None, + assertion: None, semicolon_token: None, } } @@ -1135,7 +1135,7 @@ pub struct JsExportNamedFromClauseBuilder { from_token: SyntaxToken, source: JsModuleSource, type_token: Option, - attribute: Option, + assertion: Option, semicolon_token: Option, } impl JsExportNamedFromClauseBuilder { @@ -1143,8 +1143,8 @@ impl JsExportNamedFromClauseBuilder { self.type_token = Some(type_token); self } - pub fn with_attribute(mut self, attribute: JsImportAttribute) -> Self { - self.attribute = Some(attribute); + pub fn with_assertion(mut self, assertion: JsImportAssertion) -> Self { + self.assertion = Some(assertion); self } pub fn with_semicolon_token(mut self, semicolon_token: SyntaxToken) -> Self { @@ -1161,7 +1161,7 @@ impl JsExportNamedFromClauseBuilder { Some(SyntaxElement::Token(self.r_curly_token)), Some(SyntaxElement::Token(self.from_token)), Some(SyntaxElement::Node(self.source.into_syntax())), - self.attribute + self.assertion .map(|token| SyntaxElement::Node(token.into_syntax())), self.semicolon_token .map(|token| SyntaxElement::Token(token)), @@ -1938,29 +1938,29 @@ impl JsImportBuilder { )) } } -pub fn js_import_attribute( - with_token: SyntaxToken, +pub fn js_import_assertion( + assertion_kind_token: SyntaxToken, l_curly_token: SyntaxToken, - attributes: JsImportAttributeEntryList, + assertions: JsImportAssertionEntryList, r_curly_token: SyntaxToken, -) -> JsImportAttribute { - JsImportAttribute::unwrap_cast(SyntaxNode::new_detached( - JsSyntaxKind::JS_IMPORT_ATTRIBUTE, +) -> JsImportAssertion { + JsImportAssertion::unwrap_cast(SyntaxNode::new_detached( + JsSyntaxKind::JS_IMPORT_ASSERTION, [ - Some(SyntaxElement::Token(with_token)), + Some(SyntaxElement::Token(assertion_kind_token)), Some(SyntaxElement::Token(l_curly_token)), - Some(SyntaxElement::Node(attributes.into_syntax())), + Some(SyntaxElement::Node(assertions.into_syntax())), Some(SyntaxElement::Token(r_curly_token)), ], )) } -pub fn js_import_attribute_entry( +pub fn js_import_assertion_entry( key_token: SyntaxToken, colon_token: SyntaxToken, value_token: SyntaxToken, -) -> JsImportAttributeEntry { - JsImportAttributeEntry::unwrap_cast(SyntaxNode::new_detached( - JsSyntaxKind::JS_IMPORT_ATTRIBUTE_ENTRY, +) -> JsImportAssertionEntry { + JsImportAssertionEntry::unwrap_cast(SyntaxNode::new_detached( + JsSyntaxKind::JS_IMPORT_ASSERTION_ENTRY, [ Some(SyntaxElement::Token(key_token)), Some(SyntaxElement::Token(colon_token)), @@ -1971,16 +1971,16 @@ pub fn js_import_attribute_entry( pub fn js_import_bare_clause(source: JsModuleSource) -> JsImportBareClauseBuilder { JsImportBareClauseBuilder { source, - attribute: None, + assertion: None, } } pub struct JsImportBareClauseBuilder { source: JsModuleSource, - attribute: Option, + assertion: Option, } impl JsImportBareClauseBuilder { - pub fn with_attribute(mut self, attribute: JsImportAttribute) -> Self { - self.attribute = Some(attribute); + pub fn with_assertion(mut self, assertion: JsImportAssertion) -> Self { + self.assertion = Some(assertion); self } pub fn build(self) -> JsImportBareClause { @@ -1988,7 +1988,7 @@ impl JsImportBareClauseBuilder { JsSyntaxKind::JS_IMPORT_BARE_CLAUSE, [ Some(SyntaxElement::Node(self.source.into_syntax())), - self.attribute + self.assertion .map(|token| SyntaxElement::Node(token.into_syntax())), ], )) @@ -2016,7 +2016,7 @@ pub fn js_import_default_clause( from_token, source, type_token: None, - attribute: None, + assertion: None, } } pub struct JsImportDefaultClauseBuilder { @@ -2024,15 +2024,15 @@ pub struct JsImportDefaultClauseBuilder { from_token: SyntaxToken, source: JsModuleSource, type_token: Option, - attribute: Option, + assertion: Option, } impl JsImportDefaultClauseBuilder { pub fn with_type_token(mut self, type_token: SyntaxToken) -> Self { self.type_token = Some(type_token); self } - pub fn with_attribute(mut self, attribute: JsImportAttribute) -> Self { - self.attribute = Some(attribute); + pub fn with_assertion(mut self, assertion: JsImportAssertion) -> Self { + self.assertion = Some(assertion); self } pub fn build(self) -> JsImportDefaultClause { @@ -2043,7 +2043,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.attribute + self.assertion .map(|token| SyntaxElement::Node(token.into_syntax())), ], )) @@ -2074,7 +2074,7 @@ pub fn js_import_named_clause( source, type_token: None, default_specifier: None, - attribute: None, + assertion: None, } } pub struct JsImportNamedClauseBuilder { @@ -2083,7 +2083,7 @@ pub struct JsImportNamedClauseBuilder { source: JsModuleSource, type_token: Option, default_specifier: Option, - attribute: Option, + assertion: Option, } impl JsImportNamedClauseBuilder { pub fn with_type_token(mut self, type_token: SyntaxToken) -> Self { @@ -2094,8 +2094,8 @@ impl JsImportNamedClauseBuilder { self.default_specifier = Some(default_specifier); self } - pub fn with_attribute(mut self, attribute: JsImportAttribute) -> Self { - self.attribute = Some(attribute); + pub fn with_assertion(mut self, assertion: JsImportAssertion) -> Self { + self.assertion = Some(assertion); self } pub fn build(self) -> JsImportNamedClause { @@ -2108,7 +2108,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.attribute + self.assertion .map(|token| SyntaxElement::Node(token.into_syntax())), ], )) @@ -2128,7 +2128,7 @@ pub fn js_import_namespace_clause( from_token, source, type_token: None, - attribute: None, + assertion: None, } } pub struct JsImportNamespaceClauseBuilder { @@ -2138,15 +2138,15 @@ pub struct JsImportNamespaceClauseBuilder { from_token: SyntaxToken, source: JsModuleSource, type_token: Option, - attribute: Option, + assertion: Option, } impl JsImportNamespaceClauseBuilder { pub fn with_type_token(mut self, type_token: SyntaxToken) -> Self { self.type_token = Some(type_token); self } - pub fn with_attribute(mut self, attribute: JsImportAttribute) -> Self { - self.attribute = Some(attribute); + pub fn with_assertion(mut self, assertion: JsImportAssertion) -> Self { + self.assertion = Some(assertion); self } pub fn build(self) -> JsImportNamespaceClause { @@ -2159,7 +2159,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.attribute + self.assertion .map(|token| SyntaxElement::Node(token.into_syntax())), ], )) @@ -6610,9 +6610,9 @@ where }), )) } -pub fn js_import_attribute_entry_list(items: I, separators: S) -> JsImportAttributeEntryList +pub fn js_import_assertion_entry_list(items: I, separators: S) -> JsImportAssertionEntryList where - I: IntoIterator, + I: IntoIterator, I::IntoIter: ExactSizeIterator, S: IntoIterator, S::IntoIter: ExactSizeIterator, @@ -6620,8 +6620,8 @@ where let mut items = items.into_iter(); let mut separators = separators.into_iter(); let length = items.len() + separators.len(); - JsImportAttributeEntryList::unwrap_cast(SyntaxNode::new_detached( - JsSyntaxKind::JS_IMPORT_ATTRIBUTE_ENTRY_LIST, + JsImportAssertionEntryList::unwrap_cast(SyntaxNode::new_detached( + JsSyntaxKind::JS_IMPORT_ASSERTION_ENTRY_LIST, (0..length).map(|index| { if index % 2 == 0 { Some(items.next()?.into_syntax().into()) @@ -7130,13 +7130,13 @@ where slots, )) } -pub fn js_bogus_import_attribute_entry(slots: I) -> JsBogusImportAttributeEntry +pub fn js_bogus_import_assertion_entry(slots: I) -> JsBogusImportAssertionEntry where I: IntoIterator>, I::IntoIter: ExactSizeIterator, { - JsBogusImportAttributeEntry::unwrap_cast(SyntaxNode::new_detached( - JsSyntaxKind::JS_BOGUS_IMPORT_ATTRIBUTE_ENTRY, + JsBogusImportAssertionEntry::unwrap_cast(SyntaxNode::new_detached( + JsSyntaxKind::JS_BOGUS_IMPORT_ASSERTION_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 4cf6634d9ce..388bd52abee 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_ATTRIBUTE_ENTRY + | JS_BOGUS_IMPORT_ASSERTION_ENTRY | JS_BOGUS_MEMBER | JS_BOGUS_NAMED_IMPORT_SPECIFIER | JS_BOGUS_PARAMETER @@ -1685,7 +1685,7 @@ impl SyntaxFactory for JsSyntaxFactory { } slots.next_slot(); if let Some(element) = ¤t_element { - if JsImportAttribute::can_cast(element.kind()) { + if JsImportAssertion::can_cast(element.kind()) { slots.mark_present(); current_element = elements.next(); } @@ -1800,7 +1800,7 @@ impl SyntaxFactory for JsSyntaxFactory { } slots.next_slot(); if let Some(element) = ¤t_element { - if JsImportAttribute::can_cast(element.kind()) { + if JsImportAssertion::can_cast(element.kind()) { slots.mark_present(); current_element = elements.next(); } @@ -2804,12 +2804,12 @@ impl SyntaxFactory for JsSyntaxFactory { } slots.into_node(JS_IMPORT, children) } - JS_IMPORT_ATTRIBUTE => { + JS_IMPORT_ASSERTION => { 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![with] { + if matches!(element.kind(), T![assert] | T![with]) { slots.mark_present(); current_element = elements.next(); } @@ -2823,7 +2823,7 @@ impl SyntaxFactory for JsSyntaxFactory { } slots.next_slot(); if let Some(element) = ¤t_element { - if JsImportAttributeEntryList::can_cast(element.kind()) { + if JsImportAssertionEntryList::can_cast(element.kind()) { slots.mark_present(); current_element = elements.next(); } @@ -2838,13 +2838,13 @@ impl SyntaxFactory for JsSyntaxFactory { slots.next_slot(); if current_element.is_some() { return RawSyntaxNode::new( - JS_IMPORT_ATTRIBUTE.to_bogus(), + JS_IMPORT_ASSERTION.to_bogus(), children.into_iter().map(Some), ); } - slots.into_node(JS_IMPORT_ATTRIBUTE, children) + slots.into_node(JS_IMPORT_ASSERTION, children) } - JS_IMPORT_ATTRIBUTE_ENTRY => { + JS_IMPORT_ASSERTION_ENTRY => { let mut elements = (&children).into_iter(); let mut slots: RawNodeSlots<3usize> = RawNodeSlots::default(); let mut current_element = elements.next(); @@ -2871,11 +2871,11 @@ impl SyntaxFactory for JsSyntaxFactory { slots.next_slot(); if current_element.is_some() { return RawSyntaxNode::new( - JS_IMPORT_ATTRIBUTE_ENTRY.to_bogus(), + JS_IMPORT_ASSERTION_ENTRY.to_bogus(), children.into_iter().map(Some), ); } - slots.into_node(JS_IMPORT_ATTRIBUTE_ENTRY, children) + slots.into_node(JS_IMPORT_ASSERTION_ENTRY, children) } JS_IMPORT_BARE_CLAUSE => { let mut elements = (&children).into_iter(); @@ -2889,7 +2889,7 @@ impl SyntaxFactory for JsSyntaxFactory { } slots.next_slot(); if let Some(element) = ¤t_element { - if JsImportAttribute::can_cast(element.kind()) { + if JsImportAssertion::can_cast(element.kind()) { slots.mark_present(); current_element = elements.next(); } @@ -2962,7 +2962,7 @@ impl SyntaxFactory for JsSyntaxFactory { } slots.next_slot(); if let Some(element) = ¤t_element { - if JsImportAttribute::can_cast(element.kind()) { + if JsImportAssertion::can_cast(element.kind()) { slots.mark_present(); current_element = elements.next(); } @@ -3049,7 +3049,7 @@ impl SyntaxFactory for JsSyntaxFactory { } slots.next_slot(); if let Some(element) = ¤t_element { - if JsImportAttribute::can_cast(element.kind()) { + if JsImportAssertion::can_cast(element.kind()) { slots.mark_present(); current_element = elements.next(); } @@ -3110,7 +3110,7 @@ impl SyntaxFactory for JsSyntaxFactory { } slots.next_slot(); if let Some(element) = ¤t_element { - if JsImportAttribute::can_cast(element.kind()) { + if JsImportAssertion::can_cast(element.kind()) { slots.mark_present(); current_element = elements.next(); } @@ -9852,10 +9852,10 @@ impl SyntaxFactory for JsSyntaxFactory { T ! [,], true, ), - JS_IMPORT_ATTRIBUTE_ENTRY_LIST => Self::make_separated_list_syntax( + JS_IMPORT_ASSERTION_ENTRY_LIST => Self::make_separated_list_syntax( kind, children, - AnyJsImportAttributeEntry::can_cast, + AnyJsImportAssertionEntry::can_cast, T ! [,], true, ), diff --git a/crates/rome_js_formatter/src/comments.rs b/crates/rome_js_formatter/src/comments.rs index c08535e2b81..0664f9aeafd 100644 --- a/crates/rome_js_formatter/src/comments.rs +++ b/crates/rome_js_formatter/src/comments.rs @@ -1123,7 +1123,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_ATTRIBUTE_ENTRY => { + JsSyntaxKind::JS_IMPORT_ASSERTION_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 2645b382328..3c6c90164db 100644 --- a/crates/rome_js_formatter/src/generated.rs +++ b/crates/rome_js_formatter/src/generated.rs @@ -6003,41 +6003,41 @@ impl IntoFormat for rome_js_syntax::JsModuleSource { ) } } -impl FormatRule - for crate::js::module::import_attribute::FormatJsImportAttribute +impl FormatRule + for crate::js::module::import_assertion::FormatJsImportAssertion { type Context = JsFormatContext; #[inline(always)] fn fmt( &self, - node: &rome_js_syntax::JsImportAttribute, + node: &rome_js_syntax::JsImportAssertion, f: &mut JsFormatter, ) -> FormatResult<()> { - FormatNodeRule::::fmt(self, node, f) + FormatNodeRule::::fmt(self, node, f) } } -impl AsFormat for rome_js_syntax::JsImportAttribute { +impl AsFormat for rome_js_syntax::JsImportAssertion { type Format<'a> = FormatRefWithRule< 'a, - rome_js_syntax::JsImportAttribute, - crate::js::module::import_attribute::FormatJsImportAttribute, + rome_js_syntax::JsImportAssertion, + crate::js::module::import_assertion::FormatJsImportAssertion, >; fn format(&self) -> Self::Format<'_> { FormatRefWithRule::new( self, - crate::js::module::import_attribute::FormatJsImportAttribute::default(), + crate::js::module::import_assertion::FormatJsImportAssertion::default(), ) } } -impl IntoFormat for rome_js_syntax::JsImportAttribute { +impl IntoFormat for rome_js_syntax::JsImportAssertion { type Format = FormatOwnedWithRule< - rome_js_syntax::JsImportAttribute, - crate::js::module::import_attribute::FormatJsImportAttribute, + rome_js_syntax::JsImportAssertion, + crate::js::module::import_assertion::FormatJsImportAssertion, >; fn into_format(self) -> Self::Format { FormatOwnedWithRule::new( self, - crate::js::module::import_attribute::FormatJsImportAttribute::default(), + crate::js::module::import_assertion::FormatJsImportAssertion::default(), ) } } @@ -6257,41 +6257,41 @@ impl IntoFormat for rome_js_syntax::JsLiteralExportName { ) } } -impl FormatRule - for crate::js::module::import_attribute_entry::FormatJsImportAttributeEntry +impl FormatRule + for crate::js::module::import_assertion_entry::FormatJsImportAssertionEntry { type Context = JsFormatContext; #[inline(always)] fn fmt( &self, - node: &rome_js_syntax::JsImportAttributeEntry, + node: &rome_js_syntax::JsImportAssertionEntry, f: &mut JsFormatter, ) -> FormatResult<()> { - FormatNodeRule::::fmt(self, node, f) + FormatNodeRule::::fmt(self, node, f) } } -impl AsFormat for rome_js_syntax::JsImportAttributeEntry { +impl AsFormat for rome_js_syntax::JsImportAssertionEntry { type Format<'a> = FormatRefWithRule< 'a, - rome_js_syntax::JsImportAttributeEntry, - crate::js::module::import_attribute_entry::FormatJsImportAttributeEntry, + rome_js_syntax::JsImportAssertionEntry, + crate::js::module::import_assertion_entry::FormatJsImportAssertionEntry, >; fn format(&self) -> Self::Format<'_> { FormatRefWithRule::new( self, - crate::js::module::import_attribute_entry::FormatJsImportAttributeEntry::default(), + crate::js::module::import_assertion_entry::FormatJsImportAssertionEntry::default(), ) } } -impl IntoFormat for rome_js_syntax::JsImportAttributeEntry { +impl IntoFormat for rome_js_syntax::JsImportAssertionEntry { type Format = FormatOwnedWithRule< - rome_js_syntax::JsImportAttributeEntry, - crate::js::module::import_attribute_entry::FormatJsImportAttributeEntry, + rome_js_syntax::JsImportAssertionEntry, + crate::js::module::import_assertion_entry::FormatJsImportAssertionEntry, >; fn into_format(self) -> Self::Format { FormatOwnedWithRule::new( self, - crate::js::module::import_attribute_entry::FormatJsImportAttributeEntry::default(), + crate::js::module::import_assertion_entry::FormatJsImportAssertionEntry::default(), ) } } @@ -9965,23 +9965,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::JsImportAttributeEntryList { +impl AsFormat for rome_js_syntax::JsImportAssertionEntryList { type Format<'a> = FormatRefWithRule< 'a, - rome_js_syntax::JsImportAttributeEntryList, - crate::js::lists::import_attribute_entry_list::FormatJsImportAttributeEntryList, + rome_js_syntax::JsImportAssertionEntryList, + crate::js::lists::import_assertion_entry_list::FormatJsImportAssertionEntryList, >; fn format(&self) -> Self::Format<'_> { - FormatRefWithRule :: new (self , crate :: js :: lists :: import_attribute_entry_list :: FormatJsImportAttributeEntryList :: default ()) + FormatRefWithRule :: new (self , crate :: js :: lists :: import_assertion_entry_list :: FormatJsImportAssertionEntryList :: default ()) } } -impl IntoFormat for rome_js_syntax::JsImportAttributeEntryList { +impl IntoFormat for rome_js_syntax::JsImportAssertionEntryList { type Format = FormatOwnedWithRule< - rome_js_syntax::JsImportAttributeEntryList, - crate::js::lists::import_attribute_entry_list::FormatJsImportAttributeEntryList, + rome_js_syntax::JsImportAssertionEntryList, + crate::js::lists::import_assertion_entry_list::FormatJsImportAssertionEntryList, >; fn into_format(self) -> Self::Format { - FormatOwnedWithRule :: new (self , crate :: js :: lists :: import_attribute_entry_list :: FormatJsImportAttributeEntryList :: default ()) + FormatOwnedWithRule :: new (self , crate :: js :: lists :: import_assertion_entry_list :: FormatJsImportAssertionEntryList :: default ()) } } impl AsFormat for rome_js_syntax::JsMethodModifierList { @@ -10857,36 +10857,36 @@ impl IntoFormat for rome_js_syntax::JsBogusParameter { ) } } -impl FormatRule - for crate::js::bogus::bogus_import_attribute_entry::FormatJsBogusImportAttributeEntry +impl FormatRule + for crate::js::bogus::bogus_import_assertion_entry::FormatJsBogusImportAssertionEntry { type Context = JsFormatContext; #[inline(always)] fn fmt( &self, - node: &rome_js_syntax::JsBogusImportAttributeEntry, + node: &rome_js_syntax::JsBogusImportAssertionEntry, f: &mut JsFormatter, ) -> FormatResult<()> { - FormatBogusNodeRule::::fmt(self, node, f) + FormatBogusNodeRule::::fmt(self, node, f) } } -impl AsFormat for rome_js_syntax::JsBogusImportAttributeEntry { +impl AsFormat for rome_js_syntax::JsBogusImportAssertionEntry { type Format<'a> = FormatRefWithRule< 'a, - rome_js_syntax::JsBogusImportAttributeEntry, - crate::js::bogus::bogus_import_attribute_entry::FormatJsBogusImportAttributeEntry, + rome_js_syntax::JsBogusImportAssertionEntry, + crate::js::bogus::bogus_import_assertion_entry::FormatJsBogusImportAssertionEntry, >; fn format(&self) -> Self::Format<'_> { - FormatRefWithRule :: new (self , crate :: js :: bogus :: bogus_import_attribute_entry :: FormatJsBogusImportAttributeEntry :: default ()) + FormatRefWithRule :: new (self , crate :: js :: bogus :: bogus_import_assertion_entry :: FormatJsBogusImportAssertionEntry :: default ()) } } -impl IntoFormat for rome_js_syntax::JsBogusImportAttributeEntry { +impl IntoFormat for rome_js_syntax::JsBogusImportAssertionEntry { type Format = FormatOwnedWithRule< - rome_js_syntax::JsBogusImportAttributeEntry, - crate::js::bogus::bogus_import_attribute_entry::FormatJsBogusImportAttributeEntry, + rome_js_syntax::JsBogusImportAssertionEntry, + crate::js::bogus::bogus_import_assertion_entry::FormatJsBogusImportAssertionEntry, >; fn into_format(self) -> Self::Format { - FormatOwnedWithRule :: new (self , crate :: js :: bogus :: bogus_import_attribute_entry :: FormatJsBogusImportAttributeEntry :: default ()) + FormatOwnedWithRule :: new (self , crate :: js :: bogus :: bogus_import_assertion_entry :: FormatJsBogusImportAssertionEntry :: default ()) } } impl FormatRule @@ -11990,28 +11990,28 @@ impl IntoFormat for rome_js_syntax::AnyJsNamedImportSpecifier { ) } } -impl AsFormat for rome_js_syntax::AnyJsImportAttributeEntry { +impl AsFormat for rome_js_syntax::AnyJsImportAssertionEntry { type Format<'a> = FormatRefWithRule< 'a, - rome_js_syntax::AnyJsImportAttributeEntry, - crate::js::any::import_attribute_entry::FormatAnyJsImportAttributeEntry, + rome_js_syntax::AnyJsImportAssertionEntry, + crate::js::any::import_assertion_entry::FormatAnyJsImportAssertionEntry, >; fn format(&self) -> Self::Format<'_> { FormatRefWithRule::new( self, - crate::js::any::import_attribute_entry::FormatAnyJsImportAttributeEntry::default(), + crate::js::any::import_assertion_entry::FormatAnyJsImportAssertionEntry::default(), ) } } -impl IntoFormat for rome_js_syntax::AnyJsImportAttributeEntry { +impl IntoFormat for rome_js_syntax::AnyJsImportAssertionEntry { type Format = FormatOwnedWithRule< - rome_js_syntax::AnyJsImportAttributeEntry, - crate::js::any::import_attribute_entry::FormatAnyJsImportAttributeEntry, + rome_js_syntax::AnyJsImportAssertionEntry, + crate::js::any::import_assertion_entry::FormatAnyJsImportAssertionEntry, >; fn into_format(self) -> Self::Format { FormatOwnedWithRule::new( self, - crate::js::any::import_attribute_entry::FormatAnyJsImportAttributeEntry::default(), + crate::js::any::import_assertion_entry::FormatAnyJsImportAssertionEntry::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 new file mode 100644 index 00000000000..b23bbf5aab8 --- /dev/null +++ b/crates/rome_js_formatter/src/js/any/import_assertion_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::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 deleted file mode 100644 index 1d5f2fbea43..00000000000 --- a/crates/rome_js_formatter/src/js/any/import_attribute_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::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 d70d9abde92..819ea8d7cda 100644 --- a/crates/rome_js_formatter/src/js/any/mod.rs +++ b/crates/rome_js_formatter/src/js/any/mod.rs @@ -25,7 +25,7 @@ pub(crate) mod for_initializer; pub(crate) mod formal_parameter; pub(crate) mod function; pub(crate) mod function_body; -pub(crate) mod import_attribute_entry; +pub(crate) mod import_assertion_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 new file mode 100644 index 00000000000..44b676bf68b --- /dev/null +++ b/crates/rome_js_formatter/src/js/bogus/bogus_import_assertion_entry.rs @@ -0,0 +1,7 @@ +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 deleted file mode 100644 index d8d2946b5bd..00000000000 --- a/crates/rome_js_formatter/src/js/bogus/bogus_import_attribute_entry.rs +++ /dev/null @@ -1,5 +0,0 @@ -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 98c448f420c..217dc033ce4 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_attribute_entry; +pub(crate) mod bogus_import_assertion_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_attribute_entry_list.rs b/crates/rome_js_formatter/src/js/lists/import_assertion_entry_list.rs similarity index 66% rename from crates/rome_js_formatter/src/js/lists/import_attribute_entry_list.rs rename to crates/rome_js_formatter/src/js/lists/import_assertion_entry_list.rs index ee8450e5ee6..48ce8e610f2 100644 --- a/crates/rome_js_formatter/src/js/lists/import_attribute_entry_list.rs +++ b/crates/rome_js_formatter/src/js/lists/import_assertion_entry_list.rs @@ -1,14 +1,14 @@ use crate::context::trailing_comma::FormatTrailingComma; use crate::prelude::*; -use rome_js_syntax::JsImportAttributeEntryList; +use rome_js_syntax::JsImportAssertionEntryList; #[derive(Debug, Clone, Default)] -pub(crate) struct FormatJsImportAttributeEntryList; +pub(crate) struct FormatJsImportAssertionEntryList; -impl FormatRule for FormatJsImportAttributeEntryList { +impl FormatRule for FormatJsImportAssertionEntryList { type Context = JsFormatContext; - fn fmt(&self, node: &JsImportAttributeEntryList, f: &mut JsFormatter) -> FormatResult<()> { + fn fmt(&self, node: &JsImportAssertionEntryList, 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 a89124f9e2c..445d4d707c9 100644 --- a/crates/rome_js_formatter/src/js/lists/mod.rs +++ b/crates/rome_js_formatter/src/js/lists/mod.rs @@ -11,7 +11,7 @@ pub(crate) mod decorator_list; pub(crate) mod directive_list; pub(crate) mod export_named_from_specifier_list; pub(crate) mod export_named_specifier_list; -pub(crate) mod import_attribute_entry_list; +pub(crate) mod import_assertion_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 6a0412c4d1b..2f4d4d7a01a 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, - attribute, + assertion, semicolon_token, } = node.as_fields(); @@ -33,8 +33,8 @@ impl FormatNodeRule for FormatJsExportFromClause { write!(f, [from_token.format(), space(), source.format()])?; - if let Some(attribute) = attribute { - write!(f, [space(), attribute.format()])?; + if let Some(assertion) = assertion { + write!(f, [space(), assertion.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 d1048dbf75d..13f1172afed 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, - attribute, + assertion, semicolon_token, } = node.as_fields(); @@ -64,8 +64,8 @@ impl FormatNodeRule for FormatJsExportNamedFromClause { ] ]?; - if let Some(attribute) = &attribute { - write!(f, [space(), attribute.format()])?; + if let Some(assertion) = &assertion { + write!(f, [space(), assertion.format()])?; } write!(f, [FormatStatementSemicolon::new(semicolon_token.as_ref())]) diff --git a/crates/rome_js_formatter/src/js/module/import_attribute.rs b/crates/rome_js_formatter/src/js/module/import_assertion.rs similarity index 59% rename from crates/rome_js_formatter/src/js/module/import_attribute.rs rename to crates/rome_js_formatter/src/js/module/import_assertion.rs index 6cac70b04aa..9615aa50ae7 100644 --- a/crates/rome_js_formatter/src/js/module/import_attribute.rs +++ b/crates/rome_js_formatter/src/js/module/import_assertion.rs @@ -1,21 +1,27 @@ use crate::prelude::*; + use rome_formatter::write; -use rome_js_syntax::{JsImportAttribute, JsImportAttributeFields}; -use rome_rowan::AstNode; +use rome_js_syntax::JsImportAssertion; +use rome_js_syntax::JsImportAssertionFields; + #[derive(Debug, Clone, Default)] -pub(crate) struct FormatJsImportAttribute; -impl FormatNodeRule for FormatJsImportAttribute { - fn fmt_fields(&self, node: &JsImportAttribute, f: &mut JsFormatter) -> FormatResult<()> { - let JsImportAttributeFields { - with_token, +pub(crate) struct FormatJsImportAssertion; + +impl FormatNodeRule for FormatJsImportAssertion { + fn fmt_fields(&self, node: &JsImportAssertion, f: &mut JsFormatter) -> FormatResult<()> { + let JsImportAssertionFields { l_curly_token, - attributes, + assertions, r_curly_token, + assertion_kind, } = node.as_fields(); - write![f, [with_token.format(), space(), l_curly_token.format()]]?; + write![ + f, + [assertion_kind.format(), space(), l_curly_token.format()] + ]?; - if attributes.is_empty() { + if assertions.is_empty() { let has_dangling = f.comments().has_dangling_comments(node.syntax()); write!( f, @@ -28,7 +34,7 @@ impl FormatNodeRule for FormatJsImportAttribute { } else { write!( f, - [group(&soft_space_or_block_indent(&attributes.format()))] + [group(&soft_space_or_block_indent(&assertions.format()))] )?; } @@ -37,7 +43,7 @@ impl FormatNodeRule for FormatJsImportAttribute { fn fmt_dangling_comments( &self, - _: &JsImportAttribute, + _: &JsImportAssertion, _: &mut JsFormatter, ) -> FormatResult<()> { // Handled as part of `fmt_fields` diff --git a/crates/rome_js_formatter/src/js/module/import_attribute_entry.rs b/crates/rome_js_formatter/src/js/module/import_assertion_entry.rs similarity index 77% rename from crates/rome_js_formatter/src/js/module/import_attribute_entry.rs rename to crates/rome_js_formatter/src/js/module/import_assertion_entry.rs index 903806a9387..d80b3689c4f 100644 --- a/crates/rome_js_formatter/src/js/module/import_attribute_entry.rs +++ b/crates/rome_js_formatter/src/js/module/import_assertion_entry.rs @@ -2,14 +2,16 @@ use crate::prelude::*; use rome_formatter::write; use crate::utils::{FormatLiteralStringToken, StringLiteralParentKind}; -use rome_js_syntax::{JsImportAttributeEntry, JsImportAttributeEntryFields, JsSyntaxKind}; + +use rome_js_syntax::JsImportAssertionEntryFields; +use rome_js_syntax::{JsImportAssertionEntry, JsSyntaxKind}; #[derive(Debug, Clone, Default)] -pub(crate) struct FormatJsImportAttributeEntry; +pub(crate) struct FormatJsImportAssertionEntry; -impl FormatNodeRule for FormatJsImportAttributeEntry { - fn fmt_fields(&self, node: &JsImportAttributeEntry, f: &mut JsFormatter) -> FormatResult<()> { - let JsImportAttributeEntryFields { +impl FormatNodeRule for FormatJsImportAssertionEntry { + fn fmt_fields(&self, node: &JsImportAssertionEntry, f: &mut JsFormatter) -> FormatResult<()> { + let JsImportAssertionEntryFields { key, colon_token, value_token, @@ -52,7 +54,7 @@ impl FormatNodeRule for FormatJsImportAttributeEntry { fn fmt_dangling_comments( &self, - _: &JsImportAttributeEntry, + _: &JsImportAssertionEntry, _: &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 79456530555..41a4dbfb878 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, attribute } = node.as_fields(); + let JsImportBareClauseFields { source, assertion } = node.as_fields(); write!(f, [source.format()])?; - if let Some(attribute) = attribute { - write!(f, [space(), attribute.format()])?; + if let Some(assertion) = assertion { + write!(f, [space(), assertion.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 21ad0b8a284..cc2dae43063 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, - attribute, + assertion, } = node.as_fields(); if let Some(type_token) = type_token { @@ -32,8 +32,8 @@ impl FormatNodeRule for FormatJsImportDefaultClause { ] ]?; - if let Some(attribute) = attribute { - write!(f, [space(), attribute.format()])?; + if let Some(assertion) = assertion { + write!(f, [space(), assertion.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 c6a530b4f45..f782a61c3f3 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, - attribute, + assertion, } = 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(attribute) = attribute { - write!(f, [space(), attribute.format()])?; + if let Some(assertion) = assertion { + write!(f, [space(), assertion.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 8e3687e848c..6b96bfb73ad 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, - attribute, + assertion, } = node.as_fields(); if let Some(type_token) = type_token { @@ -38,8 +38,8 @@ impl FormatNodeRule for FormatJsImportNamespaceClause { ] ]?; - if let Some(attribute) = attribute { - write!(f, [space(), attribute.format()])?; + if let Some(assertion) = assertion { + write!(f, [space(), assertion.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 e568e01fa66..bfe8e8a9a99 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_attribute; -pub(crate) mod import_attribute_entry; +pub(crate) mod import_assertion; +pub(crate) mod import_assertion_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 4ba8477f278..7235ae959b0 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" with { "type": "json", "type2": "json3"} +export * as something_bad_will_happen from "something_bad_might_not_happen" assert { "type": "json", "type2": "json3"} \ No newline at end of file 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 632b900ba17..35e043d9a14 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,6 +1,7 @@ --- source: crates/rome_formatter_test/src/snapshot_builder.rs -info: js/module/export/from_clause.js +info: + test_file: js/module/export/from_clause.js --- # Input @@ -10,8 +11,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" with { "type": "json", "type2": "json3"} - +export * as something_bad_will_happen from "something_bad_might_not_happen" assert { "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" with { +export * as something_bad_will_happen from "something_bad_might_not_happen" assert { "type": "json", "type2": "json3", }; @@ -43,7 +43,6 @@ export * as something_bad_will_happen from "something_bad_might_not_happen" with # Lines exceeding max width of 80 characters ``` - 5: export * as something_bad_will_happen from "something_bad_might_not_happen" with { + 5: export * as something_bad_will_happen from "something_bad_might_not_happen" assert { ``` - 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 5ca9b6341c9..a8f3ac2e077 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" with { type: "json"} +} from "fancy" assert { 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" with { type: "json", "type2": "json", type23: "json", "type24": "json"} +} from "fancy" assert { 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" +export { a as b } from "loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong" \ No newline at end of file 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 2fa4013687e..45a7454d39e 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,6 +1,7 @@ --- source: crates/rome_formatter_test/src/snapshot_builder.rs -info: js/module/export/named_from_clause.js +info: + test_file: js/module/export/named_from_clause.js --- # Input @@ -8,25 +9,24 @@ info: js/module/export/named_from_clause.js ```js export {a, b as c -} from "fancy" with { type: "json"} +} from "fancy" assert { 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" with { type: "json", "type2": "json", type23: "json", "type24": "json"} +} from "fancy" assert { 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" with { type: "json" }; +export { a, b as c } from "fancy" assert { 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" with { +} from "fancy" assert { 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 2caebe1531a..f424f1f08eb 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" with { type : "json"} -import "short" with { +import "very_long_import_very_long_import_very_long_import_very_long_import_very_long_import_very_long" assert { type : "json"} +import "short" assert { type : "json" } -import "very_long_import_very_long_import_very" with { +import "very_long_import_very_long_import_very" assert { // something good is here "type": /****/ "json" } -import "very_long_import_very_long_import_very" with { +import "very_long_import_very_long_import_very" assert { // 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 77eed8fbf86..c5ed0b49fe7 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" with { type : "json"} -import "short" with { +import "very_long_import_very_long_import_very_long_import_very_long_import_very_long_import_very_long" assert { type : "json"} +import "short" assert { type : "json" } -import "very_long_import_very_long_import_very" with { +import "very_long_import_very_long_import_very" assert { // something good is here "type": /****/ "json" } -import "very_long_import_very_long_import_very" with { +import "very_long_import_very_long_import_very" assert { // 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" with { +import "very_long_import_very_long_import_very_long_import_very_long_import_very_long_import_very_long" assert { type: "json", }; -import "short" with { type: "json" }; +import "short" assert { type: "json" }; -import "very_long_import_very_long_import_very" with { +import "very_long_import_very_long_import_very" assert { // something good is here "type": /****/ "json", }; -import "very_long_import_very_long_import_very" with { +import "very_long_import_very_long_import_very" assert { // something good is here "type": /****/ "json", "type2": /****/ "json", @@ -76,7 +76,7 @@ import "very_long_import_very_long_import_very" with { # 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" with { + 2: import "very_long_import_very_long_import_very_long_import_very_long_import_very_long_import_very_long" assert { 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 b5fc4d66ffd..0e997493a03 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" with { type: "json" } -import "foo" with { "type": "json" }; -import foo from "foo.json" with { type: "json" }; -import foo from "foo.json" with { +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" with { "type": "json", type: "html", "type": "js" }; +import foo2 from "foo.json" assert { "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 ab38ec1538a..ed3d6333c52 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,6 +1,7 @@ --- source: crates/rome_formatter_test/src/snapshot_builder.rs -info: js/module/import/default_import.js +info: + test_file: js/module/import/default_import.js --- # Input @@ -8,14 +9,14 @@ info: js/module/import/default_import.js ```js import hey from "hey" import hey from "hey"; -import "x" with { type: "json" } -import "foo" with { "type": "json" }; -import foo from "foo.json" with { type: "json" }; -import foo from "foo.json" with { +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" with { "type": "json", type: "html", "type": "js" }; +import foo2 from "foo.json" assert { "type": "json", type: "html", "type": "js" }; import a, * as b from "foo" ``` @@ -39,11 +40,15 @@ Semicolons: Always ```js import hey from "hey"; import hey from "hey"; -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 "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 a, * as b from "foo"; ``` diff --git a/crates/rome_js_formatter/tests/specs/js/module/import/import-attributes/bracket-spacing/dynamic-import.js b/crates/rome_js_formatter/tests/specs/js/module/import/import-attributes/bracket-spacing/dynamic-import.js deleted file mode 100644 index 717b72d4a84..00000000000 --- a/crates/rome_js_formatter/tests/specs/js/module/import/import-attributes/bracket-spacing/dynamic-import.js +++ /dev/null @@ -1 +0,0 @@ -import("./foo.json", { with: { type: "json" } }); diff --git a/crates/rome_js_formatter/tests/specs/js/module/import/import-attributes/bracket-spacing/dynamic-import.js.prettier-snap b/crates/rome_js_formatter/tests/specs/js/module/import/import-attributes/bracket-spacing/dynamic-import.js.prettier-snap deleted file mode 100644 index 717b72d4a84..00000000000 --- a/crates/rome_js_formatter/tests/specs/js/module/import/import-attributes/bracket-spacing/dynamic-import.js.prettier-snap +++ /dev/null @@ -1 +0,0 @@ -import("./foo.json", { with: { type: "json" } }); diff --git a/crates/rome_js_formatter/tests/specs/js/module/import/import-attributes/bracket-spacing/dynamic-import.js.snap b/crates/rome_js_formatter/tests/specs/js/module/import/import-attributes/bracket-spacing/dynamic-import.js.snap deleted file mode 100644 index 7ec0429a53c..00000000000 --- a/crates/rome_js_formatter/tests/specs/js/module/import/import-attributes/bracket-spacing/dynamic-import.js.snap +++ /dev/null @@ -1,33 +0,0 @@ ---- -source: crates/rome_formatter_test/src/snapshot_builder.rs -info: js/module/import/import-attributes/bracket-spacing/dynamic-import.js ---- - -# Input - -```js -import("./foo.json", { with: { type: "json" } }); - -``` - - -============================= - -# Outputs - -## Output 1 - ------ -Indent style: Tab -Line width: 80 -Quote style: Double Quotes -Quote properties: As needed -Trailing comma: All -Semicolons: Always ------ - -```js -import("./foo.json", { with: { type: "json" } }); -``` - - diff --git a/crates/rome_js_formatter/tests/specs/js/module/import/import-attributes/bracket-spacing/empty.js b/crates/rome_js_formatter/tests/specs/js/module/import/import-attributes/bracket-spacing/empty.js deleted file mode 100644 index fe2a9deb871..00000000000 --- a/crates/rome_js_formatter/tests/specs/js/module/import/import-attributes/bracket-spacing/empty.js +++ /dev/null @@ -1 +0,0 @@ -export * as bar from "bar.json" with { } diff --git a/crates/rome_js_formatter/tests/specs/js/module/import/import-attributes/bracket-spacing/empty.js.prettier-snap b/crates/rome_js_formatter/tests/specs/js/module/import/import-attributes/bracket-spacing/empty.js.prettier-snap deleted file mode 100644 index 349c495478a..00000000000 --- a/crates/rome_js_formatter/tests/specs/js/module/import/import-attributes/bracket-spacing/empty.js.prettier-snap +++ /dev/null @@ -1 +0,0 @@ -export * as bar from "bar.json"; diff --git a/crates/rome_js_formatter/tests/specs/js/module/import/import-attributes/bracket-spacing/empty.js.snap b/crates/rome_js_formatter/tests/specs/js/module/import/import-attributes/bracket-spacing/empty.js.snap deleted file mode 100644 index f67508b597b..00000000000 --- a/crates/rome_js_formatter/tests/specs/js/module/import/import-attributes/bracket-spacing/empty.js.snap +++ /dev/null @@ -1,33 +0,0 @@ ---- -source: crates/rome_formatter_test/src/snapshot_builder.rs -info: js/module/import/import-attributes/bracket-spacing/empty.js ---- - -# Input - -```js -export * as bar from "bar.json" with { } - -``` - - -============================= - -# Outputs - -## Output 1 - ------ -Indent style: Tab -Line width: 80 -Quote style: Double Quotes -Quote properties: As needed -Trailing comma: All -Semicolons: Always ------ - -```js -export * as bar from "bar.json" with {}; -``` - - diff --git a/crates/rome_js_formatter/tests/specs/js/module/import/import-attributes/bracket-spacing/re-export.js b/crates/rome_js_formatter/tests/specs/js/module/import/import-attributes/bracket-spacing/re-export.js deleted file mode 100644 index 12b98b761f4..00000000000 --- a/crates/rome_js_formatter/tests/specs/js/module/import/import-attributes/bracket-spacing/re-export.js +++ /dev/null @@ -1 +0,0 @@ -export { default as foo2 } from "foo.json" with { type: "json" }; diff --git a/crates/rome_js_formatter/tests/specs/js/module/import/import-attributes/bracket-spacing/re-export.js.prettier-snap b/crates/rome_js_formatter/tests/specs/js/module/import/import-attributes/bracket-spacing/re-export.js.prettier-snap deleted file mode 100644 index 12b98b761f4..00000000000 --- a/crates/rome_js_formatter/tests/specs/js/module/import/import-attributes/bracket-spacing/re-export.js.prettier-snap +++ /dev/null @@ -1 +0,0 @@ -export { default as foo2 } from "foo.json" with { type: "json" }; diff --git a/crates/rome_js_formatter/tests/specs/js/module/import/import-attributes/bracket-spacing/re-export.js.snap b/crates/rome_js_formatter/tests/specs/js/module/import/import-attributes/bracket-spacing/re-export.js.snap deleted file mode 100644 index deab6282602..00000000000 --- a/crates/rome_js_formatter/tests/specs/js/module/import/import-attributes/bracket-spacing/re-export.js.snap +++ /dev/null @@ -1,33 +0,0 @@ ---- -source: crates/rome_formatter_test/src/snapshot_builder.rs -info: js/module/import/import-attributes/bracket-spacing/re-export.js ---- - -# Input - -```js -export { default as foo2 } from "foo.json" with { type: "json" }; - -``` - - -============================= - -# Outputs - -## Output 1 - ------ -Indent style: Tab -Line width: 80 -Quote style: Double Quotes -Quote properties: As needed -Trailing comma: All -Semicolons: Always ------ - -```js -export { default as foo2 } from "foo.json" with { type: "json" }; -``` - - diff --git a/crates/rome_js_formatter/tests/specs/js/module/import/import-attributes/bracket-spacing/static-import.js b/crates/rome_js_formatter/tests/specs/js/module/import/import-attributes/bracket-spacing/static-import.js deleted file mode 100644 index 7770ae1f06b..00000000000 --- a/crates/rome_js_formatter/tests/specs/js/module/import/import-attributes/bracket-spacing/static-import.js +++ /dev/null @@ -1 +0,0 @@ -import json from "./foo.json" with { type: "json" }; diff --git a/crates/rome_js_formatter/tests/specs/js/module/import/import-attributes/bracket-spacing/static-import.js.prettier-snap b/crates/rome_js_formatter/tests/specs/js/module/import/import-attributes/bracket-spacing/static-import.js.prettier-snap deleted file mode 100644 index 7770ae1f06b..00000000000 --- a/crates/rome_js_formatter/tests/specs/js/module/import/import-attributes/bracket-spacing/static-import.js.prettier-snap +++ /dev/null @@ -1 +0,0 @@ -import json from "./foo.json" with { type: "json" }; diff --git a/crates/rome_js_formatter/tests/specs/js/module/import/import-attributes/bracket-spacing/static-import.js.snap b/crates/rome_js_formatter/tests/specs/js/module/import/import-attributes/bracket-spacing/static-import.js.snap deleted file mode 100644 index 94fcc1fd4d4..00000000000 --- a/crates/rome_js_formatter/tests/specs/js/module/import/import-attributes/bracket-spacing/static-import.js.snap +++ /dev/null @@ -1,33 +0,0 @@ ---- -source: crates/rome_formatter_test/src/snapshot_builder.rs -info: js/module/import/import-attributes/bracket-spacing/static-import.js ---- - -# Input - -```js -import json from "./foo.json" with { type: "json" }; - -``` - - -============================= - -# Outputs - -## Output 1 - ------ -Indent style: Tab -Line width: 80 -Quote style: Double Quotes -Quote properties: As needed -Trailing comma: All -Semicolons: Always ------ - -```js -import json from "./foo.json" with { type: "json" }; -``` - - diff --git a/crates/rome_js_formatter/tests/specs/js/module/import/import-attributes/dynamic-import.js b/crates/rome_js_formatter/tests/specs/js/module/import/import-attributes/dynamic-import.js deleted file mode 100644 index 717b72d4a84..00000000000 --- a/crates/rome_js_formatter/tests/specs/js/module/import/import-attributes/dynamic-import.js +++ /dev/null @@ -1 +0,0 @@ -import("./foo.json", { with: { type: "json" } }); diff --git a/crates/rome_js_formatter/tests/specs/js/module/import/import-attributes/dynamic-import.js.prettier-snap b/crates/rome_js_formatter/tests/specs/js/module/import/import-attributes/dynamic-import.js.prettier-snap deleted file mode 100644 index 717b72d4a84..00000000000 --- a/crates/rome_js_formatter/tests/specs/js/module/import/import-attributes/dynamic-import.js.prettier-snap +++ /dev/null @@ -1 +0,0 @@ -import("./foo.json", { with: { type: "json" } }); diff --git a/crates/rome_js_formatter/tests/specs/js/module/import/import-attributes/dynamic-import.js.snap b/crates/rome_js_formatter/tests/specs/js/module/import/import-attributes/dynamic-import.js.snap deleted file mode 100644 index ab173b35bb7..00000000000 --- a/crates/rome_js_formatter/tests/specs/js/module/import/import-attributes/dynamic-import.js.snap +++ /dev/null @@ -1,33 +0,0 @@ ---- -source: crates/rome_formatter_test/src/snapshot_builder.rs -info: js/module/import/import-attributes/dynamic-import.js ---- - -# Input - -```js -import("./foo.json", { with: { type: "json" } }); - -``` - - -============================= - -# Outputs - -## Output 1 - ------ -Indent style: Tab -Line width: 80 -Quote style: Double Quotes -Quote properties: As needed -Trailing comma: All -Semicolons: Always ------ - -```js -import("./foo.json", { with: { type: "json" } }); -``` - - diff --git a/crates/rome_js_formatter/tests/specs/js/module/import/import-attributes/empty.js b/crates/rome_js_formatter/tests/specs/js/module/import/import-attributes/empty.js deleted file mode 100644 index ab1ee6f33e4..00000000000 --- a/crates/rome_js_formatter/tests/specs/js/module/import/import-attributes/empty.js +++ /dev/null @@ -1,7 +0,0 @@ -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-attributes/empty.js.prettier-snap b/crates/rome_js_formatter/tests/specs/js/module/import/import-attributes/empty.js.prettier-snap deleted file mode 100644 index 6be0c7b7e06..00000000000 --- a/crates/rome_js_formatter/tests/specs/js/module/import/import-attributes/empty.js.prettier-snap +++ /dev/null @@ -1,7 +0,0 @@ -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-attributes/empty.js.snap b/crates/rome_js_formatter/tests/specs/js/module/import/import-attributes/empty.js.snap deleted file mode 100644 index c19540be276..00000000000 --- a/crates/rome_js_formatter/tests/specs/js/module/import/import-attributes/empty.js.snap +++ /dev/null @@ -1,45 +0,0 @@ ---- -source: crates/rome_formatter_test/src/snapshot_builder.rs -info: js/module/import/import-attributes/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 */ } - -``` - - -============================= - -# Outputs - -## Output 1 - ------ -Indent style: Tab -Line width: 80 -Quote style: Double Quotes -Quote properties: As needed -Trailing comma: All -Semicolons: Always ------ - -```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 */ }; -``` - - diff --git a/crates/rome_js_formatter/tests/specs/js/module/import/import-attributes/multi-types.js b/crates/rome_js_formatter/tests/specs/js/module/import/import-attributes/multi-types.js deleted file mode 100644 index 0f0e7115f30..00000000000 --- a/crates/rome_js_formatter/tests/specs/js/module/import/import-attributes/multi-types.js +++ /dev/null @@ -1 +0,0 @@ -import json from "./foo.json" with { type: "json", type: "bar" }; diff --git a/crates/rome_js_formatter/tests/specs/js/module/import/import-attributes/multi-types.js.prettier-snap b/crates/rome_js_formatter/tests/specs/js/module/import/import-attributes/multi-types.js.prettier-snap deleted file mode 100644 index 0f0e7115f30..00000000000 --- a/crates/rome_js_formatter/tests/specs/js/module/import/import-attributes/multi-types.js.prettier-snap +++ /dev/null @@ -1 +0,0 @@ -import json from "./foo.json" with { type: "json", type: "bar" }; diff --git a/crates/rome_js_formatter/tests/specs/js/module/import/import-attributes/multi-types.js.snap b/crates/rome_js_formatter/tests/specs/js/module/import/import-attributes/multi-types.js.snap deleted file mode 100644 index b35b5d11350..00000000000 --- a/crates/rome_js_formatter/tests/specs/js/module/import/import-attributes/multi-types.js.snap +++ /dev/null @@ -1,33 +0,0 @@ ---- -source: crates/rome_formatter_test/src/snapshot_builder.rs -info: js/module/import/import-attributes/multi-types.js ---- - -# Input - -```js -import json from "./foo.json" with { type: "json", type: "bar" }; - -``` - - -============================= - -# Outputs - -## Output 1 - ------ -Indent style: Tab -Line width: 80 -Quote style: Double Quotes -Quote properties: As needed -Trailing comma: All -Semicolons: Always ------ - -```js -import json from "./foo.json" with { type: "json", type: "bar" }; -``` - - diff --git a/crates/rome_js_formatter/tests/specs/js/module/import/import-attributes/non-type.js b/crates/rome_js_formatter/tests/specs/js/module/import/import-attributes/non-type.js deleted file mode 100644 index 1858e49c202..00000000000 --- a/crates/rome_js_formatter/tests/specs/js/module/import/import-attributes/non-type.js +++ /dev/null @@ -1 +0,0 @@ -import foo from "foo.json" with { lazy: "true" }; diff --git a/crates/rome_js_formatter/tests/specs/js/module/import/import-attributes/non-type.js.prettier-snap b/crates/rome_js_formatter/tests/specs/js/module/import/import-attributes/non-type.js.prettier-snap deleted file mode 100644 index 1858e49c202..00000000000 --- a/crates/rome_js_formatter/tests/specs/js/module/import/import-attributes/non-type.js.prettier-snap +++ /dev/null @@ -1 +0,0 @@ -import foo from "foo.json" with { lazy: "true" }; diff --git a/crates/rome_js_formatter/tests/specs/js/module/import/import-attributes/non-type.js.snap b/crates/rome_js_formatter/tests/specs/js/module/import/import-attributes/non-type.js.snap deleted file mode 100644 index 24f03bfcd90..00000000000 --- a/crates/rome_js_formatter/tests/specs/js/module/import/import-attributes/non-type.js.snap +++ /dev/null @@ -1,33 +0,0 @@ ---- -source: crates/rome_formatter_test/src/snapshot_builder.rs -info: js/module/import/import-attributes/non-type.js ---- - -# Input - -```js -import foo from "foo.json" with { lazy: "true" }; - -``` - - -============================= - -# Outputs - -## Output 1 - ------ -Indent style: Tab -Line width: 80 -Quote style: Double Quotes -Quote properties: As needed -Trailing comma: All -Semicolons: Always ------ - -```js -import foo from "foo.json" with { lazy: "true" }; -``` - - diff --git a/crates/rome_js_formatter/tests/specs/js/module/import/import-attributes/not-import-attributes.js b/crates/rome_js_formatter/tests/specs/js/module/import/import-attributes/not-import-attributes.js deleted file mode 100644 index c3624b9699d..00000000000 --- a/crates/rome_js_formatter/tests/specs/js/module/import/import-attributes/not-import-attributes.js +++ /dev/null @@ -1,2 +0,0 @@ -import "x" -with ({type: 'json'}); diff --git a/crates/rome_js_formatter/tests/specs/js/module/import/import-attributes/not-import-attributes.js.snap b/crates/rome_js_formatter/tests/specs/js/module/import/import-attributes/not-import-attributes.js.snap deleted file mode 100644 index 6db7bf8b4fb..00000000000 --- a/crates/rome_js_formatter/tests/specs/js/module/import/import-attributes/not-import-attributes.js.snap +++ /dev/null @@ -1,35 +0,0 @@ ---- -source: crates/rome_formatter_test/src/snapshot_builder.rs -info: js/module/import/import-attributes/not-import-attributes.js ---- - -# Input - -```js -import "x" -with ({type: 'json'}); - -``` - - -============================= - -# Outputs - -## Output 1 - ------ -Indent style: Tab -Line width: 80 -Quote style: Double Quotes -Quote properties: As needed -Trailing comma: All -Semicolons: Always ------ - -```js -import "x"; -with ({type: 'json'}); -``` - - diff --git a/crates/rome_js_formatter/tests/specs/js/module/import/import-attributes/re-export.js b/crates/rome_js_formatter/tests/specs/js/module/import/import-attributes/re-export.js deleted file mode 100644 index 8b7f8a81728..00000000000 --- a/crates/rome_js_formatter/tests/specs/js/module/import/import-attributes/re-export.js +++ /dev/null @@ -1,3 +0,0 @@ -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-attributes/re-export.js.prettier-snap b/crates/rome_js_formatter/tests/specs/js/module/import/import-attributes/re-export.js.prettier-snap deleted file mode 100644 index 8b7f8a81728..00000000000 --- a/crates/rome_js_formatter/tests/specs/js/module/import/import-attributes/re-export.js.prettier-snap +++ /dev/null @@ -1,3 +0,0 @@ -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-attributes/re-export.js.snap b/crates/rome_js_formatter/tests/specs/js/module/import/import-attributes/re-export.js.snap deleted file mode 100644 index 173621b2331..00000000000 --- a/crates/rome_js_formatter/tests/specs/js/module/import/import-attributes/re-export.js.snap +++ /dev/null @@ -1,37 +0,0 @@ ---- -source: crates/rome_formatter_test/src/snapshot_builder.rs -info: js/module/import/import-attributes/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" }; - -``` - - -============================= - -# Outputs - -## Output 1 - ------ -Indent style: Tab -Line width: 80 -Quote style: Double Quotes -Quote properties: As needed -Trailing comma: All -Semicolons: Always ------ - -```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" }; -``` - - diff --git a/crates/rome_js_formatter/tests/specs/js/module/import/import-attributes/static-import.js b/crates/rome_js_formatter/tests/specs/js/module/import/import-attributes/static-import.js deleted file mode 100644 index 7770ae1f06b..00000000000 --- a/crates/rome_js_formatter/tests/specs/js/module/import/import-attributes/static-import.js +++ /dev/null @@ -1 +0,0 @@ -import json from "./foo.json" with { type: "json" }; diff --git a/crates/rome_js_formatter/tests/specs/js/module/import/import-attributes/static-import.js.prettier-snap b/crates/rome_js_formatter/tests/specs/js/module/import/import-attributes/static-import.js.prettier-snap deleted file mode 100644 index 7770ae1f06b..00000000000 --- a/crates/rome_js_formatter/tests/specs/js/module/import/import-attributes/static-import.js.prettier-snap +++ /dev/null @@ -1 +0,0 @@ -import json from "./foo.json" with { type: "json" }; diff --git a/crates/rome_js_formatter/tests/specs/js/module/import/import-attributes/static-import.js.snap b/crates/rome_js_formatter/tests/specs/js/module/import/import-attributes/static-import.js.snap deleted file mode 100644 index f598a6f1684..00000000000 --- a/crates/rome_js_formatter/tests/specs/js/module/import/import-attributes/static-import.js.snap +++ /dev/null @@ -1,33 +0,0 @@ ---- -source: crates/rome_formatter_test/src/snapshot_builder.rs -info: js/module/import/import-attributes/static-import.js ---- - -# Input - -```js -import json from "./foo.json" with { type: "json" }; - -``` - - -============================= - -# Outputs - -## Output 1 - ------ -Indent style: Tab -Line width: 80 -Quote style: Double Quotes -Quote properties: As needed -Trailing comma: All -Semicolons: Always ------ - -```js -import json from "./foo.json" with { type: "json" }; -``` - - diff --git a/crates/rome_js_formatter/tests/specs/js/module/import/import-attributes/without-from.js b/crates/rome_js_formatter/tests/specs/js/module/import/import-attributes/without-from.js deleted file mode 100644 index 5009c441a73..00000000000 --- a/crates/rome_js_formatter/tests/specs/js/module/import/import-attributes/without-from.js +++ /dev/null @@ -1 +0,0 @@ -import "foo" with { type: "json" } diff --git a/crates/rome_js_formatter/tests/specs/js/module/import/import-attributes/without-from.js.prettier-snap b/crates/rome_js_formatter/tests/specs/js/module/import/import-attributes/without-from.js.prettier-snap deleted file mode 100644 index 97676575506..00000000000 --- a/crates/rome_js_formatter/tests/specs/js/module/import/import-attributes/without-from.js.prettier-snap +++ /dev/null @@ -1 +0,0 @@ -import "foo" with { type: "json" }; diff --git a/crates/rome_js_formatter/tests/specs/js/module/import/import-attributes/without-from.js.snap b/crates/rome_js_formatter/tests/specs/js/module/import/import-attributes/without-from.js.snap deleted file mode 100644 index 3e11b0c311a..00000000000 --- a/crates/rome_js_formatter/tests/specs/js/module/import/import-attributes/without-from.js.snap +++ /dev/null @@ -1,33 +0,0 @@ ---- -source: crates/rome_formatter_test/src/snapshot_builder.rs -info: js/module/import/import-attributes/without-from.js ---- - -# Input - -```js -import "foo" with { type: "json" } - -``` - - -============================= - -# Outputs - -## Output 1 - ------ -Indent style: Tab -Line width: 80 -Quote style: Double Quotes -Quote properties: As needed -Trailing comma: All -Semicolons: Always ------ - -```js -import "foo" with { type: "json" }; -``` - - 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 63dd4b790e5..d2223d44ec3 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" with { for: "for" } +import {test} from "foo.json" assert { 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 bcf28af51b5..bcee5d43f1f 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" with { for: "for" } +import {test} from "foo.json" assert { 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" with { for: "for" }; +import { test } from "foo.json" assert { 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 d7d32efdb95..ec8d585be94 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" with { type: "json" } -import "foo" with { "type": "json" }; -import foo from "foo.json" with { type: "json" }; -import foo from "foo.json" with { +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" with { "type": "json", type: "html", "type": "js" }; +import foo2 from "foo.json" assert { "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" with { "type": "json", "type2": "json3"} +export * as something_bad_will_happen from "something_bad_might_not_happen" assert { "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" with ("content \\' \\' "); // you should remove the escape -("content \'\' ") +("content \'\' ") \ No newline at end of file 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 d56e29b4dd6..52251cb5e7f 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,6 +1,7 @@ --- source: crates/rome_formatter_test/src/snapshot_builder.rs -info: js/module/string/string.js +info: + test_file: js/module/string/string.js --- # Input @@ -8,14 +9,14 @@ info: js/module/string/string.js ```js import hey from "hey" import hey from "hey"; -import "x" with { type: "json" } -import "foo" with { "type": "json" }; -import foo from "foo.json" with { type: "json" }; -import foo from "foo.json" with { +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" with { "type": "json", type: "html", "type": "js" }; +import foo2 from "foo.json" assert { "type": "json", type: "html", "type": "js" }; import a, * as b from "foo" const foo = {}; @@ -50,7 +51,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" with { "type": "json", "type2": "json3"} +export * as something_bad_will_happen from "something_bad_might_not_happen" assert { "type": "json", "type2": "json3"} // this one should switch to use single quotes @@ -64,7 +65,6 @@ export * as something_bad_will_happen from "something_bad_might_not_happen" with // you should remove the escape ("content \'\' ") - ``` @@ -86,11 +86,15 @@ Semicolons: Always ```js import hey from "hey"; import hey from "hey"; -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 "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 a, * as b from "foo"; const foo = {}; @@ -127,7 +131,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" with { +export * as something_bad_will_happen from "something_bad_might_not_happen" assert { "type": "json", "type2": "json3", }; @@ -147,7 +151,7 @@ export * as something_bad_will_happen from "something_bad_might_not_happen" with # Lines exceeding max width of 80 characters ``` - 44: export * as something_bad_will_happen from "something_bad_might_not_happen" with { + 48: export * as something_bad_will_happen from "something_bad_might_not_happen" assert { ``` ## Output 2 @@ -164,11 +168,15 @@ Semicolons: Always ```js import hey from 'hey'; import hey from 'hey'; -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 '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 a, * as b from 'foo'; const foo = {}; @@ -205,7 +213,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' with { +export * as something_bad_will_happen from 'something_bad_might_not_happen' assert { 'type': 'json', 'type2': 'json3', }; @@ -225,7 +233,7 @@ export * as something_bad_will_happen from 'something_bad_might_not_happen' with # Lines exceeding max width of 80 characters ``` - 44: export * as something_bad_will_happen from 'something_bad_might_not_happen' with { + 48: export * as something_bad_will_happen from 'something_bad_might_not_happen' assert { ``` ## Output 3 @@ -242,11 +250,15 @@ Semicolons: Always ```js import hey from "hey"; import hey from "hey"; -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 "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 a, * as b from "foo"; const foo = {}; @@ -283,7 +295,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" with { +export * as something_bad_will_happen from "something_bad_might_not_happen" assert { "type": "json", "type2": "json3", }; @@ -303,7 +315,7 @@ export * as something_bad_will_happen from "something_bad_might_not_happen" with # Lines exceeding max width of 80 characters ``` - 44: export * as something_bad_will_happen from "something_bad_might_not_happen" with { + 48: export * as something_bad_will_happen from "something_bad_might_not_happen" assert { ``` 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 deleted file mode 100644 index 552316c799b..00000000000 --- a/crates/rome_js_formatter/tests/specs/prettier/js/babel-plugins/import-assertions-static.js.snap +++ /dev/null @@ -1,83 +0,0 @@ ---- -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 614e7d8b91d..816b3af8455 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,7 @@ --- source: crates/rome_formatter_test/src/snapshot_builder.rs -assertion_line: 212 -info: js/import-assertions/bracket-spacing/empty.js +info: + test_file: js/import-assertions/bracket-spacing/empty.js --- # Input @@ -16,59 +16,15 @@ export * as bar from "bar.json" assert { } ```diff --- Prettier +++ Rome -@@ -1 +1,4 @@ - export * as bar from "bar.json"; -+assert; -+{ -+} +@@ -1 +1 @@ +-export * as bar from "bar.json"; ++export * as bar from "bar.json" assert {}; ``` # Output ```js -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 { } - │ ^^^^^^^^ - - +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 deleted file mode 100644 index 039a961ae29..00000000000 --- a/crates/rome_js_formatter/tests/specs/prettier/js/import-assertions/bracket-spacing/re-export.js.snap +++ /dev/null @@ -1,83 +0,0 @@ ---- -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 deleted file mode 100644 index 6e053afb988..00000000000 --- a/crates/rome_js_formatter/tests/specs/prettier/js/import-assertions/bracket-spacing/static-import.js.snap +++ /dev/null @@ -1,83 +0,0 @@ ---- -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 452c08c10a8..f591ebe1617 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,6 +1,5 @@ --- source: crates/rome_formatter_test/src/snapshot_builder.rs -assertion_line: 212 info: js/import-assertions/empty.js --- @@ -22,263 +21,30 @@ import * as baz from "baz.json" assert { /* comment */ } ```diff --- Prettier +++ Rome -@@ -1,7 +1,21 @@ +@@ -1,7 +1,7 @@ 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 */; -+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"; +-import * as bar from "bar.json"; -import * as baz from "baz.json" /* comment */; -+assert; -+{ -+} -+import * as baz from "baz.json"; -+assert; -+{ -+ /* comment */ -+} ++import * as bar from "bar.json" 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 */ -} -``` - -# 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 */ } - │ ^^^^^^^^ - - +import * as bar from "bar.json" assert {}; +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 deleted file mode 100644 index f88b287dd7e..00000000000 --- a/crates/rome_js_formatter/tests/specs/prettier/js/import-assertions/multi-types.js.snap +++ /dev/null @@ -1,105 +0,0 @@ ---- -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 deleted file mode 100644 index 2a0e200e7fa..00000000000 --- a/crates/rome_js_formatter/tests/specs/prettier/js/import-assertions/non-type.js.snap +++ /dev/null @@ -1,83 +0,0 @@ ---- -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 deleted file mode 100644 index b8ecf6f7b52..00000000000 --- a/crates/rome_js_formatter/tests/specs/prettier/js/import-assertions/re-export.js.snap +++ /dev/null @@ -1,217 +0,0 @@ ---- -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 deleted file mode 100644 index 5a017fd1e75..00000000000 --- a/crates/rome_js_formatter/tests/specs/prettier/js/import-assertions/static-import.js.snap +++ /dev/null @@ -1,83 +0,0 @@ ---- -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 deleted file mode 100644 index 9a4cb8a6cae..00000000000 --- a/crates/rome_js_formatter/tests/specs/prettier/js/import-assertions/without-from.js.snap +++ /dev/null @@ -1,83 +0,0 @@ ---- -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 bb39d9cc6b4..122fdfdf1ef 100644 --- a/crates/rome_js_parser/src/lexer/mod.rs +++ b/crates/rome_js_parser/src/lexer/mod.rs @@ -1061,6 +1061,7 @@ 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 99a68ee6c76..856dea7d765 100644 --- a/crates/rome_js_parser/src/lexer/tests.rs +++ b/crates/rome_js_parser/src/lexer/tests.rs @@ -1311,6 +1311,7 @@ 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 5b7af1d545f..ad960ca39ee 100644 --- a/crates/rome_js_parser/src/syntax/module.rs +++ b/crates/rome_js_parser/src/syntax/module.rs @@ -333,14 +333,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_attributes(p).ok(); + parse_import_assertion(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_attributes(p).ok(); + parse_import_assertion(p).ok(); m.complete(p, JS_IMPORT_DEFAULT_CLAUSE) } @@ -353,7 +353,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_attributes(p).ok(); + parse_import_assertion(p).ok(); m.complete(p, JS_IMPORT_BARE_CLAUSE) }) } @@ -367,7 +367,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_attributes(p).ok(); + parse_import_assertion(p).ok(); m.complete(p, JS_IMPORT_NAMESPACE_CLAUSE) } @@ -383,7 +383,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_attributes(p).ok(); + parse_import_assertion(p).ok(); m.complete(p, JS_IMPORT_NAMED_CLAUSE) } @@ -530,6 +530,15 @@ 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 +// { type: "json" } + // test import_attribute // import "x" with { type: "json" } // import "foo" with { "type": "json" }; @@ -539,45 +548,70 @@ fn parse_any_named_import_specifier(p: &mut JsParser) -> ParsedSyntax { // 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" }; +// 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 + // test_err import_attribute_err // import "foo" with { type, "json" }; -// import "bar" \u{61}ith { type: "json" }; // import { foo } with { type: "json" }; // import "lorem" -// with { type: "json" } +// 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 -fn parse_import_attributes(p: &mut JsParser) -> ParsedSyntax { - if !p.at(T![with]) || p.has_preceding_line_break() { +fn parse_import_assertion(p: &mut JsParser) -> ParsedSyntax { + if p.has_preceding_line_break() { + return Absent; + } + if !p.at(T![assert]) && !p.at(T![with]) { return Absent; } let m = p.start(); - p.expect(T![with]); - p.expect(T!['{']); + match p.cur() { + T![assert] => { + p.expect(T![assert]); + } + T![with] => { + p.expect(T![with]); + } + _ => { + m.abandon(p); + return Absent; + } + }; - ImportAttributeList::default().parse_list(p); + // bump assert or with + p.expect(T!['{']); + ImportAssertionList::default().parse_list(p); p.expect(T!['}']); - Present(m.complete(p, JS_IMPORT_ATTRIBUTE)) + Present(m.complete(p, JS_IMPORT_ASSERTION)) } #[derive(Default)] -struct ImportAttributeList { - attribute_keys: HashMap, +struct ImportAssertionList { + assertion_keys: HashMap, } -impl ParseSeparatedList for ImportAttributeList { +impl ParseSeparatedList for ImportAssertionList { type Kind = JsSyntaxKind; type Parser<'source> = JsParser<'source>; - const LIST_KIND: Self::Kind = JS_IMPORT_ATTRIBUTE_ENTRY_LIST; + const LIST_KIND: Self::Kind = JS_IMPORT_ASSERTION_ENTRY_LIST; fn parse_element(&mut self, p: &mut JsParser) -> ParsedSyntax { - parse_import_attribute_entry(p, &mut self.attribute_keys) + parse_import_assertion_entry(p, &mut self.assertion_keys) } fn is_at_list_end(&self, p: &mut JsParser) -> bool { @@ -588,11 +622,11 @@ impl ParseSeparatedList for ImportAttributeList { parsed_element.or_recover( p, &ParseRecovery::new( - JS_BOGUS_IMPORT_ATTRIBUTE_ENTRY, + JS_BOGUS_IMPORT_ASSERTION_ENTRY, STMT_RECOVERY_SET.union(token_set![T![,], T!['}']]), ) .enable_recovery_on_line_break(), - |p, range| expected_node("import attribute entry", range).into_diagnostic(p), + |p, range| expected_node("import assertion entry", range).into_diagnostic(p), ) } @@ -605,9 +639,9 @@ impl ParseSeparatedList for ImportAttributeList { } } -fn parse_import_attribute_entry( +fn parse_import_assertion_entry( p: &mut JsParser, - seen_attribute_keys: &mut HashMap, + seen_assertion_keys: &mut HashMap, ) -> ParsedSyntax { let m = p.start(); let key_range = p.cur_range(); @@ -641,7 +675,7 @@ fn parse_import_attribute_entry( let mut valid = true; if let Some(key) = key { - if let Some(first_use) = seen_attribute_keys.get(&key) { + if let Some(first_use) = seen_assertion_keys.get(&key) { p.error(duplicate_assertion_keys_error( p, &key, @@ -650,14 +684,14 @@ fn parse_import_attribute_entry( )); valid = false; } else { - seen_attribute_keys.insert(key, key_range); + seen_assertion_keys.insert(key, key_range); } }; p.expect(T![:]); p.expect(JS_STRING_LITERAL); - let mut entry = m.complete(p, JS_IMPORT_ATTRIBUTE_ENTRY); + let mut entry = m.complete(p, JS_IMPORT_ASSERTION_ENTRY); if !valid { entry.change_to_bogus(p); @@ -1007,7 +1041,7 @@ where // export * from "a"; // export * as c from "b"; // export * as default from "b" -// export * from "mod" with { type: "json" } +// export * from "mod" assert { type: "json" } // export type * from "types"; // export type * as types from "types"; // @@ -1034,7 +1068,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_attributes(p).ok(); + parse_import_assertion(p).ok(); semi(p, TextRange::new(start, p.cur_range().end())); Present(m.complete(p, JS_EXPORT_FROM_CLAUSE)) @@ -1046,7 +1080,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" with { type: "json" } +// export { a } from "mod" assert { type: "json" } // export { "a" } from "./mod"; // export { // "a" @@ -1080,7 +1114,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_attributes(p).ok(); + parse_import_assertion(p).ok(); semi(p, TextRange::new(start, p.cur_range().start())); diff --git a/crates/rome_js_parser/src/tests.rs b/crates/rome_js_parser/src/tests.rs index 836e34119bd..49e2180596d 100644 --- a/crates/rome_js_parser/src/tests.rs +++ b/crates/rome_js_parser/src/tests.rs @@ -14,9 +14,7 @@ use std::path::{Path, PathBuf}; #[test] fn parser_smoke_test() { let src = r#" -let -// comment -a; +import "x" with { type: "json" } "#; let module = parse(src, JsFileSource::tsx()); 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 fd994b6f6fa..4a00e4c147a 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 @@ -26,7 +26,7 @@ JsModule { source: JsModuleSource { value_token: JS_STRING_LITERAL@24..30 "\"life\"" [] [], }, - attribute: missing (optional), + assertion: 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 5a4efde4672..db8bd4e80d4 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 @@ -11,7 +11,7 @@ JsModule { export_as: missing (optional), from_token: missing (required), source: missing (required), - attribute: missing (optional), + assertion: missing (optional), semicolon_token: SEMICOLON@8..9 ";" [] [], }, }, @@ -24,7 +24,7 @@ JsModule { export_as: missing (optional), from_token: FROM_KW@19..24 "from" [] [Whitespace(" ")], source: missing (required), - attribute: missing (optional), + assertion: missing (optional), semicolon_token: missing (optional), }, }, @@ -50,7 +50,7 @@ JsModule { source: JsModuleSource { value_token: JS_STRING_LITERAL@42..48 "\"test\"" [] [], }, - attribute: missing (optional), + assertion: missing (optional), semicolon_token: SEMICOLON@48..49 ";" [] [], }, }, @@ -65,7 +65,7 @@ JsModule { source: JsModuleSource { value_token: JS_STRING_LITERAL@62..68 "\"test\"" [] [], }, - attribute: missing (optional), + assertion: missing (optional), semicolon_token: SEMICOLON@68..69 ";" [] [], }, }, @@ -78,7 +78,7 @@ JsModule { export_as: missing (optional), from_token: missing (required), source: missing (required), - attribute: missing (optional), + assertion: missing (optional), semicolon_token: SEMICOLON@83..84 ";" [] [], }, }, @@ -91,7 +91,7 @@ JsModule { export_as: missing (optional), from_token: FROM_KW@99..103 "from" [] [], source: missing (required), - attribute: missing (optional), + assertion: missing (optional), semicolon_token: SEMICOLON@103..104 ";" [] [], }, }, @@ -109,7 +109,7 @@ JsModule { }, from_token: missing (required), source: missing (required), - attribute: missing (optional), + assertion: missing (optional), semicolon_token: SEMICOLON@126..127 ";" [] [], }, }, @@ -127,7 +127,7 @@ JsModule { }, from_token: FROM_KW@148..152 "from" [] [], source: missing (required), - attribute: missing (optional), + assertion: 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 ba04744c9d6..4b67c2a5c32 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 @@ -25,7 +25,7 @@ JsModule { source: JsModuleSource { value_token: JS_STRING_LITERAL@21..26 "\"mod\"" [] [], }, - attribute: missing (optional), + assertion: missing (optional), semicolon_token: SEMICOLON@26..27 ";" [] [], }, }, @@ -101,7 +101,7 @@ JsModule { source: JsModuleSource { value_token: JS_STRING_LITERAL@80..85 "\"mod\"" [] [], }, - attribute: missing (optional), + assertion: 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 acedab4580b..365bcf2eaf7 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\"" [] [], }, - attribute: missing (optional), + assertion: 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 4a54ee3c286..f9049358715 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,77 +8,53 @@ JsModule { source: JsModuleSource { value_token: JS_STRING_LITERAL@7..13 "\"foo\"" [] [Whitespace(" ")], }, - 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" [] [], - }, + assertion: JsImportAssertion { + assertion_kind: 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), }, - comma_token: COMMA@26..28 "," [] [Whitespace(" ")], - right: JsStringLiteralExpression { - value_token: JS_STRING_LITERAL@28..35 "\"json\"" [] [Whitespace(" ")], + COMMA@26..28 "," [] [Whitespace(" ")], + JsImportAssertionEntry { + key: JS_STRING_LITERAL@28..35 "\"json\"" [] [Whitespace(" ")], + colon_token: missing (required), + value_token: missing (required), }, - }, - semicolon_token: missing (optional), - }, - ], - r_curly_token: R_CURLY@35..36 "}" [] [], - }, - JsEmptyStatement { - semicolon_token: SEMICOLON@36..37 ";" [] [], - }, - 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(" ")], + ], + r_curly_token: R_CURLY@35..36 "}" [] [], }, }, - semicolon_token: missing (optional), + semicolon_token: SEMICOLON@36..37 ";" [] [], }, - 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(" ")], + JsBogusStatement { + items: [ + IMPORT_KW@37..45 "import" [Newline("\n")] [Whitespace(" ")], + JsBogus { + items: [ + JsModuleSource { + value_token: JS_STRING_LITERAL@45..51 "\"bar\"" [] [Whitespace(" ")], }, - semicolon_token: missing (optional), - }, + 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 "}" [] [], + ], + }, + ], }, + 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(" ")], @@ -99,35 +75,19 @@ JsModule { }, from_token: missing (required), source: missing (required), - 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 { + assertion: JsImportAssertion { + assertion_kind: 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(" ")], value_token: JS_STRING_LITERAL@111..118 "\"json\"" [] [Whitespace(" ")], }, - semicolon_token: missing (optional), - }, + ], + r_curly_token: R_CURLY@118..119 "}" [] [], }, - ], - r_curly_token: R_CURLY@118..119 "}" [] [], - }, - JsEmptyStatement { + }, semicolon_token: SEMICOLON@119..120 ";" [] [], }, JsImport { @@ -136,7 +96,7 @@ JsModule { source: JsModuleSource { value_token: JS_STRING_LITERAL@128..135 "\"lorem\"" [] [], }, - attribute: missing (optional), + assertion: missing (optional), }, semicolon_token: missing (optional), }, @@ -175,60 +135,35 @@ JsModule { source: JsModuleSource { value_token: JS_STRING_LITERAL@177..188 "\"foo.json\"" [] [Whitespace(" ")], }, - 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\"" [] [], + assertion: JsImportAssertion { + assertion_kind: 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\"" [] [], + }, COMMA@211..213 "," [] [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\"" [] [], - }, + 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(" ")], + ], }, - 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 { @@ -237,14 +172,11 @@ JsModule { source: JsModuleSource { value_token: JS_STRING_LITERAL@250..254 "\"x\"" [] [Whitespace(" ")], }, - attribute: missing (optional), - }, - semicolon_token: missing (optional), - }, - JsExpressionStatement { - expression: JsIdentifierExpression { - name: JsReferenceIdentifier { - value_token: IDENT@254..260 "assert" [] [], + assertion: JsImportAssertion { + assertion_kind: ASSERT_KW@254..260 "assert" [] [], + l_curly_token: missing (required), + assertions: JsImportAssertionEntryList [], + r_curly_token: missing (required), }, }, semicolon_token: SEMICOLON@260..261 ";" [] [], @@ -260,53 +192,43 @@ JsModule { source: JsModuleSource { value_token: JS_STRING_LITERAL@280..293 "\"ipsum.json\"" [] [Whitespace(" ")], }, - 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" [] [], - }, - }, + assertion: JsImportAssertion { + assertion_kind: 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), }, - semicolon_token: missing (optional), - }, - }, - JsBogusStatement { - items: [ - COLON@320..322 ":" [] [Whitespace(" ")], - TRUE_KW@322..326 "true" [] [], COMMA@326..328 "," [] [Whitespace(" ")], - IDENT@328..339 "startAtLine" [] [], - COLON@339..341 ":" [] [Whitespace(" ")], - JS_NUMBER_LITERAL@341..343 "1" [] [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(" ")], + ], + }, ], + r_curly_token: R_CURLY@343..344 "}" [] [], }, - ], - r_curly_token: R_CURLY@343..344 "}" [] [], - }, - JsEmptyStatement { + }, semicolon_token: SEMICOLON@344..345 ";" [] [], }, JsImport { @@ -330,14 +252,11 @@ JsModule { source: JsModuleSource { value_token: JS_STRING_LITERAL@364..373 "\"a.json\"" [] [Whitespace(" ")], }, - attribute: missing (optional), - }, - semicolon_token: missing (optional), - }, - JsExpressionStatement { - expression: JsIdentifierExpression { - name: JsReferenceIdentifier { - value_token: IDENT@373..379 "assert" [] [], + assertion: JsImportAssertion { + assertion_kind: ASSERT_KW@373..379 "assert" [] [], + l_curly_token: missing (required), + assertions: JsImportAssertionEntryList [], + r_curly_token: missing (required), }, }, semicolon_token: missing (optional), @@ -350,61 +269,44 @@ JsModule { 0: (empty) 1: JS_DIRECTIVE_LIST@0..0 2: JS_MODULE_ITEM_LIST@0..379 - 0: JS_IMPORT@0..13 + 0: JS_IMPORT@0..37 0: IMPORT_KW@0..7 "import" [] [Whitespace(" ")] - 1: JS_IMPORT_BARE_CLAUSE@7..13 + 1: JS_IMPORT_BARE_CLAUSE@7..36 0: JS_MODULE_SOURCE@7..13 0: JS_STRING_LITERAL@7..13 "\"foo\"" [] [Whitespace(" ")] - 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: 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: COMMA@26..28 "," [] [Whitespace(" ")] - 2: JS_STRING_LITERAL_EXPRESSION@28..35 + 2: JS_IMPORT_ASSERTION_ENTRY@28..35 0: JS_STRING_LITERAL@28..35 "\"json\"" [] [Whitespace(" ")] - 1: (empty) - 2: R_CURLY@35..36 "}" [] [] - 3: JS_EMPTY_STATEMENT@36..37 - 0: SEMICOLON@36..37 ";" [] [] - 4: JS_IMPORT@37..51 + 1: (empty) + 2: (empty) + 3: R_CURLY@35..36 "}" [] [] + 2: SEMICOLON@36..37 ";" [] [] + 1: JS_BOGUS_STATEMENT@37..80 0: IMPORT_KW@37..45 "import" [Newline("\n")] [Whitespace(" ")] - 1: JS_IMPORT_BARE_CLAUSE@45..51 + 1: JS_BOGUS@45..79 0: JS_MODULE_SOURCE@45..51 0: JS_STRING_LITERAL@45..51 "\"bar\"" [] [Whitespace(" ")] - 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 + 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 0: IMPORT_KW@80..88 "import" [Newline("\n")] [Whitespace(" ")] - 1: JS_IMPORT_NAMED_CLAUSE@88..96 + 1: JS_IMPORT_NAMED_CLAUSE@88..119 0: (empty) 1: (empty) 2: JS_NAMED_IMPORT_SPECIFIERS@88..96 @@ -417,39 +319,29 @@ JsModule { 2: R_CURLY@94..96 "}" [] [Whitespace(" ")] 3: (empty) 4: (empty) - 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 + 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 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) - 13: JS_EXPRESSION_STATEMENT@135..143 + 4: 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) - 14: JS_BLOCK_STATEMENT@143..159 + 5: JS_BLOCK_STATEMENT@143..159 0: L_CURLY@143..145 "{" [] [Whitespace(" ")] 1: JS_STATEMENT_LIST@145..158 0: JS_LABELED_STATEMENT@145..158 @@ -460,106 +352,86 @@ JsModule { 0: JS_STRING_LITERAL@151..158 "\"json\"" [] [Whitespace(" ")] 1: (empty) 2: R_CURLY@158..159 "}" [] [] - 15: JS_IMPORT@159..188 + 6: JS_IMPORT@159..242 0: IMPORT_KW@159..167 "import" [Newline("\n")] [Whitespace(" ")] - 1: JS_IMPORT_DEFAULT_CLAUSE@167..188 + 1: JS_IMPORT_DEFAULT_CLAUSE@167..241 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: (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 + 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 0: IMPORT_KW@242..250 "import" [Newline("\n")] [Whitespace(" ")] - 1: JS_IMPORT_BARE_CLAUSE@250..254 + 1: JS_IMPORT_BARE_CLAUSE@250..260 0: JS_MODULE_SOURCE@250..254 0: JS_STRING_LITERAL@250..254 "\"x\"" [] [Whitespace(" ")] - 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 + 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 0: IMPORT_KW@261..269 "import" [Newline("\n")] [Whitespace(" ")] - 1: JS_IMPORT_DEFAULT_CLAUSE@269..293 + 1: JS_IMPORT_DEFAULT_CLAUSE@269..344 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: (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 + 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 0: IMPORT_KW@345..353 "import" [Newline("\n")] [Whitespace(" ")] - 1: JS_IMPORT_NAMED_CLAUSE@353..373 + 1: JS_IMPORT_NAMED_CLAUSE@353..379 0: (empty) 1: (empty) 2: JS_NAMED_IMPORT_SPECIFIERS@353..359 @@ -573,66 +445,41 @@ JsModule { 3: FROM_KW@359..364 "from" [] [Whitespace(" ")] 4: JS_MODULE_SOURCE@364..373 0: JS_STRING_LITERAL@364..373 "\"a.json\"" [] [Whitespace(" ")] - 5: (empty) + 5: JS_IMPORT_ASSERTION@373..379 + 0: ASSERT_KW@373..379 "assert" [] [] + 1: (empty) + 2: JS_IMPORT_ASSERTION_ENTRY_LIST@379..379 + 3: (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:14 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ +import_assertion_err.js:1:27 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ - × Expected a semicolon or an implicit semicolon after a statement, but found none + × expected `:` but instead found `,` > 1 │ import "foo" assert { type, "json" }; - │ ^^^^^^ + │ ^ 2 │ import "bar" \u{61}ssert { type: "json" }; 3 │ import { foo } 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" }; - - 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" }; + i Remove , -- -import_assertion_err.js:1:21 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ +import_assertion_err.js:1:36 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ - × Expected a semicolon or an implicit semicolon after a statement, but found none + × expected `:` but instead found `}` > 1 │ import "foo" assert { type, "json" }; - │ ^ - 2 │ import "bar" \u{61}ssert { type: "json" }; - 3 │ import { foo } 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" }; - 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" }; + i Remove } -- import_assertion_err.js:2:14 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ - × Expected a semicolon or an implicit semicolon after a statement, but found none + × 'assert' keyword cannot contain escape character. 1 │ import "foo" assert { type, "json" }; > 2 │ import "bar" \u{61}ssert { type: "json" }; @@ -640,49 +487,6 @@ 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 ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ @@ -697,36 +501,6 @@ 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 ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ @@ -758,271 +532,107 @@ import_assertion_err.js:5:8 parse ━━━━━━━━━━━━━━━ 7 │ import "x" assert; -- -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 ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ +import_assertion_err.js:6:38 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ - × Expected a semicolon or an implicit semicolon after a statement, but found none + × Duplicate assertion keys are not allowed 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... + i First use of the key `type` 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 + i second use 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 }; -- -import_assertion_err.js:7:12 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ +import_assertion_err.js:7:18 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ - × Expected a semicolon or an implicit semicolon after a statement, but found none + × expected `{` but instead found `;` 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 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 + i Remove ; -- -import_assertion_err.js:8:32 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ +import_assertion_err.js:8:61 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ - × 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... + × expected `string literal` but instead found `true` 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 │ + i Remove true -- -import_assertion_err.js:8:39 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ +import_assertion_err.js:8:65 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ - × 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... + × expected `:` but instead found `,` 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 │ + i Remove , -- -import_assertion_err.js:8:59 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ +import_assertion_err.js:8:80 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ - × Expected a semicolon or an implicit semicolon after a statement, but found none + × expected `string literal` but instead found `1` 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 ...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 │ + i Remove 1 -- -import_assertion_err.js:9:28 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ +import_assertion_err.js:10:1 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ - × Expected a semicolon or an implicit semicolon after a statement, but found none + × expected `{` but instead the file ends - 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... - - 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 + i the file ends 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 │ + │ -- 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 index d3f26f98235..07ad6c8c1e9 100644 --- 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 @@ -1,8 +1,7 @@ import "foo" with { type, "json" }; -import "bar" \u{61}ith { type: "json" }; import { foo } with { type: "json" }; import "lorem" -with { type: "json" } +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 }; 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 index 9eb1fa06ba3..9742aaaf415 100644 --- 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 @@ -8,17 +8,17 @@ JsModule { source: JsModuleSource { value_token: JS_STRING_LITERAL@7..13 "\"foo\"" [] [Whitespace(" ")], }, - attribute: JsImportAttribute { - with_token: WITH_KW@13..18 "with" [] [Whitespace(" ")], + assertion: JsImportAssertion { + assertion_kind: WITH_KW@13..18 "with" [] [Whitespace(" ")], l_curly_token: L_CURLY@18..20 "{" [] [Whitespace(" ")], - attributes: JsImportAttributeEntryList [ - JsImportAttributeEntry { + assertions: JsImportAssertionEntryList [ + JsImportAssertionEntry { key: IDENT@20..24 "type" [] [], colon_token: missing (required), value_token: missing (required), }, COMMA@24..26 "," [] [Whitespace(" ")], - JsImportAttributeEntry { + JsImportAssertionEntry { key: JS_STRING_LITERAL@26..33 "\"json\"" [] [Whitespace(" ")], colon_token: missing (required), value_token: missing (required), @@ -31,441 +31,385 @@ JsModule { }, 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(" ")], + l_curly_token: L_CURLY@43..45 "{" [] [Whitespace(" ")], specifiers: JsNamedImportSpecifierList [ JsShorthandNamedImportSpecifier { type_token: missing (optional), local_name: JsIdentifierBinding { - name_token: IDENT@86..90 "foo" [] [Whitespace(" ")], + name_token: IDENT@45..49 "foo" [] [Whitespace(" ")], }, }, ], - r_curly_token: R_CURLY@90..92 "}" [] [Whitespace(" ")], + r_curly_token: R_CURLY@49..51 "}" [] [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(" ")], + assertion: JsImportAssertion { + assertion_kind: WITH_KW@51..56 "with" [] [Whitespace(" ")], + l_curly_token: L_CURLY@56..58 "{" [] [Whitespace(" ")], + assertions: JsImportAssertionEntryList [ + JsImportAssertionEntry { + key: IDENT@58..62 "type" [] [], + colon_token: COLON@62..64 ":" [] [Whitespace(" ")], + value_token: JS_STRING_LITERAL@64..71 "\"json\"" [] [Whitespace(" ")], }, ], - r_curly_token: R_CURLY@112..113 "}" [] [], + r_curly_token: R_CURLY@71..72 "}" [] [], }, }, - semicolon_token: SEMICOLON@113..114 ";" [] [], + semicolon_token: SEMICOLON@72..73 ";" [] [], }, JsImport { - import_token: IMPORT_KW@114..122 "import" [Newline("\n")] [Whitespace(" ")], + import_token: IMPORT_KW@73..81 "import" [Newline("\n")] [Whitespace(" ")], import_clause: JsImportBareClause { source: JsModuleSource { - value_token: JS_STRING_LITERAL@122..129 "\"lorem\"" [] [], + value_token: JS_STRING_LITERAL@81..88 "\"lorem\"" [] [], }, - attribute: missing (optional), + assertion: missing (optional), }, semicolon_token: missing (optional), }, - JsBogusStatement { - items: [ - WITH_KW@129..135 "with" [Newline("\n")] [Whitespace(" ")], - JsBlockStatement { - l_curly_token: L_CURLY@135..137 "{" [] [Whitespace(" ")], - statements: JsStatementList [ - JsLabeledStatement { - label_token: IDENT@137..141 "type" [] [], - colon_token: COLON@141..143 ":" [] [Whitespace(" ")], - body: JsExpressionStatement { - expression: JsStringLiteralExpression { - value_token: JS_STRING_LITERAL@143..150 "\"json\"" [] [Whitespace(" ")], - }, - semicolon_token: missing (optional), - }, + JsExpressionStatement { + expression: JsIdentifierExpression { + name: JsReferenceIdentifier { + value_token: IDENT@88..96 "assert" [Newline("\n")] [Whitespace(" ")], + }, + }, + semicolon_token: missing (optional), + }, + JsBlockStatement { + l_curly_token: L_CURLY@96..98 "{" [] [Whitespace(" ")], + statements: JsStatementList [ + JsLabeledStatement { + label_token: IDENT@98..102 "type" [] [], + colon_token: COLON@102..104 ":" [] [Whitespace(" ")], + body: JsExpressionStatement { + expression: JsStringLiteralExpression { + value_token: JS_STRING_LITERAL@104..111 "\"json\"" [] [Whitespace(" ")], }, - ], - r_curly_token: R_CURLY@150..151 "}" [] [], + semicolon_token: missing (optional), + }, }, ], + r_curly_token: R_CURLY@111..112 "}" [] [], }, JsImport { - import_token: IMPORT_KW@151..159 "import" [Newline("\n")] [Whitespace(" ")], + import_token: IMPORT_KW@112..120 "import" [Newline("\n")] [Whitespace(" ")], import_clause: JsImportDefaultClause { type_token: missing (optional), local_name: JsIdentifierBinding { - name_token: IDENT@159..164 "foo2" [] [Whitespace(" ")], + name_token: IDENT@120..125 "foo2" [] [Whitespace(" ")], }, - from_token: FROM_KW@164..169 "from" [] [Whitespace(" ")], + from_token: FROM_KW@125..130 "from" [] [Whitespace(" ")], source: JsModuleSource { - value_token: JS_STRING_LITERAL@169..180 "\"foo.json\"" [] [Whitespace(" ")], + value_token: JS_STRING_LITERAL@130..141 "\"foo.json\"" [] [Whitespace(" ")], }, - attribute: JsImportAttribute { - with_token: WITH_KW@180..185 "with" [] [Whitespace(" ")], - l_curly_token: L_CURLY@185..187 "{" [] [Whitespace(" ")], - attributes: JsImportAttributeEntryList [ - JsImportAttributeEntry { - key: JS_STRING_LITERAL@187..193 "\"type\"" [] [], - colon_token: COLON@193..195 ":" [] [Whitespace(" ")], - value_token: JS_STRING_LITERAL@195..201 "\"json\"" [] [], + assertion: JsImportAssertion { + assertion_kind: WITH_KW@141..146 "with" [] [Whitespace(" ")], + l_curly_token: L_CURLY@146..148 "{" [] [Whitespace(" ")], + assertions: JsImportAssertionEntryList [ + JsImportAssertionEntry { + key: JS_STRING_LITERAL@148..154 "\"type\"" [] [], + colon_token: COLON@154..156 ":" [] [Whitespace(" ")], + value_token: JS_STRING_LITERAL@156..162 "\"json\"" [] [], }, - COMMA@201..203 "," [] [Whitespace(" ")], - JsBogusImportAttributeEntry { + COMMA@162..164 "," [] [Whitespace(" ")], + JsBogusImportAssertionEntry { items: [ - IDENT@203..207 "type" [] [], - COLON@207..209 ":" [] [Whitespace(" ")], - JS_STRING_LITERAL@209..215 "\"html\"" [] [], + IDENT@164..168 "type" [] [], + COLON@168..170 ":" [] [Whitespace(" ")], + JS_STRING_LITERAL@170..176 "\"html\"" [] [], ], }, - COMMA@215..217 "," [] [Whitespace(" ")], - JsBogusImportAttributeEntry { + COMMA@176..178 "," [] [Whitespace(" ")], + JsBogusImportAssertionEntry { items: [ - JS_STRING_LITERAL@217..223 "\"type\"" [] [], - COLON@223..225 ":" [] [Whitespace(" ")], - JS_STRING_LITERAL@225..230 "\"js\"" [] [Whitespace(" ")], + JS_STRING_LITERAL@178..184 "\"type\"" [] [], + COLON@184..186 ":" [] [Whitespace(" ")], + JS_STRING_LITERAL@186..191 "\"js\"" [] [Whitespace(" ")], ], }, ], - r_curly_token: R_CURLY@230..231 "}" [] [], + r_curly_token: R_CURLY@191..192 "}" [] [], }, }, - semicolon_token: SEMICOLON@231..232 ";" [] [], + semicolon_token: SEMICOLON@192..193 ";" [] [], }, JsImport { - import_token: IMPORT_KW@232..240 "import" [Newline("\n")] [Whitespace(" ")], + import_token: IMPORT_KW@193..201 "import" [Newline("\n")] [Whitespace(" ")], import_clause: JsImportBareClause { source: JsModuleSource { - value_token: JS_STRING_LITERAL@240..244 "\"x\"" [] [Whitespace(" ")], + value_token: JS_STRING_LITERAL@201..205 "\"x\"" [] [Whitespace(" ")], }, - attribute: JsImportAttribute { - with_token: WITH_KW@244..248 "with" [] [], + assertion: JsImportAssertion { + assertion_kind: WITH_KW@205..209 "with" [] [], l_curly_token: missing (required), - attributes: JsImportAttributeEntryList [], + assertions: JsImportAssertionEntryList [], r_curly_token: missing (required), }, }, - semicolon_token: SEMICOLON@248..249 ";" [] [], + semicolon_token: SEMICOLON@209..210 ";" [] [], }, JsImport { - import_token: IMPORT_KW@249..257 "import" [Newline("\n")] [Whitespace(" ")], + import_token: IMPORT_KW@210..218 "import" [Newline("\n")] [Whitespace(" ")], import_clause: JsImportDefaultClause { type_token: missing (optional), local_name: JsIdentifierBinding { - name_token: IDENT@257..263 "ipsum" [] [Whitespace(" ")], + name_token: IDENT@218..224 "ipsum" [] [Whitespace(" ")], }, - from_token: FROM_KW@263..268 "from" [] [Whitespace(" ")], + from_token: FROM_KW@224..229 "from" [] [Whitespace(" ")], source: JsModuleSource { - value_token: JS_STRING_LITERAL@268..281 "\"ipsum.json\"" [] [Whitespace(" ")], + value_token: JS_STRING_LITERAL@229..242 "\"ipsum.json\"" [] [Whitespace(" ")], }, - attribute: JsImportAttribute { - with_token: WITH_KW@281..286 "with" [] [Whitespace(" ")], - l_curly_token: L_CURLY@286..288 "{" [] [Whitespace(" ")], - attributes: JsImportAttributeEntryList [ - JsImportAttributeEntry { - key: IDENT@288..292 "type" [] [], - colon_token: COLON@292..294 ":" [] [Whitespace(" ")], - value_token: JS_STRING_LITERAL@294..300 "\"json\"" [] [], + assertion: JsImportAssertion { + assertion_kind: WITH_KW@242..247 "with" [] [Whitespace(" ")], + l_curly_token: L_CURLY@247..249 "{" [] [Whitespace(" ")], + assertions: JsImportAssertionEntryList [ + JsImportAssertionEntry { + key: IDENT@249..253 "type" [] [], + colon_token: COLON@253..255 ":" [] [Whitespace(" ")], + value_token: JS_STRING_LITERAL@255..261 "\"json\"" [] [], }, - COMMA@300..302 "," [] [Whitespace(" ")], - JsImportAttributeEntry { - key: IDENT@302..306 "lazy" [] [], - colon_token: COLON@306..308 ":" [] [Whitespace(" ")], + COMMA@261..263 "," [] [Whitespace(" ")], + JsImportAssertionEntry { + key: IDENT@263..267 "lazy" [] [], + colon_token: COLON@267..269 ":" [] [Whitespace(" ")], value_token: missing (required), }, missing separator, - JsImportAttributeEntry { - key: IDENT@308..312 "true" [] [], + JsImportAssertionEntry { + key: IDENT@269..273 "true" [] [], colon_token: missing (required), value_token: missing (required), }, - COMMA@312..314 "," [] [Whitespace(" ")], - JsImportAttributeEntry { - key: IDENT@314..325 "startAtLine" [] [], - colon_token: COLON@325..327 ":" [] [Whitespace(" ")], + COMMA@273..275 "," [] [Whitespace(" ")], + JsImportAssertionEntry { + key: IDENT@275..286 "startAtLine" [] [], + colon_token: COLON@286..288 ":" [] [Whitespace(" ")], value_token: missing (required), }, missing separator, - JsBogusImportAttributeEntry { + JsBogusImportAssertionEntry { items: [ - JS_NUMBER_LITERAL@327..329 "1" [] [Whitespace(" ")], + JS_NUMBER_LITERAL@288..290 "1" [] [Whitespace(" ")], ], }, ], - r_curly_token: R_CURLY@329..330 "}" [] [], + r_curly_token: R_CURLY@290..291 "}" [] [], }, }, - semicolon_token: SEMICOLON@330..331 ";" [] [], + semicolon_token: SEMICOLON@291..292 ";" [] [], }, JsImport { - import_token: IMPORT_KW@331..339 "import" [Newline("\n")] [Whitespace(" ")], + import_token: IMPORT_KW@292..300 "import" [Newline("\n")] [Whitespace(" ")], import_clause: JsImportNamedClause { type_token: missing (optional), default_specifier: missing (optional), named_import: JsNamedImportSpecifiers { - l_curly_token: L_CURLY@339..341 "{" [] [Whitespace(" ")], + l_curly_token: L_CURLY@300..302 "{" [] [Whitespace(" ")], specifiers: JsNamedImportSpecifierList [ JsShorthandNamedImportSpecifier { type_token: missing (optional), local_name: JsIdentifierBinding { - name_token: IDENT@341..343 "a" [] [Whitespace(" ")], + name_token: IDENT@302..304 "a" [] [Whitespace(" ")], }, }, ], - r_curly_token: R_CURLY@343..345 "}" [] [Whitespace(" ")], + r_curly_token: R_CURLY@304..306 "}" [] [Whitespace(" ")], }, - from_token: FROM_KW@345..350 "from" [] [Whitespace(" ")], + from_token: FROM_KW@306..311 "from" [] [Whitespace(" ")], source: JsModuleSource { - value_token: JS_STRING_LITERAL@350..359 "\"a.json\"" [] [Whitespace(" ")], + value_token: JS_STRING_LITERAL@311..320 "\"a.json\"" [] [Whitespace(" ")], }, - attribute: JsImportAttribute { - with_token: WITH_KW@359..363 "with" [] [], + assertion: JsImportAssertion { + assertion_kind: WITH_KW@320..324 "with" [] [], l_curly_token: missing (required), - attributes: JsImportAttributeEntryList [], + assertions: JsImportAssertionEntryList [], r_curly_token: missing (required), }, }, semicolon_token: missing (optional), }, ], - eof_token: EOF@363..364 "" [Newline("\n")] [], + eof_token: EOF@324..325 "" [Newline("\n")] [], } -0: JS_MODULE@0..364 +0: JS_MODULE@0..325 0: (empty) 1: JS_DIRECTIVE_LIST@0..0 - 2: JS_MODULE_ITEM_LIST@0..363 + 2: JS_MODULE_ITEM_LIST@0..324 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 + 1: JS_IMPORT_ASSERTION@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 + 2: JS_IMPORT_ASSERTION_ENTRY_LIST@20..33 + 0: JS_IMPORT_ASSERTION_ENTRY@20..24 0: IDENT@20..24 "type" [] [] 1: (empty) 2: (empty) 1: COMMA@24..26 "," [] [Whitespace(" ")] - 2: JS_IMPORT_ATTRIBUTE_ENTRY@26..33 + 2: JS_IMPORT_ASSERTION_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 + 1: JS_IMPORT@35..73 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 + 1: JS_IMPORT_NAMED_CLAUSE@43..72 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 + 2: JS_NAMED_IMPORT_SPECIFIERS@43..51 + 0: L_CURLY@43..45 "{" [] [Whitespace(" ")] + 1: JS_NAMED_IMPORT_SPECIFIER_LIST@45..49 + 0: JS_SHORTHAND_NAMED_IMPORT_SPECIFIER@45..49 0: (empty) - 1: JS_IDENTIFIER_BINDING@86..90 - 0: IDENT@86..90 "foo" [] [Whitespace(" ")] - 2: R_CURLY@90..92 "}" [] [Whitespace(" ")] + 1: JS_IDENTIFIER_BINDING@45..49 + 0: IDENT@45..49 "foo" [] [Whitespace(" ")] + 2: R_CURLY@49..51 "}" [] [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\"" [] [] + 5: JS_IMPORT_ASSERTION@51..72 + 0: WITH_KW@51..56 "with" [] [Whitespace(" ")] + 1: L_CURLY@56..58 "{" [] [Whitespace(" ")] + 2: JS_IMPORT_ASSERTION_ENTRY_LIST@58..71 + 0: JS_IMPORT_ASSERTION_ENTRY@58..71 + 0: IDENT@58..62 "type" [] [] + 1: COLON@62..64 ":" [] [Whitespace(" ")] + 2: JS_STRING_LITERAL@64..71 "\"json\"" [] [Whitespace(" ")] + 3: R_CURLY@71..72 "}" [] [] + 2: SEMICOLON@72..73 ";" [] [] + 2: JS_IMPORT@73..88 + 0: IMPORT_KW@73..81 "import" [Newline("\n")] [Whitespace(" ")] + 1: JS_IMPORT_BARE_CLAUSE@81..88 + 0: JS_MODULE_SOURCE@81..88 + 0: JS_STRING_LITERAL@81..88 "\"lorem\"" [] [] 1: (empty) 2: (empty) - 7: JS_BOGUS_STATEMENT@129..151 - 0: WITH_KW@129..135 "with" [Newline("\n")] [Whitespace(" ")] - 1: JS_BLOCK_STATEMENT@135..151 - 0: L_CURLY@135..137 "{" [] [Whitespace(" ")] - 1: JS_STATEMENT_LIST@137..150 - 0: JS_LABELED_STATEMENT@137..150 - 0: IDENT@137..141 "type" [] [] - 1: COLON@141..143 ":" [] [Whitespace(" ")] - 2: JS_EXPRESSION_STATEMENT@143..150 - 0: JS_STRING_LITERAL_EXPRESSION@143..150 - 0: JS_STRING_LITERAL@143..150 "\"json\"" [] [Whitespace(" ")] - 1: (empty) - 2: R_CURLY@150..151 "}" [] [] - 8: JS_IMPORT@151..232 - 0: IMPORT_KW@151..159 "import" [Newline("\n")] [Whitespace(" ")] - 1: JS_IMPORT_DEFAULT_CLAUSE@159..231 + 3: JS_EXPRESSION_STATEMENT@88..96 + 0: JS_IDENTIFIER_EXPRESSION@88..96 + 0: JS_REFERENCE_IDENTIFIER@88..96 + 0: IDENT@88..96 "assert" [Newline("\n")] [Whitespace(" ")] + 1: (empty) + 4: JS_BLOCK_STATEMENT@96..112 + 0: L_CURLY@96..98 "{" [] [Whitespace(" ")] + 1: JS_STATEMENT_LIST@98..111 + 0: JS_LABELED_STATEMENT@98..111 + 0: IDENT@98..102 "type" [] [] + 1: COLON@102..104 ":" [] [Whitespace(" ")] + 2: JS_EXPRESSION_STATEMENT@104..111 + 0: JS_STRING_LITERAL_EXPRESSION@104..111 + 0: JS_STRING_LITERAL@104..111 "\"json\"" [] [Whitespace(" ")] + 1: (empty) + 2: R_CURLY@111..112 "}" [] [] + 5: JS_IMPORT@112..193 + 0: IMPORT_KW@112..120 "import" [Newline("\n")] [Whitespace(" ")] + 1: JS_IMPORT_DEFAULT_CLAUSE@120..192 0: (empty) - 1: JS_IDENTIFIER_BINDING@159..164 - 0: IDENT@159..164 "foo2" [] [Whitespace(" ")] - 2: FROM_KW@164..169 "from" [] [Whitespace(" ")] - 3: JS_MODULE_SOURCE@169..180 - 0: JS_STRING_LITERAL@169..180 "\"foo.json\"" [] [Whitespace(" ")] - 4: JS_IMPORT_ATTRIBUTE@180..231 - 0: WITH_KW@180..185 "with" [] [Whitespace(" ")] - 1: L_CURLY@185..187 "{" [] [Whitespace(" ")] - 2: JS_IMPORT_ATTRIBUTE_ENTRY_LIST@187..230 - 0: JS_IMPORT_ATTRIBUTE_ENTRY@187..201 - 0: JS_STRING_LITERAL@187..193 "\"type\"" [] [] - 1: COLON@193..195 ":" [] [Whitespace(" ")] - 2: JS_STRING_LITERAL@195..201 "\"json\"" [] [] - 1: COMMA@201..203 "," [] [Whitespace(" ")] - 2: JS_BOGUS_IMPORT_ATTRIBUTE_ENTRY@203..215 - 0: IDENT@203..207 "type" [] [] - 1: COLON@207..209 ":" [] [Whitespace(" ")] - 2: JS_STRING_LITERAL@209..215 "\"html\"" [] [] - 3: COMMA@215..217 "," [] [Whitespace(" ")] - 4: JS_BOGUS_IMPORT_ATTRIBUTE_ENTRY@217..230 - 0: JS_STRING_LITERAL@217..223 "\"type\"" [] [] - 1: COLON@223..225 ":" [] [Whitespace(" ")] - 2: JS_STRING_LITERAL@225..230 "\"js\"" [] [Whitespace(" ")] - 3: R_CURLY@230..231 "}" [] [] - 2: SEMICOLON@231..232 ";" [] [] - 9: JS_IMPORT@232..249 - 0: IMPORT_KW@232..240 "import" [Newline("\n")] [Whitespace(" ")] - 1: JS_IMPORT_BARE_CLAUSE@240..248 - 0: JS_MODULE_SOURCE@240..244 - 0: JS_STRING_LITERAL@240..244 "\"x\"" [] [Whitespace(" ")] - 1: JS_IMPORT_ATTRIBUTE@244..248 - 0: WITH_KW@244..248 "with" [] [] + 1: JS_IDENTIFIER_BINDING@120..125 + 0: IDENT@120..125 "foo2" [] [Whitespace(" ")] + 2: FROM_KW@125..130 "from" [] [Whitespace(" ")] + 3: JS_MODULE_SOURCE@130..141 + 0: JS_STRING_LITERAL@130..141 "\"foo.json\"" [] [Whitespace(" ")] + 4: JS_IMPORT_ASSERTION@141..192 + 0: WITH_KW@141..146 "with" [] [Whitespace(" ")] + 1: L_CURLY@146..148 "{" [] [Whitespace(" ")] + 2: JS_IMPORT_ASSERTION_ENTRY_LIST@148..191 + 0: JS_IMPORT_ASSERTION_ENTRY@148..162 + 0: JS_STRING_LITERAL@148..154 "\"type\"" [] [] + 1: COLON@154..156 ":" [] [Whitespace(" ")] + 2: JS_STRING_LITERAL@156..162 "\"json\"" [] [] + 1: COMMA@162..164 "," [] [Whitespace(" ")] + 2: JS_BOGUS_IMPORT_ASSERTION_ENTRY@164..176 + 0: IDENT@164..168 "type" [] [] + 1: COLON@168..170 ":" [] [Whitespace(" ")] + 2: JS_STRING_LITERAL@170..176 "\"html\"" [] [] + 3: COMMA@176..178 "," [] [Whitespace(" ")] + 4: JS_BOGUS_IMPORT_ASSERTION_ENTRY@178..191 + 0: JS_STRING_LITERAL@178..184 "\"type\"" [] [] + 1: COLON@184..186 ":" [] [Whitespace(" ")] + 2: JS_STRING_LITERAL@186..191 "\"js\"" [] [Whitespace(" ")] + 3: R_CURLY@191..192 "}" [] [] + 2: SEMICOLON@192..193 ";" [] [] + 6: JS_IMPORT@193..210 + 0: IMPORT_KW@193..201 "import" [Newline("\n")] [Whitespace(" ")] + 1: JS_IMPORT_BARE_CLAUSE@201..209 + 0: JS_MODULE_SOURCE@201..205 + 0: JS_STRING_LITERAL@201..205 "\"x\"" [] [Whitespace(" ")] + 1: JS_IMPORT_ASSERTION@205..209 + 0: WITH_KW@205..209 "with" [] [] 1: (empty) - 2: JS_IMPORT_ATTRIBUTE_ENTRY_LIST@248..248 + 2: JS_IMPORT_ASSERTION_ENTRY_LIST@209..209 3: (empty) - 2: SEMICOLON@248..249 ";" [] [] - 10: JS_IMPORT@249..331 - 0: IMPORT_KW@249..257 "import" [Newline("\n")] [Whitespace(" ")] - 1: JS_IMPORT_DEFAULT_CLAUSE@257..330 + 2: SEMICOLON@209..210 ";" [] [] + 7: JS_IMPORT@210..292 + 0: IMPORT_KW@210..218 "import" [Newline("\n")] [Whitespace(" ")] + 1: JS_IMPORT_DEFAULT_CLAUSE@218..291 0: (empty) - 1: JS_IDENTIFIER_BINDING@257..263 - 0: IDENT@257..263 "ipsum" [] [Whitespace(" ")] - 2: FROM_KW@263..268 "from" [] [Whitespace(" ")] - 3: JS_MODULE_SOURCE@268..281 - 0: JS_STRING_LITERAL@268..281 "\"ipsum.json\"" [] [Whitespace(" ")] - 4: JS_IMPORT_ATTRIBUTE@281..330 - 0: WITH_KW@281..286 "with" [] [Whitespace(" ")] - 1: L_CURLY@286..288 "{" [] [Whitespace(" ")] - 2: JS_IMPORT_ATTRIBUTE_ENTRY_LIST@288..329 - 0: JS_IMPORT_ATTRIBUTE_ENTRY@288..300 - 0: IDENT@288..292 "type" [] [] - 1: COLON@292..294 ":" [] [Whitespace(" ")] - 2: JS_STRING_LITERAL@294..300 "\"json\"" [] [] - 1: COMMA@300..302 "," [] [Whitespace(" ")] - 2: JS_IMPORT_ATTRIBUTE_ENTRY@302..308 - 0: IDENT@302..306 "lazy" [] [] - 1: COLON@306..308 ":" [] [Whitespace(" ")] + 1: JS_IDENTIFIER_BINDING@218..224 + 0: IDENT@218..224 "ipsum" [] [Whitespace(" ")] + 2: FROM_KW@224..229 "from" [] [Whitespace(" ")] + 3: JS_MODULE_SOURCE@229..242 + 0: JS_STRING_LITERAL@229..242 "\"ipsum.json\"" [] [Whitespace(" ")] + 4: JS_IMPORT_ASSERTION@242..291 + 0: WITH_KW@242..247 "with" [] [Whitespace(" ")] + 1: L_CURLY@247..249 "{" [] [Whitespace(" ")] + 2: JS_IMPORT_ASSERTION_ENTRY_LIST@249..290 + 0: JS_IMPORT_ASSERTION_ENTRY@249..261 + 0: IDENT@249..253 "type" [] [] + 1: COLON@253..255 ":" [] [Whitespace(" ")] + 2: JS_STRING_LITERAL@255..261 "\"json\"" [] [] + 1: COMMA@261..263 "," [] [Whitespace(" ")] + 2: JS_IMPORT_ASSERTION_ENTRY@263..269 + 0: IDENT@263..267 "lazy" [] [] + 1: COLON@267..269 ":" [] [Whitespace(" ")] 2: (empty) 3: (empty) - 4: JS_IMPORT_ATTRIBUTE_ENTRY@308..312 - 0: IDENT@308..312 "true" [] [] + 4: JS_IMPORT_ASSERTION_ENTRY@269..273 + 0: IDENT@269..273 "true" [] [] 1: (empty) 2: (empty) - 5: COMMA@312..314 "," [] [Whitespace(" ")] - 6: JS_IMPORT_ATTRIBUTE_ENTRY@314..327 - 0: IDENT@314..325 "startAtLine" [] [] - 1: COLON@325..327 ":" [] [Whitespace(" ")] + 5: COMMA@273..275 "," [] [Whitespace(" ")] + 6: JS_IMPORT_ASSERTION_ENTRY@275..288 + 0: IDENT@275..286 "startAtLine" [] [] + 1: COLON@286..288 ":" [] [Whitespace(" ")] 2: (empty) 7: (empty) - 8: JS_BOGUS_IMPORT_ATTRIBUTE_ENTRY@327..329 - 0: JS_NUMBER_LITERAL@327..329 "1" [] [Whitespace(" ")] - 3: R_CURLY@329..330 "}" [] [] - 2: SEMICOLON@330..331 ";" [] [] - 11: JS_IMPORT@331..363 - 0: IMPORT_KW@331..339 "import" [Newline("\n")] [Whitespace(" ")] - 1: JS_IMPORT_NAMED_CLAUSE@339..363 + 8: JS_BOGUS_IMPORT_ASSERTION_ENTRY@288..290 + 0: JS_NUMBER_LITERAL@288..290 "1" [] [Whitespace(" ")] + 3: R_CURLY@290..291 "}" [] [] + 2: SEMICOLON@291..292 ";" [] [] + 8: JS_IMPORT@292..324 + 0: IMPORT_KW@292..300 "import" [Newline("\n")] [Whitespace(" ")] + 1: JS_IMPORT_NAMED_CLAUSE@300..324 0: (empty) 1: (empty) - 2: JS_NAMED_IMPORT_SPECIFIERS@339..345 - 0: L_CURLY@339..341 "{" [] [Whitespace(" ")] - 1: JS_NAMED_IMPORT_SPECIFIER_LIST@341..343 - 0: JS_SHORTHAND_NAMED_IMPORT_SPECIFIER@341..343 + 2: JS_NAMED_IMPORT_SPECIFIERS@300..306 + 0: L_CURLY@300..302 "{" [] [Whitespace(" ")] + 1: JS_NAMED_IMPORT_SPECIFIER_LIST@302..304 + 0: JS_SHORTHAND_NAMED_IMPORT_SPECIFIER@302..304 0: (empty) - 1: JS_IDENTIFIER_BINDING@341..343 - 0: IDENT@341..343 "a" [] [Whitespace(" ")] - 2: R_CURLY@343..345 "}" [] [Whitespace(" ")] - 3: FROM_KW@345..350 "from" [] [Whitespace(" ")] - 4: JS_MODULE_SOURCE@350..359 - 0: JS_STRING_LITERAL@350..359 "\"a.json\"" [] [Whitespace(" ")] - 5: JS_IMPORT_ATTRIBUTE@359..363 - 0: WITH_KW@359..363 "with" [] [] + 1: JS_IDENTIFIER_BINDING@302..304 + 0: IDENT@302..304 "a" [] [Whitespace(" ")] + 2: R_CURLY@304..306 "}" [] [Whitespace(" ")] + 3: FROM_KW@306..311 "from" [] [Whitespace(" ")] + 4: JS_MODULE_SOURCE@311..320 + 0: JS_STRING_LITERAL@311..320 "\"a.json\"" [] [Whitespace(" ")] + 5: JS_IMPORT_ASSERTION@320..324 + 0: WITH_KW@320..324 "with" [] [] 1: (empty) - 2: JS_IMPORT_ATTRIBUTE_ENTRY_LIST@363..363 + 2: JS_IMPORT_ASSERTION_ENTRY_LIST@324..324 3: (empty) 2: (empty) - 3: EOF@363..364 "" [Newline("\n")] [] + 3: EOF@324..325 "" [Newline("\n")] [] -- import_attribute_err.js:1:25 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ @@ -473,8 +417,8 @@ import_attribute_err.js:1:25 parse ━━━━━━━━━━━━━━━ > 1 │ import "foo" with { type, "json" }; │ ^ - 2 │ import "bar" \u{61}ith { type: "json" }; - 3 │ import { foo } with { type: "json" }; + 2 │ import { foo } with { type: "json" }; + 3 │ import "lorem" i Remove , @@ -485,214 +429,162 @@ import_attribute_err.js:1:34 parse ━━━━━━━━━━━━━━━ > 1 │ import "foo" with { type, "json" }; │ ^ - 2 │ import "bar" \u{61}ith { type: "json" }; - 3 │ import { foo } with { type: "json" }; + 2 │ import { foo } with { type: "json" }; + 3 │ import "lorem" i Remove } -- -import_attribute_err.js:2:14 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ +import_attribute_err.js:2:16 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... + × 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" - - i ...Which is required to end this statement + > 2 │ import { foo } with { type: "json" }; + │ ^^^^ + 3 │ import "lorem" + 4 │ assert { type: "json" } - 1 │ import "foo" with { type, "json" }; - > 2 │ import "bar" \u{61}ith { type: "json" }; - │ ^^^^^^^^^^^^^ - 3 │ import { foo } with { type: "json" }; - 4 │ import "lorem" + i Remove with -- -import_attribute_err.js:2:24 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ +import_attribute_err.js:4:8 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" + 2 │ import { foo } with { type: "json" }; + 3 │ import "lorem" + > 4 │ assert { type: "json" } + │ ^ + 5 │ import foo2 from "foo.json" with { "type": "json", type: "html", "type": "js" }; + 6 │ import "x" with; 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" + 2 │ import { foo } with { type: "json" }; + 3 │ import "lorem" + > 4 │ assert { type: "json" } + │ ^ + 5 │ import foo2 from "foo.json" with { "type": "json", type: "html", "type": "js" }; + 6 │ import "x" with; 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 │ with { type: "json" } - - i Remove with - --- -import_attribute_err.js:5:6 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ - - × expected `(` but instead found `{` - - 3 │ import { foo } with { type: "json" }; - 4 │ import "lorem" - > 5 │ with { type: "json" } - │ ^ - 6 │ import foo2 from "foo.json" with { "type": "json", type: "html", "type": "js" }; - 7 │ import "x" with; - - i Remove { - --- -import_attribute_err.js:5:1 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ - - × `with` statements are not allowed in strict mode - - 3 │ import { foo } with { type: "json" }; - 4 │ import "lorem" - > 5 │ with { type: "json" } - │ ^^^^^^^^^^^^^^^^^^^^^ - 6 │ import foo2 from "foo.json" with { "type": "json", type: "html", "type": "js" }; - 7 │ import "x" with; + 2 │ import { foo } with { type: "json" }; + 3 │ import "lorem" + > 4 │ assert { type: "json" } + │ ^^^^^^^^ + 5 │ import foo2 from "foo.json" with { "type": "json", type: "html", "type": "js" }; + 6 │ import "x" with; -- -import_attribute_err.js:6:36 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ +import_attribute_err.js:5:36 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ × Duplicate assertion keys are not allowed - 4 │ import "lorem" - 5 │ with { type: "json" } - > 6 │ import foo2 from "foo.json" with { "type": "json", type: "html", "type": "js" }; + 3 │ import "lorem" + 4 │ assert { type: "json" } + > 5 │ 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 }; + 6 │ import "x" with; + 7 │ import ipsum from "ipsum.json" with { type: "json", lazy: true, startAtLine: 1 }; i First use of the key `type` - 4 │ import "lorem" - 5 │ with { type: "json" } - > 6 │ import foo2 from "foo.json" with { "type": "json", type: "html", "type": "js" }; + 3 │ import "lorem" + 4 │ assert { type: "json" } + > 5 │ 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 }; + 6 │ import "x" with; + 7 │ import ipsum from "ipsum.json" with { type: "json", lazy: true, startAtLine: 1 }; i second use here - 4 │ import "lorem" - 5 │ with { type: "json" } - > 6 │ import foo2 from "foo.json" with { "type": "json", type: "html", "type": "js" }; + 3 │ import "lorem" + 4 │ assert { type: "json" } + > 5 │ 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 }; + 6 │ import "x" with; + 7 │ import ipsum from "ipsum.json" with { type: "json", lazy: true, startAtLine: 1 }; -- -import_attribute_err.js:7:16 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ +import_attribute_err.js:6:16 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ × expected `{` but instead found `;` - 5 │ with { type: "json" } - 6 │ import foo2 from "foo.json" with { "type": "json", type: "html", "type": "js" }; - > 7 │ import "x" with; + 4 │ assert { type: "json" } + 5 │ import foo2 from "foo.json" with { "type": "json", type: "html", "type": "js" }; + > 6 │ import "x" with; │ ^ - 8 │ import ipsum from "ipsum.json" with { type: "json", lazy: true, startAtLine: 1 }; - 9 │ import { a } from "a.json" with + 7 │ import ipsum from "ipsum.json" with { type: "json", lazy: true, startAtLine: 1 }; + 8 │ import { a } from "a.json" with i Remove ; -- -import_attribute_err.js:8:59 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ +import_attribute_err.js:7: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 │ + 5 │ import foo2 from "foo.json" with { "type": "json", type: "html", "type": "js" }; + 6 │ import "x" with; + > 7 │ import ipsum from "ipsum.json" with { type: "json", lazy: true, startAtLine: 1 }; + │ ^^^^ + 8 │ import { a } from "a.json" with + 9 │ i Remove true -- -import_attribute_err.js:8:63 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ +import_attribute_err.js:7: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 │ + 5 │ import foo2 from "foo.json" with { "type": "json", type: "html", "type": "js" }; + 6 │ import "x" with; + > 7 │ import ipsum from "ipsum.json" with { type: "json", lazy: true, startAtLine: 1 }; + │ ^ + 8 │ import { a } from "a.json" with + 9 │ i Remove , -- -import_attribute_err.js:8:78 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ +import_attribute_err.js:7: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 │ + 5 │ import foo2 from "foo.json" with { "type": "json", type: "html", "type": "js" }; + 6 │ import "x" with; + > 7 │ import ipsum from "ipsum.json" with { type: "json", lazy: true, startAtLine: 1 }; + │ ^ + 8 │ import { a } from "a.json" with + 9 │ i Remove 1 -- -import_attribute_err.js:10:1 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ +import_attribute_err.js:9: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 │ - │ + 7 │ import ipsum from "ipsum.json" with { type: "json", lazy: true, startAtLine: 1 }; + 8 │ import { a } from "a.json" with + > 9 │ + │ 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 │ - │ + 7 │ import ipsum from "ipsum.json" with { type: "json", lazy: true, startAtLine: 1 }; + 8 │ import { a } from "a.json" with + > 9 │ + │ -- import "foo" with { type, "json" }; -import "bar" \u{61}ith { type: "json" }; import { foo } with { type: "json" }; import "lorem" -with { type: "json" } +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 }; 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 eb841f5163d..ef6d49bd8a8 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\"" [] [], }, - attribute: missing (optional), + assertion: 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 21d6892f09a..e8a0259cc1d 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), - attribute: missing (optional), + assertion: missing (optional), }, semicolon_token: SEMICOLON@16..17 ";" [] [], }, @@ -31,7 +31,7 @@ JsModule { }, from_token: missing (required), source: missing (required), - attribute: missing (optional), + assertion: missing (optional), }, semicolon_token: missing (optional), }, @@ -111,7 +111,7 @@ JsModule { source: JsModuleSource { value_token: JS_STRING_LITERAL@80..83 "\"c\"" [] [], }, - attribute: missing (optional), + assertion: missing (optional), }, semicolon_token: SEMICOLON@83..84 ";" [] [], }, @@ -143,7 +143,7 @@ JsModule { source: JsModuleSource { value_token: JS_STRING_LITERAL@108..111 "\"c\"" [] [], }, - attribute: missing (optional), + assertion: missing (optional), }, semicolon_token: SEMICOLON@111..112 ";" [] [], }, @@ -170,7 +170,7 @@ JsModule { source: JsModuleSource { value_token: JS_STRING_LITERAL@137..140 "\"c\"" [] [], }, - attribute: missing (optional), + assertion: missing (optional), }, semicolon_token: SEMICOLON@140..141 ";" [] [], }, @@ -197,7 +197,7 @@ JsModule { source: JsModuleSource { value_token: JS_STRING_LITERAL@162..165 "\"c\"" [] [], }, - attribute: missing (optional), + assertion: missing (optional), }, semicolon_token: SEMICOLON@165..166 ";" [] [], }, @@ -224,7 +224,7 @@ JsModule { source: JsModuleSource { value_token: JS_STRING_LITERAL@188..191 "\"c\"" [] [], }, - attribute: missing (optional), + assertion: missing (optional), }, semicolon_token: SEMICOLON@191..192 ";" [] [], }, @@ -262,7 +262,7 @@ JsModule { }, from_token: FROM_KW@221..226 "from" [] [Whitespace(" ")], source: missing (required), - attribute: missing (optional), + assertion: 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 8cb239d76db..3300c6c939d 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\"" [] [], }, - attribute: missing (optional), + assertion: missing (optional), }, semicolon_token: SEMICOLON@31..32 ";" [] [], }, @@ -52,7 +52,7 @@ JsModule { source: JsModuleSource { value_token: JS_STRING_LITERAL@62..69 "\"./mod\"" [] [], }, - attribute: missing (optional), + assertion: missing (optional), }, semicolon_token: SEMICOLON@69..70 ";" [] [], }, @@ -79,7 +79,7 @@ JsModule { source: JsModuleSource { value_token: JS_STRING_LITERAL@102..109 "\"./mod\"" [] [], }, - attribute: missing (optional), + assertion: missing (optional), }, semicolon_token: SEMICOLON@109..110 ";" [] [], }, @@ -106,7 +106,7 @@ JsModule { source: JsModuleSource { value_token: JS_STRING_LITERAL@147..154 "\"./mod\"" [] [], }, - attribute: missing (optional), + assertion: missing (optional), }, semicolon_token: SEMICOLON@154..155 ";" [] [], }, @@ -122,7 +122,7 @@ JsModule { }, from_token: missing (required), source: missing (required), - attribute: missing (optional), + assertion: 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 8365c3bf7f7..970c5b41dd0 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" with { type: "json" } +export * from "mod" assert { 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 34ca24034c1..4325437217d 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 @@ -27,7 +27,7 @@ JsModule { source: JsModuleSource { value_token: JS_STRING_LITERAL@33..36 "\"b\"" [] [], }, - attribute: missing (optional), + assertion: missing (optional), semicolon_token: SEMICOLON@36..37 ";" [] [], }, }, @@ -56,7 +56,7 @@ JsModule { source: JsModuleSource { value_token: JS_STRING_LITERAL@67..70 "\"b\"" [] [], }, - attribute: missing (optional), + assertion: missing (optional), semicolon_token: SEMICOLON@70..71 ";" [] [], }, }, @@ -71,7 +71,7 @@ JsModule { source: JsModuleSource { value_token: JS_STRING_LITERAL@86..89 "\"a\"" [] [], }, - attribute: missing (optional), + assertion: missing (optional), semicolon_token: SEMICOLON@89..90 ";" [] [], }, }, @@ -91,7 +91,7 @@ JsModule { source: JsModuleSource { value_token: JS_STRING_LITERAL@110..113 "\"b\"" [] [], }, - attribute: missing (optional), + assertion: missing (optional), semicolon_token: SEMICOLON@113..114 ";" [] [], }, }, @@ -111,7 +111,7 @@ JsModule { source: JsModuleSource { value_token: JS_STRING_LITERAL@140..143 "\"b\"" [] [], }, - attribute: missing (optional), + assertion: missing (optional), semicolon_token: missing (optional), }, }, @@ -126,64 +126,64 @@ JsModule { source: JsModuleSource { value_token: JS_STRING_LITERAL@158..164 "\"mod\"" [] [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(" ")], + assertion: JsImportAssertion { + assertion_kind: 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(" ")], }, ], - r_curly_token: R_CURLY@184..185 "}" [] [], + r_curly_token: R_CURLY@186..187 "}" [] [], }, semicolon_token: missing (optional), }, }, JsExport { decorators: JsDecoratorList [], - export_token: EXPORT_KW@185..193 "export" [Newline("\n")] [Whitespace(" ")], + export_token: EXPORT_KW@187..195 "export" [Newline("\n")] [Whitespace(" ")], export_clause: JsExportFromClause { - type_token: TYPE_KW@193..198 "type" [] [Whitespace(" ")], - star_token: STAR@198..200 "*" [] [Whitespace(" ")], + type_token: TYPE_KW@195..200 "type" [] [Whitespace(" ")], + star_token: STAR@200..202 "*" [] [Whitespace(" ")], export_as: missing (optional), - from_token: FROM_KW@200..205 "from" [] [Whitespace(" ")], + from_token: FROM_KW@202..207 "from" [] [Whitespace(" ")], source: JsModuleSource { - value_token: JS_STRING_LITERAL@205..212 "\"types\"" [] [], + value_token: JS_STRING_LITERAL@207..214 "\"types\"" [] [], }, - attribute: missing (optional), - semicolon_token: SEMICOLON@212..213 ";" [] [], + assertion: missing (optional), + semicolon_token: SEMICOLON@214..215 ";" [] [], }, }, JsExport { decorators: JsDecoratorList [], - export_token: EXPORT_KW@213..221 "export" [Newline("\n")] [Whitespace(" ")], + export_token: EXPORT_KW@215..223 "export" [Newline("\n")] [Whitespace(" ")], export_clause: JsExportFromClause { - type_token: TYPE_KW@221..226 "type" [] [Whitespace(" ")], - star_token: STAR@226..228 "*" [] [Whitespace(" ")], + type_token: TYPE_KW@223..228 "type" [] [Whitespace(" ")], + star_token: STAR@228..230 "*" [] [Whitespace(" ")], export_as: JsExportAsClause { - as_token: AS_KW@228..231 "as" [] [Whitespace(" ")], + as_token: AS_KW@230..233 "as" [] [Whitespace(" ")], exported_name: JsLiteralExportName { - value: IDENT@231..237 "types" [] [Whitespace(" ")], + value: IDENT@233..239 "types" [] [Whitespace(" ")], }, }, - from_token: FROM_KW@237..242 "from" [] [Whitespace(" ")], + from_token: FROM_KW@239..244 "from" [] [Whitespace(" ")], source: JsModuleSource { - value_token: JS_STRING_LITERAL@242..249 "\"types\"" [] [], + value_token: JS_STRING_LITERAL@244..251 "\"types\"" [] [], }, - attribute: missing (optional), - semicolon_token: SEMICOLON@249..250 ";" [] [], + assertion: missing (optional), + semicolon_token: SEMICOLON@251..252 ";" [] [], }, }, ], - eof_token: EOF@250..251 "" [Newline("\n")] [], + eof_token: EOF@252..253 "" [Newline("\n")] [], } -0: JS_MODULE@0..251 +0: JS_MODULE@0..253 0: (empty) 1: JS_DIRECTIVE_LIST@0..0 - 2: JS_MODULE_ITEM_LIST@0..250 + 2: JS_MODULE_ITEM_LIST@0..252 0: JS_EXPORT@0..37 0: JS_DECORATOR_LIST@0..0 1: EXPORT_KW@0..7 "export" [] [Whitespace(" ")] @@ -268,51 +268,51 @@ JsModule { 0: JS_STRING_LITERAL@140..143 "\"b\"" [] [] 5: (empty) 6: (empty) - 5: JS_EXPORT@143..185 + 5: JS_EXPORT@143..187 0: JS_DECORATOR_LIST@143..143 1: EXPORT_KW@143..151 "export" [Newline("\n")] [Whitespace(" ")] - 2: JS_EXPORT_FROM_CLAUSE@151..185 + 2: JS_EXPORT_FROM_CLAUSE@151..187 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_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 "}" [] [] + 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 "}" [] [] 6: (empty) - 6: JS_EXPORT@185..213 - 0: JS_DECORATOR_LIST@185..185 - 1: EXPORT_KW@185..193 "export" [Newline("\n")] [Whitespace(" ")] - 2: JS_EXPORT_FROM_CLAUSE@193..213 - 0: TYPE_KW@193..198 "type" [] [Whitespace(" ")] - 1: STAR@198..200 "*" [] [Whitespace(" ")] + 6: JS_EXPORT@187..215 + 0: JS_DECORATOR_LIST@187..187 + 1: EXPORT_KW@187..195 "export" [Newline("\n")] [Whitespace(" ")] + 2: JS_EXPORT_FROM_CLAUSE@195..215 + 0: TYPE_KW@195..200 "type" [] [Whitespace(" ")] + 1: STAR@200..202 "*" [] [Whitespace(" ")] 2: (empty) - 3: FROM_KW@200..205 "from" [] [Whitespace(" ")] - 4: JS_MODULE_SOURCE@205..212 - 0: JS_STRING_LITERAL@205..212 "\"types\"" [] [] + 3: FROM_KW@202..207 "from" [] [Whitespace(" ")] + 4: JS_MODULE_SOURCE@207..214 + 0: JS_STRING_LITERAL@207..214 "\"types\"" [] [] 5: (empty) - 6: SEMICOLON@212..213 ";" [] [] - 7: JS_EXPORT@213..250 - 0: JS_DECORATOR_LIST@213..213 - 1: EXPORT_KW@213..221 "export" [Newline("\n")] [Whitespace(" ")] - 2: 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\"" [] [] + 6: SEMICOLON@214..215 ";" [] [] + 7: JS_EXPORT@215..252 + 0: JS_DECORATOR_LIST@215..215 + 1: EXPORT_KW@215..223 "export" [Newline("\n")] [Whitespace(" ")] + 2: 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\"" [] [] 5: (empty) - 6: SEMICOLON@249..250 ";" [] [] - 3: EOF@250..251 "" [Newline("\n")] [] + 6: SEMICOLON@251..252 ";" [] [] + 3: EOF@252..253 "" [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 c223f8df728..9b350448e32 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" with { type: "json" } +export { a } from "mod" assert { 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 0c3fc5f4219..ed914364e59 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 @@ -30,7 +30,7 @@ JsModule { source: JsModuleSource { value_token: JS_STRING_LITERAL@27..32 "\"mod\"" [] [], }, - attribute: missing (optional), + assertion: missing (optional), semicolon_token: SEMICOLON@32..33 ";" [] [], }, }, @@ -85,7 +85,7 @@ JsModule { source: JsModuleSource { value_token: JS_STRING_LITERAL@81..86 "\"mod\"" [] [], }, - attribute: missing (optional), + assertion: missing (optional), semicolon_token: missing (optional), }, }, @@ -109,7 +109,7 @@ JsModule { source: JsModuleSource { value_token: JS_STRING_LITERAL@106..111 "\"mod\"" [] [], }, - attribute: missing (optional), + assertion: missing (optional), semicolon_token: SEMICOLON@111..112 ";" [] [], }, }, @@ -138,7 +138,7 @@ JsModule { source: JsModuleSource { value_token: JS_STRING_LITERAL@144..149 "\"mod\"" [] [], }, - attribute: missing (optional), + assertion: missing (optional), semicolon_token: SEMICOLON@149..150 ";" [] [], }, }, @@ -167,7 +167,7 @@ JsModule { source: JsModuleSource { value_token: JS_STRING_LITERAL@176..181 "\"mod\"" [] [], }, - attribute: missing (optional), + assertion: missing (optional), semicolon_token: SEMICOLON@181..182 ";" [] [], }, }, @@ -191,77 +191,77 @@ JsModule { source: JsModuleSource { value_token: JS_STRING_LITERAL@201..207 "\"mod\"" [] [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(" ")], + assertion: JsImportAssertion { + assertion_kind: 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(" ")], }, ], - r_curly_token: R_CURLY@227..228 "}" [] [], + r_curly_token: R_CURLY@229..230 "}" [] [], }, semicolon_token: missing (optional), }, }, JsExport { decorators: JsDecoratorList [], - export_token: EXPORT_KW@228..236 "export" [Newline("\n")] [Whitespace(" ")], + export_token: EXPORT_KW@230..238 "export" [Newline("\n")] [Whitespace(" ")], export_clause: JsExportNamedFromClause { type_token: missing (optional), - l_curly_token: L_CURLY@236..238 "{" [] [Whitespace(" ")], + l_curly_token: L_CURLY@238..240 "{" [] [Whitespace(" ")], specifiers: JsExportNamedFromSpecifierList [ JsExportNamedFromSpecifier { type_token: missing (optional), source_name: JsLiteralExportName { - value: JS_STRING_LITERAL@238..242 "\"a\"" [] [Whitespace(" ")], + value: JS_STRING_LITERAL@240..244 "\"a\"" [] [Whitespace(" ")], }, export_as: missing (optional), }, ], - r_curly_token: R_CURLY@242..244 "}" [] [Whitespace(" ")], - from_token: FROM_KW@244..249 "from" [] [Whitespace(" ")], + r_curly_token: R_CURLY@244..246 "}" [] [Whitespace(" ")], + from_token: FROM_KW@246..251 "from" [] [Whitespace(" ")], source: JsModuleSource { - value_token: JS_STRING_LITERAL@249..256 "\"./mod\"" [] [], + value_token: JS_STRING_LITERAL@251..258 "\"./mod\"" [] [], }, - attribute: missing (optional), - semicolon_token: SEMICOLON@256..257 ";" [] [], + assertion: missing (optional), + semicolon_token: SEMICOLON@258..259 ";" [] [], }, }, JsExport { decorators: JsDecoratorList [], - export_token: EXPORT_KW@257..265 "export" [Newline("\n")] [Whitespace(" ")], + export_token: EXPORT_KW@259..267 "export" [Newline("\n")] [Whitespace(" ")], export_clause: JsExportNamedFromClause { type_token: missing (optional), - l_curly_token: L_CURLY@265..266 "{" [] [], + l_curly_token: L_CURLY@267..268 "{" [] [], specifiers: JsExportNamedFromSpecifierList [ JsExportNamedFromSpecifier { type_token: missing (optional), source_name: JsLiteralExportName { - value: JS_STRING_LITERAL@266..275 "\"a\"" [Newline("\n"), Whitespace(" ")] [], + value: JS_STRING_LITERAL@268..277 "\"a\"" [Newline("\n"), Whitespace(" ")] [], }, export_as: missing (optional), }, ], - r_curly_token: R_CURLY@275..278 "}" [Newline("\n")] [Whitespace(" ")], - from_token: FROM_KW@278..283 "from" [] [Whitespace(" ")], + r_curly_token: R_CURLY@277..280 "}" [Newline("\n")] [Whitespace(" ")], + from_token: FROM_KW@280..285 "from" [] [Whitespace(" ")], source: JsModuleSource { - value_token: JS_STRING_LITERAL@283..290 "\"./mod\"" [] [], + value_token: JS_STRING_LITERAL@285..292 "\"./mod\"" [] [], }, - attribute: missing (optional), - semicolon_token: SEMICOLON@290..291 ";" [] [], + assertion: missing (optional), + semicolon_token: SEMICOLON@292..293 ";" [] [], }, }, ], - eof_token: EOF@291..292 "" [Newline("\n")] [], + eof_token: EOF@293..294 "" [Newline("\n")] [], } -0: JS_MODULE@0..292 +0: JS_MODULE@0..294 0: (empty) 1: JS_DIRECTIVE_LIST@0..0 - 2: JS_MODULE_ITEM_LIST@0..291 + 2: JS_MODULE_ITEM_LIST@0..293 0: JS_EXPORT@0..33 0: JS_DECORATOR_LIST@0..0 1: EXPORT_KW@0..7 "export" [] [Whitespace(" ")] @@ -385,10 +385,10 @@ JsModule { 0: JS_STRING_LITERAL@176..181 "\"mod\"" [] [] 6: (empty) 7: SEMICOLON@181..182 ";" [] [] - 5: JS_EXPORT@182..228 + 5: JS_EXPORT@182..230 0: JS_DECORATOR_LIST@182..182 1: EXPORT_KW@182..190 "export" [Newline("\n")] [Whitespace(" ")] - 2: JS_EXPORT_NAMED_FROM_CLAUSE@190..228 + 2: JS_EXPORT_NAMED_FROM_CLAUSE@190..230 0: (empty) 1: L_CURLY@190..192 "{" [] [Whitespace(" ")] 2: JS_EXPORT_NAMED_FROM_SPECIFIER_LIST@192..194 @@ -401,50 +401,50 @@ 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_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 "}" [] [] + 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 "}" [] [] 7: (empty) - 6: JS_EXPORT@228..257 - 0: JS_DECORATOR_LIST@228..228 - 1: EXPORT_KW@228..236 "export" [Newline("\n")] [Whitespace(" ")] - 2: JS_EXPORT_NAMED_FROM_CLAUSE@236..257 + 6: JS_EXPORT@230..259 + 0: JS_DECORATOR_LIST@230..230 + 1: EXPORT_KW@230..238 "export" [Newline("\n")] [Whitespace(" ")] + 2: JS_EXPORT_NAMED_FROM_CLAUSE@238..259 0: (empty) - 1: L_CURLY@236..238 "{" [] [Whitespace(" ")] - 2: JS_EXPORT_NAMED_FROM_SPECIFIER_LIST@238..242 - 0: JS_EXPORT_NAMED_FROM_SPECIFIER@238..242 + 1: L_CURLY@238..240 "{" [] [Whitespace(" ")] + 2: JS_EXPORT_NAMED_FROM_SPECIFIER_LIST@240..244 + 0: JS_EXPORT_NAMED_FROM_SPECIFIER@240..244 0: (empty) - 1: JS_LITERAL_EXPORT_NAME@238..242 - 0: JS_STRING_LITERAL@238..242 "\"a\"" [] [Whitespace(" ")] + 1: JS_LITERAL_EXPORT_NAME@240..244 + 0: JS_STRING_LITERAL@240..244 "\"a\"" [] [Whitespace(" ")] 2: (empty) - 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\"" [] [] + 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\"" [] [] 6: (empty) - 7: SEMICOLON@256..257 ";" [] [] - 7: JS_EXPORT@257..291 - 0: JS_DECORATOR_LIST@257..257 - 1: EXPORT_KW@257..265 "export" [Newline("\n")] [Whitespace(" ")] - 2: JS_EXPORT_NAMED_FROM_CLAUSE@265..291 + 7: SEMICOLON@258..259 ";" [] [] + 7: JS_EXPORT@259..293 + 0: JS_DECORATOR_LIST@259..259 + 1: EXPORT_KW@259..267 "export" [Newline("\n")] [Whitespace(" ")] + 2: JS_EXPORT_NAMED_FROM_CLAUSE@267..293 0: (empty) - 1: L_CURLY@265..266 "{" [] [] - 2: JS_EXPORT_NAMED_FROM_SPECIFIER_LIST@266..275 - 0: JS_EXPORT_NAMED_FROM_SPECIFIER@266..275 + 1: L_CURLY@267..268 "{" [] [] + 2: JS_EXPORT_NAMED_FROM_SPECIFIER_LIST@268..277 + 0: JS_EXPORT_NAMED_FROM_SPECIFIER@268..277 0: (empty) - 1: JS_LITERAL_EXPORT_NAME@266..275 - 0: JS_STRING_LITERAL@266..275 "\"a\"" [Newline("\n"), Whitespace(" ")] [] + 1: JS_LITERAL_EXPORT_NAME@268..277 + 0: JS_STRING_LITERAL@268..277 "\"a\"" [Newline("\n"), Whitespace(" ")] [] 2: (empty) - 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\"" [] [] + 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\"" [] [] 6: (empty) - 7: SEMICOLON@290..291 ";" [] [] - 3: EOF@291..292 "" [Newline("\n")] [] + 7: SEMICOLON@292..293 ";" [] [] + 3: EOF@293..294 "" [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 5276275f704..cf72e03e151 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\"" [] [], }, - attribute: missing (optional), + assertion: 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 d21f27365b4..a16685b319e 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\"" [] [], }, - attribute: missing (optional), + assertion: 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 new file mode 100644 index 00000000000..e7c0ce4a164 --- /dev/null +++ b/crates/rome_js_parser/test_data/inline/ok/import_assertion.js @@ -0,0 +1,7 @@ +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 new file mode 100644 index 00000000000..f379a1e8fe4 --- /dev/null +++ b/crates/rome_js_parser/test_data/inline/ok/import_assertion.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(" ")], + }, + assertion: JsImportAssertion { + assertion_kind: 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 { + assertion_kind: 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 { + assertion_kind: 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 { + assertion_kind: 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 { + assertion_kind: 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 { + assertion_kind: 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.rast b/crates/rome_js_parser/test_data/inline/ok/import_attribute.rast index e013b80e440..cd1baa06317 100644 --- a/crates/rome_js_parser/test_data/inline/ok/import_attribute.rast +++ b/crates/rome_js_parser/test_data/inline/ok/import_attribute.rast @@ -8,11 +8,11 @@ JsModule { source: JsModuleSource { value_token: JS_STRING_LITERAL@7..11 "\"x\"" [] [Whitespace(" ")], }, - attribute: JsImportAttribute { - with_token: WITH_KW@11..16 "with" [] [Whitespace(" ")], + assertion: JsImportAssertion { + assertion_kind: WITH_KW@11..16 "with" [] [Whitespace(" ")], l_curly_token: L_CURLY@16..18 "{" [] [Whitespace(" ")], - attributes: JsImportAttributeEntryList [ - JsImportAttributeEntry { + assertions: JsImportAssertionEntryList [ + JsImportAssertionEntry { key: IDENT@18..22 "type" [] [], colon_token: COLON@22..24 ":" [] [Whitespace(" ")], value_token: JS_STRING_LITERAL@24..31 "\"json\"" [] [Whitespace(" ")], @@ -29,11 +29,11 @@ JsModule { source: JsModuleSource { value_token: JS_STRING_LITERAL@40..46 "\"foo\"" [] [Whitespace(" ")], }, - attribute: JsImportAttribute { - with_token: WITH_KW@46..51 "with" [] [Whitespace(" ")], + assertion: JsImportAssertion { + assertion_kind: WITH_KW@46..51 "with" [] [Whitespace(" ")], l_curly_token: L_CURLY@51..53 "{" [] [Whitespace(" ")], - attributes: JsImportAttributeEntryList [ - JsImportAttributeEntry { + assertions: JsImportAssertionEntryList [ + JsImportAssertionEntry { key: JS_STRING_LITERAL@53..59 "\"type\"" [] [], colon_token: COLON@59..61 ":" [] [Whitespace(" ")], value_token: JS_STRING_LITERAL@61..68 "\"json\"" [] [Whitespace(" ")], @@ -55,11 +55,11 @@ JsModule { source: JsModuleSource { value_token: JS_STRING_LITERAL@87..98 "\"foo.json\"" [] [Whitespace(" ")], }, - attribute: JsImportAttribute { - with_token: WITH_KW@98..103 "with" [] [Whitespace(" ")], + assertion: JsImportAssertion { + assertion_kind: WITH_KW@98..103 "with" [] [Whitespace(" ")], l_curly_token: L_CURLY@103..105 "{" [] [Whitespace(" ")], - attributes: JsImportAttributeEntryList [ - JsImportAttributeEntry { + assertions: JsImportAssertionEntryList [ + JsImportAssertionEntry { key: IDENT@105..109 "type" [] [], colon_token: COLON@109..111 ":" [] [Whitespace(" ")], value_token: JS_STRING_LITERAL@111..118 "\"json\"" [] [Whitespace(" ")], @@ -91,11 +91,11 @@ JsModule { source: JsModuleSource { value_token: JS_STRING_LITERAL@140..151 "\"foo.json\"" [] [Whitespace(" ")], }, - attribute: JsImportAttribute { - with_token: WITH_KW@151..156 "with" [] [Whitespace(" ")], + assertion: JsImportAssertion { + assertion_kind: WITH_KW@151..156 "with" [] [Whitespace(" ")], l_curly_token: L_CURLY@156..158 "{" [] [Whitespace(" ")], - attributes: JsImportAttributeEntryList [ - JsImportAttributeEntry { + assertions: JsImportAssertionEntryList [ + JsImportAssertionEntry { key: IDENT@158..161 "for" [] [], colon_token: COLON@161..163 ":" [] [Whitespace(" ")], value_token: JS_STRING_LITERAL@163..169 "\"for\"" [] [Whitespace(" ")], @@ -117,17 +117,17 @@ JsModule { source: JsModuleSource { value_token: JS_STRING_LITERAL@192..203 "\"foo.json\"" [] [Whitespace(" ")], }, - attribute: JsImportAttribute { - with_token: WITH_KW@203..208 "with" [] [Whitespace(" ")], + assertion: JsImportAssertion { + assertion_kind: WITH_KW@203..208 "with" [] [Whitespace(" ")], l_curly_token: L_CURLY@208..210 "{" [] [Whitespace(" ")], - attributes: JsImportAttributeEntryList [ - JsImportAttributeEntry { + assertions: JsImportAssertionEntryList [ + JsImportAssertionEntry { key: IDENT@210..214 "type" [] [], colon_token: COLON@214..216 ":" [] [Whitespace(" ")], value_token: JS_STRING_LITERAL@216..222 "\"json\"" [] [], }, COMMA@222..224 "," [] [Whitespace(" ")], - JsImportAttributeEntry { + JsImportAssertionEntry { key: IDENT@224..238 "hasOwnProperty" [] [], colon_token: COLON@238..240 ":" [] [Whitespace(" ")], value_token: JS_STRING_LITERAL@240..247 "\"true\"" [] [Whitespace(" ")], @@ -144,11 +144,11 @@ JsModule { source: JsModuleSource { value_token: JS_STRING_LITERAL@257..261 "\"x\"" [] [Whitespace(" ")], }, - attribute: JsImportAttribute { - with_token: WITH_KW@261..265 "with" [] [], + assertion: JsImportAssertion { + assertion_kind: WITH_KW@261..265 "with" [] [], l_curly_token: L_CURLY@265..268 "{" [Newline("\n")] [Whitespace(" ")], - attributes: JsImportAttributeEntryList [ - JsImportAttributeEntry { + assertions: JsImportAssertionEntryList [ + JsImportAssertionEntry { key: IDENT@268..272 "type" [] [], colon_token: COLON@272..274 ":" [] [Whitespace(" ")], value_token: JS_STRING_LITERAL@274..281 "\"json\"" [] [Whitespace(" ")], @@ -172,11 +172,11 @@ JsModule { 1: JS_IMPORT_BARE_CLAUSE@7..32 0: JS_MODULE_SOURCE@7..11 0: JS_STRING_LITERAL@7..11 "\"x\"" [] [Whitespace(" ")] - 1: JS_IMPORT_ATTRIBUTE@11..32 + 1: JS_IMPORT_ASSERTION@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 + 2: JS_IMPORT_ASSERTION_ENTRY_LIST@18..31 + 0: JS_IMPORT_ASSERTION_ENTRY@18..31 0: IDENT@18..22 "type" [] [] 1: COLON@22..24 ":" [] [Whitespace(" ")] 2: JS_STRING_LITERAL@24..31 "\"json\"" [] [Whitespace(" ")] @@ -187,11 +187,11 @@ JsModule { 1: JS_IMPORT_BARE_CLAUSE@40..69 0: JS_MODULE_SOURCE@40..46 0: JS_STRING_LITERAL@40..46 "\"foo\"" [] [Whitespace(" ")] - 1: JS_IMPORT_ATTRIBUTE@46..69 + 1: JS_IMPORT_ASSERTION@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 + 2: JS_IMPORT_ASSERTION_ENTRY_LIST@53..68 + 0: JS_IMPORT_ASSERTION_ENTRY@53..68 0: JS_STRING_LITERAL@53..59 "\"type\"" [] [] 1: COLON@59..61 ":" [] [Whitespace(" ")] 2: JS_STRING_LITERAL@61..68 "\"json\"" [] [Whitespace(" ")] @@ -206,11 +206,11 @@ JsModule { 2: FROM_KW@82..87 "from" [] [Whitespace(" ")] 3: JS_MODULE_SOURCE@87..98 0: JS_STRING_LITERAL@87..98 "\"foo.json\"" [] [Whitespace(" ")] - 4: JS_IMPORT_ATTRIBUTE@98..119 + 4: JS_IMPORT_ASSERTION@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 + 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(" ")] @@ -232,11 +232,11 @@ JsModule { 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 + 5: JS_IMPORT_ASSERTION@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 + 2: JS_IMPORT_ASSERTION_ENTRY_LIST@158..169 + 0: JS_IMPORT_ASSERTION_ENTRY@158..169 0: IDENT@158..161 "for" [] [] 1: COLON@161..163 ":" [] [Whitespace(" ")] 2: JS_STRING_LITERAL@163..169 "\"for\"" [] [Whitespace(" ")] @@ -251,16 +251,16 @@ JsModule { 2: FROM_KW@187..192 "from" [] [Whitespace(" ")] 3: JS_MODULE_SOURCE@192..203 0: JS_STRING_LITERAL@192..203 "\"foo.json\"" [] [Whitespace(" ")] - 4: JS_IMPORT_ATTRIBUTE@203..248 + 4: JS_IMPORT_ASSERTION@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 + 2: JS_IMPORT_ASSERTION_ENTRY_LIST@210..247 + 0: JS_IMPORT_ASSERTION_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 + 2: JS_IMPORT_ASSERTION_ENTRY@224..247 0: IDENT@224..238 "hasOwnProperty" [] [] 1: COLON@238..240 ":" [] [Whitespace(" ")] 2: JS_STRING_LITERAL@240..247 "\"true\"" [] [Whitespace(" ")] @@ -271,11 +271,11 @@ JsModule { 1: JS_IMPORT_BARE_CLAUSE@257..282 0: JS_MODULE_SOURCE@257..261 0: JS_STRING_LITERAL@257..261 "\"x\"" [] [Whitespace(" ")] - 1: JS_IMPORT_ATTRIBUTE@261..282 + 1: JS_IMPORT_ASSERTION@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 + 2: JS_IMPORT_ASSERTION_ENTRY_LIST@268..281 + 0: JS_IMPORT_ASSERTION_ENTRY@268..281 0: IDENT@268..272 "type" [] [] 1: COLON@272..274 ":" [] [Whitespace(" ")] 2: JS_STRING_LITERAL@274..281 "\"json\"" [] [Whitespace(" ")] diff --git a/crates/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 28197e17e16..dcc82510746 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\"" [] [], }, - attribute: missing (optional), + assertion: missing (optional), }, semicolon_token: SEMICOLON@13..14 ";" [] [], }, @@ -18,7 +18,7 @@ JsModule { source: JsModuleSource { value_token: JS_STRING_LITERAL@22..36 "\"no_semicolon\"" [] [], }, - attribute: missing (optional), + assertion: 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 aa58c059192..4bad1615e1e 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\"" [] [], }, - attribute: missing (optional), + assertion: 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 eb6f1a65b4a..e062bf4264f 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\"" [] [], }, - attribute: missing (optional), + assertion: 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 f61ca77cc7b..f54b7c55ffe 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\"" [] [], }, - attribute: missing (optional), + assertion: missing (optional), }, semicolon_token: SEMICOLON@18..19 ";" [] [], }, @@ -56,7 +56,7 @@ JsModule { source: JsModuleSource { value_token: JS_STRING_LITERAL@45..48 "\"b\"" [] [], }, - attribute: missing (optional), + assertion: missing (optional), }, semicolon_token: SEMICOLON@48..49 ";" [] [], }, @@ -86,7 +86,7 @@ JsModule { source: JsModuleSource { value_token: JS_STRING_LITERAL@71..74 "\"b\"" [] [], }, - attribute: missing (optional), + assertion: missing (optional), }, semicolon_token: SEMICOLON@74..75 ";" [] [], }, @@ -111,7 +111,7 @@ JsModule { source: JsModuleSource { value_token: JS_STRING_LITERAL@102..105 "\"c\"" [] [], }, - attribute: missing (optional), + assertion: missing (optional), }, semicolon_token: SEMICOLON@105..106 ";" [] [], }, @@ -162,7 +162,7 @@ JsModule { source: JsModuleSource { value_token: JS_STRING_LITERAL@158..161 "\"b\"" [] [], }, - attribute: missing (optional), + assertion: 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 d7fab9784c8..9081478ae12 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\"" [] [], }, - attribute: missing (optional), + assertion: missing (optional), }, semicolon_token: SEMICOLON@17..18 ";" [] [], }, @@ -73,7 +73,7 @@ JsModule { source: JsModuleSource { value_token: JS_STRING_LITERAL@56..59 "\"c\"" [] [], }, - attribute: missing (optional), + assertion: 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 811fe6516d6..11c2bf08211 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 @@ -22,7 +22,7 @@ JsModule { source: JsModuleSource { value_token: JS_STRING_LITERAL@23..26 "\"a\"" [] [], }, - attribute: missing (optional), + assertion: missing (optional), semicolon_token: missing (optional), }, }, @@ -46,7 +46,7 @@ JsModule { source: JsModuleSource { value_token: JS_STRING_LITERAL@48..56 "\"./type\"" [] [], }, - attribute: missing (optional), + assertion: 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 f713d3abcd7..a3692c7fd92 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 @@ -22,7 +22,7 @@ JsModule { source: JsModuleSource { value_token: JS_STRING_LITERAL@23..26 "\"a\"" [] [], }, - attribute: missing (optional), + assertion: 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 92f576466bc..cc5887a5623 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\"" [] [], }, - attribute: missing (optional), + assertion: 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\"" [] [], }, - attribute: missing (optional), + assertion: missing (optional), }, semicolon_token: SEMICOLON@68..69 ";" [] [], }, @@ -45,7 +45,7 @@ JsModule { source: JsModuleSource { value_token: JS_STRING_LITERAL@97..104 "\"./mod\"" [] [], }, - attribute: missing (optional), + assertion: missing (optional), }, semicolon_token: SEMICOLON@104..105 ";" [] [], }, @@ -70,7 +70,7 @@ JsModule { source: JsModuleSource { value_token: JS_STRING_LITERAL@132..137 "\"mod\"" [] [], }, - attribute: missing (optional), + assertion: 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 7fc72c65940..9efa5619dfb 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\"" [] [], }, - attribute: missing (optional), + assertion: missing (optional), }, semicolon_token: SEMICOLON@37..38 ";" [] [], }, @@ -59,7 +59,7 @@ JsModule { source: JsModuleSource { value_token: JS_STRING_LITERAL@69..76 "\"./mod\"" [] [], }, - attribute: missing (optional), + assertion: missing (optional), }, semicolon_token: missing (optional), }, @@ -88,7 +88,7 @@ JsModule { source: JsModuleSource { value_token: JS_STRING_LITERAL@104..111 "\"./mod\"" [] [], }, - attribute: missing (optional), + assertion: missing (optional), }, semicolon_token: SEMICOLON@111..112 ";" [] [], }, @@ -117,7 +117,7 @@ JsModule { source: JsModuleSource { value_token: JS_STRING_LITERAL@143..150 "\"./mod\"" [] [], }, - attribute: missing (optional), + assertion: missing (optional), }, semicolon_token: missing (optional), }, @@ -146,7 +146,7 @@ JsModule { source: JsModuleSource { value_token: JS_STRING_LITERAL@192..199 "\"./mod\"" [] [], }, - attribute: missing (optional), + assertion: 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 a94d5106978..f9c527c5377 100644 --- a/crates/rome_js_syntax/src/generated/kind.rs +++ b/crates/rome_js_syntax/src/generated/kind.rs @@ -119,6 +119,7 @@ pub enum JsSyntaxKind { AS_KW, SATISFIES_KW, ASSERTS_KW, + ASSERT_KW, ANY_KW, ASYNC_KW, AWAIT_KW, @@ -342,9 +343,9 @@ pub enum JsSyntaxKind { JS_DEFAULT_IMPORT_SPECIFIER, JS_NAMED_IMPORT_SPECIFIER, JS_SHORTHAND_NAMED_IMPORT_SPECIFIER, - JS_IMPORT_ATTRIBUTE, - JS_IMPORT_ATTRIBUTE_ENTRY_LIST, - JS_IMPORT_ATTRIBUTE_ENTRY, + JS_IMPORT_ASSERTION, + JS_IMPORT_ASSERTION_ENTRY_LIST, + JS_IMPORT_ASSERTION_ENTRY, JS_MODULE_SOURCE, JS_EXPORT, JS_EXPORT_NAMED_CLAUSE, @@ -499,7 +500,7 @@ pub enum JsSyntaxKind { JS_BOGUS_MEMBER, JS_BOGUS_BINDING, JS_BOGUS_PARAMETER, - JS_BOGUS_IMPORT_ATTRIBUTE_ENTRY, + JS_BOGUS_IMPORT_ASSERTION_ENTRY, JS_BOGUS_NAMED_IMPORT_SPECIFIER, JS_BOGUS_ASSIGNMENT, TS_BOGUS_TYPE, @@ -550,7 +551,7 @@ impl JsSyntaxKind { | JS_ARRAY_ASSIGNMENT_PATTERN_ELEMENT_LIST | JS_OBJECT_ASSIGNMENT_PATTERN_PROPERTY_LIST | JS_NAMED_IMPORT_SPECIFIER_LIST - | JS_IMPORT_ATTRIBUTE_ENTRY_LIST + | JS_IMPORT_ASSERTION_ENTRY_LIST | JS_EXPORT_NAMED_SPECIFIER_LIST | JS_EXPORT_NAMED_FROM_SPECIFIER_LIST | JS_DECORATOR_LIST @@ -624,6 +625,7 @@ impl JsSyntaxKind { "as" => AS_KW, "satisfies" => SATISFIES_KW, "asserts" => ASSERTS_KW, + "assert" => ASSERT_KW, "any" => ANY_KW, "async" => ASYNC_KW, "await" => AWAIT_KW, @@ -769,6 +771,7 @@ 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 +810,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 } ; [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 } ; [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 } ; } diff --git a/crates/rome_js_syntax/src/generated/macros.rs b/crates/rome_js_syntax/src/generated/macros.rs index 89e8a492d44..156e7651a53 100644 --- a/crates/rome_js_syntax/src/generated/macros.rs +++ b/crates/rome_js_syntax/src/generated/macros.rs @@ -314,12 +314,12 @@ macro_rules! map_syntax_node { let $pattern = unsafe { $crate::JsImport::new_unchecked(node) }; $body } - $crate::JsSyntaxKind::JS_IMPORT_ATTRIBUTE => { - let $pattern = unsafe { $crate::JsImportAttribute::new_unchecked(node) }; + $crate::JsSyntaxKind::JS_IMPORT_ASSERTION => { + let $pattern = unsafe { $crate::JsImportAssertion::new_unchecked(node) }; $body } - $crate::JsSyntaxKind::JS_IMPORT_ATTRIBUTE_ENTRY => { - let $pattern = unsafe { $crate::JsImportAttributeEntry::new_unchecked(node) }; + $crate::JsSyntaxKind::JS_IMPORT_ASSERTION_ENTRY => { + let $pattern = unsafe { $crate::JsImportAssertionEntry::new_unchecked(node) }; $body } $crate::JsSyntaxKind::JS_IMPORT_BARE_CLAUSE => { @@ -1239,9 +1239,9 @@ macro_rules! map_syntax_node { let $pattern = unsafe { $crate::JsBogusExpression::new_unchecked(node) }; $body } - $crate::JsSyntaxKind::JS_BOGUS_IMPORT_ATTRIBUTE_ENTRY => { + $crate::JsSyntaxKind::JS_BOGUS_IMPORT_ASSERTION_ENTRY => { let $pattern = - unsafe { $crate::JsBogusImportAttributeEntry::new_unchecked(node) }; + unsafe { $crate::JsBogusImportAssertionEntry::new_unchecked(node) }; $body } $crate::JsSyntaxKind::JS_BOGUS_MEMBER => { @@ -1315,9 +1315,9 @@ macro_rules! map_syntax_node { unsafe { $crate::JsExportNamedSpecifierList::new_unchecked(node) }; $body } - $crate::JsSyntaxKind::JS_IMPORT_ATTRIBUTE_ENTRY_LIST => { + $crate::JsSyntaxKind::JS_IMPORT_ASSERTION_ENTRY_LIST => { let $pattern = - unsafe { $crate::JsImportAttributeEntryList::new_unchecked(node) }; + unsafe { $crate::JsImportAssertionEntryList::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 3ab91f8e2d3..e99b1675531 100644 --- a/crates/rome_js_syntax/src/generated/nodes.rs +++ b/crates/rome_js_syntax/src/generated/nodes.rs @@ -2016,7 +2016,7 @@ impl JsExportFromClause { export_as: self.export_as(), from_token: self.from_token(), source: self.source(), - attribute: self.attribute(), + assertion: self.assertion(), semicolon_token: self.semicolon_token(), } } @@ -2031,7 +2031,7 @@ impl JsExportFromClause { pub fn source(&self) -> SyntaxResult { support::required_node(&self.syntax, 4usize) } - pub fn attribute(&self) -> Option { support::node(&self.syntax, 5usize) } + pub fn assertion(&self) -> Option { support::node(&self.syntax, 5usize) } pub fn semicolon_token(&self) -> Option { support::token(&self.syntax, 6usize) } } #[cfg(feature = "serde")] @@ -2050,7 +2050,7 @@ pub struct JsExportFromClauseFields { pub export_as: Option, pub from_token: SyntaxResult, pub source: SyntaxResult, - pub attribute: Option, + pub assertion: Option, pub semicolon_token: Option, } #[derive(Clone, PartialEq, Eq, Hash)] @@ -2121,7 +2121,7 @@ impl JsExportNamedFromClause { r_curly_token: self.r_curly_token(), from_token: self.from_token(), source: self.source(), - attribute: self.attribute(), + assertion: self.assertion(), semicolon_token: self.semicolon_token(), } } @@ -2141,7 +2141,7 @@ impl JsExportNamedFromClause { pub fn source(&self) -> SyntaxResult { support::required_node(&self.syntax, 5usize) } - pub fn attribute(&self) -> Option { support::node(&self.syntax, 6usize) } + pub fn assertion(&self) -> Option { support::node(&self.syntax, 6usize) } pub fn semicolon_token(&self) -> Option { support::token(&self.syntax, 7usize) } } #[cfg(feature = "serde")] @@ -2161,7 +2161,7 @@ pub struct JsExportNamedFromClauseFields { pub r_curly_token: SyntaxResult, pub from_token: SyntaxResult, pub source: SyntaxResult, - pub attribute: Option, + pub assertion: Option, pub semicolon_token: Option, } #[derive(Clone, PartialEq, Eq, Hash)] @@ -3281,10 +3281,10 @@ pub struct JsImportFields { pub semicolon_token: Option, } #[derive(Clone, PartialEq, Eq, Hash)] -pub struct JsImportAttribute { +pub struct JsImportAssertion { pub(crate) syntax: SyntaxNode, } -impl JsImportAttribute { +impl JsImportAssertion { #[doc = r" Create an AstNode from a SyntaxNode without checking its kind"] #[doc = r""] #[doc = r" # Safety"] @@ -3292,27 +3292,27 @@ impl JsImportAttribute { #[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) -> JsImportAttributeFields { - JsImportAttributeFields { - with_token: self.with_token(), + pub fn as_fields(&self) -> JsImportAssertionFields { + JsImportAssertionFields { + assertion_kind: self.assertion_kind(), l_curly_token: self.l_curly_token(), - attributes: self.attributes(), + assertions: self.assertions(), r_curly_token: self.r_curly_token(), } } - pub fn with_token(&self) -> SyntaxResult { + pub fn assertion_kind(&self) -> SyntaxResult { support::required_token(&self.syntax, 0usize) } pub fn l_curly_token(&self) -> SyntaxResult { support::required_token(&self.syntax, 1usize) } - pub fn attributes(&self) -> JsImportAttributeEntryList { support::list(&self.syntax, 2usize) } + pub fn assertions(&self) -> JsImportAssertionEntryList { support::list(&self.syntax, 2usize) } pub fn r_curly_token(&self) -> SyntaxResult { support::required_token(&self.syntax, 3usize) } } #[cfg(feature = "serde")] -impl Serialize for JsImportAttribute { +impl Serialize for JsImportAssertion { fn serialize(&self, serializer: S) -> Result where S: Serializer, @@ -3321,17 +3321,17 @@ impl Serialize for JsImportAttribute { } } #[cfg_attr(feature = "serde", derive(Serialize))] -pub struct JsImportAttributeFields { - pub with_token: SyntaxResult, +pub struct JsImportAssertionFields { + pub assertion_kind: SyntaxResult, pub l_curly_token: SyntaxResult, - pub attributes: JsImportAttributeEntryList, + pub assertions: JsImportAssertionEntryList, pub r_curly_token: SyntaxResult, } #[derive(Clone, PartialEq, Eq, Hash)] -pub struct JsImportAttributeEntry { +pub struct JsImportAssertionEntry { pub(crate) syntax: SyntaxNode, } -impl JsImportAttributeEntry { +impl JsImportAssertionEntry { #[doc = r" Create an AstNode from a SyntaxNode without checking its kind"] #[doc = r""] #[doc = r" # Safety"] @@ -3339,8 +3339,8 @@ impl JsImportAttributeEntry { #[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) -> JsImportAttributeEntryFields { - JsImportAttributeEntryFields { + pub fn as_fields(&self) -> JsImportAssertionEntryFields { + JsImportAssertionEntryFields { key: self.key(), colon_token: self.colon_token(), value_token: self.value_token(), @@ -3355,7 +3355,7 @@ impl JsImportAttributeEntry { } } #[cfg(feature = "serde")] -impl Serialize for JsImportAttributeEntry { +impl Serialize for JsImportAssertionEntry { fn serialize(&self, serializer: S) -> Result where S: Serializer, @@ -3364,7 +3364,7 @@ impl Serialize for JsImportAttributeEntry { } } #[cfg_attr(feature = "serde", derive(Serialize))] -pub struct JsImportAttributeEntryFields { +pub struct JsImportAssertionEntryFields { pub key: SyntaxResult, pub colon_token: SyntaxResult, pub value_token: SyntaxResult, @@ -3384,13 +3384,13 @@ impl JsImportBareClause { pub fn as_fields(&self) -> JsImportBareClauseFields { JsImportBareClauseFields { source: self.source(), - attribute: self.attribute(), + assertion: self.assertion(), } } pub fn source(&self) -> SyntaxResult { support::required_node(&self.syntax, 0usize) } - pub fn attribute(&self) -> Option { support::node(&self.syntax, 1usize) } + pub fn assertion(&self) -> Option { support::node(&self.syntax, 1usize) } } #[cfg(feature = "serde")] impl Serialize for JsImportBareClause { @@ -3404,7 +3404,7 @@ impl Serialize for JsImportBareClause { #[cfg_attr(feature = "serde", derive(Serialize))] pub struct JsImportBareClauseFields { pub source: SyntaxResult, - pub attribute: Option, + pub assertion: Option, } #[derive(Clone, PartialEq, Eq, Hash)] pub struct JsImportCallExpression { @@ -3463,7 +3463,7 @@ impl JsImportDefaultClause { local_name: self.local_name(), from_token: self.from_token(), source: self.source(), - attribute: self.attribute(), + assertion: self.assertion(), } } pub fn type_token(&self) -> Option { support::token(&self.syntax, 0usize) } @@ -3476,7 +3476,7 @@ impl JsImportDefaultClause { pub fn source(&self) -> SyntaxResult { support::required_node(&self.syntax, 3usize) } - pub fn attribute(&self) -> Option { support::node(&self.syntax, 4usize) } + pub fn assertion(&self) -> Option { support::node(&self.syntax, 4usize) } } #[cfg(feature = "serde")] impl Serialize for JsImportDefaultClause { @@ -3493,7 +3493,7 @@ pub struct JsImportDefaultClauseFields { pub local_name: SyntaxResult, pub from_token: SyntaxResult, pub source: SyntaxResult, - pub attribute: Option, + pub assertion: Option, } #[derive(Clone, PartialEq, Eq, Hash)] pub struct JsImportMetaExpression { @@ -3558,7 +3558,7 @@ impl JsImportNamedClause { named_import: self.named_import(), from_token: self.from_token(), source: self.source(), - attribute: self.attribute(), + assertion: self.assertion(), } } pub fn type_token(&self) -> Option { support::token(&self.syntax, 0usize) } @@ -3574,7 +3574,7 @@ impl JsImportNamedClause { pub fn source(&self) -> SyntaxResult { support::required_node(&self.syntax, 4usize) } - pub fn attribute(&self) -> Option { support::node(&self.syntax, 5usize) } + pub fn assertion(&self) -> Option { support::node(&self.syntax, 5usize) } } #[cfg(feature = "serde")] impl Serialize for JsImportNamedClause { @@ -3592,7 +3592,7 @@ pub struct JsImportNamedClauseFields { pub named_import: SyntaxResult, pub from_token: SyntaxResult, pub source: SyntaxResult, - pub attribute: Option, + pub assertion: Option, } #[derive(Clone, PartialEq, Eq, Hash)] pub struct JsImportNamespaceClause { @@ -3614,7 +3614,7 @@ impl JsImportNamespaceClause { local_name: self.local_name(), from_token: self.from_token(), source: self.source(), - attribute: self.attribute(), + assertion: self.assertion(), } } pub fn type_token(&self) -> Option { support::token(&self.syntax, 0usize) } @@ -3633,7 +3633,7 @@ impl JsImportNamespaceClause { pub fn source(&self) -> SyntaxResult { support::required_node(&self.syntax, 5usize) } - pub fn attribute(&self) -> Option { support::node(&self.syntax, 6usize) } + pub fn assertion(&self) -> Option { support::node(&self.syntax, 6usize) } } #[cfg(feature = "serde")] impl Serialize for JsImportNamespaceClause { @@ -3652,7 +3652,7 @@ pub struct JsImportNamespaceClauseFields { pub local_name: SyntaxResult, pub from_token: SyntaxResult, pub source: SyntaxResult, - pub attribute: Option, + pub assertion: Option, } #[derive(Clone, PartialEq, Eq, Hash)] pub struct JsInExpression { @@ -13516,20 +13516,20 @@ impl AnyJsFunctionBody { } #[derive(Clone, PartialEq, Eq, Hash)] #[cfg_attr(feature = "serde", derive(Serialize))] -pub enum AnyJsImportAttributeEntry { - JsBogusImportAttributeEntry(JsBogusImportAttributeEntry), - JsImportAttributeEntry(JsImportAttributeEntry), +pub enum AnyJsImportAssertionEntry { + JsBogusImportAssertionEntry(JsBogusImportAssertionEntry), + JsImportAssertionEntry(JsImportAssertionEntry), } -impl AnyJsImportAttributeEntry { - pub fn as_js_bogus_import_attribute_entry(&self) -> Option<&JsBogusImportAttributeEntry> { +impl AnyJsImportAssertionEntry { + pub fn as_js_bogus_import_assertion_entry(&self) -> Option<&JsBogusImportAssertionEntry> { match &self { - AnyJsImportAttributeEntry::JsBogusImportAttributeEntry(item) => Some(item), + AnyJsImportAssertionEntry::JsBogusImportAssertionEntry(item) => Some(item), _ => None, } } - pub fn as_js_import_attribute_entry(&self) -> Option<&JsImportAttributeEntry> { + pub fn as_js_import_assertion_entry(&self) -> Option<&JsImportAssertionEntry> { match &self { - AnyJsImportAttributeEntry::JsImportAttributeEntry(item) => Some(item), + AnyJsImportAssertionEntry::JsImportAssertionEntry(item) => Some(item), _ => None, } } @@ -16918,8 +16918,8 @@ impl std::fmt::Debug for JsExportFromClause { .field("from_token", &support::DebugSyntaxResult(self.from_token())) .field("source", &support::DebugSyntaxResult(self.source())) .field( - "attribute", - &support::DebugOptionalElement(self.attribute()), + "assertion", + &support::DebugOptionalElement(self.assertion()), ) .field( "semicolon_token", @@ -17012,8 +17012,8 @@ impl std::fmt::Debug for JsExportNamedFromClause { .field("from_token", &support::DebugSyntaxResult(self.from_token())) .field("source", &support::DebugSyntaxResult(self.source())) .field( - "attribute", - &support::DebugOptionalElement(self.attribute()), + "assertion", + &support::DebugOptionalElement(self.assertion()), ) .field( "semicolon_token", @@ -17915,11 +17915,11 @@ impl From for SyntaxNode { impl From for SyntaxElement { fn from(n: JsImport) -> SyntaxElement { n.syntax.into() } } -impl AstNode for JsImportAttribute { +impl AstNode for JsImportAssertion { type Language = Language; const KIND_SET: SyntaxKindSet = - SyntaxKindSet::from_raw(RawSyntaxKind(JS_IMPORT_ATTRIBUTE as u16)); - fn can_cast(kind: SyntaxKind) -> bool { kind == JS_IMPORT_ATTRIBUTE } + SyntaxKindSet::from_raw(RawSyntaxKind(JS_IMPORT_ASSERTION as u16)); + fn can_cast(kind: SyntaxKind) -> bool { kind == JS_IMPORT_ASSERTION } fn cast(syntax: SyntaxNode) -> Option { if Self::can_cast(syntax.kind()) { Some(Self { syntax }) @@ -17930,15 +17930,18 @@ impl AstNode for JsImportAttribute { fn syntax(&self) -> &SyntaxNode { &self.syntax } fn into_syntax(self) -> SyntaxNode { self.syntax } } -impl std::fmt::Debug for JsImportAttribute { +impl std::fmt::Debug for JsImportAssertion { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - f.debug_struct("JsImportAttribute") - .field("with_token", &support::DebugSyntaxResult(self.with_token())) + f.debug_struct("JsImportAssertion") + .field( + "assertion_kind", + &support::DebugSyntaxResult(self.assertion_kind()), + ) .field( "l_curly_token", &support::DebugSyntaxResult(self.l_curly_token()), ) - .field("attributes", &self.attributes()) + .field("assertions", &self.assertions()) .field( "r_curly_token", &support::DebugSyntaxResult(self.r_curly_token()), @@ -17946,17 +17949,17 @@ impl std::fmt::Debug for JsImportAttribute { .finish() } } -impl From for SyntaxNode { - fn from(n: JsImportAttribute) -> SyntaxNode { n.syntax } +impl From for SyntaxNode { + fn from(n: JsImportAssertion) -> SyntaxNode { n.syntax } } -impl From for SyntaxElement { - fn from(n: JsImportAttribute) -> SyntaxElement { n.syntax.into() } +impl From for SyntaxElement { + fn from(n: JsImportAssertion) -> SyntaxElement { n.syntax.into() } } -impl AstNode for JsImportAttributeEntry { +impl AstNode for JsImportAssertionEntry { type Language = Language; const KIND_SET: SyntaxKindSet = - SyntaxKindSet::from_raw(RawSyntaxKind(JS_IMPORT_ATTRIBUTE_ENTRY as u16)); - fn can_cast(kind: SyntaxKind) -> bool { kind == JS_IMPORT_ATTRIBUTE_ENTRY } + SyntaxKindSet::from_raw(RawSyntaxKind(JS_IMPORT_ASSERTION_ENTRY as u16)); + fn can_cast(kind: SyntaxKind) -> bool { kind == JS_IMPORT_ASSERTION_ENTRY } fn cast(syntax: SyntaxNode) -> Option { if Self::can_cast(syntax.kind()) { Some(Self { syntax }) @@ -17967,9 +17970,9 @@ impl AstNode for JsImportAttributeEntry { fn syntax(&self) -> &SyntaxNode { &self.syntax } fn into_syntax(self) -> SyntaxNode { self.syntax } } -impl std::fmt::Debug for JsImportAttributeEntry { +impl std::fmt::Debug for JsImportAssertionEntry { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - f.debug_struct("JsImportAttributeEntry") + f.debug_struct("JsImportAssertionEntry") .field("key", &support::DebugSyntaxResult(self.key())) .field( "colon_token", @@ -17982,11 +17985,11 @@ impl std::fmt::Debug for JsImportAttributeEntry { .finish() } } -impl From for SyntaxNode { - fn from(n: JsImportAttributeEntry) -> SyntaxNode { n.syntax } +impl From for SyntaxNode { + fn from(n: JsImportAssertionEntry) -> SyntaxNode { n.syntax } } -impl From for SyntaxElement { - fn from(n: JsImportAttributeEntry) -> SyntaxElement { n.syntax.into() } +impl From for SyntaxElement { + fn from(n: JsImportAssertionEntry) -> SyntaxElement { n.syntax.into() } } impl AstNode for JsImportBareClause { type Language = Language; @@ -18008,8 +18011,8 @@ impl std::fmt::Debug for JsImportBareClause { f.debug_struct("JsImportBareClause") .field("source", &support::DebugSyntaxResult(self.source())) .field( - "attribute", - &support::DebugOptionalElement(self.attribute()), + "assertion", + &support::DebugOptionalElement(self.assertion()), ) .finish() } @@ -18078,8 +18081,8 @@ impl std::fmt::Debug for JsImportDefaultClause { .field("from_token", &support::DebugSyntaxResult(self.from_token())) .field("source", &support::DebugSyntaxResult(self.source())) .field( - "attribute", - &support::DebugOptionalElement(self.attribute()), + "assertion", + &support::DebugOptionalElement(self.assertion()), ) .finish() } @@ -18156,8 +18159,8 @@ impl std::fmt::Debug for JsImportNamedClause { .field("from_token", &support::DebugSyntaxResult(self.from_token())) .field("source", &support::DebugSyntaxResult(self.source())) .field( - "attribute", - &support::DebugOptionalElement(self.attribute()), + "assertion", + &support::DebugOptionalElement(self.assertion()), ) .finish() } @@ -18196,8 +18199,8 @@ impl std::fmt::Debug for JsImportNamespaceClause { .field("from_token", &support::DebugSyntaxResult(self.from_token())) .field("source", &support::DebugSyntaxResult(self.source())) .field( - "attribute", - &support::DebugOptionalElement(self.attribute()), + "assertion", + &support::DebugOptionalElement(self.assertion()), ) .finish() } @@ -28375,35 +28378,35 @@ impl From for SyntaxElement { node.into() } } -impl From for AnyJsImportAttributeEntry { - fn from(node: JsBogusImportAttributeEntry) -> AnyJsImportAttributeEntry { - AnyJsImportAttributeEntry::JsBogusImportAttributeEntry(node) +impl From for AnyJsImportAssertionEntry { + fn from(node: JsBogusImportAssertionEntry) -> AnyJsImportAssertionEntry { + AnyJsImportAssertionEntry::JsBogusImportAssertionEntry(node) } } -impl From for AnyJsImportAttributeEntry { - fn from(node: JsImportAttributeEntry) -> AnyJsImportAttributeEntry { - AnyJsImportAttributeEntry::JsImportAttributeEntry(node) +impl From for AnyJsImportAssertionEntry { + fn from(node: JsImportAssertionEntry) -> AnyJsImportAssertionEntry { + AnyJsImportAssertionEntry::JsImportAssertionEntry(node) } } -impl AstNode for AnyJsImportAttributeEntry { +impl AstNode for AnyJsImportAssertionEntry { type Language = Language; const KIND_SET: SyntaxKindSet = - JsBogusImportAttributeEntry::KIND_SET.union(JsImportAttributeEntry::KIND_SET); + JsBogusImportAssertionEntry::KIND_SET.union(JsImportAssertionEntry::KIND_SET); fn can_cast(kind: SyntaxKind) -> bool { matches!( kind, - JS_BOGUS_IMPORT_ATTRIBUTE_ENTRY | JS_IMPORT_ATTRIBUTE_ENTRY + JS_BOGUS_IMPORT_ASSERTION_ENTRY | JS_IMPORT_ASSERTION_ENTRY ) } fn cast(syntax: SyntaxNode) -> Option { let res = match syntax.kind() { - JS_BOGUS_IMPORT_ATTRIBUTE_ENTRY => { - AnyJsImportAttributeEntry::JsBogusImportAttributeEntry( - JsBogusImportAttributeEntry { syntax }, + JS_BOGUS_IMPORT_ASSERTION_ENTRY => { + AnyJsImportAssertionEntry::JsBogusImportAssertionEntry( + JsBogusImportAssertionEntry { syntax }, ) } - JS_IMPORT_ATTRIBUTE_ENTRY => { - AnyJsImportAttributeEntry::JsImportAttributeEntry(JsImportAttributeEntry { syntax }) + JS_IMPORT_ASSERTION_ENTRY => { + AnyJsImportAssertionEntry::JsImportAssertionEntry(JsImportAssertionEntry { syntax }) } _ => return None, }; @@ -28411,37 +28414,37 @@ impl AstNode for AnyJsImportAttributeEntry { } fn syntax(&self) -> &SyntaxNode { match self { - AnyJsImportAttributeEntry::JsBogusImportAttributeEntry(it) => &it.syntax, - AnyJsImportAttributeEntry::JsImportAttributeEntry(it) => &it.syntax, + AnyJsImportAssertionEntry::JsBogusImportAssertionEntry(it) => &it.syntax, + AnyJsImportAssertionEntry::JsImportAssertionEntry(it) => &it.syntax, } } fn into_syntax(self) -> SyntaxNode { match self { - AnyJsImportAttributeEntry::JsBogusImportAttributeEntry(it) => it.syntax, - AnyJsImportAttributeEntry::JsImportAttributeEntry(it) => it.syntax, + AnyJsImportAssertionEntry::JsBogusImportAssertionEntry(it) => it.syntax, + AnyJsImportAssertionEntry::JsImportAssertionEntry(it) => it.syntax, } } } -impl std::fmt::Debug for AnyJsImportAttributeEntry { +impl std::fmt::Debug for AnyJsImportAssertionEntry { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { match self { - AnyJsImportAttributeEntry::JsBogusImportAttributeEntry(it) => { + AnyJsImportAssertionEntry::JsBogusImportAssertionEntry(it) => { std::fmt::Debug::fmt(it, f) } - AnyJsImportAttributeEntry::JsImportAttributeEntry(it) => std::fmt::Debug::fmt(it, f), + AnyJsImportAssertionEntry::JsImportAssertionEntry(it) => std::fmt::Debug::fmt(it, f), } } } -impl From for SyntaxNode { - fn from(n: AnyJsImportAttributeEntry) -> SyntaxNode { +impl From for SyntaxNode { + fn from(n: AnyJsImportAssertionEntry) -> SyntaxNode { match n { - AnyJsImportAttributeEntry::JsBogusImportAttributeEntry(it) => it.into(), - AnyJsImportAttributeEntry::JsImportAttributeEntry(it) => it.into(), + AnyJsImportAssertionEntry::JsBogusImportAssertionEntry(it) => it.into(), + AnyJsImportAssertionEntry::JsImportAssertionEntry(it) => it.into(), } } } -impl From for SyntaxElement { - fn from(n: AnyJsImportAttributeEntry) -> SyntaxElement { +impl From for SyntaxElement { + fn from(n: AnyJsImportAssertionEntry) -> SyntaxElement { let node: SyntaxNode = n.into(); node.into() } @@ -32856,7 +32859,7 @@ impl std::fmt::Display for AnyJsFunctionBody { std::fmt::Display::fmt(self.syntax(), f) } } -impl std::fmt::Display for AnyJsImportAttributeEntry { +impl std::fmt::Display for AnyJsImportAssertionEntry { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { std::fmt::Display::fmt(self.syntax(), f) } @@ -33436,12 +33439,12 @@ impl std::fmt::Display for JsImport { std::fmt::Display::fmt(self.syntax(), f) } } -impl std::fmt::Display for JsImportAttribute { +impl std::fmt::Display for JsImportAssertion { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { std::fmt::Display::fmt(self.syntax(), f) } } -impl std::fmt::Display for JsImportAttributeEntry { +impl std::fmt::Display for JsImportAssertionEntry { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { std::fmt::Display::fmt(self.syntax(), f) } @@ -34675,10 +34678,10 @@ impl From for SyntaxElement { } #[derive(Clone, PartialEq, Eq, Hash)] #[cfg_attr(feature = "serde", derive(Serialize))] -pub struct JsBogusImportAttributeEntry { +pub struct JsBogusImportAssertionEntry { syntax: SyntaxNode, } -impl JsBogusImportAttributeEntry { +impl JsBogusImportAssertionEntry { #[doc = r" Create an AstNode from a SyntaxNode without checking its kind"] #[doc = r""] #[doc = r" # Safety"] @@ -34688,11 +34691,11 @@ impl JsBogusImportAttributeEntry { pub const unsafe fn new_unchecked(syntax: SyntaxNode) -> Self { Self { syntax } } pub fn items(&self) -> SyntaxElementChildren { support::elements(&self.syntax) } } -impl AstNode for JsBogusImportAttributeEntry { +impl AstNode for JsBogusImportAssertionEntry { type Language = Language; const KIND_SET: SyntaxKindSet = - SyntaxKindSet::from_raw(RawSyntaxKind(JS_BOGUS_IMPORT_ATTRIBUTE_ENTRY as u16)); - fn can_cast(kind: SyntaxKind) -> bool { kind == JS_BOGUS_IMPORT_ATTRIBUTE_ENTRY } + SyntaxKindSet::from_raw(RawSyntaxKind(JS_BOGUS_IMPORT_ASSERTION_ENTRY as u16)); + fn can_cast(kind: SyntaxKind) -> bool { kind == JS_BOGUS_IMPORT_ASSERTION_ENTRY } fn cast(syntax: SyntaxNode) -> Option { if Self::can_cast(syntax.kind()) { Some(Self { syntax }) @@ -34703,18 +34706,18 @@ impl AstNode for JsBogusImportAttributeEntry { fn syntax(&self) -> &SyntaxNode { &self.syntax } fn into_syntax(self) -> SyntaxNode { self.syntax } } -impl std::fmt::Debug for JsBogusImportAttributeEntry { +impl std::fmt::Debug for JsBogusImportAssertionEntry { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - f.debug_struct("JsBogusImportAttributeEntry") + f.debug_struct("JsBogusImportAssertionEntry") .field("items", &DebugSyntaxElementChildren(self.items())) .finish() } } -impl From for SyntaxNode { - fn from(n: JsBogusImportAttributeEntry) -> SyntaxNode { n.syntax } +impl From for SyntaxNode { + fn from(n: JsBogusImportAssertionEntry) -> SyntaxNode { n.syntax } } -impl From for SyntaxElement { - fn from(n: JsBogusImportAttributeEntry) -> SyntaxElement { n.syntax.into() } +impl From for SyntaxElement { + fn from(n: JsBogusImportAssertionEntry) -> SyntaxElement { n.syntax.into() } } #[derive(Clone, PartialEq, Eq, Hash)] #[cfg_attr(feature = "serde", derive(Serialize))] @@ -35692,10 +35695,10 @@ impl IntoIterator for &JsExportNamedSpecifierList { fn into_iter(self) -> Self::IntoIter { self.iter() } } #[derive(Clone, Eq, PartialEq, Hash)] -pub struct JsImportAttributeEntryList { +pub struct JsImportAssertionEntryList { syntax_list: SyntaxList, } -impl JsImportAttributeEntryList { +impl JsImportAssertionEntryList { #[doc = r" Create an AstNode from a SyntaxNode without checking its kind"] #[doc = r""] #[doc = r" # Safety"] @@ -35708,14 +35711,14 @@ impl JsImportAttributeEntryList { } } } -impl AstNode for JsImportAttributeEntryList { +impl AstNode for JsImportAssertionEntryList { type Language = Language; const KIND_SET: SyntaxKindSet = - 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 { + 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 { if Self::can_cast(syntax.kind()) { - Some(JsImportAttributeEntryList { + Some(JsImportAssertionEntryList { syntax_list: syntax.into_list(), }) } else { @@ -35726,7 +35729,7 @@ impl AstNode for JsImportAttributeEntryList { fn into_syntax(self) -> SyntaxNode { self.syntax_list.into_node() } } #[cfg(feature = "serde")] -impl Serialize for JsImportAttributeEntryList { +impl Serialize for JsImportAssertionEntryList { fn serialize(&self, serializer: S) -> Result where S: Serializer, @@ -35738,26 +35741,26 @@ impl Serialize for JsImportAttributeEntryList { seq.end() } } -impl AstSeparatedList for JsImportAttributeEntryList { +impl AstSeparatedList for JsImportAssertionEntryList { type Language = Language; - type Node = AnyJsImportAttributeEntry; + type Node = AnyJsImportAssertionEntry; fn syntax_list(&self) -> &SyntaxList { &self.syntax_list } fn into_syntax_list(self) -> SyntaxList { self.syntax_list } } -impl Debug for JsImportAttributeEntryList { +impl Debug for JsImportAssertionEntryList { fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result { - f.write_str("JsImportAttributeEntryList ")?; + f.write_str("JsImportAssertionEntryList ")?; f.debug_list().entries(self.elements()).finish() } } -impl IntoIterator for JsImportAttributeEntryList { - type Item = SyntaxResult; - type IntoIter = AstSeparatedListNodesIterator; +impl IntoIterator for JsImportAssertionEntryList { + type Item = SyntaxResult; + type IntoIter = AstSeparatedListNodesIterator; fn into_iter(self) -> Self::IntoIter { self.iter() } } -impl IntoIterator for &JsImportAttributeEntryList { - type Item = SyntaxResult; - type IntoIter = AstSeparatedListNodesIterator; +impl IntoIterator for &JsImportAssertionEntryList { + 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 f8cf14ef832..231cfc1f8df 100644 --- a/crates/rome_js_syntax/src/generated/nodes_mut.rs +++ b/crates/rome_js_syntax/src/generated/nodes_mut.rs @@ -1017,7 +1017,7 @@ impl JsExportFromClause { .splice_slots(4usize..=4usize, once(Some(element.into_syntax().into()))), ) } - pub fn with_attribute(self, element: Option) -> Self { + pub fn with_assertion(self, element: Option) -> Self { Self::unwrap_cast(self.syntax.splice_slots( 5usize..=5usize, once(element.map(|element| element.into_syntax().into())), @@ -1099,7 +1099,7 @@ impl JsExportNamedFromClause { .splice_slots(5usize..=5usize, once(Some(element.into_syntax().into()))), ) } - pub fn with_attribute(self, element: Option) -> Self { + pub fn with_assertion(self, element: Option) -> Self { Self::unwrap_cast(self.syntax.splice_slots( 6usize..=6usize, once(element.map(|element| element.into_syntax().into())), @@ -1764,8 +1764,8 @@ impl JsImport { ) } } -impl JsImportAttribute { - pub fn with_with_token(self, element: SyntaxToken) -> Self { +impl JsImportAssertion { + pub fn with_assertion_kind_token(self, element: SyntaxToken) -> Self { Self::unwrap_cast( self.syntax .splice_slots(0usize..=0usize, once(Some(element.into()))), @@ -1777,7 +1777,7 @@ impl JsImportAttribute { .splice_slots(1usize..=1usize, once(Some(element.into()))), ) } - pub fn with_attributes(self, element: JsImportAttributeEntryList) -> Self { + pub fn with_assertions(self, element: JsImportAssertionEntryList) -> Self { Self::unwrap_cast( self.syntax .splice_slots(2usize..=2usize, once(Some(element.into_syntax().into()))), @@ -1790,7 +1790,7 @@ impl JsImportAttribute { ) } } -impl JsImportAttributeEntry { +impl JsImportAssertionEntry { pub fn with_key_token(self, element: SyntaxToken) -> Self { Self::unwrap_cast( self.syntax @@ -1817,7 +1817,7 @@ impl JsImportBareClause { .splice_slots(0usize..=0usize, once(Some(element.into_syntax().into()))), ) } - pub fn with_attribute(self, element: Option) -> Self { + pub fn with_assertion(self, element: Option) -> Self { Self::unwrap_cast(self.syntax.splice_slots( 1usize..=1usize, once(element.map(|element| element.into_syntax().into())), @@ -1863,7 +1863,7 @@ impl JsImportDefaultClause { .splice_slots(3usize..=3usize, once(Some(element.into_syntax().into()))), ) } - pub fn with_attribute(self, element: Option) -> Self { + pub fn with_assertion(self, element: Option) -> Self { Self::unwrap_cast(self.syntax.splice_slots( 4usize..=4usize, once(element.map(|element| element.into_syntax().into())), @@ -1921,7 +1921,7 @@ impl JsImportNamedClause { .splice_slots(4usize..=4usize, once(Some(element.into_syntax().into()))), ) } - pub fn with_attribute(self, element: Option) -> Self { + pub fn with_assertion(self, element: Option) -> Self { Self::unwrap_cast(self.syntax.splice_slots( 5usize..=5usize, once(element.map(|element| element.into_syntax().into())), @@ -1965,7 +1965,7 @@ impl JsImportNamespaceClause { .splice_slots(5usize..=5usize, once(Some(element.into_syntax().into()))), ) } - pub fn with_attribute(self, element: Option) -> Self { + pub fn with_assertion(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 5a47641a74f..4a487b57737 100644 --- a/crates/rome_js_syntax/src/lib.rs +++ b/crates/rome_js_syntax/src/lib.rs @@ -99,7 +99,7 @@ impl rome_rowan::SyntaxKind for JsSyntaxKind { | JS_BOGUS_BINDING | JS_BOGUS_MEMBER | JS_BOGUS_EXPRESSION - | JS_BOGUS_IMPORT_ATTRIBUTE_ENTRY + | JS_BOGUS_IMPORT_ASSERTION_ENTRY | JS_BOGUS_NAMED_IMPORT_SPECIFIER | JS_BOGUS_ASSIGNMENT | TS_BOGUS_TYPE @@ -116,7 +116,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 AnyJsImportAttributeEntry::can_cast(*kind) => JS_BOGUS_IMPORT_ATTRIBUTE_ENTRY, + kind if AnyJsImportAssertionEntry::can_cast(*kind) => JS_BOGUS_IMPORT_ASSERTION_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 5d11a76dd76..8bcf0017ade 100644 --- a/xtask/codegen/js.ungram +++ b/xtask/codegen/js.ungram @@ -44,7 +44,7 @@ JsBogusMember = SyntaxElement* JsBogusBinding = SyntaxElement* JsBogusAssignment = SyntaxElement* JsBogusParameter = SyntaxElement* -JsBogusImportAttributeEntry = SyntaxElement* +JsBogusImportAssertionEntry = SyntaxElement* JsBogusNamedImportSpecifier = SyntaxElement* TsBogusType = SyntaxElement* @@ -1227,7 +1227,7 @@ AnyJsImportClause = // import "abcd" assert ... JsImportBareClause = source: JsModuleSource - attribute: JsImportAttribute? + assertion: JsImportAssertion? // import foo from "mod" // import type foo from "mod" @@ -1236,7 +1236,7 @@ JsImportDefaultClause = local_name: AnyJsBinding 'from' source: JsModuleSource - attribute: JsImportAttribute? + assertion: JsImportAssertion? // import * as foo from "mod"; // import type * as foo from "mod"; @@ -1247,7 +1247,7 @@ JsImportNamespaceClause = local_name: AnyJsBinding 'from' source: JsModuleSource - attribute: JsImportAttribute? + assertion: JsImportAssertion? // import { a, b: c } from "d" // ^^^^^^^^^^^^^^^^^^^^ @@ -1266,7 +1266,7 @@ JsImportNamedClause = named_import: AnyJsNamedImport 'from' source: JsModuleSource - attribute: JsImportAttribute? + assertion: JsImportAssertion? // import a, { b, c } from "d"; // ^^ @@ -1317,21 +1317,21 @@ JsShorthandNamedImportSpecifier = // import a from "mod" assert { type: "json" } // ^^^^^^^^^^^^^^^^^^^^^^^ -JsImportAttribute = - 'with' +JsImportAssertion = + assertion_kind: ('assert' | 'with') '{' - attributes: JsImportAttributeEntryList + assertions: JsImportAssertionEntryList '}' -JsImportAttributeEntryList = (AnyJsImportAttributeEntry (',' AnyJsImportAttributeEntry)* ','?) +JsImportAssertionEntryList = (AnyJsImportAssertionEntry (',' AnyJsImportAssertionEntry)* ','?) -AnyJsImportAttributeEntry = - JsImportAttributeEntry - | JsBogusImportAttributeEntry +AnyJsImportAssertionEntry = + JsImportAssertionEntry + | JsBogusImportAssertionEntry -// import a from "mod" with { type: "json" } +// import a from "mod" assert { type: "json" } // ^^^^^^^^^^^^ -JsImportAttributeEntry = +JsImportAssertionEntry = key: ('ident' | 'js_string_literal') ':' value: 'js_string_literal' @@ -1470,7 +1470,7 @@ JsExportFromClause = export_as: JsExportAsClause? 'from' source: JsModuleSource - attribute: JsImportAttribute? + assertion: JsImportAssertion? ';'? // export { a } from "b"; @@ -1484,7 +1484,7 @@ JsExportNamedFromClause = '}' 'from' source: JsModuleSource - attribute: JsImportAttribute? + assertion: JsImportAssertion? ';'? JsExportNamedFromSpecifierList = (JsExportNamedFromSpecifier (',' JsExportNamedFromSpecifier)* ','?) diff --git a/xtask/codegen/src/kinds_src.rs b/xtask/codegen/src/kinds_src.rs index 9129f2ea7cb..eab1d74893c 100644 --- a/xtask/codegen/src/kinds_src.rs +++ b/xtask/codegen/src/kinds_src.rs @@ -132,6 +132,7 @@ pub const JS_KINDS_SRC: KindsSrc = KindsSrc { "as", "satisfies", "asserts", + "assert", "any", "async", "await", @@ -361,9 +362,9 @@ pub const JS_KINDS_SRC: KindsSrc = KindsSrc { "JS_DEFAULT_IMPORT_SPECIFIER", "JS_NAMED_IMPORT_SPECIFIER", "JS_SHORTHAND_NAMED_IMPORT_SPECIFIER", - "JS_IMPORT_ATTRIBUTE", - "JS_IMPORT_ATTRIBUTE_ENTRY_LIST", - "JS_IMPORT_ATTRIBUTE_ENTRY", + "JS_IMPORT_ASSERTION", + "JS_IMPORT_ASSERTION_ENTRY_LIST", + "JS_IMPORT_ASSERTION_ENTRY", "JS_MODULE_SOURCE", "JS_EXPORT", "JS_EXPORT_NAMED_CLAUSE", @@ -521,7 +522,7 @@ pub const JS_KINDS_SRC: KindsSrc = KindsSrc { "JS_BOGUS_MEMBER", "JS_BOGUS_BINDING", "JS_BOGUS_PARAMETER", - "JS_BOGUS_IMPORT_ATTRIBUTE_ENTRY", + "JS_BOGUS_IMPORT_ASSERTION_ENTRY", "JS_BOGUS_NAMED_IMPORT_SPECIFIER", "JS_BOGUS_ASSIGNMENT", "TS_BOGUS_TYPE",