Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/fresh-suits-glow.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@bomb.sh/tools": patch
---

In some failure or no-op cases, oxlint seems to return output which is not json-parseable even with --json passed. Log output directly in these instances.
43 changes: 25 additions & 18 deletions src/commands/lint.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,24 +25,31 @@ export async function runOxlint(targets: string[], fix?: boolean): Promise<Viola
const args = ['-c', oxlintConfig, '--format=json', ...targets];
if (fix) args.push('--fix');
const result = await x(local('oxlint'), args, { throwOnError: false });
const json = JSON.parse(result.stdout);
return (json.diagnostics ?? []).map(
(d: {
message: string;
code: string;
severity: string;
filename?: string;
labels?: Array<{ span?: { line?: number; column?: number } }>;
}) => ({
tool: 'oxlint' as const,
level: d.severity === 'error' ? 'error' : 'warning',
code: d.code ?? 'unknown',
message: d.message,
file: d.filename,
line: d.labels?.[0]?.span?.line,
column: d.labels?.[0]?.span?.column,
}),
);
try {
const json = JSON.parse(result.stdout);
return (json.diagnostics ?? []).map(
(d: {
message: string;
code: string;
severity: string;
filename?: string;
labels?: Array<{ span?: { line?: number; column?: number } }>;
}) => ({
tool: 'oxlint' as const,
level: d.severity === 'error' ? 'error' : 'warning',
code: d.code ?? 'unknown',
message: d.message,
file: d.filename,
line: d.labels?.[0]?.span?.line,
column: d.labels?.[0]?.span?.column,
}),
);
} catch {
// in some cases, failures or no-ops do not produce valid JSON
// fallback to raw output rather than throwing an error
console.log(result.stdout);
return [];
}
}

export async function runKnip(): Promise<Violation[]> {
Expand Down
Loading