Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var JsxPropsNoSpreadMultiRule = rule.Rule{ Name: "react/jsx-props-no-spread-multi", Run: func(ctx rule.RuleContext, options []any) rule.RuleListeners { check := func(node *ast.Node) { attrs := reactutil.GetJsxElementAttributes(node) if len(attrs) == 0 { return } seen := map[string]struct{}{} for _, attr := range attrs { if !ast.IsJsxSpreadAttribute(attr) { continue } expr := attr.AsJsxSpreadAttribute().Expression if expr != nil { expr = ast.SkipParentheses(expr) } if !ast.IsIdentifier(expr) { continue } name := expr.AsIdentifier().Text if _, ok := seen[name]; ok { ctx.ReportNode(attr, rule.RuleMessage{ Id: "noMultiSpreading", Description: "Spreading the same expression multiple times is forbidden", }) } seen[name] = struct{}{} } } return rule.RuleListeners{ ast.KindJsxOpeningElement: check, ast.KindJsxSelfClosingElement: check, } }, }
JsxPropsNoSpreadMultiRule disallows spreading the same identifier multiple times in one JSX opening element.
Functions ¶
This section is empty.
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.