This repository has been archived by the owner on Aug 31, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 660
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(rome_js_formatter): improve handling of arrow parentheses (#4704)
* fix(rome_js_formatter): improve handling of arrow parentheses * chore: move the new tests to their own file
- Loading branch information
1 parent
adf9d69
commit 4c8cf32
Showing
5 changed files
with
130 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
13 changes: 13 additions & 0 deletions
13
crates/rome_js_formatter/tests/specs/ts/arrow/arrow_parentheses.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
action => {} | ||
(action) => {} | ||
(action?) => {} | ||
(action: string) => {} | ||
(action): void => {} | ||
( | ||
action | ||
// hhhhhhhh | ||
) => {} | ||
({ action }) => {} | ||
([ action ]) => {} | ||
(...action) => {} | ||
(action = 1) => {} |
88 changes: 88 additions & 0 deletions
88
crates/rome_js_formatter/tests/specs/ts/arrow/arrow_parentheses.ts.snap
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
--- | ||
source: crates/rome_formatter_test/src/snapshot_builder.rs | ||
info: ts/arrow/arrow_parentheses.ts | ||
--- | ||
|
||
# Input | ||
|
||
```ts | ||
action => {} | ||
(action) => {} | ||
(action?) => {} | ||
(action: string) => {} | ||
(action): void => {} | ||
( | ||
action | ||
// hhhhhhhh | ||
) => {} | ||
({ action }) => {} | ||
([ action ]) => {} | ||
(...action) => {} | ||
(action = 1) => {} | ||
|
||
``` | ||
|
||
|
||
============================= | ||
|
||
# Outputs | ||
|
||
## Output 1 | ||
|
||
----- | ||
Indent style: Tab | ||
Line width: 80 | ||
Quote style: Double Quotes | ||
JSX quote style: Double Quotes | ||
Quote properties: As needed | ||
Trailing comma: All | ||
Semicolons: Always | ||
Arrow parentheses: Always | ||
----- | ||
|
||
```ts | ||
(action) => {}; | ||
(action) => {}; | ||
(action?) => {}; | ||
(action: string) => {}; | ||
(action): void => {}; | ||
( | ||
action, | ||
// hhhhhhhh | ||
) => {}; | ||
({ action }) => {}; | ||
([action]) => {}; | ||
(...action) => {}; | ||
(action = 1) => {}; | ||
``` | ||
|
||
## Output 2 | ||
|
||
----- | ||
Indent style: Tab | ||
Line width: 80 | ||
Quote style: Double Quotes | ||
JSX quote style: Double Quotes | ||
Quote properties: As needed | ||
Trailing comma: All | ||
Semicolons: Always | ||
Arrow parentheses: As needed | ||
----- | ||
|
||
```ts | ||
action => {}; | ||
action => {}; | ||
(action?) => {}; | ||
(action: string) => {}; | ||
(action): void => {}; | ||
( | ||
action, | ||
// hhhhhhhh | ||
) => {}; | ||
({ action }) => {}; | ||
([action]) => {}; | ||
(...action) => {}; | ||
(action = 1) => {}; | ||
``` | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
{ | ||
"cases": [ | ||
{ | ||
"arrow_parentheses": "AsNeeded" | ||
} | ||
] | ||
} |