File tree Expand file tree Collapse file tree 3 files changed +19
-14
lines changed
Expand file tree Collapse file tree 3 files changed +19
-14
lines changed Original file line number Diff line number Diff line change @@ -64,6 +64,7 @@ func (c *Config) Validate() error {
6464 c .Run .Validate ,
6565 c .Output .Validate ,
6666 c .Linters .Validate ,
67+ c .Formatters .Validate ,
6768 c .Severity .Validate ,
6869 }
6970
Original file line number Diff line number Diff line change 11package config
22
3+ import (
4+ "fmt"
5+ "slices"
6+ )
7+
38type Formatters struct {
49 Enable []string `mapstructure:"enable"`
510 Settings FormatterSettings `mapstructure:"settings"`
611 Exclusions FormatterExclusions `mapstructure:"exclusions"`
712}
813
14+ func (f * Formatters ) Validate () error {
15+ for _ , n := range f .Enable {
16+ if ! slices .Contains (getAllFormatterNames (), n ) {
17+ return fmt .Errorf ("%s is a formatter" , n )
18+ }
19+ }
20+
21+ return nil
22+ }
23+
924type FormatterExclusions struct {
1025 Generated string `mapstructure:"generated"`
1126 Paths []string `mapstructure:"paths"`
Original file line number Diff line number Diff line change @@ -26,8 +26,7 @@ type Linters struct {
2626func (l * Linters ) Validate () error {
2727 validators := []func () error {
2828 l .Exclusions .Validate ,
29- l .validateNoFormattersEnabled ,
30- l .validateNoFormattersDisabled ,
29+ l .validateNoFormatters ,
3130 }
3231
3332 for _ , v := range validators {
@@ -39,18 +38,8 @@ func (l *Linters) Validate() error {
3938 return nil
4039}
4140
42- func (l * Linters ) validateNoFormattersEnabled () error {
43- for _ , n := range l .Enable {
44- if slices .Contains (getAllFormatterNames (), n ) {
45- return fmt .Errorf ("%s is a formatter" , n )
46- }
47- }
48-
49- return nil
50- }
51-
52- func (l * Linters ) validateNoFormattersDisabled () error {
53- for _ , n := range l .Disable {
41+ func (l * Linters ) validateNoFormatters () error {
42+ for _ , n := range slices .Concat (l .Enable , l .Disable ) {
5443 if slices .Contains (getAllFormatterNames (), n ) {
5544 return fmt .Errorf ("%s is a formatter" , n )
5645 }
You can’t perform that action at this time.
0 commit comments