Skip to content

Commit 5f74642

Browse files
authored
Chore: don't check Program.start in SourceCode#getComments (refs #14744) (#14748)
1 parent 19a871a commit 5f74642

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

lib/source-code/source-code.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -349,7 +349,7 @@ class SourceCode extends TokenStore {
349349
let currentToken = this.getTokenBefore(node, { includeComments: true });
350350

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

363363
while (currentToken && isCommentToken(currentToken)) {
364-
if (node.parent && (currentToken.end > node.parent.end)) {
364+
if (node.parent && node.parent.type !== "Program" && (currentToken.end > node.parent.end)) {
365365
break;
366366
}
367367
comments.trailing.push(currentToken);

0 commit comments

Comments
 (0)