Further improve handleParenthesizedExpressionTrailingComment (#19282)
This commit is contained in:
1 parent
296fbe6b7f
commit
cecb09abac
1 file changed
+4
-5
@@ -1079,7 +1079,7 @@ function handleParenthesizedExpressionTrailingComment({
|
|||||||
precedingNode,
|
precedingNode,
|
||||||
followingNode,
|
followingNode,
|
||||||
}) {
|
}) {
|
||||||
if (!followingNode && enclosingNode) {
|
if (!followingNode && enclosingNode && precedingNode) {
|
||||||
if (
|
if (
|
||||||
enclosingNode.type === "ExpressionStatement" &&
|
enclosingNode.type === "ExpressionStatement" &&
|
||||||
enclosingNode.expression === precedingNode
|
enclosingNode.expression === precedingNode
|
||||||
@@ -1088,8 +1088,8 @@ function handleParenthesizedExpressionTrailingComment({
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
const isSequence = precedingNode?.type === "SequenceExpression";
|
const isSequence = precedingNode.type === "SequenceExpression";
|
||||||
const isAssignment = precedingNode?.type === "AssignmentExpression";
|
const isAssignment = precedingNode.type === "AssignmentExpression";
|
||||||
|
|
||||||
if (
|
if (
|
||||||
(isSequence || isAssignment) &&
|
(isSequence || isAssignment) &&
|
||||||
@@ -1099,8 +1099,7 @@ function handleParenthesizedExpressionTrailingComment({
|
|||||||
enclosingNode.init === precedingNode) ||
|
enclosingNode.init === precedingNode) ||
|
||||||
(enclosingNode.type === "ReturnStatement" &&
|
(enclosingNode.type === "ReturnStatement" &&
|
||||||
enclosingNode.argument === precedingNode) ||
|
enclosingNode.argument === precedingNode) ||
|
||||||
(isSequence &&
|
(enclosingNode.type === "AssignmentExpression" &&
|
||||||
enclosingNode.type === "AssignmentExpression" &&
|
|
||||||
enclosingNode.right === precedingNode))
|
enclosingNode.right === precedingNode))
|
||||||
) {
|
) {
|
||||||
addTrailingComment(
|
addTrailingComment(
|
||||||
|
|||||||
Reference in new issue
Block a user