eslint-plugin-comment-length
Version:
An ESLint plugin that provides rules that limit the line length of your comments
35 lines (32 loc) • 1.03 kB
JavaScript
import { MessageIds } from '../../const.message-ids.js';
import { fixOverflowingBlock } from './fix.overflow.js';
import { canBlockBeCompated } from './util.can-block-be-compacted.js';
function reportCompactableBlocks(ruleContext, baseComment, context, blocks) {
if (context.mode !== "compact") {
return;
}
for (const block of blocks) {
if (!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: MessageIds.CAN_COMPACT,
data: {
maxLength: context.maxLength
},
fix: (fixer) => fixOverflowingBlock(fixer, block, context)
});
}
}
export { reportCompactableBlocks };
//# sourceMappingURL=report.compact.js.map