Replace normalizeParts with safer cleanDoc (#9844)

This commit is contained in:
fisker Cheung authored and GitHub committed 2020-12-17 08:39:23 +08:00
1 parent 2f930ee314
commit 790c8ee9db
1 file changed
+9 -3
+9 -3
View File
@@ -4,7 +4,7 @@ const { printComments } = require("../../main/comments");
const { getLast } = require("../../common/util");
const {
builders: { concat, join, line, softline, group, indent, align, ifBreak },
utils: { normalizeParts },
utils: { cleanDoc },
} = require("../../document");
const {
hasLeadingOwnLineComment,
@@ -271,9 +271,15 @@ function printBinaryishExpressions(
// the other ones since we don't call the normal print on BinaryExpression,
// only for the left and right parts
if (isNested && hasComment(node)) {
parts = normalizeParts(
printComments(path, () => concat(parts), options).parts
const printed = cleanDoc(
printComments(path, () => concat(parts), options)
);
/* istanbul ignore if */
if (printed.type === "string") {
parts = [printed];
} else {
parts = printed.parts;
}
}
} else {
// Our stopping case. Simply print the node normally.