add Terminatorless alias key for node expression wrappers that don't accept new lines
This commit is contained in:
parent
471d60e5cd
commit
713845d14c
@ -151,9 +151,7 @@ class CodeGenerator {
|
||||
// catch up to this nodes newline if we're behind
|
||||
if (node.loc && this.format.retainLines && this.buffer.buf) {
|
||||
var needsParens = false;
|
||||
if (parent && (this.position.line < node.loc.start.line) &&
|
||||
(t.isContinueStatement(parent) || t.isBreakStatement(parent) ||
|
||||
t.isReturnStatement(parent) || t.isThrowStatement(parent))) {
|
||||
if (parent && (this.position.line < node.loc.start.line) && t.isTerminatorless(parent)) {
|
||||
needsParens = true;
|
||||
this._push("(");
|
||||
}
|
||||
|
||||
@ -85,16 +85,7 @@ export default class Node {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (t.isYieldExpression(parent) || t.isAwaitExpression(parent)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (t.isContinueStatement(parent) || t.isBreakStatement(parent) ||
|
||||
t.isReturnStatement(parent) || t.isThrowStatement(parent)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
return t.isTerminatorless(parent);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -1,13 +1,13 @@
|
||||
{
|
||||
"ExpressionStatement": ["Statement"],
|
||||
"BreakStatement": ["Statement"],
|
||||
"ContinueStatement": ["Statement"],
|
||||
"BreakStatement": ["Statement", "Terminatorless"],
|
||||
"ContinueStatement": ["Statement", "Terminatorless"],
|
||||
"DebuggerStatement": ["Statement"],
|
||||
"DoWhileStatement": ["Statement", "Loop", "While", "Scopable"],
|
||||
"IfStatement": ["Statement"],
|
||||
"ReturnStatement": ["Statement"],
|
||||
"ReturnStatement": ["Statement", "Terminatorless"],
|
||||
"SwitchStatement": ["Statement", "Scopable"],
|
||||
"ThrowStatement": ["Statement"],
|
||||
"ThrowStatement": ["Statement", "Terminatorless"],
|
||||
"TryStatement": ["Statement"],
|
||||
"WhileStatement": ["Statement", "Loop", "While", "Scopable"],
|
||||
"WithStatement": ["Statement"],
|
||||
@ -56,7 +56,7 @@
|
||||
|
||||
"ArrayExpression": ["Expression"],
|
||||
"AssignmentExpression": ["Expression"],
|
||||
"AwaitExpression": ["Expression"],
|
||||
"AwaitExpression": ["Expression", "Terminatorless"],
|
||||
"CallExpression": ["Expression"],
|
||||
"ComprehensionExpression": ["Expression", "Scopable"],
|
||||
"ConditionalExpression": ["Expression"],
|
||||
@ -74,7 +74,7 @@
|
||||
"UpdateExpression": ["Expression"],
|
||||
"JSXEmptyExpression": ["Expression"],
|
||||
"JSXMemberExpression": ["Expression"],
|
||||
"YieldExpression": ["Expression"],
|
||||
"YieldExpression": ["Expression", "Terminatorless"],
|
||||
|
||||
"AnyTypeAnnotation": ["Flow"],
|
||||
"ArrayTypeAnnotation": ["Flow"],
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user