eslint-plugin-comment-length
Version:
An ESLint plugin that provides rules that limit the line length of your comments
29 lines (25 loc) • 901 B
JavaScript
;
var util_mergeComments = require('./util.merge-comments.cjs');
function captureNearbyComments(comments, startIndex) {
let comment = comments[startIndex];
if (!comment) {
return;
}
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 = util_mergeComments.mergeComments(prevComment, comment, "\n");
}
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 = util_mergeComments.mergeComments(comment, nextComment, "\n");
}
return comment;
}
exports.captureNearbyComments = captureNearbyComments;
//# sourceMappingURL=util.capture-nearby-comments.cjs.map