Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(js_formatter): format hook with 3 arguments #4462

Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -1205,14 +1205,21 @@ fn is_multiline_template_only_args(arguments: &JsCallArguments) -> bool {
/// useMemo(() => {}, [])
/// ```
fn is_react_hook_with_deps_array(arguments: &JsCallArguments, comments: &JsComments) -> bool {
if arguments.args().len() > 3 || arguments.args().len() < 2 {
return false;
};

use AnyJsExpression::*;
let mut args = arguments.args().iter();
if arguments.args().len() == 3 {
args.next();
}

match (args.next(), args.next()) {
(
Some(Ok(AnyJsCallArgument::AnyJsExpression(JsArrowFunctionExpression(callback)))),
Some(Ok(AnyJsCallArgument::AnyJsExpression(JsArrayExpression(deps)))),
) if arguments.args().len() == 2 => {
) => {
if comments.has_comments(callback.syntax()) || comments.has_comments(deps.syntax()) {
return false;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
useImperativeHandle(ref, () => {
return;
}, []);
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
---
source: crates/biome_formatter_test/src/snapshot_builder.rs
info: js/module/expression/call_arguments.js
---
# Input

```js
useImperativeHandle(ref, () => {
return;
}, []);

```


=============================

# Outputs

## Output 1

-----
Indent style: Tab
Indent width: 2
Line ending: LF
Line width: 80
Quote style: Double Quotes
JSX quote style: Double Quotes
Quote properties: As needed
Trailing commas: All
Semicolons: Always
Arrow parentheses: Always
Bracket spacing: true
Bracket same line: false
Attribute Position: Auto
-----

```js
useImperativeHandle(ref, () => {
return;
}, []);
```