Skip to content

Commit f1c060b

Browse files
refactor(config): remove onlyEnabled in config/create
* rename GetDefaultConfig to Default
1 parent b36891d commit f1c060b

File tree

3 files changed

+6
-28
lines changed

3 files changed

+6
-28
lines changed

config/default.go

Lines changed: 3 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -149,22 +149,7 @@ var defRuleConf = map[string]lint.RuleConfig{
149149
},
150150
}
151151

152-
// GetDefaultConfig writes default config to given file
153-
func GetDefaultConfig(onlyEnabled bool) *lint.Config {
154-
if !onlyEnabled {
155-
return defConf
156-
}
157-
158-
confClone := &lint.Config{
159-
MinVersion: defConf.MinVersion,
160-
Formatter: defConf.Formatter,
161-
Rules: map[string]lint.RuleConfig{},
162-
}
163-
164-
for ruleName, r := range defConf.Rules {
165-
if r.Enabled {
166-
confClone.Rules[ruleName] = r
167-
}
168-
}
169-
return confClone
152+
// Default returns default config
153+
func Default() *lint.Config {
154+
return defConf
170155
}

internal/cmd/callback.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,8 @@ func hookCreate(confPath string, isReplace bool) error {
4747
}
4848

4949
// configCreate is the callback function for create config command
50-
func configCreate(onlyEnabled, isReplace bool) error {
51-
defConf := config.GetDefaultConfig(onlyEnabled)
50+
func configCreate(isReplace bool) error {
51+
defConf := config.Default()
5252
outPath := filepath.Join(".", config.ConfigFile)
5353
// if config file already exists skip creating or overwriting it
5454
if _, err := os.Stat(outPath); !os.IsNotExist(err) {

internal/cmd/cmd.go

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -99,12 +99,6 @@ func configCmd() *cli.Command {
9999
Name: "create",
100100
Usage: "Creates default config in current directory",
101101
Flags: []cli.Flag{
102-
&cli.BoolFlag{
103-
Name: "enabled",
104-
Aliases: []string{"e"},
105-
Usage: "writes only default enabled rules",
106-
Value: false,
107-
},
108102
&cli.BoolFlag{
109103
Name: "replace",
110104
Aliases: []string{"r"},
@@ -113,9 +107,8 @@ func configCmd() *cli.Command {
113107
},
114108
},
115109
Action: func(ctx *cli.Context) error {
116-
isOnlyEnabled := ctx.Bool("enabled")
117110
isReplace := ctx.Bool("replace")
118-
err := configCreate(isOnlyEnabled, isReplace)
111+
err := configCreate(isReplace)
119112
if err != nil {
120113
if isConfExists(err) {
121114
fmt.Println("config create failed")

0 commit comments

Comments
 (0)