Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(js_formatter): fix #1511 #1547

Merged
merged 2 commits into from
Jan 12, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ Read our [guidelines for writing a good changelog entry](https://github.com/biom

- Fix [#1172](https://github.com/biomejs/biome/issues/1172). Fix placement of line comment after function expression parentheses, they are now attached to first statement in body. Contributed by @kalleep

- Fix [#1511](https://github.com/biomejs/biome/issues/1511) that made the JavaScript formatter crash. COntributed @Conaclos
ematipico marked this conversation as resolved.
Show resolved Hide resolved

### JavaScript APIs

### Linter
Expand Down Expand Up @@ -1911,7 +1913,7 @@ The following rules are now recommended:

The code action now removes any whitespace between the parameter name and its initialization.

- Relax [noConfusingArrow](https://biomejs.dev/linter/rules/no-confusing-arrow/)
- Relax `noConfusingArrow`

All arrow functions that enclose its parameter with parenthesis are allowed.
Thus, the following snippet no longer trigger the rule:
Expand Down
4 changes: 0 additions & 4 deletions crates/biome_formatter/src/buffer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -557,10 +557,6 @@ fn clean_interned(
Some((mut cleaned, rest)) => {
let mut is_in_expanded_conditional_content = false;
for element in rest {
if is_in_expanded_conditional_content {
continue;
}

let element = match element {
FormatElement::Tag(Tag::StartConditionalContent(condition))
if condition.mode == PrintMode::Expanded =>
Expand Down
3 changes: 3 additions & 0 deletions crates/biome_js_formatter/tests/specs/ts/issue1511.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
call(a, function (b: () => t1 | t2) {});

call(a, (b: () => t1 | t2) => {});
43 changes: 43 additions & 0 deletions crates/biome_js_formatter/tests/specs/ts/issue1511.ts.snap
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
---
source: crates/biome_formatter_test/src/snapshot_builder.rs
info: ts/issue1511.ts
---

# Input

```ts
call(a, function (b: () => t1 | t2) {});

call(a, (b: () => t1 | t2) => {});

```


=============================

# 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
call(a, function (b: () => t1 | t2) {});

call(a, (b: () => t1 | t2) => {});
```


4 changes: 3 additions & 1 deletion website/src/content/docs/internals/changelog.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ Read our [guidelines for writing a good changelog entry](https://github.com/biom

- Fix [#1172](https://github.com/biomejs/biome/issues/1172). Fix placement of line comment after function expression parentheses, they are now attached to first statement in body. Contributed by @kalleep

- Fix [#1511](https://github.com/biomejs/biome/issues/1511) that made the JavaScript formatter crash. COntributed @Conaclos

### JavaScript APIs

### Linter
Expand Down Expand Up @@ -1917,7 +1919,7 @@ The following rules are now recommended:

The code action now removes any whitespace between the parameter name and its initialization.

- Relax [noConfusingArrow](https://biomejs.dev/linter/rules/no-confusing-arrow/)
- Relax `noConfusingArrow`

All arrow functions that enclose its parameter with parenthesis are allowed.
Thus, the following snippet no longer trigger the rule:
Expand Down
4 changes: 2 additions & 2 deletions website/src/content/docs/zh-cn/internals/changelog.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -1216,7 +1216,7 @@ The following rules are promoted:

#### Removed rules

- Remove [noConfusingArrow](https://biomejs.dev/linter/rules/no-confusing-arrow/).
- Remove `noConfusingArrow`

Code formatters, such as prettier and Biome, always adds parentheses around the parameter or the body of an arrow function.
This makes the rule useless.
Expand Down Expand Up @@ -1876,7 +1876,7 @@ The following rules are now recommended:

The code action now removes any whitespace between the parameter name and its initialization.

- Relax [noConfusingArrow](https://biomejs.dev/linter/rules/no-confusing-arrow/)
- Relax `noConfusingArrow`

All arrow functions that enclose its parameter with parenthesis are allowed.
Thus, the following snippet no longer trigger the rule:
Expand Down
Loading