diff --git a/lib/source-code/source-code.js b/lib/source-code/source-code.js index 591d5a7e454e..e9c318c05348 100644 --- a/lib/source-code/source-code.js +++ b/lib/source-code/source-code.js @@ -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 && (currentToken.range[0] < node.parent.range[0])) { break; } comments.leading.push(currentToken); @@ -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 && (currentToken.range[1] > node.parent.range[1])) { break; } comments.trailing.push(currentToken);