UNPKG

eslint-plugin-comment-length

Version:

An ESLint plugin that provides rules that limit the line length of your comments

27 lines (23 loc) 1.3 kB
'use strict'; var isLineOverflowing = require('../../utils/is-line-overflowing.cjs'); var isOnOwnLine = require('../../utils/is-on-own-line.cjs'); var isSemanticComment = require('../../utils/is-semantic-comment.cjs'); var util_mergeComments = require('./util.merge-comments.cjs'); function captureRelevantCommentsIntoBlock(sourceCode, comments, startIndex, context) { let comment = comments[startIndex]; if (!comment) { return { mergedComment: void 0, startIndex, endIndex: startIndex }; } let endIndex = startIndex; for (let i = startIndex + 1; i < comments.length; i++) { const nextComment = comments[i]; if (context.mode === "overflow-only" && !isLineOverflowing.isLineOverflowing(comment.value, context) || !nextComment || nextComment.value.trim() === "" || nextComment.loc?.start.line !== (comment.loc?.end.line ?? 0) + 1 || isSemanticComment.isSemanticComment(nextComment, context.semanticComments) || !isOnOwnLine.isCommentOnOwnLine(sourceCode, nextComment)) { break; } comment = util_mergeComments.mergeComments(comment, nextComment); endIndex = i; } return { mergedComment: comment, startIndex, endIndex }; } exports.captureRelevantCommentsIntoBlock = captureRelevantCommentsIntoBlock; //# sourceMappingURL=util.capture-relevant-comments.cjs.map