Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
9 changes: 8 additions & 1 deletion crates/oxc_formatter/src/write/parameters.rs
Original file line number Diff line number Diff line change
Expand Up @@ -382,7 +382,14 @@ pub fn has_only_simple_parameters(
parameters: &FormalParameters<'_>,
allow_type_annotations: bool,
) -> bool {
parameters.items.iter().all(|parameter| is_simple_parameter(parameter, allow_type_annotations))
// NOTE: A rest parameter is never considered simple.
// Prettier only checks `param.type` is `Identifier` or not.
// https://github.com/prettier/prettier/blob/7848357af654883e21ed05c0bbbedf89ee88750e/src/language-js/print/function.js#L72-L74
parameters.rest.is_none()
&& parameters
.items
.iter()
.all(|parameter| is_simple_parameter(parameter, allow_type_annotations))
}

/// Tests if the single parameter is "simple", as in a plain identifier with no
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
useStableCallback(function useShowToast(
...args: Parameters<typeof toastService.addToastItem>
): void {
toastService.addToastItem(...args);
});

Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
---
source: crates/oxc_formatter/tests/fixtures/mod.rs
---
==================== Input ====================
useStableCallback(function useShowToast(
...args: Parameters<typeof toastService.addToastItem>
): void {
toastService.addToastItem(...args);
});


==================== Output ====================
------------------
{ printWidth: 80 }
------------------
useStableCallback(function useShowToast(
...args: Parameters<typeof toastService.addToastItem>
): void {
toastService.addToastItem(...args);
});

-------------------
{ printWidth: 100 }
-------------------
useStableCallback(function useShowToast(
...args: Parameters<typeof toastService.addToastItem>
): void {
toastService.addToastItem(...args);
});

===================== End =====================
Loading