Skip to content

Commit 940d8f2

Browse files
committed
feat(cli): add --failures-only flag to filter diagnostic output
Only prints errors and messages (diagnostics that cause exit code 1), suppressing warnings and suggestions. Counts are still tracked for the summary.
1 parent f31796a commit 940d8f2

1 file changed

Lines changed: 8 additions & 2 deletions

File tree

packages/cli/index.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ Options:
2222
--filter <glob...> Filter files to lint
2323
--fix Apply automatic fixes
2424
--force Ignore cache
25+
--failures-only Only print diagnostics that cause exit code 1 (errors and messages)
2526
-h, --help Show this help message
2627
2728
Examples:
@@ -193,6 +194,7 @@ class Project {
193194
let messages = 0;
194195
let suggestions = 0;
195196
let cached = 0;
197+
const failuresOnly = process.argv.includes('--failures-only');
196198

197199
if (isTTY) {
198200
const write = process.stdout.write.bind(process.stdout);
@@ -551,15 +553,19 @@ class Project {
551553
}
552554
else if (diagnostic.category === ts.DiagnosticCategory.Warning) {
553555
warnings++;
554-
log(output, 2);
556+
if (!failuresOnly) {
557+
log(output, 2);
558+
}
555559
}
556560
else if (diagnostic.category === ts.DiagnosticCategory.Message) {
557561
messages++;
558562
log(output);
559563
}
560564
else {
561565
suggestions++;
562-
log(output);
566+
if (!failuresOnly) {
567+
log(output);
568+
}
563569
}
564570
}
565571
}

0 commit comments

Comments
 (0)