diff --git a/src/language-js/printer-estree.js b/src/language-js/printer-estree.js index 802df73f..f3851e44 100644 --- a/src/language-js/printer-estree.js +++ b/src/language-js/printer-estree.js @@ -3420,6 +3420,7 @@ function couldGroupArg(arg) { arg.body.type === "ArrayExpression" || arg.body.type === "CallExpression" || arg.body.type === "OptionalCallExpression" || + arg.body.type === "ConditionalExpression" || isJSXNode(arg.body))) ); } diff --git a/tests/arrow-call/__snapshots__/jsfmt.spec.js.snap b/tests/arrow-call/__snapshots__/jsfmt.spec.js.snap index d2b9b1a0..7d7535f7 100644 --- a/tests/arrow-call/__snapshots__/jsfmt.spec.js.snap +++ b/tests/arrow-call/__snapshots__/jsfmt.spec.js.snap @@ -1,6 +1,6 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP -exports[`arrow_call.js - flow-verify 1`] = ` +exports[`arrow_call.js - babylon-verify 1`] = ` const testResults = results.testResults.map(testResult => formatResult(testResult, formatter, reporter) ); @@ -43,6 +43,8 @@ const composition = (ViewComponent, ContainerComponent) => class extends React.Component { static propTypes = {}; }; + +promise.then(result => result.veryLongVariable.veryLongPropertyName > someOtherVariable ? "ok" : "fail"); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ const testResults = results.testResults.map(testResult => formatResult(testResult, formatter, reporter) @@ -93,9 +95,15 @@ const composition = (ViewComponent, ContainerComponent) => static propTypes = {}; }; +promise.then(result => + result.veryLongVariable.veryLongPropertyName > someOtherVariable + ? "ok" + : "fail" +); + `; -exports[`arrow_call.js - flow-verify 2`] = ` +exports[`arrow_call.js - babylon-verify 2`] = ` const testResults = results.testResults.map(testResult => formatResult(testResult, formatter, reporter) ); @@ -138,6 +146,8 @@ const composition = (ViewComponent, ContainerComponent) => class extends React.Component { static propTypes = {}; }; + +promise.then(result => result.veryLongVariable.veryLongPropertyName > someOtherVariable ? "ok" : "fail"); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ const testResults = results.testResults.map(testResult => formatResult(testResult, formatter, reporter), @@ -188,9 +198,15 @@ const composition = (ViewComponent, ContainerComponent) => static propTypes = {}; }; +promise.then(result => + result.veryLongVariable.veryLongPropertyName > someOtherVariable + ? "ok" + : "fail", +); + `; -exports[`arrow_call.js - flow-verify 3`] = ` +exports[`arrow_call.js - babylon-verify 3`] = ` const testResults = results.testResults.map(testResult => formatResult(testResult, formatter, reporter) ); @@ -233,6 +249,8 @@ const composition = (ViewComponent, ContainerComponent) => class extends React.Component { static propTypes = {}; }; + +promise.then(result => result.veryLongVariable.veryLongPropertyName > someOtherVariable ? "ok" : "fail"); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ const testResults = results.testResults.map((testResult) => formatResult(testResult, formatter, reporter) @@ -283,4 +301,10 @@ const composition = (ViewComponent, ContainerComponent) => static propTypes = {}; }; +promise.then((result) => + result.veryLongVariable.veryLongPropertyName > someOtherVariable + ? "ok" + : "fail" +); + `; diff --git a/tests/arrow-call/arrow_call.js b/tests/arrow-call/arrow_call.js index cb73bf52..536ad9e5 100644 --- a/tests/arrow-call/arrow_call.js +++ b/tests/arrow-call/arrow_call.js @@ -40,3 +40,5 @@ const composition = (ViewComponent, ContainerComponent) => class extends React.Component { static propTypes = {}; }; + +promise.then(result => result.veryLongVariable.veryLongPropertyName > someOtherVariable ? "ok" : "fail"); diff --git a/tests/arrow-call/jsfmt.spec.js b/tests/arrow-call/jsfmt.spec.js index 6929f9c2..93724d9b 100644 --- a/tests/arrow-call/jsfmt.spec.js +++ b/tests/arrow-call/jsfmt.spec.js @@ -1,3 +1,7 @@ -run_spec(__dirname, ["flow", "typescript"]); -run_spec(__dirname, ["flow", "typescript"], { trailingComma: "all" }); -run_spec(__dirname, ["flow", "typescript"], { arrowParens: "always" }); +run_spec(__dirname, ["babylon", "flow", "typescript"]); +run_spec(__dirname, ["babylon", "flow", "typescript"], { + trailingComma: "all" +}); +run_spec(__dirname, ["babylon", "flow", "typescript"], { + arrowParens: "always" +}); diff --git a/tests/ternaries/__snapshots__/jsfmt.spec.js.snap b/tests/ternaries/__snapshots__/jsfmt.spec.js.snap index eb4f931d..e215d086 100644 --- a/tests/ternaries/__snapshots__/jsfmt.spec.js.snap +++ b/tests/ternaries/__snapshots__/jsfmt.spec.js.snap @@ -22,14 +22,13 @@ const funnelSnapshotCard = ) : null; room = room.map((row, rowIndex) => - row.map( - (col, colIndex) => - rowIndex === 0 || - colIndex === 0 || - rowIndex === height || - colIndex === width - ? 1 - : 0 + row.map((col, colIndex) => + rowIndex === 0 || + colIndex === 0 || + rowIndex === height || + colIndex === width + ? 1 + : 0 ) ); @@ -57,14 +56,13 @@ const funnelSnapshotCard = ) : null; room = room.map((row, rowIndex) => - row.map( - (col, colIndex) => - rowIndex === 0 || - colIndex === 0 || - rowIndex === height || - colIndex === width - ? 1 - : 0 + row.map((col, colIndex) => + rowIndex === 0 || + colIndex === 0 || + rowIndex === height || + colIndex === width + ? 1 + : 0 ) ); @@ -92,14 +90,13 @@ const funnelSnapshotCard = ) : null; room = room.map((row, rowIndex) => - row.map( - (col, colIndex) => - rowIndex === 0 || - colIndex === 0 || - rowIndex === height || - colIndex === width - ? 1 - : 0 + row.map((col, colIndex) => + rowIndex === 0 || + colIndex === 0 || + rowIndex === height || + colIndex === width + ? 1 + : 0 ) ); @@ -127,14 +124,13 @@ const funnelSnapshotCard = ) : null; room = room.map((row, rowIndex) => - row.map( - (col, colIndex) => - rowIndex === 0 || - colIndex === 0 || - rowIndex === height || - colIndex === width - ? 1 - : 0 + row.map((col, colIndex) => + rowIndex === 0 || + colIndex === 0 || + rowIndex === height || + colIndex === width + ? 1 + : 0 ) );