From 27a774fddde0ddb9a25f41d88a5d883720db4f7d Mon Sep 17 00:00:00 2001 From: Emanuele Stoppa Date: Mon, 10 Apr 2023 16:53:53 +0100 Subject: [PATCH] fix: bad tests --- .../bracket-spacing/empty.js.snap | 73 ----- .../bracket-spacing/re-export.js.snap | 83 ----- .../bracket-spacing/static-import.js.snap | 83 ----- .../import/import-assertions/empty.js.snap | 283 ------------------ .../import-assertions/multi-types.js.snap | 105 ------- .../import/import-assertions/non-type.js.snap | 83 ----- .../not-import-assertions.js.prettier-snap | 2 - .../import-assertions/re-export.js.snap | 217 -------------- .../import-assertions/static-import.js.snap | 83 ----- .../import-assertions/without-from.js.snap | 83 ----- .../bracket-spacing/dynamic-import.js | 0 .../dynamic-import.js.prettier-snap | 0 .../bracket-spacing/dynamic-import.js.snap | 33 ++ .../bracket-spacing/empty.js | 0 .../bracket-spacing/empty.js.prettier-snap | 0 .../bracket-spacing/empty.js.snap | 33 ++ .../bracket-spacing/re-export.js | 0 .../re-export.js.prettier-snap | 0 .../bracket-spacing/re-export.js.snap | 33 ++ .../bracket-spacing/static-import.js | 0 .../static-import.js.prettier-snap | 0 .../bracket-spacing/static-import.js.snap | 33 ++ .../dynamic-import.js | 0 .../dynamic-import.js.prettier-snap | 0 .../import-attributes/dynamic-import.js.snap | 33 ++ .../empty.js | 0 .../empty.js.prettier-snap | 0 .../import/import-attributes/empty.js.snap | 45 +++ .../multi-types.js | 0 .../multi-types.js.prettier-snap | 0 .../import-attributes/multi-types.js.snap | 33 ++ .../non-type.js | 0 .../non-type.js.prettier-snap | 0 .../import/import-attributes/non-type.js.snap | 33 ++ .../not-import-attributes.js} | 0 .../not-import-attributes.js.snap | 35 +++ .../re-export.js | 0 .../re-export.js.prettier-snap | 0 .../import-attributes/re-export.js.snap | 37 +++ .../static-import.js | 0 .../static-import.js.prettier-snap | 0 .../import-attributes/static-import.js.snap | 33 ++ .../without-from.js | 0 .../without-from.js.prettier-snap | 0 .../import-attributes/without-from.js.snap | 33 ++ crates/rome_js_parser/src/syntax/module.rs | 16 +- 46 files changed, 422 insertions(+), 1103 deletions(-) delete mode 100644 crates/rome_js_formatter/tests/specs/js/module/import/import-assertions/bracket-spacing/empty.js.snap delete mode 100644 crates/rome_js_formatter/tests/specs/js/module/import/import-assertions/bracket-spacing/re-export.js.snap delete mode 100644 crates/rome_js_formatter/tests/specs/js/module/import/import-assertions/bracket-spacing/static-import.js.snap delete mode 100644 crates/rome_js_formatter/tests/specs/js/module/import/import-assertions/empty.js.snap delete mode 100644 crates/rome_js_formatter/tests/specs/js/module/import/import-assertions/multi-types.js.snap delete mode 100644 crates/rome_js_formatter/tests/specs/js/module/import/import-assertions/non-type.js.snap delete mode 100644 crates/rome_js_formatter/tests/specs/js/module/import/import-assertions/not-import-assertions.js.prettier-snap delete mode 100644 crates/rome_js_formatter/tests/specs/js/module/import/import-assertions/re-export.js.snap delete mode 100644 crates/rome_js_formatter/tests/specs/js/module/import/import-assertions/static-import.js.snap delete mode 100644 crates/rome_js_formatter/tests/specs/js/module/import/import-assertions/without-from.js.snap rename crates/rome_js_formatter/tests/specs/js/module/import/{import-assertions => import-attributes}/bracket-spacing/dynamic-import.js (100%) rename crates/rome_js_formatter/tests/specs/js/module/import/{import-assertions => import-attributes}/bracket-spacing/dynamic-import.js.prettier-snap (100%) create mode 100644 crates/rome_js_formatter/tests/specs/js/module/import/import-attributes/bracket-spacing/dynamic-import.js.snap rename crates/rome_js_formatter/tests/specs/js/module/import/{import-assertions => import-attributes}/bracket-spacing/empty.js (100%) rename crates/rome_js_formatter/tests/specs/js/module/import/{import-assertions => import-attributes}/bracket-spacing/empty.js.prettier-snap (100%) create mode 100644 crates/rome_js_formatter/tests/specs/js/module/import/import-attributes/bracket-spacing/empty.js.snap rename crates/rome_js_formatter/tests/specs/js/module/import/{import-assertions => import-attributes}/bracket-spacing/re-export.js (100%) rename crates/rome_js_formatter/tests/specs/js/module/import/{import-assertions => import-attributes}/bracket-spacing/re-export.js.prettier-snap (100%) create mode 100644 crates/rome_js_formatter/tests/specs/js/module/import/import-attributes/bracket-spacing/re-export.js.snap rename crates/rome_js_formatter/tests/specs/js/module/import/{import-assertions => import-attributes}/bracket-spacing/static-import.js (100%) rename crates/rome_js_formatter/tests/specs/js/module/import/{import-assertions => import-attributes}/bracket-spacing/static-import.js.prettier-snap (100%) create mode 100644 crates/rome_js_formatter/tests/specs/js/module/import/import-attributes/bracket-spacing/static-import.js.snap rename crates/rome_js_formatter/tests/specs/js/module/import/{import-assertions => import-attributes}/dynamic-import.js (100%) rename crates/rome_js_formatter/tests/specs/js/module/import/{import-assertions => import-attributes}/dynamic-import.js.prettier-snap (100%) create mode 100644 crates/rome_js_formatter/tests/specs/js/module/import/import-attributes/dynamic-import.js.snap rename crates/rome_js_formatter/tests/specs/js/module/import/{import-assertions => import-attributes}/empty.js (100%) rename crates/rome_js_formatter/tests/specs/js/module/import/{import-assertions => import-attributes}/empty.js.prettier-snap (100%) create mode 100644 crates/rome_js_formatter/tests/specs/js/module/import/import-attributes/empty.js.snap rename crates/rome_js_formatter/tests/specs/js/module/import/{import-assertions => import-attributes}/multi-types.js (100%) rename crates/rome_js_formatter/tests/specs/js/module/import/{import-assertions => import-attributes}/multi-types.js.prettier-snap (100%) create mode 100644 crates/rome_js_formatter/tests/specs/js/module/import/import-attributes/multi-types.js.snap rename crates/rome_js_formatter/tests/specs/js/module/import/{import-assertions => import-attributes}/non-type.js (100%) rename crates/rome_js_formatter/tests/specs/js/module/import/{import-assertions => import-attributes}/non-type.js.prettier-snap (100%) create mode 100644 crates/rome_js_formatter/tests/specs/js/module/import/import-attributes/non-type.js.snap rename crates/rome_js_formatter/tests/specs/js/module/import/{import-assertions/not-import-assertions.js => import-attributes/not-import-attributes.js} (100%) create mode 100644 crates/rome_js_formatter/tests/specs/js/module/import/import-attributes/not-import-attributes.js.snap rename crates/rome_js_formatter/tests/specs/js/module/import/{import-assertions => import-attributes}/re-export.js (100%) rename crates/rome_js_formatter/tests/specs/js/module/import/{import-assertions => import-attributes}/re-export.js.prettier-snap (100%) create mode 100644 crates/rome_js_formatter/tests/specs/js/module/import/import-attributes/re-export.js.snap rename crates/rome_js_formatter/tests/specs/js/module/import/{import-assertions => import-attributes}/static-import.js (100%) rename crates/rome_js_formatter/tests/specs/js/module/import/{import-assertions => import-attributes}/static-import.js.prettier-snap (100%) create mode 100644 crates/rome_js_formatter/tests/specs/js/module/import/import-attributes/static-import.js.snap rename crates/rome_js_formatter/tests/specs/js/module/import/{import-assertions => import-attributes}/without-from.js (100%) rename crates/rome_js_formatter/tests/specs/js/module/import/{import-assertions => import-attributes}/without-from.js.prettier-snap (100%) create mode 100644 crates/rome_js_formatter/tests/specs/js/module/import/import-attributes/without-from.js.snap diff --git a/crates/rome_js_formatter/tests/specs/js/module/import/import-assertions/bracket-spacing/empty.js.snap b/crates/rome_js_formatter/tests/specs/js/module/import/import-assertions/bracket-spacing/empty.js.snap deleted file mode 100644 index e334e7c1fe5..00000000000 --- a/crates/rome_js_formatter/tests/specs/js/module/import/import-assertions/bracket-spacing/empty.js.snap +++ /dev/null @@ -1,73 +0,0 @@ ---- -source: crates/rome_formatter_test/src/snapshot_builder.rs -info: js/import-withions/bracket-spacing/empty.js ---- - -# Input - -```js -export * as bar from "bar.json" with { } -``` - - -# Prettier differences - -```diff ---- Prettier -+++ Rome -@@ -1 +1,4 @@ - export * as bar from "bar.json"; -+with; -+{ -+} -``` - -# Output - -```js -export * as bar from "bar.json"; -with; -{ -} -``` - -# Errors -``` -empty.js:1:33 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ - - × Expected a semicolon or an implicit semicolon after a statement, but found none - - > 1 │ export * as bar from "bar.json" with { } - │ ^^^^^^ - - i An explicit or implicit semicolon is expected here... - - > 1 │ export * as bar from "bar.json" with { } - │ ^^^^^^ - - i ...Which is required to end this statement - - > 1 │ export * as bar from "bar.json" with { } - │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - -empty.js:1:40 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ - - × Expected a semicolon or an implicit semicolon after a statement, but found none - - > 1 │ export * as bar from "bar.json" with { } - │ ^ - - i An explicit or implicit semicolon is expected here... - - > 1 │ export * as bar from "bar.json" with { } - │ ^ - - i ...Which is required to end this statement - - > 1 │ export * as bar from "bar.json" with { } - │ ^^^^^^^^ - - -``` - - diff --git a/crates/rome_js_formatter/tests/specs/js/module/import/import-assertions/bracket-spacing/re-export.js.snap b/crates/rome_js_formatter/tests/specs/js/module/import/import-assertions/bracket-spacing/re-export.js.snap deleted file mode 100644 index 80361e55862..00000000000 --- a/crates/rome_js_formatter/tests/specs/js/module/import/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-withions/bracket-spacing/re-export.js ---- - -# Input - -```js -export { default as foo2 } from "foo.json" with { type: "json" }; - -``` - - -# Prettier differences - -```diff ---- Prettier -+++ Rome -@@ -1 +1,5 @@ --export { default as foo2 } from "foo.json" with { type: "json" }; -+export { default as foo2 } from "foo.json"; -+with; -+{ -+ type: "json"; -+} -``` - -# Output - -```js -export { default as foo2 } from "foo.json"; -with; -{ - type: "json"; -} -``` - -# Errors -``` -re-export.js:1:44 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ - - × Expected a semicolon or an implicit semicolon after a statement, but found none - - > 1 │ export { default as foo2 } from "foo.json" with { type: "json" }; - │ ^^^^^^ - 2 │ - - i An explicit or implicit semicolon is expected here... - - > 1 │ export { default as foo2 } from "foo.json" with { type: "json" }; - │ ^^^^^^ - 2 │ - - i ...Which is required to end this statement - - > 1 │ export { default as foo2 } from "foo.json" with { type: "json" }; - │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - 2 │ - -re-export.js:1:51 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ - - × Expected a semicolon or an implicit semicolon after a statement, but found none - - > 1 │ export { default as foo2 } from "foo.json" with { type: "json" }; - │ ^ - 2 │ - - i An explicit or implicit semicolon is expected here... - - > 1 │ export { default as foo2 } from "foo.json" with { type: "json" }; - │ ^ - 2 │ - - i ...Which is required to end this statement - - > 1 │ export { default as foo2 } from "foo.json" with { type: "json" }; - │ ^^^^^^^^ - 2 │ - - -``` - - diff --git a/crates/rome_js_formatter/tests/specs/js/module/import/import-assertions/bracket-spacing/static-import.js.snap b/crates/rome_js_formatter/tests/specs/js/module/import/import-assertions/bracket-spacing/static-import.js.snap deleted file mode 100644 index 252f22d2dd2..00000000000 --- a/crates/rome_js_formatter/tests/specs/js/module/import/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-withions/bracket-spacing/static-import.js ---- - -# Input - -```js -import json from "./foo.json" with { type: "json" }; - -``` - - -# Prettier differences - -```diff ---- Prettier -+++ Rome -@@ -1 +1,5 @@ --import json from "./foo.json" with { type: "json" }; -+import json from "./foo.json"; -+with; -+{ -+ type: "json"; -+} -``` - -# Output - -```js -import json from "./foo.json"; -with; -{ - type: "json"; -} -``` - -# Errors -``` -static-import.js:1:31 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ - - × Expected a semicolon or an implicit semicolon after a statement, but found none - - > 1 │ import json from "./foo.json" with { type: "json" }; - │ ^^^^^^ - 2 │ - - i An explicit or implicit semicolon is expected here... - - > 1 │ import json from "./foo.json" with { type: "json" }; - │ ^^^^^^ - 2 │ - - i ...Which is required to end this statement - - > 1 │ import json from "./foo.json" with { type: "json" }; - │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - 2 │ - -static-import.js:1:38 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ - - × Expected a semicolon or an implicit semicolon after a statement, but found none - - > 1 │ import json from "./foo.json" with { type: "json" }; - │ ^ - 2 │ - - i An explicit or implicit semicolon is expected here... - - > 1 │ import json from "./foo.json" with { type: "json" }; - │ ^ - 2 │ - - i ...Which is required to end this statement - - > 1 │ import json from "./foo.json" with { type: "json" }; - │ ^^^^^^^^ - 2 │ - - -``` - - diff --git a/crates/rome_js_formatter/tests/specs/js/module/import/import-assertions/empty.js.snap b/crates/rome_js_formatter/tests/specs/js/module/import/import-assertions/empty.js.snap deleted file mode 100644 index 5cf5902228c..00000000000 --- a/crates/rome_js_formatter/tests/specs/js/module/import/import-assertions/empty.js.snap +++ /dev/null @@ -1,283 +0,0 @@ ---- -source: crates/rome_formatter_test/src/snapshot_builder.rs -info: js/import-withions/empty.js ---- - -# Input - -```js -export * as foo from "foo.json" -export * as bar from "bar.json" with { } -export * as baz from "baz.json" with { /* comment */ } - -import * as foo from "foo.json" -import * as bar from "bar.json" with { } -import * as baz from "baz.json" with { /* comment */ } -``` - - -# Prettier differences - -```diff ---- Prettier -+++ Rome -@@ -1,7 +1,21 @@ - export * as foo from "foo.json"; - export * as bar from "bar.json"; --export * as baz from "baz.json" /* comment */; -+with; -+{ -+} -+export * as baz from "baz.json"; -+with; -+{ -+ /* comment */ -+} - - import * as foo from "foo.json"; - import * as bar from "bar.json"; --import * as baz from "baz.json" /* comment */; -+with; -+{ -+} -+import * as baz from "baz.json"; -+with; -+{ -+ /* comment */ -+} -``` - -# Output - -```js -export * as foo from "foo.json"; -export * as bar from "bar.json"; -with; -{ -} -export * as baz from "baz.json"; -with; -{ - /* comment */ -} - -import * as foo from "foo.json"; -import * as bar from "bar.json"; -with; -{ -} -import * as baz from "baz.json"; -with; -{ - /* comment */ -} -``` - -# Errors -``` -empty.js:2:33 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ - - × Expected a semicolon or an implicit semicolon after a statement, but found none - - 1 │ export * as foo from "foo.json" - > 2 │ export * as bar from "bar.json" with { } - │ ^^^^^^ - 3 │ export * as baz from "baz.json" with { /* comment */ } - 4 │ - - i An explicit or implicit semicolon is expected here... - - 1 │ export * as foo from "foo.json" - > 2 │ export * as bar from "bar.json" with { } - │ ^^^^^^ - 3 │ export * as baz from "baz.json" with { /* comment */ } - 4 │ - - i ...Which is required to end this statement - - 1 │ export * as foo from "foo.json" - > 2 │ export * as bar from "bar.json" with { } - │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - 3 │ export * as baz from "baz.json" with { /* comment */ } - 4 │ - -empty.js:2:40 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ - - × Expected a semicolon or an implicit semicolon after a statement, but found none - - 1 │ export * as foo from "foo.json" - > 2 │ export * as bar from "bar.json" with { } - │ ^ - 3 │ export * as baz from "baz.json" with { /* comment */ } - 4 │ - - i An explicit or implicit semicolon is expected here... - - 1 │ export * as foo from "foo.json" - > 2 │ export * as bar from "bar.json" with { } - │ ^ - 3 │ export * as baz from "baz.json" with { /* comment */ } - 4 │ - - i ...Which is required to end this statement - - 1 │ export * as foo from "foo.json" - > 2 │ export * as bar from "bar.json" with { } - │ ^^^^^^^^ - 3 │ export * as baz from "baz.json" with { /* comment */ } - 4 │ - -empty.js:3:33 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ - - × Expected a semicolon or an implicit semicolon after a statement, but found none - - 1 │ export * as foo from "foo.json" - 2 │ export * as bar from "bar.json" with { } - > 3 │ export * as baz from "baz.json" with { /* comment */ } - │ ^^^^^^ - 4 │ - 5 │ import * as foo from "foo.json" - - i An explicit or implicit semicolon is expected here... - - 1 │ export * as foo from "foo.json" - 2 │ export * as bar from "bar.json" with { } - > 3 │ export * as baz from "baz.json" with { /* comment */ } - │ ^^^^^^ - 4 │ - 5 │ import * as foo from "foo.json" - - i ...Which is required to end this statement - - 1 │ export * as foo from "foo.json" - 2 │ export * as bar from "bar.json" with { } - > 3 │ export * as baz from "baz.json" with { /* comment */ } - │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - 4 │ - 5 │ import * as foo from "foo.json" - -empty.js:3:40 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ - - × Expected a semicolon or an implicit semicolon after a statement, but found none - - 1 │ export * as foo from "foo.json" - 2 │ export * as bar from "bar.json" with { } - > 3 │ export * as baz from "baz.json" with { /* comment */ } - │ ^ - 4 │ - 5 │ import * as foo from "foo.json" - - i An explicit or implicit semicolon is expected here... - - 1 │ export * as foo from "foo.json" - 2 │ export * as bar from "bar.json" with { } - > 3 │ export * as baz from "baz.json" with { /* comment */ } - │ ^ - 4 │ - 5 │ import * as foo from "foo.json" - - i ...Which is required to end this statement - - 1 │ export * as foo from "foo.json" - 2 │ export * as bar from "bar.json" with { } - > 3 │ export * as baz from "baz.json" with { /* comment */ } - │ ^^^^^^^^ - 4 │ - 5 │ import * as foo from "foo.json" - -empty.js:6:33 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ - - × Expected a semicolon or an implicit semicolon after a statement, but found none - - 5 │ import * as foo from "foo.json" - > 6 │ import * as bar from "bar.json" with { } - │ ^^^^^^ - 7 │ import * as baz from "baz.json" with { /* comment */ } - - i An explicit or implicit semicolon is expected here... - - 5 │ import * as foo from "foo.json" - > 6 │ import * as bar from "bar.json" with { } - │ ^^^^^^ - 7 │ import * as baz from "baz.json" with { /* comment */ } - - i ...Which is required to end this statement - - 5 │ import * as foo from "foo.json" - > 6 │ import * as bar from "bar.json" with { } - │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - 7 │ import * as baz from "baz.json" with { /* comment */ } - -empty.js:6:40 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ - - × Expected a semicolon or an implicit semicolon after a statement, but found none - - 5 │ import * as foo from "foo.json" - > 6 │ import * as bar from "bar.json" with { } - │ ^ - 7 │ import * as baz from "baz.json" with { /* comment */ } - - i An explicit or implicit semicolon is expected here... - - 5 │ import * as foo from "foo.json" - > 6 │ import * as bar from "bar.json" with { } - │ ^ - 7 │ import * as baz from "baz.json" with { /* comment */ } - - i ...Which is required to end this statement - - 5 │ import * as foo from "foo.json" - > 6 │ import * as bar from "bar.json" with { } - │ ^^^^^^^^ - 7 │ import * as baz from "baz.json" with { /* comment */ } - -empty.js:7:33 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ - - × Expected a semicolon or an implicit semicolon after a statement, but found none - - 5 │ import * as foo from "foo.json" - 6 │ import * as bar from "bar.json" with { } - > 7 │ import * as baz from "baz.json" with { /* comment */ } - │ ^^^^^^ - - i An explicit or implicit semicolon is expected here... - - 5 │ import * as foo from "foo.json" - 6 │ import * as bar from "bar.json" with { } - > 7 │ import * as baz from "baz.json" with { /* comment */ } - │ ^^^^^^ - - i ...Which is required to end this statement - - 5 │ import * as foo from "foo.json" - 6 │ import * as bar from "bar.json" with { } - > 7 │ import * as baz from "baz.json" with { /* comment */ } - │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - -empty.js:7:40 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ - - × Expected a semicolon or an implicit semicolon after a statement, but found none - - 5 │ import * as foo from "foo.json" - 6 │ import * as bar from "bar.json" with { } - > 7 │ import * as baz from "baz.json" with { /* comment */ } - │ ^ - - i An explicit or implicit semicolon is expected here... - - 5 │ import * as foo from "foo.json" - 6 │ import * as bar from "bar.json" with { } - > 7 │ import * as baz from "baz.json" with { /* comment */ } - │ ^ - - i ...Which is required to end this statement - - 5 │ import * as foo from "foo.json" - 6 │ import * as bar from "bar.json" with { } - > 7 │ import * as baz from "baz.json" with { /* comment */ } - │ ^^^^^^^^ - - -``` - - diff --git a/crates/rome_js_formatter/tests/specs/js/module/import/import-assertions/multi-types.js.snap b/crates/rome_js_formatter/tests/specs/js/module/import/import-assertions/multi-types.js.snap deleted file mode 100644 index ce9ed9c8559..00000000000 --- a/crates/rome_js_formatter/tests/specs/js/module/import/import-assertions/multi-types.js.snap +++ /dev/null @@ -1,105 +0,0 @@ ---- -source: crates/rome_formatter_test/src/snapshot_builder.rs -info: js/import-withions/multi-types.js ---- - -# Input - -```js -import json from "./foo.json" with { type: "json", type: "bar" }; - -``` - - -# Prettier differences - -```diff ---- Prettier -+++ Rome -@@ -1 +1,6 @@ --import json from "./foo.json" with { type: "json", type: "bar" }; -+import json from "./foo.json"; -+with; -+{ -+ type: "json", type; -+ : "bar" -+} -``` - -# Output - -```js -import json from "./foo.json"; -with; -{ - type: "json", type; - : "bar" -} -``` - -# Errors -``` -multi-types.js:1:31 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ - - × Expected a semicolon or an implicit semicolon after a statement, but found none - - > 1 │ import json from "./foo.json" with { type: "json", type: "bar" }; - │ ^^^^^^ - 2 │ - - i An explicit or implicit semicolon is expected here... - - > 1 │ import json from "./foo.json" with { type: "json", type: "bar" }; - │ ^^^^^^ - 2 │ - - i ...Which is required to end this statement - - > 1 │ import json from "./foo.json" with { type: "json", type: "bar" }; - │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - 2 │ - -multi-types.js:1:38 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ - - × Expected a semicolon or an implicit semicolon after a statement, but found none - - > 1 │ import json from "./foo.json" with { type: "json", type: "bar" }; - │ ^ - 2 │ - - i An explicit or implicit semicolon is expected here... - - > 1 │ import json from "./foo.json" with { type: "json", type: "bar" }; - │ ^ - 2 │ - - i ...Which is required to end this statement - - > 1 │ import json from "./foo.json" with { type: "json", type: "bar" }; - │ ^^^^^^^^ - 2 │ - -multi-types.js:1:58 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ - - × Expected a semicolon or an implicit semicolon after a statement, but found none - - > 1 │ import json from "./foo.json" with { type: "json", type: "bar" }; - │ ^ - 2 │ - - i An explicit or implicit semicolon is expected here... - - > 1 │ import json from "./foo.json" with { type: "json", type: "bar" }; - │ ^ - 2 │ - - i ...Which is required to end this statement - - > 1 │ import json from "./foo.json" with { type: "json", type: "bar" }; - │ ^^^^^^^^^^^^^ - 2 │ - - -``` - - diff --git a/crates/rome_js_formatter/tests/specs/js/module/import/import-assertions/non-type.js.snap b/crates/rome_js_formatter/tests/specs/js/module/import/import-assertions/non-type.js.snap deleted file mode 100644 index 50ff1f13e38..00000000000 --- a/crates/rome_js_formatter/tests/specs/js/module/import/import-assertions/non-type.js.snap +++ /dev/null @@ -1,83 +0,0 @@ ---- -source: crates/rome_formatter_test/src/snapshot_builder.rs -info: js/import-withions/non-type.js ---- - -# Input - -```js -import foo from "foo.json" with { lazy: "true" }; - -``` - - -# Prettier differences - -```diff ---- Prettier -+++ Rome -@@ -1 +1,5 @@ --import foo from "foo.json" with { lazy: "true" }; -+import foo from "foo.json"; -+with; -+{ -+ lazy: "true"; -+} -``` - -# Output - -```js -import foo from "foo.json"; -with; -{ - lazy: "true"; -} -``` - -# Errors -``` -non-type.js:1:28 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ - - × Expected a semicolon or an implicit semicolon after a statement, but found none - - > 1 │ import foo from "foo.json" with { lazy: "true" }; - │ ^^^^^^ - 2 │ - - i An explicit or implicit semicolon is expected here... - - > 1 │ import foo from "foo.json" with { lazy: "true" }; - │ ^^^^^^ - 2 │ - - i ...Which is required to end this statement - - > 1 │ import foo from "foo.json" with { lazy: "true" }; - │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^ - 2 │ - -non-type.js:1:35 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ - - × Expected a semicolon or an implicit semicolon after a statement, but found none - - > 1 │ import foo from "foo.json" with { lazy: "true" }; - │ ^ - 2 │ - - i An explicit or implicit semicolon is expected here... - - > 1 │ import foo from "foo.json" with { lazy: "true" }; - │ ^ - 2 │ - - i ...Which is required to end this statement - - > 1 │ import foo from "foo.json" with { lazy: "true" }; - │ ^^^^^^^^ - 2 │ - - -``` - - diff --git a/crates/rome_js_formatter/tests/specs/js/module/import/import-assertions/not-import-assertions.js.prettier-snap b/crates/rome_js_formatter/tests/specs/js/module/import/import-assertions/not-import-assertions.js.prettier-snap deleted file mode 100644 index 253720d1d42..00000000000 --- a/crates/rome_js_formatter/tests/specs/js/module/import/import-assertions/not-import-assertions.js.prettier-snap +++ /dev/null @@ -1,2 +0,0 @@ -import "x"; -with({ type: "json" }); diff --git a/crates/rome_js_formatter/tests/specs/js/module/import/import-assertions/re-export.js.snap b/crates/rome_js_formatter/tests/specs/js/module/import/import-assertions/re-export.js.snap deleted file mode 100644 index d2b29d85a17..00000000000 --- a/crates/rome_js_formatter/tests/specs/js/module/import/import-assertions/re-export.js.snap +++ /dev/null @@ -1,217 +0,0 @@ ---- -source: crates/rome_formatter_test/src/snapshot_builder.rs -info: js/import-withions/re-export.js ---- - -# Input - -```js -export { default as foo2 } from "foo.json" with { type: "json" }; -export * from "foo.json" with { type: "json" }; -export * as foo3 from "foo.json" with { type: "json" }; - -``` - - -# Prettier differences - -```diff ---- Prettier -+++ Rome -@@ -1,3 +1,15 @@ --export { default as foo2 } from "foo.json" with { type: "json" }; --export * from "foo.json" with { type: "json" }; --export * as foo3 from "foo.json" with { type: "json" }; -+export { default as foo2 } from "foo.json"; -+with; -+{ -+ type: "json"; -+} -+export * from "foo.json"; -+with; -+{ -+ type: "json"; -+} -+export * as foo3 from "foo.json"; -+with; -+{ -+ type: "json"; -+} -``` - -# Output - -```js -export { default as foo2 } from "foo.json"; -with; -{ - type: "json"; -} -export * from "foo.json"; -with; -{ - type: "json"; -} -export * as foo3 from "foo.json"; -with; -{ - type: "json"; -} -``` - -# Errors -``` -re-export.js:1:44 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ - - × Expected a semicolon or an implicit semicolon after a statement, but found none - - > 1 │ export { default as foo2 } from "foo.json" with { type: "json" }; - │ ^^^^^^ - 2 │ export * from "foo.json" with { type: "json" }; - 3 │ export * as foo3 from "foo.json" with { type: "json" }; - - i An explicit or implicit semicolon is expected here... - - > 1 │ export { default as foo2 } from "foo.json" with { type: "json" }; - │ ^^^^^^ - 2 │ export * from "foo.json" with { type: "json" }; - 3 │ export * as foo3 from "foo.json" with { type: "json" }; - - i ...Which is required to end this statement - - > 1 │ export { default as foo2 } from "foo.json" with { type: "json" }; - │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - 2 │ export * from "foo.json" with { type: "json" }; - 3 │ export * as foo3 from "foo.json" with { type: "json" }; - -re-export.js:1:51 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ - - × Expected a semicolon or an implicit semicolon after a statement, but found none - - > 1 │ export { default as foo2 } from "foo.json" with { type: "json" }; - │ ^ - 2 │ export * from "foo.json" with { type: "json" }; - 3 │ export * as foo3 from "foo.json" with { type: "json" }; - - i An explicit or implicit semicolon is expected here... - - > 1 │ export { default as foo2 } from "foo.json" with { type: "json" }; - │ ^ - 2 │ export * from "foo.json" with { type: "json" }; - 3 │ export * as foo3 from "foo.json" with { type: "json" }; - - i ...Which is required to end this statement - - > 1 │ export { default as foo2 } from "foo.json" with { type: "json" }; - │ ^^^^^^^^ - 2 │ export * from "foo.json" with { type: "json" }; - 3 │ export * as foo3 from "foo.json" with { type: "json" }; - -re-export.js:2:26 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ - - × Expected a semicolon or an implicit semicolon after a statement, but found none - - 1 │ export { default as foo2 } from "foo.json" with { type: "json" }; - > 2 │ export * from "foo.json" with { type: "json" }; - │ ^^^^^^ - 3 │ export * as foo3 from "foo.json" with { type: "json" }; - 4 │ - - i An explicit or implicit semicolon is expected here... - - 1 │ export { default as foo2 } from "foo.json" with { type: "json" }; - > 2 │ export * from "foo.json" with { type: "json" }; - │ ^^^^^^ - 3 │ export * as foo3 from "foo.json" with { type: "json" }; - 4 │ - - i ...Which is required to end this statement - - 1 │ export { default as foo2 } from "foo.json" with { type: "json" }; - > 2 │ export * from "foo.json" with { type: "json" }; - │ ^^^^^^^^^^^^^^^^^^^^^^^^ - 3 │ export * as foo3 from "foo.json" with { type: "json" }; - 4 │ - -re-export.js:2:33 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ - - × Expected a semicolon or an implicit semicolon after a statement, but found none - - 1 │ export { default as foo2 } from "foo.json" with { type: "json" }; - > 2 │ export * from "foo.json" with { type: "json" }; - │ ^ - 3 │ export * as foo3 from "foo.json" with { type: "json" }; - 4 │ - - i An explicit or implicit semicolon is expected here... - - 1 │ export { default as foo2 } from "foo.json" with { type: "json" }; - > 2 │ export * from "foo.json" with { type: "json" }; - │ ^ - 3 │ export * as foo3 from "foo.json" with { type: "json" }; - 4 │ - - i ...Which is required to end this statement - - 1 │ export { default as foo2 } from "foo.json" with { type: "json" }; - > 2 │ export * from "foo.json" with { type: "json" }; - │ ^^^^^^^^ - 3 │ export * as foo3 from "foo.json" with { type: "json" }; - 4 │ - -re-export.js:3:34 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ - - × Expected a semicolon or an implicit semicolon after a statement, but found none - - 1 │ export { default as foo2 } from "foo.json" with { type: "json" }; - 2 │ export * from "foo.json" with { type: "json" }; - > 3 │ export * as foo3 from "foo.json" with { type: "json" }; - │ ^^^^^^ - 4 │ - - i An explicit or implicit semicolon is expected here... - - 1 │ export { default as foo2 } from "foo.json" with { type: "json" }; - 2 │ export * from "foo.json" with { type: "json" }; - > 3 │ export * as foo3 from "foo.json" with { type: "json" }; - │ ^^^^^^ - 4 │ - - i ...Which is required to end this statement - - 1 │ export { default as foo2 } from "foo.json" with { type: "json" }; - 2 │ export * from "foo.json" with { type: "json" }; - > 3 │ export * as foo3 from "foo.json" with { type: "json" }; - │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - 4 │ - -re-export.js:3:41 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ - - × Expected a semicolon or an implicit semicolon after a statement, but found none - - 1 │ export { default as foo2 } from "foo.json" with { type: "json" }; - 2 │ export * from "foo.json" with { type: "json" }; - > 3 │ export * as foo3 from "foo.json" with { type: "json" }; - │ ^ - 4 │ - - i An explicit or implicit semicolon is expected here... - - 1 │ export { default as foo2 } from "foo.json" with { type: "json" }; - 2 │ export * from "foo.json" with { type: "json" }; - > 3 │ export * as foo3 from "foo.json" with { type: "json" }; - │ ^ - 4 │ - - i ...Which is required to end this statement - - 1 │ export { default as foo2 } from "foo.json" with { type: "json" }; - 2 │ export * from "foo.json" with { type: "json" }; - > 3 │ export * as foo3 from "foo.json" with { type: "json" }; - │ ^^^^^^^^ - 4 │ - - -``` - - diff --git a/crates/rome_js_formatter/tests/specs/js/module/import/import-assertions/static-import.js.snap b/crates/rome_js_formatter/tests/specs/js/module/import/import-assertions/static-import.js.snap deleted file mode 100644 index 370914e6b02..00000000000 --- a/crates/rome_js_formatter/tests/specs/js/module/import/import-assertions/static-import.js.snap +++ /dev/null @@ -1,83 +0,0 @@ ---- -source: crates/rome_formatter_test/src/snapshot_builder.rs -info: js/import-withions/static-import.js ---- - -# Input - -```js -import json from "./foo.json" with { type: "json" }; - -``` - - -# Prettier differences - -```diff ---- Prettier -+++ Rome -@@ -1 +1,5 @@ --import json from "./foo.json" with { type: "json" }; -+import json from "./foo.json"; -+with; -+{ -+ type: "json"; -+} -``` - -# Output - -```js -import json from "./foo.json"; -with; -{ - type: "json"; -} -``` - -# Errors -``` -static-import.js:1:31 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ - - × Expected a semicolon or an implicit semicolon after a statement, but found none - - > 1 │ import json from "./foo.json" with { type: "json" }; - │ ^^^^^^ - 2 │ - - i An explicit or implicit semicolon is expected here... - - > 1 │ import json from "./foo.json" with { type: "json" }; - │ ^^^^^^ - 2 │ - - i ...Which is required to end this statement - - > 1 │ import json from "./foo.json" with { type: "json" }; - │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - 2 │ - -static-import.js:1:38 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ - - × Expected a semicolon or an implicit semicolon after a statement, but found none - - > 1 │ import json from "./foo.json" with { type: "json" }; - │ ^ - 2 │ - - i An explicit or implicit semicolon is expected here... - - > 1 │ import json from "./foo.json" with { type: "json" }; - │ ^ - 2 │ - - i ...Which is required to end this statement - - > 1 │ import json from "./foo.json" with { type: "json" }; - │ ^^^^^^^^ - 2 │ - - -``` - - diff --git a/crates/rome_js_formatter/tests/specs/js/module/import/import-assertions/without-from.js.snap b/crates/rome_js_formatter/tests/specs/js/module/import/import-assertions/without-from.js.snap deleted file mode 100644 index cc6e08f4102..00000000000 --- a/crates/rome_js_formatter/tests/specs/js/module/import/import-assertions/without-from.js.snap +++ /dev/null @@ -1,83 +0,0 @@ ---- -source: crates/rome_formatter_test/src/snapshot_builder.rs -info: js/import-withions/without-from.js ---- - -# Input - -```js -import "foo" with { type: "json" } - -``` - - -# Prettier differences - -```diff ---- Prettier -+++ Rome -@@ -1 +1,5 @@ --import "foo" with { type: "json" }; -+import "foo"; -+with; -+{ -+ type: "json"; -+} -``` - -# Output - -```js -import "foo"; -with; -{ - type: "json"; -} -``` - -# Errors -``` -without-from.js:1:14 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ - - × Expected a semicolon or an implicit semicolon after a statement, but found none - - > 1 │ import "foo" with { type: "json" } - │ ^^^^^^ - 2 │ - - i An explicit or implicit semicolon is expected here... - - > 1 │ import "foo" with { type: "json" } - │ ^^^^^^ - 2 │ - - i ...Which is required to end this statement - - > 1 │ import "foo" with { type: "json" } - │ ^^^^^^^^^^^^^ - 2 │ - -without-from.js:1:21 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ - - × Expected a semicolon or an implicit semicolon after a statement, but found none - - > 1 │ import "foo" with { type: "json" } - │ ^ - 2 │ - - i An explicit or implicit semicolon is expected here... - - > 1 │ import "foo" with { type: "json" } - │ ^ - 2 │ - - i ...Which is required to end this statement - - > 1 │ import "foo" with { type: "json" } - │ ^^^^^^^^ - 2 │ - - -``` - - diff --git a/crates/rome_js_formatter/tests/specs/js/module/import/import-assertions/bracket-spacing/dynamic-import.js b/crates/rome_js_formatter/tests/specs/js/module/import/import-attributes/bracket-spacing/dynamic-import.js similarity index 100% rename from crates/rome_js_formatter/tests/specs/js/module/import/import-assertions/bracket-spacing/dynamic-import.js rename to crates/rome_js_formatter/tests/specs/js/module/import/import-attributes/bracket-spacing/dynamic-import.js diff --git a/crates/rome_js_formatter/tests/specs/js/module/import/import-assertions/bracket-spacing/dynamic-import.js.prettier-snap b/crates/rome_js_formatter/tests/specs/js/module/import/import-attributes/bracket-spacing/dynamic-import.js.prettier-snap similarity index 100% rename from crates/rome_js_formatter/tests/specs/js/module/import/import-assertions/bracket-spacing/dynamic-import.js.prettier-snap rename to crates/rome_js_formatter/tests/specs/js/module/import/import-attributes/bracket-spacing/dynamic-import.js.prettier-snap 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 new file mode 100644 index 00000000000..7ec0429a53c --- /dev/null +++ b/crates/rome_js_formatter/tests/specs/js/module/import/import-attributes/bracket-spacing/dynamic-import.js.snap @@ -0,0 +1,33 @@ +--- +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-assertions/bracket-spacing/empty.js b/crates/rome_js_formatter/tests/specs/js/module/import/import-attributes/bracket-spacing/empty.js similarity index 100% rename from crates/rome_js_formatter/tests/specs/js/module/import/import-assertions/bracket-spacing/empty.js rename to crates/rome_js_formatter/tests/specs/js/module/import/import-attributes/bracket-spacing/empty.js diff --git a/crates/rome_js_formatter/tests/specs/js/module/import/import-assertions/bracket-spacing/empty.js.prettier-snap b/crates/rome_js_formatter/tests/specs/js/module/import/import-attributes/bracket-spacing/empty.js.prettier-snap similarity index 100% rename from crates/rome_js_formatter/tests/specs/js/module/import/import-assertions/bracket-spacing/empty.js.prettier-snap rename to crates/rome_js_formatter/tests/specs/js/module/import/import-attributes/bracket-spacing/empty.js.prettier-snap 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 new file mode 100644 index 00000000000..f67508b597b --- /dev/null +++ b/crates/rome_js_formatter/tests/specs/js/module/import/import-attributes/bracket-spacing/empty.js.snap @@ -0,0 +1,33 @@ +--- +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-assertions/bracket-spacing/re-export.js b/crates/rome_js_formatter/tests/specs/js/module/import/import-attributes/bracket-spacing/re-export.js similarity index 100% rename from crates/rome_js_formatter/tests/specs/js/module/import/import-assertions/bracket-spacing/re-export.js rename to crates/rome_js_formatter/tests/specs/js/module/import/import-attributes/bracket-spacing/re-export.js diff --git a/crates/rome_js_formatter/tests/specs/js/module/import/import-assertions/bracket-spacing/re-export.js.prettier-snap b/crates/rome_js_formatter/tests/specs/js/module/import/import-attributes/bracket-spacing/re-export.js.prettier-snap similarity index 100% rename from crates/rome_js_formatter/tests/specs/js/module/import/import-assertions/bracket-spacing/re-export.js.prettier-snap rename to crates/rome_js_formatter/tests/specs/js/module/import/import-attributes/bracket-spacing/re-export.js.prettier-snap 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 new file mode 100644 index 00000000000..deab6282602 --- /dev/null +++ b/crates/rome_js_formatter/tests/specs/js/module/import/import-attributes/bracket-spacing/re-export.js.snap @@ -0,0 +1,33 @@ +--- +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-assertions/bracket-spacing/static-import.js b/crates/rome_js_formatter/tests/specs/js/module/import/import-attributes/bracket-spacing/static-import.js similarity index 100% rename from crates/rome_js_formatter/tests/specs/js/module/import/import-assertions/bracket-spacing/static-import.js rename to crates/rome_js_formatter/tests/specs/js/module/import/import-attributes/bracket-spacing/static-import.js diff --git a/crates/rome_js_formatter/tests/specs/js/module/import/import-assertions/bracket-spacing/static-import.js.prettier-snap b/crates/rome_js_formatter/tests/specs/js/module/import/import-attributes/bracket-spacing/static-import.js.prettier-snap similarity index 100% rename from crates/rome_js_formatter/tests/specs/js/module/import/import-assertions/bracket-spacing/static-import.js.prettier-snap rename to crates/rome_js_formatter/tests/specs/js/module/import/import-attributes/bracket-spacing/static-import.js.prettier-snap 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 new file mode 100644 index 00000000000..94fcc1fd4d4 --- /dev/null +++ b/crates/rome_js_formatter/tests/specs/js/module/import/import-attributes/bracket-spacing/static-import.js.snap @@ -0,0 +1,33 @@ +--- +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-assertions/dynamic-import.js b/crates/rome_js_formatter/tests/specs/js/module/import/import-attributes/dynamic-import.js similarity index 100% rename from crates/rome_js_formatter/tests/specs/js/module/import/import-assertions/dynamic-import.js rename to crates/rome_js_formatter/tests/specs/js/module/import/import-attributes/dynamic-import.js diff --git a/crates/rome_js_formatter/tests/specs/js/module/import/import-assertions/dynamic-import.js.prettier-snap b/crates/rome_js_formatter/tests/specs/js/module/import/import-attributes/dynamic-import.js.prettier-snap similarity index 100% rename from crates/rome_js_formatter/tests/specs/js/module/import/import-assertions/dynamic-import.js.prettier-snap rename to crates/rome_js_formatter/tests/specs/js/module/import/import-attributes/dynamic-import.js.prettier-snap 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 new file mode 100644 index 00000000000..ab173b35bb7 --- /dev/null +++ b/crates/rome_js_formatter/tests/specs/js/module/import/import-attributes/dynamic-import.js.snap @@ -0,0 +1,33 @@ +--- +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-assertions/empty.js b/crates/rome_js_formatter/tests/specs/js/module/import/import-attributes/empty.js similarity index 100% rename from crates/rome_js_formatter/tests/specs/js/module/import/import-assertions/empty.js rename to crates/rome_js_formatter/tests/specs/js/module/import/import-attributes/empty.js diff --git a/crates/rome_js_formatter/tests/specs/js/module/import/import-assertions/empty.js.prettier-snap b/crates/rome_js_formatter/tests/specs/js/module/import/import-attributes/empty.js.prettier-snap similarity index 100% rename from crates/rome_js_formatter/tests/specs/js/module/import/import-assertions/empty.js.prettier-snap rename to crates/rome_js_formatter/tests/specs/js/module/import/import-attributes/empty.js.prettier-snap 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 new file mode 100644 index 00000000000..c19540be276 --- /dev/null +++ b/crates/rome_js_formatter/tests/specs/js/module/import/import-attributes/empty.js.snap @@ -0,0 +1,45 @@ +--- +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-assertions/multi-types.js b/crates/rome_js_formatter/tests/specs/js/module/import/import-attributes/multi-types.js similarity index 100% rename from crates/rome_js_formatter/tests/specs/js/module/import/import-assertions/multi-types.js rename to crates/rome_js_formatter/tests/specs/js/module/import/import-attributes/multi-types.js diff --git a/crates/rome_js_formatter/tests/specs/js/module/import/import-assertions/multi-types.js.prettier-snap b/crates/rome_js_formatter/tests/specs/js/module/import/import-attributes/multi-types.js.prettier-snap similarity index 100% rename from crates/rome_js_formatter/tests/specs/js/module/import/import-assertions/multi-types.js.prettier-snap rename to crates/rome_js_formatter/tests/specs/js/module/import/import-attributes/multi-types.js.prettier-snap 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 new file mode 100644 index 00000000000..b35b5d11350 --- /dev/null +++ b/crates/rome_js_formatter/tests/specs/js/module/import/import-attributes/multi-types.js.snap @@ -0,0 +1,33 @@ +--- +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-assertions/non-type.js b/crates/rome_js_formatter/tests/specs/js/module/import/import-attributes/non-type.js similarity index 100% rename from crates/rome_js_formatter/tests/specs/js/module/import/import-assertions/non-type.js rename to crates/rome_js_formatter/tests/specs/js/module/import/import-attributes/non-type.js diff --git a/crates/rome_js_formatter/tests/specs/js/module/import/import-assertions/non-type.js.prettier-snap b/crates/rome_js_formatter/tests/specs/js/module/import/import-attributes/non-type.js.prettier-snap similarity index 100% rename from crates/rome_js_formatter/tests/specs/js/module/import/import-assertions/non-type.js.prettier-snap rename to crates/rome_js_formatter/tests/specs/js/module/import/import-attributes/non-type.js.prettier-snap 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 new file mode 100644 index 00000000000..24f03bfcd90 --- /dev/null +++ b/crates/rome_js_formatter/tests/specs/js/module/import/import-attributes/non-type.js.snap @@ -0,0 +1,33 @@ +--- +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-assertions/not-import-assertions.js b/crates/rome_js_formatter/tests/specs/js/module/import/import-attributes/not-import-attributes.js similarity index 100% rename from crates/rome_js_formatter/tests/specs/js/module/import/import-assertions/not-import-assertions.js rename to crates/rome_js_formatter/tests/specs/js/module/import/import-attributes/not-import-attributes.js 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 new file mode 100644 index 00000000000..6db7bf8b4fb --- /dev/null +++ b/crates/rome_js_formatter/tests/specs/js/module/import/import-attributes/not-import-attributes.js.snap @@ -0,0 +1,35 @@ +--- +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-assertions/re-export.js b/crates/rome_js_formatter/tests/specs/js/module/import/import-attributes/re-export.js similarity index 100% rename from crates/rome_js_formatter/tests/specs/js/module/import/import-assertions/re-export.js rename to crates/rome_js_formatter/tests/specs/js/module/import/import-attributes/re-export.js diff --git a/crates/rome_js_formatter/tests/specs/js/module/import/import-assertions/re-export.js.prettier-snap b/crates/rome_js_formatter/tests/specs/js/module/import/import-attributes/re-export.js.prettier-snap similarity index 100% rename from crates/rome_js_formatter/tests/specs/js/module/import/import-assertions/re-export.js.prettier-snap rename to crates/rome_js_formatter/tests/specs/js/module/import/import-attributes/re-export.js.prettier-snap 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 new file mode 100644 index 00000000000..173621b2331 --- /dev/null +++ b/crates/rome_js_formatter/tests/specs/js/module/import/import-attributes/re-export.js.snap @@ -0,0 +1,37 @@ +--- +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-assertions/static-import.js b/crates/rome_js_formatter/tests/specs/js/module/import/import-attributes/static-import.js similarity index 100% rename from crates/rome_js_formatter/tests/specs/js/module/import/import-assertions/static-import.js rename to crates/rome_js_formatter/tests/specs/js/module/import/import-attributes/static-import.js diff --git a/crates/rome_js_formatter/tests/specs/js/module/import/import-assertions/static-import.js.prettier-snap b/crates/rome_js_formatter/tests/specs/js/module/import/import-attributes/static-import.js.prettier-snap similarity index 100% rename from crates/rome_js_formatter/tests/specs/js/module/import/import-assertions/static-import.js.prettier-snap rename to crates/rome_js_formatter/tests/specs/js/module/import/import-attributes/static-import.js.prettier-snap 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 new file mode 100644 index 00000000000..f598a6f1684 --- /dev/null +++ b/crates/rome_js_formatter/tests/specs/js/module/import/import-attributes/static-import.js.snap @@ -0,0 +1,33 @@ +--- +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-assertions/without-from.js b/crates/rome_js_formatter/tests/specs/js/module/import/import-attributes/without-from.js similarity index 100% rename from crates/rome_js_formatter/tests/specs/js/module/import/import-assertions/without-from.js rename to crates/rome_js_formatter/tests/specs/js/module/import/import-attributes/without-from.js diff --git a/crates/rome_js_formatter/tests/specs/js/module/import/import-assertions/without-from.js.prettier-snap b/crates/rome_js_formatter/tests/specs/js/module/import/import-attributes/without-from.js.prettier-snap similarity index 100% rename from crates/rome_js_formatter/tests/specs/js/module/import/import-assertions/without-from.js.prettier-snap rename to crates/rome_js_formatter/tests/specs/js/module/import/import-attributes/without-from.js.prettier-snap 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 new file mode 100644 index 00000000000..3e11b0c311a --- /dev/null +++ b/crates/rome_js_formatter/tests/specs/js/module/import/import-attributes/without-from.js.snap @@ -0,0 +1,33 @@ +--- +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_parser/src/syntax/module.rs b/crates/rome_js_parser/src/syntax/module.rs index 7f91997f0ad..3e9b3171789 100644 --- a/crates/rome_js_parser/src/syntax/module.rs +++ b/crates/rome_js_parser/src/syntax/module.rs @@ -459,7 +459,7 @@ fn parse_any_named_import_specifier(p: &mut JsParser) -> ParsedSyntax { // import "bar" \u{61}ith { type: "json" }; // import { foo } with { type: "json" }; // import "lorem" -// assert { type: "json" } +// with { 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 }; @@ -482,7 +482,7 @@ fn parse_import_attributes(p: &mut JsParser) -> ParsedSyntax { #[derive(Default)] struct ImportAttributeList { - assertion_keys: HashMap, + attribute_keys: HashMap, } impl ParseSeparatedList for ImportAttributeList { @@ -492,7 +492,7 @@ impl ParseSeparatedList for ImportAttributeList { const LIST_KIND: Self::Kind = JS_IMPORT_ATTRIBUTE_ENTRY_LIST; fn parse_element(&mut self, p: &mut JsParser) -> ParsedSyntax { - parse_import_assertion_entry(p, &mut self.assertion_keys) + parse_import_attribute_entry(p, &mut self.attribute_keys) } fn is_at_list_end(&self, p: &mut JsParser) -> bool { @@ -507,7 +507,7 @@ impl ParseSeparatedList for ImportAttributeList { STMT_RECOVERY_SET.union(token_set![T![,], T!['}']]), ) .enable_recovery_on_line_break(), - |p, range| expected_node("import assertion entry", range).into_diagnostic(p), + |p, range| expected_node("import attribute entry", range).into_diagnostic(p), ) } @@ -520,9 +520,9 @@ impl ParseSeparatedList for ImportAttributeList { } } -fn parse_import_assertion_entry( +fn parse_import_attribute_entry( p: &mut JsParser, - seen_assertion_keys: &mut HashMap, + seen_attribute_keys: &mut HashMap, ) -> ParsedSyntax { let m = p.start(); let key_range = p.cur_range(); @@ -556,7 +556,7 @@ fn parse_import_assertion_entry( let mut valid = true; if let Some(key) = key { - if let Some(first_use) = seen_assertion_keys.get(&key) { + if let Some(first_use) = seen_attribute_keys.get(&key) { p.error(duplicate_assertion_keys_error( p, &key, @@ -565,7 +565,7 @@ fn parse_import_assertion_entry( )); valid = false; } else { - seen_assertion_keys.insert(key, key_range); + seen_attribute_keys.insert(key, key_range); } };