--- source: crates/rome_formatter_test/src/snapshot_builder.rs info: test_file: js/tuple/tuple.js --- # Input ```js const tuple1 = #[1, 2, 3]; assert(tuple1[0] === 1); const tuple2 = tuple1.with(0, 2); assert(tuple1 !== tuple2); assert(tuple2 === #[2, 2, 3]); const tuple3 = #[1, ...tuple2]; assert(tuple3 === #[1, 2, 2, 3]); const tuple4 = tuple3.pushed(4); assert(tuple4 === #[1, 2, 2, 3, 4]); assert(tuple4.first() === 1); const tuple5 = tuple4.popped(); assert(tuple5 === #[2, 2, 3, 4]); ``` # Prettier differences ```diff --- Prettier +++ Rome @@ -1,4 +1,5 @@ -const tuple1 = #[1, 2, 3]; +const tuple1 = #; +[1, 2, 3]; assert(tuple1[0] === 1); @@ -6,7 +7,8 @@ assert(tuple1 !== tuple2); assert(tuple2 === #[2, 2, 3]); -const tuple3 = #[1, ...tuple2]; +const tuple3 = #; +[1, ...tuple2]; assert(tuple3 === #[1, 2, 2, 3]); const tuple4 = tuple3.pushed(4); ``` # Output ```js const tuple1 = #; [1, 2, 3]; assert(tuple1[0] === 1); const tuple2 = tuple1.with(0, 2); assert(tuple1 !== tuple2); assert(tuple2 === #[2, 2, 3]); const tuple3 = #; [1, ...tuple2]; assert(tuple3 === #[1, 2, 2, 3]); const tuple4 = tuple3.pushed(4); assert(tuple4 === #[1, 2, 2, 3, 4]); assert(tuple4.first() === 1); const tuple5 = tuple4.popped(); assert(tuple5 === #[2, 2, 3, 4]); ``` # Errors ``` tuple.js:1:17 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ × expected an identifier but instead found '[' > 1 │ const tuple1 = #[1, 2, 3]; │ ^ 2 │ 3 │ assert(tuple1[0] === 1); i Expected an identifier here > 1 │ const tuple1 = #[1, 2, 3]; │ ^ 2 │ 3 │ assert(tuple1[0] === 1); tuple.js:1:16 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ × Private names are only allowed on the left side of a 'in' expression > 1 │ const tuple1 = #[1, 2, 3]; │ ^ 2 │ 3 │ assert(tuple1[0] === 1); tuple.js:1:17 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ × Expected a semicolon or an implicit semicolon after a statement, but found none > 1 │ const tuple1 = #[1, 2, 3]; │ ^ 2 │ 3 │ assert(tuple1[0] === 1); i An explicit or implicit semicolon is expected here... > 1 │ const tuple1 = #[1, 2, 3]; │ ^ 2 │ 3 │ assert(tuple1[0] === 1); i ...Which is required to end this statement > 1 │ const tuple1 = #[1, 2, 3]; │ ^^^^^^^^^^^^^^^^ 2 │ 3 │ assert(tuple1[0] === 1); tuple.js:7:20 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ × expected an identifier but instead found '[' 5 │ const tuple2 = tuple1.with(0, 2); 6 │ assert(tuple1 !== tuple2); > 7 │ assert(tuple2 === #[2, 2, 3]); │ ^ 8 │ 9 │ const tuple3 = #[1, ...tuple2]; i Expected an identifier here 5 │ const tuple2 = tuple1.with(0, 2); 6 │ assert(tuple1 !== tuple2); > 7 │ assert(tuple2 === #[2, 2, 3]); │ ^ 8 │ 9 │ const tuple3 = #[1, ...tuple2]; tuple.js:7:19 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ × Private names are only allowed on the left side of a 'in' expression 5 │ const tuple2 = tuple1.with(0, 2); 6 │ assert(tuple1 !== tuple2); > 7 │ assert(tuple2 === #[2, 2, 3]); │ ^ 8 │ 9 │ const tuple3 = #[1, ...tuple2]; tuple.js:7:20 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ × expected `,` but instead found `[` 5 │ const tuple2 = tuple1.with(0, 2); 6 │ assert(tuple1 !== tuple2); > 7 │ assert(tuple2 === #[2, 2, 3]); │ ^ 8 │ 9 │ const tuple3 = #[1, ...tuple2]; i Remove [ tuple.js:9:17 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ × expected an identifier but instead found '[' 7 │ assert(tuple2 === #[2, 2, 3]); 8 │ > 9 │ const tuple3 = #[1, ...tuple2]; │ ^ 10 │ assert(tuple3 === #[1, 2, 2, 3]); 11 │ i Expected an identifier here 7 │ assert(tuple2 === #[2, 2, 3]); 8 │ > 9 │ const tuple3 = #[1, ...tuple2]; │ ^ 10 │ assert(tuple3 === #[1, 2, 2, 3]); 11 │ tuple.js:9:16 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ × Private names are only allowed on the left side of a 'in' expression 7 │ assert(tuple2 === #[2, 2, 3]); 8 │ > 9 │ const tuple3 = #[1, ...tuple2]; │ ^ 10 │ assert(tuple3 === #[1, 2, 2, 3]); 11 │ tuple.js:9:17 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ × Expected a semicolon or an implicit semicolon after a statement, but found none 7 │ assert(tuple2 === #[2, 2, 3]); 8 │ > 9 │ const tuple3 = #[1, ...tuple2]; │ ^ 10 │ assert(tuple3 === #[1, 2, 2, 3]); 11 │ i An explicit or implicit semicolon is expected here... 7 │ assert(tuple2 === #[2, 2, 3]); 8 │ > 9 │ const tuple3 = #[1, ...tuple2]; │ ^ 10 │ assert(tuple3 === #[1, 2, 2, 3]); 11 │ i ...Which is required to end this statement 7 │ assert(tuple2 === #[2, 2, 3]); 8 │ > 9 │ const tuple3 = #[1, ...tuple2]; │ ^^^^^^^^^^^^^^^^ 10 │ assert(tuple3 === #[1, 2, 2, 3]); 11 │ tuple.js:10:20 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ × expected an identifier but instead found '[' 9 │ const tuple3 = #[1, ...tuple2]; > 10 │ assert(tuple3 === #[1, 2, 2, 3]); │ ^ 11 │ 12 │ const tuple4 = tuple3.pushed(4); i Expected an identifier here 9 │ const tuple3 = #[1, ...tuple2]; > 10 │ assert(tuple3 === #[1, 2, 2, 3]); │ ^ 11 │ 12 │ const tuple4 = tuple3.pushed(4); tuple.js:10:19 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ × Private names are only allowed on the left side of a 'in' expression 9 │ const tuple3 = #[1, ...tuple2]; > 10 │ assert(tuple3 === #[1, 2, 2, 3]); │ ^ 11 │ 12 │ const tuple4 = tuple3.pushed(4); tuple.js:10:20 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ × expected `,` but instead found `[` 9 │ const tuple3 = #[1, ...tuple2]; > 10 │ assert(tuple3 === #[1, 2, 2, 3]); │ ^ 11 │ 12 │ const tuple4 = tuple3.pushed(4); i Remove [ tuple.js:13:20 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ × expected an identifier but instead found '[' 12 │ const tuple4 = tuple3.pushed(4); > 13 │ assert(tuple4 === #[1, 2, 2, 3, 4]); │ ^ 14 │ 15 │ assert(tuple4.first() === 1); i Expected an identifier here 12 │ const tuple4 = tuple3.pushed(4); > 13 │ assert(tuple4 === #[1, 2, 2, 3, 4]); │ ^ 14 │ 15 │ assert(tuple4.first() === 1); tuple.js:13:19 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ × Private names are only allowed on the left side of a 'in' expression 12 │ const tuple4 = tuple3.pushed(4); > 13 │ assert(tuple4 === #[1, 2, 2, 3, 4]); │ ^ 14 │ 15 │ assert(tuple4.first() === 1); tuple.js:13:20 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ × expected `,` but instead found `[` 12 │ const tuple4 = tuple3.pushed(4); > 13 │ assert(tuple4 === #[1, 2, 2, 3, 4]); │ ^ 14 │ 15 │ assert(tuple4.first() === 1); i Remove [ tuple.js:17:20 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ × expected an identifier but instead found '[' 15 │ assert(tuple4.first() === 1); 16 │ const tuple5 = tuple4.popped(); > 17 │ assert(tuple5 === #[2, 2, 3, 4]); │ ^ 18 │ i Expected an identifier here 15 │ assert(tuple4.first() === 1); 16 │ const tuple5 = tuple4.popped(); > 17 │ assert(tuple5 === #[2, 2, 3, 4]); │ ^ 18 │ tuple.js:17:19 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ × Private names are only allowed on the left side of a 'in' expression 15 │ assert(tuple4.first() === 1); 16 │ const tuple5 = tuple4.popped(); > 17 │ assert(tuple5 === #[2, 2, 3, 4]); │ ^ 18 │ tuple.js:17:20 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ × expected `,` but instead found `[` 15 │ assert(tuple4.first() === 1); 16 │ const tuple5 = tuple4.popped(); > 17 │ assert(tuple5 === #[2, 2, 3, 4]); │ ^ 18 │ i Remove [ ```