@felixgeelhaar/cclint
Version:
A comprehensive linter for CLAUDE.md files with multi-language code block validation
56 lines âĸ 1.8 kB
JavaScript
import { LintingResult } from '../../domain/LintingResult.js';
import { Severity } from '../../domain/Severity.js';
export function formatResult(result, format = 'text') {
if (format === 'json') {
return formatJsonResult(result);
}
return formatTextResult(result);
}
function formatTextResult(result) {
const lines = [];
if (!result.hasViolations()) {
lines.push(`â
No issues found in ${result.file.path}`);
return lines.join('\n');
}
lines.push(`đ Linting results for ${result.file.path}:`);
lines.push('');
for (const violation of result.violations) {
const icon = getSeverityIcon(violation.severity);
lines.push(`${icon} ${violation.toString()}`);
}
lines.push('');
lines.push(`Summary: ${result.getErrorCount()} errors, ${result.getWarningCount()} warnings`);
return lines.join('\n');
}
function formatJsonResult(result) {
const jsonResult = {
file: result.file.path,
violations: result.violations.map(violation => ({
ruleId: violation.ruleId,
message: violation.message,
severity: violation.severity.name,
location: {
line: violation.location.line,
column: violation.location.column,
},
})),
summary: {
errors: result.getErrorCount(),
warnings: result.getWarningCount(),
infos: result.getInfoCount(),
},
};
return JSON.stringify(jsonResult, null, 2);
}
function getSeverityIcon(severity) {
if (severity === Severity.ERROR) {
return 'â';
}
else if (severity === Severity.WARNING) {
return 'â ī¸';
}
else {
return 'âšī¸';
}
}
//# sourceMappingURL=textFormatter.js.map