eslint-plugin-comment-length
Version:
An ESLint plugin that provides rules that limit the line length of your comments
21 lines (18 loc) • 725 B
JavaScript
import { isURL } from '../../utils/is-url.js';
function canBlockBeCompated(comments, block, context) {
for (let i = block.startIndex + 1; i <= block.endIndex; i++) {
const prev = comments[i - 1];
const curr = comments[i];
if (!prev || !curr || context.ignoreUrls && isURL(curr?.value)) {
continue;
}
const firstWordOnCurrentLine = curr.value.trim().split(" ")[0];
const lengthOfPrevLine = prev.value.length + context.boilerplateSize + context.whitespace.size + 1;
if (lengthOfPrevLine + 1 + (firstWordOnCurrentLine?.length ?? 0) <= context.maxLength) {
return true;
}
}
return false;
}
export { canBlockBeCompated };
//# sourceMappingURL=util.can-block-be-compacted.js.map