diff --git a/.changeset/smart-garlics-shop.md b/.changeset/smart-garlics-shop.md new file mode 100644 index 000000000..32885e007 --- /dev/null +++ b/.changeset/smart-garlics-shop.md @@ -0,0 +1,5 @@ +--- +'@kitajs/ts-html-plugin': patch +--- + +Improved xss-scan cli errors diff --git a/packages/ts-html-plugin/src/cli.ts b/packages/ts-html-plugin/src/cli.ts index c2afbdd6d..8874f4356 100644 --- a/packages/ts-html-plugin/src/cli.ts +++ b/packages/ts-html-plugin/src/cli.ts @@ -35,7 +35,7 @@ Examples: Exit codes: 0 - No XSS vulnerabilities were found 1 - XSS vulnerabilities were found - 2 - Only XSS warnings were found + 2 - Only warnings were found `.trim(); @@ -43,7 +43,7 @@ function readCompilerOptions(tsconfigPath: string) { const { config, error } = ts.readConfigFile(tsconfigPath, ts.sys.readFile); if (error) { - throw error; + return { errors: [error] }; } const { options, errors, fileNames } = ts.parseJsonConfigFileContent( @@ -70,7 +70,7 @@ function prettyPrintErrorCount(diagnostics: ts.Diagnostic[], root: string) { continue; } - const file = files.get(diagnostic.file.fileName)!; + const file = files.get(diagnostic.file.fileName); if (file !== undefined) { files.set(diagnostic.file.fileName, file + 1); @@ -208,7 +208,7 @@ async function main() { } ts.forEachChild(source, function loopSourceNodes(node) { - recursiveDiagnoseJsxElements(ts as any, node, typeChecker, diagnostics); + recursiveDiagnoseJsxElements(ts, node, typeChecker, diagnostics); }); }