UNPKG

@isentinel/eslint-plugin-comment-length

Version:
31 lines 1.16 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.captureNearbyComments = void 0; const util_merge_comments_1 = require("./util.merge-comments"); function captureNearbyComments(comments, startIndex) { let comment = comments[startIndex]; if (!comment) { return; } // Previous comments for (let i = startIndex - 1; i >= 0; i--) { const prevComment = comments[i]; if (!prevComment || (prevComment.loc?.end.line ?? 0) + 1 !== comment.loc?.start.line) { break; } comment = (0, util_merge_comments_1.mergeComments)(prevComment, comment, "\n"); } // Following comments for (let i = startIndex + 1; i < comments.length; i++) { const nextComment = comments[i]; if (!nextComment || nextComment.loc?.start.line !== (comment.loc?.end.line ?? 0) + 1) { break; } comment = (0, util_merge_comments_1.mergeComments)(comment, nextComment, "\n"); } return comment; } exports.captureNearbyComments = captureNearbyComments; //# sourceMappingURL=util.capture-nearby-comments.js.map