Skip to content

Commit 768711e

Browse files
committed
fix(formatter): handle chain expression for JSXExpressionContainer
1 parent c2bdaa5 commit 768711e

File tree

3 files changed

+7
-6
lines changed

3 files changed

+7
-6
lines changed

crates/oxc_formatter/src/write/jsx/element.rs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -200,8 +200,11 @@ pub fn should_expand(mut parent: &AstNodes<'_>) -> bool {
200200
},
201201
_ => return false,
202202
};
203-
matches!(maybe_jsx_expression_child, AstNodes::JSXExpressionContainer(container)
204-
if matches!(container.parent, AstNodes::JSXElement(_) | AstNodes::JSXFragment(_)) )
203+
matches!(
204+
maybe_jsx_expression_child.without_chain_expression(),
205+
AstNodes::JSXExpressionContainer(container)
206+
if matches!(container.parent, AstNodes::JSXElement(_) | AstNodes::JSXFragment(_))
207+
)
205208
}
206209

207210
impl<'a, 'b> AnyJsxTagWithChildren<'a, 'b> {

tasks/prettier_conformance/snapshots/prettier.js.snap.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
js compatibility: 693/749 (92.52%)
1+
js compatibility: 694/749 (92.66%)
22

33
# Failed
44

@@ -57,6 +57,5 @@ js compatibility: 693/749 (92.52%)
5757
| js/test-declarations/test_declarations.js | 💥💥 | 95.88% |
5858
| jsx/fbt/test.js | 💥 | 84.06% |
5959
| jsx/jsx/quotes.js | 💥💥💥💥 | 79.41% |
60-
| jsx/optional-chaining/optional-chaining.jsx | 💥 | 85.96% |
6160
| jsx/single-attribute-per-line/single-attribute-per-line.js | 💥✨ | 43.37% |
6261
| jsx/text-wrap/test.js | 💥 | 99.56% |

tasks/prettier_conformance/snapshots/prettier.ts.snap.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
1-
ts compatibility: 542/598 (90.64%)
1+
ts compatibility: 543/598 (90.80%)
22

33
# Failed
44

55
| Spec path | Failed or Passed | Match ratio |
66
| :-------- | :--------------: | :---------: |
77
| jsx/fbt/test.js | 💥 | 84.06% |
88
| jsx/jsx/quotes.js | 💥💥💥💥 | 79.41% |
9-
| jsx/optional-chaining/optional-chaining.jsx | 💥 | 85.96% |
109
| jsx/single-attribute-per-line/single-attribute-per-line.js | 💥✨ | 43.37% |
1110
| jsx/text-wrap/test.js | 💥 | 99.56% |
1211
| typescript/angular-component-examples/15934-computed.component.ts | 💥💥 | 76.92% |

0 commit comments

Comments
 (0)