Skip to content

Commit aa118c2

Browse files
refactor(config): move default to registry
1 parent 8aa70c7 commit aa118c2

File tree

2 files changed

+20
-33
lines changed

2 files changed

+20
-33
lines changed

config/default.go

Lines changed: 0 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -146,39 +146,6 @@ var defConf = &lint.Config{
146146
},
147147
}
148148

149-
var defaultFormatters = []lint.Formatter{
150-
&formatter.DefaultFormatter{},
151-
&formatter.JSONFormatter{},
152-
}
153-
154-
var defaultRules = []lint.Rule{
155-
&rule.BodyMinLenRule{},
156-
&rule.BodyMaxLenRule{},
157-
158-
&rule.FooterMinLenRule{},
159-
&rule.FooterMaxLenRule{},
160-
161-
&rule.HeadMaxLenRule{},
162-
&rule.HeadMinLenRule{},
163-
164-
&rule.TypeEnumRule{},
165-
&rule.ScopeEnumRule{},
166-
167-
&rule.BodyMaxLineLenRule{},
168-
&rule.FooterMaxLineLenRule{},
169-
170-
&rule.TypeCharsetRule{},
171-
&rule.ScopeCharsetRule{},
172-
173-
&rule.TypeMaxLenRule{},
174-
&rule.ScopeMaxLenRule{},
175-
&rule.DescriptionMaxLenRule{},
176-
177-
&rule.TypeMinLenRule{},
178-
&rule.ScopeMinLenRule{},
179-
&rule.DescriptionMinLenRule{},
180-
}
181-
182149
// DefaultConfig writes default config to given file
183150
func DefaultConfig(onlyEnabled bool) *lint.Config {
184151
if !onlyEnabled {

config/registry.go

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,9 @@ import (
44
"fmt"
55
"sync"
66

7+
"github.com/conventionalcommit/commitlint/formatter"
78
"github.com/conventionalcommit/commitlint/lint"
9+
"github.com/conventionalcommit/commitlint/rule"
810
)
911

1012
var globalRegistry = newRegistry()
@@ -29,6 +31,24 @@ type registry struct {
2931
}
3032

3133
func newRegistry() *registry {
34+
defaultRules := []lint.Rule{
35+
&rule.BodyMinLenRule{}, &rule.BodyMaxLenRule{},
36+
&rule.FooterMinLenRule{}, &rule.FooterMaxLenRule{},
37+
&rule.HeadMaxLenRule{}, &rule.HeadMinLenRule{},
38+
&rule.TypeEnumRule{}, &rule.ScopeEnumRule{},
39+
40+
&rule.BodyMaxLineLenRule{}, &rule.FooterMaxLineLenRule{},
41+
&rule.TypeCharsetRule{}, &rule.ScopeCharsetRule{},
42+
43+
&rule.TypeMaxLenRule{}, &rule.ScopeMaxLenRule{}, &rule.DescriptionMaxLenRule{},
44+
&rule.TypeMinLenRule{}, &rule.ScopeMinLenRule{}, &rule.DescriptionMinLenRule{},
45+
}
46+
47+
defaultFormatters := []lint.Formatter{
48+
&formatter.DefaultFormatter{},
49+
&formatter.JSONFormatter{},
50+
}
51+
3252
reg := &registry{
3353
mut: &sync.Mutex{},
3454

0 commit comments

Comments
 (0)