Avoid unnecessary print() in printStatementSequence (#14255)
This commit is contained in:
1 parent
5d4380372e
commit
bad0906a8d
1 file changed
+10
-12
@@ -29,22 +29,20 @@ function printStatementSequence(path, options, print) {
|
||||
return;
|
||||
}
|
||||
|
||||
const printed = print();
|
||||
const needsSemi =
|
||||
!options.semi &&
|
||||
!isTheOnlyJsxElementInMarkdown(options, path) &&
|
||||
statementNeedsASIProtection(path, options);
|
||||
|
||||
// in no-semi mode, prepend statement with semicolon if it might break ASI
|
||||
// don't prepend the only JSX element in a program with semicolon
|
||||
if (
|
||||
!options.semi &&
|
||||
!isTheOnlyJsxElementInMarkdown(options, path) &&
|
||||
statementNeedsASIProtection(path, options)
|
||||
) {
|
||||
if (hasComment(node, CommentCheckFlags.Leading)) {
|
||||
parts.push(print([], { needsSemi: true }));
|
||||
} else {
|
||||
parts.push(";", printed);
|
||||
}
|
||||
if (needsSemi && hasComment(node, CommentCheckFlags.Leading)) {
|
||||
parts.push(print([], { needsSemi: true }));
|
||||
} else {
|
||||
parts.push(printed);
|
||||
if (needsSemi) {
|
||||
parts.push(";");
|
||||
}
|
||||
parts.push(print());
|
||||
}
|
||||
|
||||
if (node !== lastStatement) {
|
||||
|
||||
Reference in new issue
Block a user