Make terminator paren comment check more strict (#5651)
This commit is contained in:
@@ -199,7 +199,7 @@ export function AssignmentExpression(node: Object): boolean {
|
||||
}
|
||||
}
|
||||
|
||||
// Walk up the print stack to deterimine if our node can come first
|
||||
// Walk up the print stack to determine if our node can come first
|
||||
// in statement.
|
||||
function isFirstInStatement(
|
||||
printStack: Array<Object>,
|
||||
|
||||
@@ -246,8 +246,10 @@ export default class Printer {
|
||||
if (i === str.length) return;
|
||||
|
||||
const cha = str[i];
|
||||
if (cha === "\n" || cha === "/") {
|
||||
// we're going to break this terminator expression so we need to add a parentheses
|
||||
const chaPost = str[i + 1];
|
||||
|
||||
// Check for newline or comment
|
||||
if (cha === "\n" || (cha === "/" && (chaPost === "/" || chaPost === "*"))) {
|
||||
this.token("(");
|
||||
this.indent();
|
||||
parenPushNewlineState.printed = true;
|
||||
|
||||
@@ -9,3 +9,7 @@ function bar() {
|
||||
function foo() {
|
||||
return 1, "foo";
|
||||
}
|
||||
|
||||
() => { return /a/; }
|
||||
|
||||
function foo() { return /a/; }
|
||||
|
||||
@@ -8,4 +8,12 @@ function bar() {
|
||||
|
||||
function foo() {
|
||||
return 1, "foo";
|
||||
}
|
||||
}
|
||||
|
||||
() => {
|
||||
return /a/;
|
||||
};
|
||||
|
||||
function foo() {
|
||||
return /a/;
|
||||
}
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
throw err;
|
||||
throw Error("foobar");
|
||||
throw new Error("foobar");
|
||||
throw /a/;
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
throw err;
|
||||
throw Error("foobar");
|
||||
throw new Error("foobar");
|
||||
throw new Error("foobar");
|
||||
throw /a/;
|
||||
|
||||
Reference in New Issue
Block a user