Skip to content
This repository has been archived by the owner on Aug 31, 2023. It is now read-only.

Commit

Permalink
test(rome_js_formatter): update prettier tests (#4104)
Browse files Browse the repository at this point in the history
  • Loading branch information
nissy-dev committed Dec 28, 2022
1 parent 210b950 commit f2c6ac4
Show file tree
Hide file tree
Showing 40 changed files with 540 additions and 347 deletions.
2 changes: 1 addition & 1 deletion crates/rome_formatter_test/src/prettier/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"start": "node prepare_tests"
},
"dependencies": {
"prettier": "^2.7.1"
"prettier": "2.8.1"
},
"devDependencies": {
"@types/prettier": "^2.7.1"
Expand Down
8 changes: 4 additions & 4 deletions crates/rome_formatter_test/src/prettier/pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,7 @@
}
}
{
for (const srcPath of [
123, 123_123_123, 123_123_123_1, 13_123_3123_31_432,
]) {
for (const srcPath of [123, 123_123_123, 123_123_123_1, 13_123_3123_31_432]) {
}
}
{
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
---
source: crates/rome_formatter_test/src/snapshot_builder.rs
info: js/arrays/issue-10159.js
---

# Input

```js
{for (const srcPath of [src, `${src}.js`, `${src}/index`, `${src}/index.js`]) {}}
{for (const srcPath of [123, 123_123_123, 123_123_123_1, 13_123_3123_31_43]) {}}
{for (const srcPath of [123, 123_123_123, 123_123_123_1, 13_123_3123_31_432]) {}}
{for (const srcPath of [123, 123_123_123, 123_123_123_1, 13_123_3123_31_4321]) {}}

```


# Prettier differences

```diff
--- Prettier
+++ Rome
@@ -7,7 +7,9 @@
}
}
{
- for (const srcPath of [123, 123_123_123, 123_123_123_1, 13_123_3123_31_432]) {
+ for (const srcPath of [
+ 123, 123_123_123, 123_123_123_1, 13_123_3123_31_432,
+ ]) {
}
}
{
```

# Output

```js
{
for (const srcPath of [src, `${src}.js`, `${src}/index`, `${src}/index.js`]) {
}
}
{
for (const srcPath of [123, 123_123_123, 123_123_123_1, 13_123_3123_31_43]) {
}
}
{
for (const srcPath of [
123, 123_123_123, 123_123_123_1, 13_123_3123_31_432,
]) {
}
}
{
for (const srcPath of [
123, 123_123_123, 123_123_123_1, 13_123_3123_31_4321,
]) {
}
}
```


Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
class A {
async;
foo() {};
}

class B {
async = 1;
foo() {}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
class A {
async;
foo() {}
}

class B {
async = 1;
foo() {}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
---
source: crates/rome_formatter_test/src/snapshot_builder.rs
info: js/classes/keyword-property/async.js
---

# Input

```js
class A {
async;
foo() {};
}

class B {
async = 1;
foo() {}
}

```


# Prettier differences

```diff
--- Prettier
+++ Rome
@@ -1,9 +1,10 @@
class A {
- async;
+ async
foo() {}
}

class B {
- async = 1;
+ async
+ = 1
foo() {}
}
```

# Output

```js
class A {
async
foo() {}
}

class B {
async
= 1
foo() {}
}
```

# Errors
```
async.js:2:8 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
× expected an identifier, a string literal, a number literal, a private field name, or a computed name but instead found ';'
1 │ class A {
> 2 │ async;
│ ^
3 │ foo() {};
4 │ }
i Expected an identifier, a string literal, a number literal, a private field name, or a computed name here
1 │ class A {
> 2 │ async;
│ ^
3 │ foo() {};
4 │ }
async.js:7:9 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
× expected an identifier, a string literal, a number literal, a private field name, or a computed name but instead found '='
6 │ class B {
> 7 │ async = 1;
│ ^
8 │ foo() {}
9 │ }
i Expected an identifier, a string literal, a number literal, a private field name, or a computed name here
6 │ class B {
> 7 │ async = 1;
│ ^
8 │ foo() {}
9 │ }
```


Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
class A {
get;
foo() {}
}

class B {
get = 1;
foo() {}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
class A {
get;
foo() {}
}

class B {
get = 1;
foo() {}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
class A {
set;
foo(v) {}
}

class B {
set = 1;
foo(v) {}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
class A {
set;
foo(v) {}
}

class B {
set = 1;
foo(v) {}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
class A {
static async;
foo() {}
}

class B {
static async = 1;
foo() {}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
class A {
static async;
foo() {}
}

class B {
static async = 1;
foo() {}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
---
source: crates/rome_formatter_test/src/snapshot_builder.rs
info: js/classes/keyword-property/static-async.js
---

# Input

```js
class A {
static async;
foo() {}
}

class B {
static async = 1;
foo() {}
}

```


# Prettier differences

```diff
--- Prettier
+++ Rome
@@ -1,9 +1,10 @@
class A {
- static async;
+ static async
foo() {}
}

class B {
- static async = 1;
+ static async
+ = 1
foo() {}
}
```

# Output

```js
class A {
static async
foo() {}
}

class B {
static async
= 1
foo() {}
}
```

# Errors
```
static-async.js:2:15 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
× expected an identifier, a string literal, a number literal, a private field name, or a computed name but instead found ';'
1 │ class A {
> 2 │ static async;
│ ^
3 │ foo() {}
4 │ }
i Expected an identifier, a string literal, a number literal, a private field name, or a computed name here
1 │ class A {
> 2 │ static async;
│ ^
3 │ foo() {}
4 │ }
static-async.js:7:16 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
× expected an identifier, a string literal, a number literal, a private field name, or a computed name but instead found '='
6 │ class B {
> 7 │ static async = 1;
│ ^
8 │ foo() {}
9 │ }
i Expected an identifier, a string literal, a number literal, a private field name, or a computed name here
6 │ class B {
> 7 │ static async = 1;
│ ^
8 │ foo() {}
9 │ }
```


Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
class A {
static get;
foo() {}
}

class B {
static get = 1;
foo() {}
}
Loading

0 comments on commit f2c6ac4

Please sign in to comment.