UNPKG

markuplint

Version:

An HTML linter for all markup developers

31 lines (30 loc) 1.06 kB
import { messageToString } from '@markuplint/cli-utils'; /** * Formats lint results as GitHub Actions workflow commands. * * Each violation is emitted as a `::error`, `::warning`, or `::notice` command * that GitHub Actions interprets as an inline annotation on the affected file and line. * * @param results - The lint result information for a single file. * @returns An array of GitHub Actions workflow command strings. */ export function githubReporter(results) { const out = []; for (const violation of results.violations) { const command = severityToCommand(violation.severity); const meg = messageToString(violation.message, violation.reason); out.push(`::${command} file=${results.filePath},line=${violation.line},col=${violation.col}::${meg} (${violation.ruleId})`); } return out; } function severityToCommand(severity) { switch (severity) { case 'info': { return 'notice'; } case 'error': case 'warning': { return severity; } } }