-
-
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): ensure flat conditional content is always written …
…in `RemoveSoftLinesBuffer` (#1357) Co-authored-by: Emanuele Stoppa <[email protected]>
- Loading branch information
1 parent
cd8b0c9
commit c212dd6
Showing
6 changed files
with
140 additions
and
8 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
8 changes: 8 additions & 0 deletions
8
crates/biome_js_formatter/tests/specs/ts/parameters/issue-1356/options.json
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,8 @@ | ||
{ | ||
"cases": [ | ||
{ | ||
"semicolon": "AsNeeded", | ||
"line_width": 40 | ||
} | ||
] | ||
} |
10 changes: 10 additions & 0 deletions
10
..._js_formatter/tests/specs/ts/parameters/issue-1356/parameter_type_annotation_semicolon.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,10 @@ | ||
// Ensure that the type annotation preserves the semicolon in the type | ||
// annotation, even though the parent group breaks. This was only an issue when | ||
// `semicolon: AsNeeded` was set, since the semicolon became conditional on | ||
// whether the group was printed inline. | ||
// | ||
// https://github.com/biomejs/biome/issues/1356. | ||
|
||
foo((args: {a: string; b: string}) => { | ||
return a; | ||
}) |
96 changes: 96 additions & 0 deletions
96
...ormatter/tests/specs/ts/parameters/issue-1356/parameter_type_annotation_semicolon.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,96 @@ | ||
--- | ||
source: crates/biome_formatter_test/src/snapshot_builder.rs | ||
info: ts/parameters/issue-1356/parameter_type_annotation_semicolon.ts | ||
--- | ||
|
||
# Input | ||
|
||
```ts | ||
// Ensure that the type annotation preserves the semicolon in the type | ||
// annotation, even though the parent group breaks. This was only an issue when | ||
// `semicolon: AsNeeded` was set, since the semicolon became conditional on | ||
// whether the group was printed inline. | ||
// | ||
// https://github.com/biomejs/biome/issues/1356. | ||
|
||
foo((args: {a: string; b: string}) => { | ||
return a; | ||
}) | ||
``` | ||
|
||
|
||
============================= | ||
|
||
# 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 | ||
// Ensure that the type annotation preserves the semicolon in the type | ||
// annotation, even though the parent group breaks. This was only an issue when | ||
// `semicolon: AsNeeded` was set, since the semicolon became conditional on | ||
// whether the group was printed inline. | ||
// | ||
// https://github.com/biomejs/biome/issues/1356. | ||
|
||
foo((args: { a: string; b: string }) => { | ||
return a; | ||
}); | ||
``` | ||
|
||
## Output 2 | ||
|
||
----- | ||
Indent style: Tab | ||
Indent width: 2 | ||
Line ending: LF | ||
Line width: 40 | ||
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 | ||
// Ensure that the type annotation preserves the semicolon in the type | ||
// annotation, even though the parent group breaks. This was only an issue when | ||
// `semicolon: AsNeeded` was set, since the semicolon became conditional on | ||
// whether the group was printed inline. | ||
// | ||
// https://github.com/biomejs/biome/issues/1356. | ||
|
||
foo( | ||
(args: { a: string; b: string }) => { | ||
return a; | ||
}, | ||
); | ||
``` | ||
|
||
# Lines exceeding max width of 40 characters | ||
``` | ||
1: // Ensure that the type annotation preserves the semicolon in the type | ||
2: // annotation, even though the parent group breaks. This was only an issue when | ||
3: // `semicolon: AsNeeded` was set, since the semicolon became conditional on | ||
6: // https://github.com/biomejs/biome/issues/1356. | ||
``` | ||
|
||
|
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