Fix various print inefficiencies/bugs
This commit is contained in:
@@ -107,7 +107,12 @@ function buildLabelStatement(prefix, key = "label") {
|
||||
|
||||
let label = node[key];
|
||||
if (label) {
|
||||
this.push(" ");
|
||||
if (!(this.format.minified && (t.isUnaryExpression(label, { prefix: true }) ||
|
||||
t.isUpdateExpression(label, { prefix: true })))) {
|
||||
this.push(" ");
|
||||
|
||||
}
|
||||
|
||||
let terminatorState = this.startTerminatorless();
|
||||
this.print(label, node);
|
||||
this.endTerminatorless(terminatorState);
|
||||
@@ -153,7 +158,8 @@ export function CatchClause(node: Object) {
|
||||
this.keyword("catch");
|
||||
this.push("(");
|
||||
this.print(node.param, node);
|
||||
this.push(") ");
|
||||
this.push(")");
|
||||
this.space();
|
||||
this.print(node.body, node);
|
||||
}
|
||||
|
||||
|
||||
@@ -123,6 +123,22 @@ export function SequenceExpression(node: Object, parent: Object): boolean {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (t.isSwitchStatement(parent) && parent.discriminant === node) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (t.isWhileStatement(parent) && parent.test === node) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (t.isIfStatement(parent) && parent.test === node) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (t.isForInStatement(parent) && parent.right === node) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Otherwise err on the side of overparenthesization, adding
|
||||
// explicit exceptions above if this proves overzealous.
|
||||
return true;
|
||||
|
||||
Reference in New Issue
Block a user