File tree 2 files changed +28
-3
lines changed
2 files changed +28
-3
lines changed Original file line number Diff line number Diff line change @@ -28,6 +28,9 @@ func setupLintersFlagSet(v *viper.Viper, fs *pflag.FlagSet) {
28
28
fs .StringSliceP ("presets" , "p" , nil ,
29
29
color .GreenString (fmt .Sprintf ("Enable presets (%s) of linters. Run 'golangci-lint help linters' to see " +
30
30
"them. This option implies option --disable-all" , strings .Join (lintersdb .AllPresets (), "|" ))))
31
+
32
+ fs .StringSlice ("enable-only" , nil ,
33
+ color .GreenString ("Override linters configuration section to only run the specific linter(s)" )) // Flags only.
31
34
}
32
35
33
36
func setupRunFlagSet (v * viper.Viper , fs * pflag.FlagSet ) {
Original file line number Diff line number Diff line change @@ -61,6 +61,27 @@ func (l *Loader) Load() error {
61
61
62
62
l .handleGoVersion ()
63
63
64
+ err = l .handleEnableOnlyOption ()
65
+ if err != nil {
66
+ return err
67
+ }
68
+
69
+ return nil
70
+ }
71
+
72
+ func (l * Loader ) handleEnableOnlyOption () error {
73
+ only , err := l .fs .GetStringSlice ("enable-only" )
74
+ if err != nil {
75
+ return err
76
+ }
77
+
78
+ if len (only ) > 0 {
79
+ l .cfg .Linters = Linters {
80
+ Enable : only ,
81
+ DisableAll : true ,
82
+ }
83
+ }
84
+
64
85
return nil
65
86
}
66
87
@@ -73,13 +94,14 @@ func (l *Loader) handleGoVersion() {
73
94
74
95
l .cfg .LintersSettings .ParallelTest .Go = l .cfg .Run .Go
75
96
76
- trimmedGoVersion := trimGoVersion (l .cfg .Run .Go )
77
-
78
- l .cfg .LintersSettings .Gocritic .Go = trimmedGoVersion
79
97
if l .cfg .LintersSettings .Gofumpt .LangVersion == "" {
80
98
l .cfg .LintersSettings .Gofumpt .LangVersion = l .cfg .Run .Go
81
99
}
82
100
101
+ trimmedGoVersion := trimGoVersion (l .cfg .Run .Go )
102
+
103
+ l .cfg .LintersSettings .Gocritic .Go = trimmedGoVersion
104
+
83
105
// staticcheck related linters.
84
106
if l .cfg .LintersSettings .Staticcheck .GoVersion == "" {
85
107
l .cfg .LintersSettings .Staticcheck .GoVersion = trimmedGoVersion
You can’t perform that action at this time.
0 commit comments