diff --git a/src/printer.js b/src/printer.js index 3a9e6e86d..d39bbc2c5 100644 --- a/src/printer.js +++ b/src/printer.js @@ -2394,7 +2394,10 @@ function printMemberChain(path, options, print) { // If we only have a single `.`, we shouldn't do anything fancy and just // render everything concatenated together. - if (groups.length <= (shouldMerge ? 3 : 2) && !hasComment) { + if (groups.length <= (shouldMerge ? 3 : 2) && + !hasComment && + // (a || b).map() should be break before .map() instead of || + groups[0][0].node.type !== "LogicalExpression") { return group(oneLine); } diff --git a/tests/method-chain/__snapshots__/jsfmt.spec.js.snap b/tests/method-chain/__snapshots__/jsfmt.spec.js.snap index 7d364b6fe..0ca8d7e0a 100644 --- a/tests/method-chain/__snapshots__/jsfmt.spec.js.snap +++ b/tests/method-chain/__snapshots__/jsfmt.spec.js.snap @@ -224,6 +224,15 @@ Object.keys( " `; +exports[`logical.js 1`] = ` +"(veryLongVeryLongVeryLong || e).map(tickets => + TicketRecord.createFromSomeLongString()); +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +(veryLongVeryLongVeryLong || e) + .map(tickets => TicketRecord.createFromSomeLongString()); +" +`; + exports[`multiple-members.js 1`] = ` "if (testConfig.ENABLE_ONLINE_TESTS === \\"true\\") { describe(\\"POST /users/me/pet\\", function() { diff --git a/tests/method-chain/logical.js b/tests/method-chain/logical.js new file mode 100644 index 000000000..a7ab0442d --- /dev/null +++ b/tests/method-chain/logical.js @@ -0,0 +1,2 @@ +(veryLongVeryLongVeryLong || e).map(tickets => + TicketRecord.createFromSomeLongString());