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

Add support for React useEffect hook #5608

Merged
merged 7 commits into from Dec 10, 2018
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/language-js/printer-estree.js
Expand Up @@ -3802,7 +3802,8 @@ function shouldGroupFirstArg(args) {
secondArg.type !== "FunctionExpression" &&
secondArg.type !== "ArrowFunctionExpression" &&
secondArg.type !== "ConditionalExpression" &&
!couldGroupArg(secondArg)
(!couldGroupArg(secondArg) ||
(secondArg.type === "ArrayExpression" && !secondArg.comments))
);
}

Expand Down
22 changes: 22 additions & 0 deletions tests/break-calls/__snapshots__/jsfmt.spec.js.snap
Expand Up @@ -116,3 +116,25 @@ runtimeAgent.getProperties(

================================================================================
`;

exports[`react.js 1`] = `
j-f1 marked this conversation as resolved.
Show resolved Hide resolved
====================================options=====================================
parsers: ["flow", "typescript"]
printWidth: 80
| printWidth
=====================================input======================================
function helloWorld() {
useEffect(() => {
// do something
}, [props.value])
}

=====================================output=====================================
function helloWorld() {
useEffect(() => {
// do something
}, [props.value]);
}

================================================================================
`;
5 changes: 5 additions & 0 deletions tests/break-calls/react.js
@@ -0,0 +1,5 @@
function helloWorld() {
useEffect(() => {
j-f1 marked this conversation as resolved.
Show resolved Hide resolved
// do something
}, [props.value])
}