Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var NoReturnAssignRule = rule.Rule{ Name: "no-return-assign", Run: func(ctx rule.RuleContext, options any) rule.RuleListeners { always := parseMode(options) == "always" return rule.RuleListeners{ ast.KindBinaryExpression: func(node *ast.Node) { if !ast.IsAssignmentExpression(node, false) { return } if !always && node.Parent != nil && ast.IsParenthesizedExpression(node.Parent) { return } currentChild := node parent := node.Parent for parent != nil && !isSentinel(parent) { currentChild = parent parent = parent.Parent } if parent == nil { return } switch { case ast.IsReturnStatement(parent): ctx.ReportNode(parent, rule.RuleMessage{ Id: "returnAssignment", Description: "Return statement should not contain assignment.", }) case ast.IsArrowFunction(parent): if arrow := parent.AsArrowFunction(); arrow != nil && arrow.Body == currentChild { ctx.ReportNode(parent, rule.RuleMessage{ Id: "arrowAssignment", Description: "Arrow function should not return assignment.", }) } } }, } }, }
Functions ¶
This section is empty.
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.