diff --git a/index.ts b/index.ts index fd070f3..b8d8924 100644 --- a/index.ts +++ b/index.ts @@ -219,6 +219,10 @@ function formatDiagnostics(result: unknown, limit = 20): string { 4: "Hint", }; + // Sort By Severity - Errors first, then warnings, info, hints. Ensures + // the most actionable issues survive truncation. + diags.sort((a: any, b: any) => (a.severity ?? 99) - (b.severity ?? 99)); + const shown = diags.slice(0, limit); const formatted = shown .map((d: any, i: number) => {