File tree 1 file changed +21
-0
lines changed
1 file changed +21
-0
lines changed Original file line number Diff line number Diff line change @@ -88,6 +88,8 @@ 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 ()
92
+
91
93
if opts .CheckDeprecation {
92
94
err = l .handleDeprecation ()
93
95
if err != nil {
@@ -502,6 +504,25 @@ func (l *Loader) handleEnableOnlyOption() error {
502
504
return nil
503
505
}
504
506
507
+ // Overrides linter settings with formatter settings if the formatter is enabled.
508
+ func (l * Loader ) handleFormatterOverrides () {
509
+ if slices .Contains (l .cfg .Formatters .Enable , "gofmt" ) {
510
+ l .cfg .LintersSettings .GoFmt = l .cfg .Formatters .Settings .GoFmt
511
+ }
512
+
513
+ if slices .Contains (l .cfg .Formatters .Enable , "gofumpt" ) {
514
+ l .cfg .LintersSettings .GoFumpt = l .cfg .Formatters .Settings .GoFumpt
515
+ }
516
+
517
+ if slices .Contains (l .cfg .Formatters .Enable , "goimports" ) {
518
+ l .cfg .LintersSettings .GoImports = l .cfg .Formatters .Settings .GoImports
519
+ }
520
+
521
+ if slices .Contains (l .cfg .Formatters .Enable , "gci" ) {
522
+ l .cfg .LintersSettings .Gci = l .cfg .Formatters .Settings .Gci
523
+ }
524
+ }
525
+
505
526
func customDecoderHook () viper.DecoderConfigOption {
506
527
return viper .DecodeHook (mapstructure .ComposeDecodeHookFunc (
507
528
// Default hooks (https://github.com/spf13/viper/blob/518241257478c557633ab36e474dfcaeb9a3c623/viper.go#L135-L138).
You can’t perform that action at this time.
0 commit comments