@@ -45,6 +45,46 @@ const core = __importStar(__nccwpck_require__(7484));
4545const exec = __importStar(__nccwpck_require__(5236));
4646const path = __importStar(__nccwpck_require__(6928));
4747const fs = __importStar(__nccwpck_require__(9896));
48+ function stripAnsi(input) {
49+ return input.replace(/[\u001B\u009B][[()\]#;?]*(?:[0-9]{1,4}(?:;[0-9]{0,4})*)?[0-9A-ORZcf-nqry=><]/g, '');
50+ }
51+ function parseFindings(output, workingDirectory) {
52+ const clean = stripAnsi(output);
53+ const lines = clean.split(/\r?\n/);
54+ const findings = [];
55+ for (let i = 0; i < lines.length; i++) {
56+ const loc = lines[i].match(/^(.+?):(\d+):(\d+)$/);
57+ if (!loc)
58+ continue;
59+ const [, relFile, lineStr, colStr] = loc;
60+ const next = lines[i + 1] || '';
61+ const sevLine = next.match(/^\s*(Error|Warning|Warn|Hint):\s*(.*?)(?:\s+\([^)]+\))?$/);
62+ if (!sevLine)
63+ continue;
64+ let sev = sevLine[1];
65+ const message = sevLine[2];
66+ if (sev === 'Warn')
67+ sev = 'Warning';
68+ const filePath = path.normalize(path.join(workingDirectory, relFile));
69+ const line = parseInt(lineStr, 10) || 1;
70+ const col = parseInt(colStr, 10) || 1;
71+ findings.push({ severity: sev, message, file: filePath, line, col });
72+ }
73+ return findings;
74+ }
75+ function annotateFromOutput(output, workingDirectory) {
76+ const findings = parseFindings(output, workingDirectory);
77+ for (const f of findings) {
78+ const props = { file: f.file, startLine: f.line, startColumn: f.col, title: 'svelte-check' };
79+ if (f.severity === 'Error')
80+ core.error(f.message, props);
81+ else if (f.severity === 'Warning')
82+ core.warning(f.message, props);
83+ else
84+ core.notice(f.message, props);
85+ }
86+ return findings;
87+ }
4888async function run() {
4989 try {
5090 const workingDirectory = core.getInput('working-directory') || '.';
@@ -54,7 +94,6 @@ async function run() {
5494 const matcherPath = path.join(__dirname, '..', '.github', 'svelte-check-matcher.json');
5595 core.info(`Adding problem matcher: ${matcherPath}`);
5696 console.log(`::add-matcher::${matcherPath}`);
57- // Detect SvelteKit and run `svelte-kit sync` to ensure .svelte-kit/tsconfig.json exists
5897 let looksLikeSvelteKit = false;
5998 try {
6099 const pkgJsonPath = path.join(workingDirectory, 'package.json');
@@ -100,9 +139,10 @@ async function run() {
100139 };
101140 const exitCode = await exec.exec(npx, args, options);
102141 core.info(`svelte-check exit code: ${exitCode}`);
103- const errorCount = (output.match(/Error:/g) || []).length;
104- const warningCount = (output.match(/Warning:/g) || []).length;
105- const hintCount = (output.match(/Hint:/g) || []).length;
142+ const findings = annotateFromOutput(output + '\n' + errorOutput, workingDirectory);
143+ const errorCount = findings.filter((f) => f.severity === 'Error').length;
144+ const warningCount = findings.filter((f) => f.severity === 'Warning').length;
145+ const hintCount = findings.filter((f) => f.severity === 'Hint').length;
106146 core.setOutput('errors', String(errorCount));
107147 core.setOutput('warnings', String(warningCount));
108148 core.setOutput('hints', String(hintCount));
@@ -123,7 +163,6 @@ async function run() {
123163 shouldFail = true;
124164 core.error(`Found ${hintCount} hints (fail-on-hints is enabled)`);
125165 }
126- // If svelte-check failed for other reasons, surface stderr
127166 if (!shouldFail && exitCode !== 0 && errorOutput.trim()) {
128167 shouldFail = true;
129168 core.error(errorOutput);
0 commit comments