@isentinel/eslint-plugin-comment-length
Version:
31 lines • 1.55 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.captureRelevantCommentsIntoBlock = void 0;
const is_line_overflowing_1 = require("../../utils/is-line-overflowing");
const is_on_own_line_1 = require("../../utils/is-on-own-line");
const is_semantic_comment_1 = require("../../utils/is-semantic-comment");
const util_merge_comments_1 = require("./util.merge-comments");
function captureRelevantCommentsIntoBlock(sourceCode, comments, startIndex, context) {
let comment = comments[startIndex];
if (!comment) {
return { mergedComment: undefined, startIndex, endIndex: startIndex };
}
let endIndex = startIndex;
for (let i = startIndex + 1; i < comments.length; i++) {
const nextComment = comments[i];
if ((context.mode === "overflow-only" &&
!(0, is_line_overflowing_1.isLineOverflowing)(comment.value, context)) ||
!nextComment ||
nextComment.value.trim() === "" ||
nextComment.loc?.start.line !== (comment.loc?.end.line ?? 0) + 1 ||
(0, is_semantic_comment_1.isSemanticComment)(nextComment) ||
!(0, is_on_own_line_1.isCommentOnOwnLine)(sourceCode, nextComment)) {
break;
}
comment = (0, util_merge_comments_1.mergeComments)(comment, nextComment);
endIndex = i;
}
return { mergedComment: comment, startIndex, endIndex };
}
exports.captureRelevantCommentsIntoBlock = captureRelevantCommentsIntoBlock;
//# sourceMappingURL=util.capture-relevant-comments.js.map