Skip to content

Commit 3e25ef6

Browse files
committed
chore: code changes according to cr
1 parent a59959a commit 3e25ef6

File tree

1 file changed

+1
-57
lines changed

1 file changed

+1
-57
lines changed

internal/plugins/react_hooks/rules/rules_of_hooks/rules_of_hooks.go

Lines changed: 1 addition & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -345,7 +345,7 @@ var RulesOfHooksRule = rule.Rule{
345345
if isInsideClass(codePathNode) {
346346
ctx.ReportNode(hook, buildClassHookMessage(hookText))
347347
} else if codePathFunctionName != "" {
348-
// Custom message if we found an invalid function name.kj
348+
// Custom message if we found an invalid function name.
349349
ctx.ReportNode(hook, buildFunctionHookMessage(hookText, codePathFunctionName))
350350
} else if isTopLevel(codePathNode) {
351351
// These are dangerous if you have inline requires enabled.
@@ -742,64 +742,8 @@ func isUseIdentifier(node *ast.Node) bool {
742742
return isReactFunction(node, "use")
743743
}
744744

745-
// Helper function to check if call expression is a hook call
746-
// func isHookCall(node *ast.Node) (bool, string) {
747-
// if node.Kind != ast.KindCallExpression {
748-
// return false, ""
749-
// }
750-
751-
// callExpr := node.AsCallExpression()
752-
// if callExpr == nil {
753-
// return false, ""
754-
// }
755-
756-
// // Get the callee and extract the hook name
757-
// // Handle different call patterns:
758-
// // - useHook()
759-
// // - React.useHook()
760-
// // - obj.useHook()
761-
// callee := callExpr.Expression
762-
// if callee == nil {
763-
// return false, ""
764-
// }
765-
766-
// switch callee.Kind {
767-
// case ast.KindIdentifier:
768-
// // Direct call: useHook()
769-
// identifier := callee.AsIdentifier()
770-
// if identifier != nil {
771-
// name := scanner.GetTextOfNode(&identifier.Node)
772-
// if isHookName(name) {
773-
// return true, name
774-
// }
775-
// }
776-
// case ast.KindPropertyAccessExpression:
777-
// // Property access: React.useHook(), obj.useHook()
778-
// propAccess := callee.AsPropertyAccessExpression()
779-
// if propAccess != nil {
780-
// nameNode := propAccess.Name()
781-
// if nameNode != nil {
782-
// name := scanner.GetTextOfNode(nameNode)
783-
// if isHookName(name) {
784-
// return true, name
785-
// }
786-
// }
787-
// }
788-
// }
789-
790-
// return false, ""
791-
// }
792-
793745
// Helper function to check if node is at top level
794746
func isTopLevel(node *ast.Node) bool {
795-
// current := node.Parent
796-
// for current != nil {
797-
// if isFunctionLike(current) {
798-
// return false
799-
// }
800-
// current = current.Parent
801-
// }
802-
// return true
803747
return node.Kind == ast.KindSourceFile
804748
}
805749

0 commit comments

Comments
 (0)