Skip to content

Commit

Permalink
Chore: don't check Program.start in SourceCode#getComments (refs #14744
Browse files Browse the repository at this point in the history
…) (#14748)
  • Loading branch information
mdjermanovic committed Jul 2, 2021
1 parent 19a871a commit 5f74642
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions lib/source-code/source-code.js
Expand Up @@ -349,7 +349,7 @@ class SourceCode extends TokenStore {
let currentToken = this.getTokenBefore(node, { includeComments: true });

while (currentToken && isCommentToken(currentToken)) {
if (node.parent && (currentToken.start < node.parent.start)) {
if (node.parent && node.parent.type !== "Program" && (currentToken.start < node.parent.start)) {
break;
}
comments.leading.push(currentToken);
Expand All @@ -361,7 +361,7 @@ class SourceCode extends TokenStore {
currentToken = this.getTokenAfter(node, { includeComments: true });

while (currentToken && isCommentToken(currentToken)) {
if (node.parent && (currentToken.end > node.parent.end)) {
if (node.parent && node.parent.type !== "Program" && (currentToken.end > node.parent.end)) {
break;
}
comments.trailing.push(currentToken);
Expand Down

0 comments on commit 5f74642

Please sign in to comment.