Skip to content
This repository has been archived by the owner on Mar 23, 2024. It is now read-only.

requireVarDeclFirst: Fixing an edge case #2060

Closed
wants to merge 2 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions lib/rules/require-var-decl-first.js
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,14 @@ function getCommentOffsetBetweenNodes(previousNode, currentNode, commentTokens,
break;
}

if (previousNode.range[1] < currentNode.range[0] &&
comment.range[0] > previousNode.range[0] &&
comment.range[1] < previousNode.range[1]) {
// Stop processing comments that are within multiple declarators in a single variable declaration
// of the previous node and the previousNode is not the parent of currentNode
break;
}

if (comment.range[0] > currentNode.range[0] &&
comment.range[1] < currentNode.range[1]) {
// Stop processing comments that are within multiple declarators in a single variable declaration
Expand Down