@@ -18,7 +18,7 @@ const (
18
18
ConfFileName = "commitlint.yaml"
19
19
)
20
20
21
- // GetConfig returns conf
21
+ // GetConfig returns parses config file and returns Config instance
22
22
func GetConfig (flagConfPath string ) (* lint.Config , error ) {
23
23
confFilePath , useDefault , err := GetConfigPath (flagConfPath )
24
24
if err != nil {
@@ -77,7 +77,7 @@ func Parse(confPath string) (*lint.Config, error) {
77
77
78
78
err = Validate (conf )
79
79
if err != nil {
80
- return nil , fmt .Errorf ("config error : %w" , err )
80
+ return nil , fmt .Errorf ("config: %w" , err )
81
81
}
82
82
return conf , nil
83
83
}
@@ -88,14 +88,25 @@ func Validate(conf *lint.Config) error {
88
88
return errors .New ("formatter is empty" )
89
89
}
90
90
91
- // Check Severity Level of rule config
91
+ _ , ok := globalRegistry .GetFormatter (conf .Formatter )
92
+ if ! ok {
93
+ return fmt .Errorf ("unknown formatter '%s'" , conf .Formatter )
94
+ }
95
+
92
96
for ruleName , r := range conf .Rules {
97
+ // Check Severity Level of rule config
93
98
switch r .Severity {
94
99
case lint .SeverityError :
95
100
case lint .SeverityWarn :
96
101
default :
97
102
return fmt .Errorf ("unknown severity level '%s' for rule '%s'" , r .Severity , ruleName )
98
103
}
104
+
105
+ // Check if rule is registered
106
+ _ , ok := globalRegistry .GetRule (ruleName )
107
+ if ! ok {
108
+ return fmt .Errorf ("unknown rule '%s'" , ruleName )
109
+ }
99
110
}
100
111
101
112
return nil
0 commit comments