Skip to content

Commit 7f13ac0

Browse files
committed
fix(formatter): should not break when the parent of root of StaticMemberExpression is used as the Argument of NewExpression
1 parent 7519237 commit 7f13ac0

File tree

3 files changed

+42
-1
lines changed

3 files changed

+42
-1
lines changed

crates/oxc_formatter/src/write/member_expression.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,9 @@ fn layout<'a>(
147147
}
148148

149149
match first_non_static_member_ancestor {
150-
AstNodes::NewExpression(_) => StaticMemberLayout::NoBreak,
150+
AstNodes::Argument(argument) if matches!(argument.parent, AstNodes::NewExpression(_)) => {
151+
StaticMemberLayout::NoBreak
152+
}
151153
AstNodes::AssignmentExpression(assignment) => {
152154
if matches!(assignment.left, AssignmentTarget::AssignmentTargetIdentifier(_)) {
153155
StaticMemberLayout::BreakAfterObject
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
TelemetryTrustedValue(
2+
instance.capabilities.get(
3+
TerminalCapability?.PromptTypeDetection
4+
)?.promptType
5+
)
6+
7+
new TelemetryTrustedValue(
8+
instance.capabilities.get(
9+
TerminalCapability?.PromptTypeDetection
10+
)?.promptType
11+
)
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
---
2+
source: crates/oxc_formatter/tests/fixtures/mod.rs
3+
---
4+
==================== Input ====================
5+
TelemetryTrustedValue(
6+
instance.capabilities.get(
7+
TerminalCapability?.PromptTypeDetection
8+
)?.promptType
9+
)
10+
11+
new TelemetryTrustedValue(
12+
instance.capabilities.get(
13+
TerminalCapability?.PromptTypeDetection
14+
)?.promptType
15+
)
16+
==================== Output ====================
17+
TelemetryTrustedValue(
18+
instance.capabilities.get(TerminalCapability?.PromptTypeDetection)
19+
?.promptType,
20+
);
21+
22+
new TelemetryTrustedValue(
23+
instance.capabilities.get(
24+
TerminalCapability?.PromptTypeDetection,
25+
)?.promptType,
26+
);
27+
28+
===================== End =====================

0 commit comments

Comments
 (0)