Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var PreferArrowCallbackRule = rule.Rule{ Name: "prefer-arrow-callback", Run: func(ctx rule.RuleContext, _raw []any) rule.RuleListeners { raw := rule.LegacyUnwrapOptions(_raw) opts := parseOptions(raw) return rule.RuleListeners{ ast.KindFunctionExpression: func(node *ast.Node) { if opts.allowNamedFunctions { if name := node.Name(); name != nil && name.Kind == ast.KindIdentifier && name.Text() != "" { return } } if ast.GetFunctionFlags(node)&ast.FunctionFlagsGenerator != 0 { return } if functionNameReferenced(ctx, node) || hasArgumentsReference(ctx, node) { return } scope := getFunctionScopeInfo(node) info := getCallbackInfo(node) if !info.isCallback { return } if (opts.allowUnboundThis && scope.this && !info.isLexicalThis) || scope.super || scope.meta { return } msg := preferArrowCallbackMessage() if fixes := buildFixes(ctx, node, scope, info); len(fixes) > 0 { ctx.ReportNodeWithFixes(node, msg, fixes...) } else { ctx.ReportNode(node, msg) } }, } }, }
Functions ¶
This section is empty.
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.