diff --git a/crates/oxc_formatter/src/write/call_arguments.rs b/crates/oxc_formatter/src/write/call_arguments.rs index 65007c492a239..b018a9d0a7bca 100644 --- a/crates/oxc_formatter/src/write/call_arguments.rs +++ b/crates/oxc_formatter/src/write/call_arguments.rs @@ -124,17 +124,14 @@ impl<'a> Format<'a> for AstNode<'a, ArenaVec<'a, Argument<'a>>> { if let Some(group_layout) = arguments_grouped_layout(call_like_span, self, f) { write_grouped_arguments(self, group_layout, f) } else if call_expression.is_some_and(|call| is_long_curried_call(call)) { + let trailing_operator = FormatTrailingCommas::All.trailing_separator(f.options()); write!( f, [ l_paren_token, soft_block_indent(&format_once(|f| { f.join_with(soft_line_break_or_space()) - .entries_with_trailing_separator( - self.iter(), - ",", - TrailingSeparator::Allowed, - ) + .entries_with_trailing_separator(self.iter(), ",", trailing_operator) .finish() })), r_paren_token, diff --git a/crates/oxc_formatter/tests/fixtures/js/arguments/long-curried-call/options.json b/crates/oxc_formatter/tests/fixtures/js/arguments/long-curried-call/options.json new file mode 100644 index 0000000000000..5441ebbe7f9eb --- /dev/null +++ b/crates/oxc_formatter/tests/fixtures/js/arguments/long-curried-call/options.json @@ -0,0 +1,11 @@ +[ + { + "trailingComma": "none" + }, + { + "trailingComma": "es5" + }, + { + "trailingComma": "all" + } +] \ No newline at end of file diff --git a/crates/oxc_formatter/tests/fixtures/js/arguments/long-curried-call/trailing-comma.js b/crates/oxc_formatter/tests/fixtures/js/arguments/long-curried-call/trailing-comma.js new file mode 100644 index 0000000000000..ce320d6746650 --- /dev/null +++ b/crates/oxc_formatter/tests/fixtures/js/arguments/long-curried-call/trailing-comma.js @@ -0,0 +1,4 @@ +Event.debounce( + call(A, B), + DDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDD +)(() => { }); diff --git a/crates/oxc_formatter/tests/fixtures/js/arguments/long-curried-call/trailing-comma.js.snap b/crates/oxc_formatter/tests/fixtures/js/arguments/long-curried-call/trailing-comma.js.snap new file mode 100644 index 0000000000000..6a07fa6e98431 --- /dev/null +++ b/crates/oxc_formatter/tests/fixtures/js/arguments/long-curried-call/trailing-comma.js.snap @@ -0,0 +1,35 @@ +--- +source: crates/oxc_formatter/tests/fixtures/mod.rs +--- +==================== Input ==================== +Event.debounce( + call(A, B), + DDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDD +)(() => { }); + +==================== Output ==================== +------------------------- +{ trailingComma: "none" } +------------------------- +Event.debounce( + call(A, B), + DDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDD +)(() => {}); + +------------------------ +{ trailingComma: "es5" } +------------------------ +Event.debounce( + call(A, B), + DDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDD +)(() => {}); + +------------------------ +{ trailingComma: "all" } +------------------------ +Event.debounce( + call(A, B), + DDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDD, +)(() => {}); + +===================== End =====================