eslint-plugin-comment-length
Version:
An ESLint plugin that provides rules that limit the line length of your comments
30 lines (27 loc) • 1.02 kB
JavaScript
import { MessageIds } from '../../const.message-ids.js';
import { fixOverflowingBlock } from './fix.overflow.js';
function reportOverflowingBlocks(ruleContext, baseComment, context, overflowingBlocks) {
for (const fixableBlock of overflowingBlocks) {
ruleContext.report({
// Ensure we only highlight exactly the block within the multi-line
// comment which violates the rule.
loc: {
start: {
column: 0,
line: baseComment.loc.start.line + fixableBlock.startIndex
},
end: {
column: baseComment.loc.start.column + context.boilerplateSize + (fixableBlock.lines.at(-1)?.length ?? 0),
line: baseComment.loc.start.line + fixableBlock.endIndex
}
},
messageId: MessageIds.EXCEEDS_MAX_LENGTH,
data: {
maxLength: context.maxLength
},
fix: (fixer) => fixOverflowingBlock(fixer, fixableBlock, context)
});
}
}
export { reportOverflowingBlocks };
//# sourceMappingURL=report.overflow.js.map