diff --git a/pkg/lint/lintersdb/lintersdb.go b/pkg/lint/lintersdb/lintersdb.go index a1856fca..67853e7c 100644 --- a/pkg/lint/lintersdb/lintersdb.go +++ b/pkg/lint/lintersdb/lintersdb.go @@ -256,7 +256,7 @@ func validateAllDisableEnableOptions(cfg *config.Linters) error { } } - if cfg.EnableAll && len(cfg.Enable) != 0 { + if cfg.EnableAll && len(cfg.Enable) != 0 && !cfg.Fast { return fmt.Errorf("can't combine options --enable-all and --enable %s", cfg.Enable[0]) } diff --git a/test/run_test.go b/test/run_test.go index b1af7ed8..993ba32e 100644 --- a/test/run_test.go +++ b/test/run_test.go @@ -139,6 +139,19 @@ func getEnabledByDefaultFastLintersExcept(except ...string) []string { return ret } +func getAllFastLintersWith(with ...string) []string { + linters := lintersdb.GetAllSupportedLinterConfigs() + ret := append([]string{}, with...) + for _, linter := range linters { + if linter.DoesFullImport { + continue + } + ret = append(ret, linter.Linter.Name()) + } + + return ret +} + func getEnabledByDefaultLinters() []string { ebdl := lintersdb.GetAllEnabledByDefaultLinters() ret := []string{} @@ -180,6 +193,15 @@ func mergeMegacheck(linters []string) []string { return linters } +func TestEnableAllFastAndEnableCanCoexist(t *testing.T) { + out, exitCode := runGolangciLint(t, "--fast", "--enable-all", "--enable=typecheck") + checkNoIssuesRun(t, out, exitCode) + + _, exitCode = runGolangciLint(t, "--enable-all", "--enable=typecheck") + assert.Equal(t, 3, exitCode) + +} + func TestEnabledLinters(t *testing.T) { type tc struct { name string @@ -267,6 +289,12 @@ func TestEnabledLinters(t *testing.T) { el: getEnabledByDefaultLinters(), noImplicitFast: true, }, + { + name: "fast option combined with enable and enable-all", + args: "--enable-all --fast --enable=typecheck", + el: getAllFastLintersWith("typecheck"), + noImplicitFast: true, + }, } for _, c := range cases {