Only break for conditionals (#1350)

We only want to break for && and ||, not for ===
master
Christopher Chedeau 2017-04-19 13:18:01 -07:00 committed by GitHub
parent 076804c09c
commit bae08d4e7e
3 changed files with 12 additions and 1 deletions

View File

@ -3205,7 +3205,7 @@ function printBinaryishExpressions(path, print, options, isNested, isInsideParen
// in order to avoid having a small right part like -1 be on its own line.
const parent = path.getParentNode();
const shouldGroup =
!isInsideParenthesis &&
!(isInsideParenthesis && node.type === "LogicalExpression") &&
parent.type !== node.type &&
node.left.type !== node.type &&
node.right.type !== node.type;

View File

@ -61,6 +61,9 @@ if (this.hasPlugin("dynamicImports") && this.lookahead().type) {}
if (this.hasPlugin("dynamicImports") && this.lookahead().type === tt.parenLeft) {}
if (this.hasPlugin("dynamicImports") && this.lookahead().type === tt.parenLeft.right) {}
if (VeryVeryVeryVeryVeryVeryVeryVeryLong === VeryVeryVeryVeryVeryVeryVeryVeryLong) {
}
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
if (this.hasPlugin("dynamicImports") && this.lookahead().type) {
}
@ -77,6 +80,11 @@ if (
) {
}
if (
VeryVeryVeryVeryVeryVeryVeryVeryLong === VeryVeryVeryVeryVeryVeryVeryVeryLong
) {
}
`;
exports[`inline-object-array.js 1`] = `

View File

@ -3,3 +3,6 @@ if (this.hasPlugin("dynamicImports") && this.lookahead().type) {}
if (this.hasPlugin("dynamicImports") && this.lookahead().type === tt.parenLeft) {}
if (this.hasPlugin("dynamicImports") && this.lookahead().type === tt.parenLeft.right) {}
if (VeryVeryVeryVeryVeryVeryVeryVeryLong === VeryVeryVeryVeryVeryVeryVeryVeryLong) {
}