Skip to content

Commit 396f6b1

Browse files
feat(config): check for min version in GetLinter
1 parent 0bae4c3 commit 396f6b1

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

config/lint.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,17 @@ package config
33
import (
44
"fmt"
55

6+
"golang.org/x/mod/semver"
7+
68
"github.com/conventionalcommit/commitlint/lint"
79
)
810

911
// GetLinter returns Linter for given confFilePath
1012
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. \nupgrade commitlint", conf.Version, Version())
15+
}
16+
1117
rules, err := GetEnabledRules(conf)
1218
if err != nil {
1319
return nil, err
@@ -49,3 +55,7 @@ func GetEnabledRules(conf *lint.Config) ([]lint.Rule, error) {
4955

5056
return enabledRules, nil
5157
}
58+
59+
func checkIfMinVersion(conf *lint.Config) bool {
60+
return semver.Compare(Version(), conf.Version) != -1
61+
}

0 commit comments

Comments
 (0)