diff --git a/src/language-js/printer-estree.js b/src/language-js/printer-estree.js index abfad10e2..e992950ef 100644 --- a/src/language-js/printer-estree.js +++ b/src/language-js/printer-estree.js @@ -3415,6 +3415,8 @@ function shouldGroupFirstArg(args) { (firstArg.type === "FunctionExpression" || (firstArg.type === "ArrowFunctionExpression" && firstArg.body.type === "BlockStatement")) && + secondArg.type !== "FunctionExpression" && + secondArg.type !== "ArrowFunctionExpression" && !couldGroupArg(secondArg) ); } diff --git a/tests/first_argument_expansion/__snapshots__/jsfmt.spec.js.snap b/tests/first_argument_expansion/__snapshots__/jsfmt.spec.js.snap index 3ee6c88f1..1709bc086 100644 --- a/tests/first_argument_expansion/__snapshots__/jsfmt.spec.js.snap +++ b/tests/first_argument_expansion/__snapshots__/jsfmt.spec.js.snap @@ -88,6 +88,10 @@ setTimeout( setTimeout(/* blip */ function() { thing(); }, 500); + +func((args) => { + execute(args); +}, result => result && console.log("success")) ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ setTimeout(function() { thing(); @@ -200,4 +204,11 @@ setTimeout( 500 ); +func( + args => { + execute(args); + }, + result => result && console.log("success") +); + `; diff --git a/tests/first_argument_expansion/jsfmt.spec.js b/tests/first_argument_expansion/jsfmt.spec.js index a842e1348..c0e8f2eb2 100644 --- a/tests/first_argument_expansion/jsfmt.spec.js +++ b/tests/first_argument_expansion/jsfmt.spec.js @@ -1 +1 @@ -run_spec(__dirname, ["flow", "typescript"]); +run_spec(__dirname, ["babylon", "flow", "typescript"]); diff --git a/tests/first_argument_expansion/test.js b/tests/first_argument_expansion/test.js index a27a3cdcf..93f1b9e9e 100644 --- a/tests/first_argument_expansion/test.js +++ b/tests/first_argument_expansion/test.js @@ -85,3 +85,7 @@ setTimeout( setTimeout(/* blip */ function() { thing(); }, 500); + +func((args) => { + execute(args); +}, result => result && console.log("success"))