Skip to content

Commit 54984ae

Browse files
committed
fix(formatter): handle leading comments in arrow function sequence expressions (#18798)
Fixes `js/arrows/comment.js` prettier test
1 parent fd07f3f commit 54984ae

File tree

2 files changed

+6
-5
lines changed

2 files changed

+6
-5
lines changed

crates/oxc_formatter/src/print/arrow_function_expression.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -150,8 +150,9 @@ impl<'a, 'b> FormatJsArrowFunctionExpression<'a, 'b> {
150150
formatted_signature,
151151
group(&format_args!(indent(&format_args!(
152152
hard_line_break(),
153+
format_leading_comments(sequence.span()),
153154
token("("),
154-
soft_block_indent(&format_body),
155+
format_body,
155156
token(")")
156157
))))
157158
))]
@@ -568,8 +569,9 @@ impl<'a> Format<'a> for ArrowChain<'a, '_> {
568569
f,
569570
[group(&format_args!(indent(&format_args!(
570571
hard_line_break(),
572+
format_leading_comments(sequence.span()),
571573
token("("),
572-
soft_block_indent(&format_tail_body),
574+
format_tail_body,
573575
token(")")
574576
))))]
575577
);
Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
1-
js compatibility: 742/753 (98.54%)
1+
js compatibility: 743/753 (98.67%)
22

33
# Failed
44

55
| Spec path | Failed or Passed | Match ratio |
66
| :-------- | :--------------: | :---------: |
7-
| js/arrows/comment.js | 💥💥 | 88.89% |
87
| js/comments/15661.js | 💥💥 | 55.17% |
98
| js/comments/empty-statements.js | 💥💥 | 90.91% |
109
| js/comments/function-declaration.js | 💥💥 | 92.80% |
@@ -14,4 +13,4 @@ js compatibility: 742/753 (98.54%)
1413
| js/last-argument-expansion/dangling-comment-in-arrow-function.js | 💥 | 22.22% |
1514
| js/quote-props/objects.js | 💥💥✨✨ | 48.04% |
1615
| js/quote-props/with_numbers.js | 💥💥✨✨ | 46.43% |
17-
| js/sequence-expression/ignored.js | 💥 | 25.00% |
16+
| js/sequence-expression/ignored.js | 💥 | 66.67% |

0 commit comments

Comments
 (0)