diff --git a/src/printer.js b/src/printer.js index 229c36377..2e975a3c6 100644 --- a/src/printer.js +++ b/src/printer.js @@ -3255,7 +3255,6 @@ function hasLeadingOwnLineComment(text, node) { node.comments.some( comment => comment.leading && - util.hasNewline(text, util.locStart(comment), { backwards: true }) && util.hasNewline(text, util.locEnd(comment)) ); return res; diff --git a/tests/comments/__snapshots__/jsfmt.spec.js.snap b/tests/comments/__snapshots__/jsfmt.spec.js.snap index 37bdc08cb..3ebc42676 100644 --- a/tests/comments/__snapshots__/jsfmt.spec.js.snap +++ b/tests/comments/__snapshots__/jsfmt.spec.js.snap @@ -839,6 +839,12 @@ function sequenceExpression() { ), b } +function sequenceExpressionInside() { + return ( // Reason for a + a, b + ); +} + function taggedTemplate() { return ( // Reason for a @@ -963,6 +969,13 @@ function sequenceExpression() { ); } +function sequenceExpressionInside() { + return ( + // Reason for a + a, b + ); +} + function taggedTemplate() { return ( // Reason for a diff --git a/tests/comments/return-statement.js b/tests/comments/return-statement.js index 51dd75abc..69e1555cf 100644 --- a/tests/comments/return-statement.js +++ b/tests/comments/return-statement.js @@ -100,6 +100,12 @@ function sequenceExpression() { ), b } +function sequenceExpressionInside() { + return ( // Reason for a + a, b + ); +} + function taggedTemplate() { return ( // Reason for a