Fix break on conditional expressions inside return
Fixes #2777 Since we can't break after `return` and don't add `()` around ConditionalExpressions' tests, we end up with some weird indentation when breaking.master
parent
3db840258b
commit
bba7dcf498
|
@ -346,7 +346,8 @@ function genericPrintNoParens(path, options, print, args) {
|
|||
parentParent.type === "JSXAttribute") ||
|
||||
(n === parent.body && parent.type === "ArrowFunctionExpression") ||
|
||||
(n !== parent.body && parent.type === "ForStatement") ||
|
||||
parent.type === "ConditionalExpression";
|
||||
(parent.type === "ConditionalExpression" &&
|
||||
parentParent.type !== "ReturnStatement");
|
||||
|
||||
const shouldIdentIfInlining =
|
||||
parent.type === "AssignmentExpression" ||
|
||||
|
|
|
@ -352,6 +352,46 @@ x & (y >> z);
|
|||
|
||||
`;
|
||||
|
||||
exports[`return.js 1`] = `
|
||||
function foo() {
|
||||
return this.hasPlugin("dynamicImports") && this.lookahead().type === tt.parenLeft.right;
|
||||
}
|
||||
|
||||
function foo() {
|
||||
return this.hasPlugin("dynamicImports") && this.lookahead().type === tt.parenLeft.right
|
||||
? true
|
||||
: false;
|
||||
}
|
||||
|
||||
function foo() {
|
||||
return this.calculate().compute().first.numberOfThings > this.calculate().compute().last.numberOfThings
|
||||
? true
|
||||
: false;
|
||||
}
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
function foo() {
|
||||
return (
|
||||
this.hasPlugin("dynamicImports") &&
|
||||
this.lookahead().type === tt.parenLeft.right
|
||||
);
|
||||
}
|
||||
|
||||
function foo() {
|
||||
return this.hasPlugin("dynamicImports") &&
|
||||
this.lookahead().type === tt.parenLeft.right
|
||||
? true
|
||||
: false;
|
||||
}
|
||||
|
||||
function foo() {
|
||||
return this.calculate().compute().first.numberOfThings >
|
||||
this.calculate().compute().last.numberOfThings
|
||||
? true
|
||||
: false;
|
||||
}
|
||||
|
||||
`;
|
||||
|
||||
exports[`short-right.js 1`] = `
|
||||
this._cumulativeHeights &&
|
||||
Math.abs(
|
||||
|
|
|
@ -0,0 +1,15 @@
|
|||
function foo() {
|
||||
return this.hasPlugin("dynamicImports") && this.lookahead().type === tt.parenLeft.right;
|
||||
}
|
||||
|
||||
function foo() {
|
||||
return this.hasPlugin("dynamicImports") && this.lookahead().type === tt.parenLeft.right
|
||||
? true
|
||||
: false;
|
||||
}
|
||||
|
||||
function foo() {
|
||||
return this.calculate().compute().first.numberOfThings > this.calculate().compute().last.numberOfThings
|
||||
? true
|
||||
: false;
|
||||
}
|
Loading…
Reference in New Issue