From 5010b289f35d8ebc13f4b8d442b453aae4bf2cf2 Mon Sep 17 00:00:00 2001 From: Claude Date: Fri, 9 Oct 2026 08:49:41 +0000 Subject: [PATCH] fix(scripts): show cspell suggestions in filename lint annotations cspell reports stdin entries with an empty file name, so the previous regex never matched and no ::error annotations were emitted. Allow the empty file name and include cspell's suggestions in the annotation message. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01WWiYD36q9Zg9sRvGLHn4q3 --- scripts/lintFilenames.mts | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/scripts/lintFilenames.mts b/scripts/lintFilenames.mts index 912068be3..9398286d5 100644 --- a/scripts/lintFilenames.mts +++ b/scripts/lintFilenames.mts @@ -3,12 +3,17 @@ import fs from 'fs'; import process from 'process'; import { spawn } from 'child_process'; -const regex = /(?[^:]+):(?\d+):(?\d+)\s-\s+(?.+)/; +// cspell reports stdin entries without a file name, e.g. +// `:1:7 - Unknown word (arow) Suggestions: [alow, arrow]` +const regex = + /(?[^:]*):(?\d+):(?\d+)\s-\s+(?.+?)(?:\s+Suggestions:\s+\[(?[^\]]*)\])?$/; const fileList = process.env.CHANGED_FILES ? (process.env.CHANGED_FILES || '').split(' ') : fs.readdirSync('./icons').map((fileName) => path.join('./icons', fileName)); -const cspell = spawn('npx', ['cspell', 'stdin'], { stdio: ['pipe', 'pipe', 'inherit'] }); +const cspell = spawn('npx', ['cspell', 'stdin', '--show-suggestions'], { + stdio: ['pipe', 'pipe', 'inherit'], +}); cspell.stdin.write(fileList.join('\n')); cspell.stdin.end(); @@ -20,8 +25,11 @@ cspell.stdout.on('data', (data) => { .forEach((line: string) => { const match = line.match(regex); if (match) { - const { line, message } = match.groups ?? {}; - console.log(`::error file=${fileList[Number(line) - 1]},line=1,column=1::${message}`); + const { line, message, suggestions } = match.groups ?? {}; + const hint = suggestions ? ` Did you mean: ${suggestions}?` : ''; + console.log( + `::error file=${fileList[Number(line) - 1]},line=1,column=1::${message}.${hint}`, + ); } }); });