Skip to content

Commit

Permalink
refactor(config): move default to registry
Browse files Browse the repository at this point in the history
  • Loading branch information
muthukrishnan24 committed Oct 17, 2021
1 parent 8aa70c7 commit aa118c2
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 33 deletions.
33 changes: 0 additions & 33 deletions config/default.go
Original file line number Diff line number Diff line change
Expand Up @@ -146,39 +146,6 @@ var defConf = &lint.Config{
},
}

var defaultFormatters = []lint.Formatter{
&formatter.DefaultFormatter{},
&formatter.JSONFormatter{},
}

var defaultRules = []lint.Rule{
&rule.BodyMinLenRule{},
&rule.BodyMaxLenRule{},

&rule.FooterMinLenRule{},
&rule.FooterMaxLenRule{},

&rule.HeadMaxLenRule{},
&rule.HeadMinLenRule{},

&rule.TypeEnumRule{},
&rule.ScopeEnumRule{},

&rule.BodyMaxLineLenRule{},
&rule.FooterMaxLineLenRule{},

&rule.TypeCharsetRule{},
&rule.ScopeCharsetRule{},

&rule.TypeMaxLenRule{},
&rule.ScopeMaxLenRule{},
&rule.DescriptionMaxLenRule{},

&rule.TypeMinLenRule{},
&rule.ScopeMinLenRule{},
&rule.DescriptionMinLenRule{},
}

// DefaultConfig writes default config to given file
func DefaultConfig(onlyEnabled bool) *lint.Config {
if !onlyEnabled {
Expand Down
20 changes: 20 additions & 0 deletions config/registry.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@ import (
"fmt"
"sync"

"github.com/conventionalcommit/commitlint/formatter"
"github.com/conventionalcommit/commitlint/lint"
"github.com/conventionalcommit/commitlint/rule"
)

var globalRegistry = newRegistry()
Expand All @@ -29,6 +31,24 @@ type registry struct {
}

func newRegistry() *registry {
defaultRules := []lint.Rule{
&rule.BodyMinLenRule{}, &rule.BodyMaxLenRule{},
&rule.FooterMinLenRule{}, &rule.FooterMaxLenRule{},
&rule.HeadMaxLenRule{}, &rule.HeadMinLenRule{},
&rule.TypeEnumRule{}, &rule.ScopeEnumRule{},

&rule.BodyMaxLineLenRule{}, &rule.FooterMaxLineLenRule{},
&rule.TypeCharsetRule{}, &rule.ScopeCharsetRule{},

&rule.TypeMaxLenRule{}, &rule.ScopeMaxLenRule{}, &rule.DescriptionMaxLenRule{},
&rule.TypeMinLenRule{}, &rule.ScopeMinLenRule{}, &rule.DescriptionMinLenRule{},
}

defaultFormatters := []lint.Formatter{
&formatter.DefaultFormatter{},
&formatter.JSONFormatter{},
}

reg := &registry{
mut: &sync.Mutex{},

Expand Down

0 comments on commit aa118c2

Please sign in to comment.