@@ -3,15 +3,14 @@ package config
3
3
import (
4
4
"fmt"
5
5
6
- "golang.org/x/mod/semver"
7
-
8
6
"github.com/conventionalcommit/commitlint/lint"
9
7
)
10
8
11
9
// GetLinter returns Linter for given confFilePath
12
10
func GetLinter (conf * lint.Config ) (* lint.Linter , error ) {
13
- if ! checkIfMinVersion (conf ) {
14
- return nil , fmt .Errorf ("min version required is %s. you have %s. \n upgrade commitlint" , conf .Version , Version ())
11
+ err := checkIfMinVersion (conf .Version )
12
+ if err != nil {
13
+ return nil , err
15
14
}
16
15
17
16
rules , err := GetEnabledRules (conf )
@@ -23,6 +22,11 @@ func GetLinter(conf *lint.Config) (*lint.Linter, error) {
23
22
24
23
// GetFormatter returns the formatter as defined in conf
25
24
func GetFormatter (conf * lint.Config ) (lint.Formatter , error ) {
25
+ err := checkIfMinVersion (conf .Version )
26
+ if err != nil {
27
+ return nil , err
28
+ }
29
+
26
30
format , ok := globalRegistry .GetFormatter (conf .Formatter )
27
31
if ! ok {
28
32
return nil , fmt .Errorf ("config error: '%s' formatter not found" , conf .Formatter )
@@ -55,7 +59,3 @@ func GetEnabledRules(conf *lint.Config) ([]lint.Rule, error) {
55
59
56
60
return enabledRules , nil
57
61
}
58
-
59
- func checkIfMinVersion (conf * lint.Config ) bool {
60
- return semver .Compare (Version (), conf .Version ) != - 1
61
- }
0 commit comments