eslint-plugin-comment-length
Version:
An ESLint plugin that provides rules that limit the line length of your comments
37 lines (33 loc) • 1.13 kB
JavaScript
;
var const_messageIds = require('../../const.message-ids.cjs');
var fix_overflow = require('./fix.overflow.cjs');
var util_canBlockBeCompacted = require('./util.can-block-be-compacted.cjs');
function reportCompactableBlocks(ruleContext, baseComment, context, blocks) {
if (context.mode !== "compact") {
return;
}
for (const block of blocks) {
if (!util_canBlockBeCompacted.canBlockBeCompated(block, context)) {
continue;
}
ruleContext.report({
loc: {
start: {
column: 0,
line: baseComment.loc.start.line + block.startIndex
},
end: {
column: baseComment.loc.start.column + context.boilerplateSize + (block.lines.at(-1)?.length ?? 0),
line: baseComment.loc.start.line + block.endIndex
}
},
messageId: const_messageIds.MessageIds.CAN_COMPACT,
data: {
maxLength: context.maxLength
},
fix: (fixer) => fix_overflow.fixOverflowingBlock(fixer, block, context)
});
}
}
exports.reportCompactableBlocks = reportCompactableBlocks;
//# sourceMappingURL=report.compact.cjs.map