Skip to content

Commit

Permalink
Use node.loc.end.line instead of start.line in certain comparison…
Browse files Browse the repository at this point in the history
…s (just in case)
  • Loading branch information
fbartho committed May 12, 2023
1 parent 6eadf55 commit ec11257
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/utils/get-comment-registry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -149,11 +149,11 @@ const attachCommentsToRegistryMap = <

// LeadingGap is used with firstImport to protect top-of-file comments, and pick the right ImportSpecifier when Specifiers are re-sorted
const hasLeadingGap =
(comment.loc?.start.line || 0) < (owner.loc?.start.line || 0) - 1;
(comment.loc?.end.line || 0) < (owner.loc?.start.line || 0) - 1;

// TrailingGap is used with lastImport to protect bottom-of-imports comments, and pick the right ImportSpecifier when Specifiers are re-sorted
const hasTrailingGap =
(comment.loc?.start.line || 0) > (owner.loc?.start.line || 0) + 1;
(comment.loc?.start.line || 0) > (owner.loc?.end.line || 0) + 1;

if (attachmentKey === 'trailingComments') {
// Trailing comments might be on the same line "attached"
Expand Down

0 comments on commit ec11257

Please sign in to comment.