-
-
Notifications
You must be signed in to change notification settings - Fork 535
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(js_formatter): fix invalid formatting of expanded bindings for As…
…Needed arrow parens (#1449)
- Loading branch information
1 parent
86688e4
commit 01ada2e
Showing
7 changed files
with
220 additions
and
2 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
4 changes: 4 additions & 0 deletions
4
crates/biome_js_formatter/tests/specs/js/module/arrow/assignment_binding_line_break.js
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,4 @@ | ||
const foo = bar => `This is a string that's long enough to wrap and contains an interpolated value ${bar} | ||
and then a newline` | ||
|
||
const foo = bar => `This is a string that's long enough to wrap and contains an interpolated value ${bar} and then a newline` |
85 changes: 85 additions & 0 deletions
85
crates/biome_js_formatter/tests/specs/js/module/arrow/assignment_binding_line_break.js.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,85 @@ | ||
--- | ||
source: crates/biome_formatter_test/src/snapshot_builder.rs | ||
info: js/module/arrow/assignment_binding_line_break.js | ||
--- | ||
|
||
# Input | ||
|
||
```js | ||
const foo = bar => `This is a string that's long enough to wrap and contains an interpolated value ${bar} | ||
and then a newline` | ||
|
||
const foo = bar => `This is a string that's long enough to wrap and contains an interpolated value ${bar} and then a newline` | ||
``` | ||
|
||
|
||
============================= | ||
|
||
# Outputs | ||
|
||
## Output 1 | ||
|
||
----- | ||
Indent style: Tab | ||
Indent width: 2 | ||
Line ending: LF | ||
Line width: 80 | ||
Quote style: Double Quotes | ||
JSX quote style: Double Quotes | ||
Quote properties: As needed | ||
Trailing comma: All | ||
Semicolons: Always | ||
Arrow parentheses: Always | ||
Bracket spacing: true | ||
Bracket same line: false | ||
----- | ||
|
||
```js | ||
const foo = ( | ||
bar, | ||
) => `This is a string that's long enough to wrap and contains an interpolated value ${bar} | ||
and then a newline`; | ||
|
||
const foo = (bar) => | ||
`This is a string that's long enough to wrap and contains an interpolated value ${bar} and then a newline`; | ||
``` | ||
|
||
# Lines exceeding max width of 80 characters | ||
``` | ||
3: ) => `This is a string that's long enough to wrap and contains an interpolated value ${bar} | ||
7: `This is a string that's long enough to wrap and contains an interpolated value ${bar} and then a newline`; | ||
``` | ||
|
||
## Output 2 | ||
|
||
----- | ||
Indent style: Tab | ||
Indent width: 2 | ||
Line ending: LF | ||
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 | ||
Bracket spacing: true | ||
Bracket same line: false | ||
----- | ||
|
||
```js | ||
const foo = | ||
bar => `This is a string that's long enough to wrap and contains an interpolated value ${bar} | ||
and then a newline`; | ||
|
||
const foo = bar => | ||
`This is a string that's long enough to wrap and contains an interpolated value ${bar} and then a newline`; | ||
``` | ||
|
||
# Lines exceeding max width of 80 characters | ||
``` | ||
2: bar => `This is a string that's long enough to wrap and contains an interpolated value ${bar} | ||
6: `This is a string that's long enough to wrap and contains an interpolated value ${bar} and then a newline`; | ||
``` | ||
|
||
|
21 changes: 21 additions & 0 deletions
21
crates/biome_js_formatter/tests/specs/ts/arrow/parameter_default_binding_line_break.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,21 @@ | ||
class T { | ||
// This aggregates all values per `timestamp` | ||
calculateTotalsPerTimestamp( | ||
getName: ( | ||
timestamp: number, | ||
countArray: {count: number}[], | ||
i: number | ||
) => number = timestamp => timestamp * 1000 | ||
): SeriesDataUnit[] { | ||
} | ||
|
||
calculateTotalsPerTimestamp( | ||
getName: ( | ||
timestamp: number | ||
) => number = | ||
timestamp => timestamp * 1000 | ||
) { | ||
|
||
|
||
} | ||
} |
105 changes: 105 additions & 0 deletions
105
crates/biome_js_formatter/tests/specs/ts/arrow/parameter_default_binding_line_break.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,105 @@ | ||
--- | ||
source: crates/biome_formatter_test/src/snapshot_builder.rs | ||
info: ts/arrow/parameter_default_binding_line_break.ts | ||
--- | ||
|
||
# Input | ||
|
||
```ts | ||
class T { | ||
// This aggregates all values per `timestamp` | ||
calculateTotalsPerTimestamp( | ||
getName: ( | ||
timestamp: number, | ||
countArray: {count: number}[], | ||
i: number | ||
) => number = timestamp => timestamp * 1000 | ||
): SeriesDataUnit[] { | ||
} | ||
|
||
calculateTotalsPerTimestamp( | ||
getName: ( | ||
timestamp: number | ||
) => number = | ||
timestamp => timestamp * 1000 | ||
) { | ||
|
||
|
||
} | ||
} | ||
``` | ||
|
||
|
||
============================= | ||
|
||
# Outputs | ||
|
||
## Output 1 | ||
|
||
----- | ||
Indent style: Tab | ||
Indent width: 2 | ||
Line ending: LF | ||
Line width: 80 | ||
Quote style: Double Quotes | ||
JSX quote style: Double Quotes | ||
Quote properties: As needed | ||
Trailing comma: All | ||
Semicolons: Always | ||
Arrow parentheses: Always | ||
Bracket spacing: true | ||
Bracket same line: false | ||
----- | ||
|
||
```ts | ||
class T { | ||
// This aggregates all values per `timestamp` | ||
calculateTotalsPerTimestamp( | ||
getName: ( | ||
timestamp: number, | ||
countArray: { count: number }[], | ||
i: number, | ||
) => number = (timestamp) => timestamp * 1000, | ||
): SeriesDataUnit[] {} | ||
|
||
calculateTotalsPerTimestamp( | ||
getName: (timestamp: number) => number = (timestamp) => timestamp * 1000, | ||
) {} | ||
} | ||
``` | ||
|
||
## Output 2 | ||
|
||
----- | ||
Indent style: Tab | ||
Indent width: 2 | ||
Line ending: LF | ||
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 | ||
Bracket spacing: true | ||
Bracket same line: false | ||
----- | ||
|
||
```ts | ||
class T { | ||
// This aggregates all values per `timestamp` | ||
calculateTotalsPerTimestamp( | ||
getName: ( | ||
timestamp: number, | ||
countArray: { count: number }[], | ||
i: number, | ||
) => number = timestamp => timestamp * 1000, | ||
): SeriesDataUnit[] {} | ||
|
||
calculateTotalsPerTimestamp( | ||
getName: (timestamp: number) => number = timestamp => timestamp * 1000, | ||
) {} | ||
} | ||
``` | ||
|
||
|
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