Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var NoDidUpdateSetStateRule = rule.Rule{ Name: "react/no-did-update-set-state", Run: func(ctx rule.RuleContext, options any) rule.RuleListeners { if reactVersionNoop(ctx.Settings) { return rule.RuleListeners{} } disallowInFunc := parseDisallowInFunc(options) return rule.RuleListeners{ ast.KindCallExpression: func(node *ast.Node) { call := node.AsCallExpression() callee := ast.SkipParentheses(call.Expression) if callee.Kind != ast.KindPropertyAccessExpression { return } prop := callee.AsPropertyAccessExpression() if ast.SkipParentheses(prop.Expression).Kind != ast.KindThisKeyword { return } nameNode := prop.Name() if nameNode == nil { return } var propName string switch nameNode.Kind { case ast.KindIdentifier: propName = nameNode.AsIdentifier().Text case ast.KindPrivateIdentifier: propName = strings.TrimPrefix(nameNode.AsPrivateIdentifier().Text, "#") default: return } if propName != "setState" { return } depth := 0 for p := node.Parent; p != nil; p = p.Parent { if ast.IsFunctionLikeDeclaration(p) { depth++ } if !isStopper(p) { continue } if stopperName(p) != methodName { continue } if !disallowInFunc && depth > 1 { continue } ctx.ReportNode(callee, rule.RuleMessage{ Id: "noSetState", Description: "Do not use setState in componentDidUpdate", }) return } }, } }, }
Functions ¶
This section is empty.
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.