UNPKG

@isentinel/eslint-plugin-comment-length

Version:
29 lines 1.34 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.extractBlocksFromMultilineComment = void 0; const util_capture_next_block_1 = require("./util.capture-next-block"); const util_merge_lines_1 = require("./util.merge-lines"); function extractBlocksFromMultilineComment(context) { const blocks = []; let ignoreFollowingLines = false; // Processing multi-line comments becomes a tad more difficult than simply // parsing single-line comments since a single comment may contain // multiple logical comment blocks which should be handled individually. // // Thus our first step is to take a multi-line comment and convert it into // logical blocks for (let i = 0; i < context.comment.lines.length; i++) { if (i <= (blocks[blocks.length - 1]?.endIndex ?? -1)) { continue; } const [block, ignoreLines] = (0, util_capture_next_block_1.captureNextBlock)(ignoreFollowingLines, i, context); blocks.push({ ...block, value: block.lines.reduce((acc, curr) => (0, util_merge_lines_1.mergeLines)(acc, curr)), }); ignoreFollowingLines = ignoreLines; } return blocks; } exports.extractBlocksFromMultilineComment = extractBlocksFromMultilineComment; //# sourceMappingURL=util.extract-blocks.js.map