@@ -315,14 +315,15 @@ Usage:
315
315
rslint [OPTIONS]
316
316
317
317
Options:
318
- --config PATH Which rslint config file to use. Defaults to rslint.json.
319
- --list-files List matched files
320
- --format FORMAT Output format: default | jsonline
321
- --fix Automatically fix problems
322
- --no-color Disable colored output
323
- --force-color Force colored output
324
- --quiet Report errors only
325
- -h, --help Show help
318
+ --config PATH Which rslint config file to use. Defaults to rslint.json.
319
+ --list-files List matched files
320
+ --format FORMAT Output format: default | jsonline
321
+ --fix Automatically fix problems
322
+ --no-color Disable colored output
323
+ --force-color Force colored output
324
+ --quiet Report errors only
325
+ --max-warnings Int Number of warnings to trigger nonzero exit code
326
+ -h, --help Show help
326
327
`
327
328
328
329
func runCMD () int {
@@ -341,6 +342,7 @@ func runCMD() int {
341
342
noColor bool
342
343
forceColor bool
343
344
quiet bool
345
+ maxWarnings int
344
346
)
345
347
flag .StringVar (& format , "format" , "default" , "output format" )
346
348
flag .StringVar (& config , "config" , "" , "which rslint config to use" )
@@ -351,6 +353,7 @@ func runCMD() int {
351
353
flag .BoolVar (& noColor , "no-color" , false , "disable colored output" )
352
354
flag .BoolVar (& forceColor , "force-color" , false , "force colored output" )
353
355
flag .BoolVar (& quiet , "quiet" , false , "report errors only" )
356
+ flag .IntVar (& maxWarnings , "max-warnings" , - 1 , "Number of warnings to trigger nonzero exit code" )
354
357
355
358
flag .StringVar (& traceOut , "trace" , "" , "file to put trace to" )
356
359
flag .StringVar (& cpuprofOut , "cpuprof" , "" , "file to put cpu profiling to" )
@@ -628,8 +631,17 @@ func runCMD() int {
628
631
}
629
632
}
630
633
634
+ tooManyWarnings := false
635
+ if maxWarnings >= 0 && warningsCount > maxWarnings {
636
+ tooManyWarnings = true
637
+ }
638
+
639
+ if errorsCount == 0 && tooManyWarnings {
640
+ fmt .Fprintf (os .Stderr , "Rslint found too many warnings (maximum: %d).\n " , maxWarnings )
641
+ }
642
+
631
643
// Exit with non-zero status code if errors were found
632
- if errorsCount > 0 {
644
+ if errorsCount > 0 || tooManyWarnings {
633
645
return 1
634
646
}
635
647
return 0
0 commit comments