Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ArrayCallbackReturnRule = rule.CreateRule(rule.Rule{ Name: "array-callback-return", Run: func(ctx rule.RuleContext, options any) rule.RuleListeners { opts := parseOptions(options) return rule.RuleListeners{ ast.KindCallExpression: func(node *ast.Node) { methodName := getMethodName(node) isArrayFrom := false if isArrayFromCall(node) { methodName = "from" isArrayFrom = true } if methodName == "" { return } isTarget := isTargetMethod(methodName) isForEach := opts.CheckForEach && isForEachMethod(methodName) if !isTarget && !isForEach && !isArrayFrom { return } args := node.Arguments() if len(args) == 0 { return } var callbackArg *ast.Node if isArrayFrom { if len(args) >= 2 { callbackArg = args[1] } } else { callbackArg = args[0] } if callbackArg == nil { return } if !isFunctionNode(callbackArg) { return } checkCallbackReturn(ctx, callbackArg, methodName, opts, isForEach) }, } }, })
ArrayCallbackReturnRule enforces return statements in callbacks of array methods
Functions ¶
This section is empty.
Types ¶
Click to show internal directories.
Click to hide internal directories.