File tree Expand file tree Collapse file tree 1 file changed +21
-0
lines changed Expand file tree Collapse file tree 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 {
8888 l .cfg .Linters .LinterExclusions .Rules = append (l .cfg .Linters .LinterExclusions .Rules , l .cfg .Issues .ExcludeRules ... )
8989 }
9090
91+ l .handleFormatterOverrides ()
92+
9193 if opts .CheckDeprecation {
9294 err = l .handleDeprecation ()
9395 if err != nil {
@@ -502,6 +504,25 @@ func (l *Loader) handleEnableOnlyOption() error {
502504 return nil
503505}
504506
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+
505526func customDecoderHook () viper.DecoderConfigOption {
506527 return viper .DecodeHook (mapstructure .ComposeDecodeHookFunc (
507528 // 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