Skip to content

Commit 739be52

Browse files
committed
style(go_flags): extract constants
1 parent 0212d4a commit 739be52

File tree

3 files changed

+15
-4
lines changed

3 files changed

+15
-4
lines changed

cmd/react_component.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import (
77

88
"github.com/iancoleman/strcase"
99
"github.com/pot-code/web-cli/pkg/commands"
10+
"github.com/pot-code/web-cli/pkg/constants"
1011
"github.com/pot-code/web-cli/pkg/core"
1112
"github.com/pot-code/web-cli/pkg/util"
1213
"github.com/pot-code/web-cli/templates"
@@ -107,15 +108,15 @@ func (arc *AddReactComponentService) addReactComponent(cfg *ReactComponentConfig
107108
}
108109

109110
func (arc *AddReactComponentService) getScssFileName() string {
110-
return fmt.Sprintf("%s.%s.%s", arc.ComponentName, "module", "scss")
111+
return fmt.Sprintf(constants.ReactScssPattern, arc.ComponentName)
111112
}
112113

113114
func (arc *AddReactComponentService) getStoryFileName() string {
114-
return fmt.Sprintf("%s.%s.%s", arc.ComponentName, "stories", "tsx")
115+
return fmt.Sprintf(constants.ReactStorybookPattern, arc.ComponentName, constants.TsxSuffix)
115116
}
116117

117118
func (arc *AddReactComponentService) getComponentFileName() string {
118-
return fmt.Sprintf("%s.%s", arc.ComponentName, "tsx")
119+
return fmt.Sprintf(constants.ReactComponentPattern, arc.ComponentName, constants.TsxSuffix)
119120
}
120121

121122
type AddReactEmotionService struct{}

pkg/constants/go.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
package constants
22

33
const (
4-
GoSuffix = ".go"
4+
GoSuffix = "go"
55
GoModFile = "go.mod"
66

77
GoGithubPrefix = "github.com"

pkg/constants/react.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
package constants
2+
3+
const (
4+
JsxSuffix = "jsx"
5+
TsxSuffix = "tsx"
6+
7+
ReactComponentPattern = "%s.%s"
8+
ReactStorybookPattern = "%s.stories.%s"
9+
ReactScssPattern = "%s.module.scss"
10+
)

0 commit comments

Comments
 (0)