Skip to content

Commit e901f69

Browse files
authored
refactor: use ast.IsStringLIteralLike (#254)
1 parent f284ece commit e901f69

File tree

1 file changed

+3
-11
lines changed

1 file changed

+3
-11
lines changed

internal/plugins/import/utils/module_visitor.go

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ func VisitModules(visitor func(source *ast.StringLiteralLike, node *ast.Node), o
1717
visitors := rule.RuleListeners{}
1818

1919
checkSourceValue := func(source *ast.StringLiteralLike, node *ast.Node) {
20-
if !isStringLiteralLike(source) {
20+
if source == nil {
2121
return
2222
}
2323

@@ -39,7 +39,7 @@ func VisitModules(visitor func(source *ast.StringLiteralLike, node *ast.Node), o
3939
}
4040

4141
modulePath := call.Arguments.Nodes[0]
42-
if modulePath == nil || !isStringLiteralLike(modulePath) {
42+
if modulePath == nil || !ast.IsStringLiteralLike(modulePath) {
4343
return
4444
}
4545

@@ -63,7 +63,7 @@ func VisitModules(visitor func(source *ast.StringLiteralLike, node *ast.Node), o
6363
}
6464

6565
modulePath := call.Arguments.Nodes[0]
66-
if modulePath == nil || !isStringLiteralLike(modulePath) {
66+
if modulePath == nil || !ast.IsStringLiteralLike(modulePath) {
6767
return
6868
}
6969

@@ -100,11 +100,3 @@ func VisitModules(visitor func(source *ast.StringLiteralLike, node *ast.Node), o
100100

101101
return visitors
102102
}
103-
104-
func isStringLiteralLike(node *ast.Node) bool {
105-
if node == nil {
106-
return false
107-
}
108-
109-
return node.Kind == ast.KindStringLiteral || node.Kind == ast.KindNoSubstitutionTemplateLiteral
110-
}

0 commit comments

Comments
 (0)