UNPKG

@felixgeelhaar/cclint

Version:

A comprehensive linter for CLAUDE.md files with multi-language code block validation

41 lines 1.25 kB
export class ContextFile { path; content; lines; constructor(path, content) { if (path.trim() === '') { throw new Error('File path cannot be empty'); } this.path = path; this.content = content; this.lines = content.split('\n'); } static fromFile(filePath) { const fs = require('fs'); const content = fs.readFileSync(filePath, 'utf-8'); return new ContextFile(filePath, content); } getLineCount() { return this.lines.length; } getCharacterCount() { return this.content.length; } getLine(lineNumber) { if (lineNumber <= 0) { throw new Error('Line number must be positive'); } if (lineNumber > this.lines.length) { throw new Error(`Line number ${lineNumber} is out of range`); } return this.lines[lineNumber - 1] ?? ''; } hasSection(sectionTitle) { const headerRegex = new RegExp(`^#{1,6}\\s+${this.escapeRegExp(sectionTitle)}\\s*$`, 'm'); return headerRegex.test(this.content); } escapeRegExp(string) { return string.replace(/[.*+?^${}()|[\]\\]/g, '\\$&'); } } //# sourceMappingURL=ContextFile.js.map