@@ -88,7 +88,7 @@ func (l *Loader) Load(opts LoadOptions) error {
88
88
l .cfg .Linters .LinterExclusions .Rules = append (l .cfg .Linters .LinterExclusions .Rules , l .cfg .Issues .ExcludeRules ... )
89
89
}
90
90
91
- l .handleFormatterOverrides ()
91
+ l .handleFormatters ()
92
92
93
93
if opts .CheckDeprecation {
94
94
err = l .handleDeprecation ()
@@ -504,6 +504,11 @@ func (l *Loader) handleEnableOnlyOption() error {
504
504
return nil
505
505
}
506
506
507
+ func (l * Loader ) handleFormatters () {
508
+ l .handleFormatterOverrides ()
509
+ l .handleFormatterExclusions ()
510
+ }
511
+
507
512
// Overrides linter settings with formatter settings if the formatter is enabled.
508
513
func (l * Loader ) handleFormatterOverrides () {
509
514
if slices .Contains (l .cfg .Formatters .Enable , "gofmt" ) {
@@ -523,6 +528,22 @@ func (l *Loader) handleFormatterOverrides() {
523
528
}
524
529
}
525
530
531
+ // Add formatter exclusions to linters exclusions.
532
+ func (l * Loader ) handleFormatterExclusions () {
533
+ if len (l .cfg .Formatters .Enable ) == 0 {
534
+ return
535
+ }
536
+
537
+ for _ , path := range l .cfg .Formatters .Exclusions .Paths {
538
+ l .cfg .Linters .LinterExclusions .Rules = append (l .cfg .Linters .LinterExclusions .Rules , ExcludeRule {
539
+ BaseRule : BaseRule {
540
+ Linters : l .cfg .Formatters .Enable ,
541
+ Path : path ,
542
+ },
543
+ })
544
+ }
545
+ }
546
+
526
547
func customDecoderHook () viper.DecoderConfigOption {
527
548
return viper .DecodeHook (mapstructure .ComposeDecodeHookFunc (
528
549
// Default hooks (https://github.com/spf13/viper/blob/518241257478c557633ab36e474dfcaeb9a3c623/viper.go#L135-L138).
0 commit comments