Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var NoMultiAssignRule = rule.Rule{ Name: "no-multi-assign", Run: func(ctx rule.RuleContext, options any) rule.RuleListeners { opts := parseOptions(options) return rule.RuleListeners{ ast.KindBinaryExpression: func(node *ast.Node) { binExpr := node.AsBinaryExpression() if binExpr == nil || binExpr.OperatorToken == nil { return } if !ast.IsAssignmentOperator(binExpr.OperatorToken.Kind) { return } parent := ast.WalkUpParenthesizedExpressions(node.Parent) if parent == nil { return } switch parent.Kind { case ast.KindVariableDeclaration: decl := parent.AsVariableDeclaration() if decl != nil && decl.Initializer != nil && ast.SkipParentheses(decl.Initializer) == node { ctx.ReportNode(node, buildMessage()) } case ast.KindPropertyDeclaration: decl := parent.AsPropertyDeclaration() if decl != nil && decl.Initializer != nil && ast.SkipParentheses(decl.Initializer) == node { ctx.ReportNode(node, buildMessage()) } case ast.KindBinaryExpression: if opts.ignoreNonDeclaration { return } outer := parent.AsBinaryExpression() if outer == nil || outer.OperatorToken == nil { return } if !ast.IsAssignmentOperator(outer.OperatorToken.Kind) { return } if outer.Right != nil && ast.SkipParentheses(outer.Right) == node { ctx.ReportNode(node, buildMessage()) } } }, } }, }
Functions ¶
This section is empty.
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.