Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var JsxNoDuplicatePropsRule = rule.Rule{ Name: "react/jsx-no-duplicate-props", Run: func(ctx rule.RuleContext, options any) rule.RuleListeners { ignoreCase := false if optsMap := utils.GetOptionsMap(options); optsMap != nil { if v, ok := optsMap["ignoreCase"].(bool); ok { ignoreCase = v } } check := func(node *ast.Node) { attrs := reactutil.GetJsxElementAttributes(node) if len(attrs) == 0 { return } seen := map[string]struct{}{} for _, attr := range attrs { if !ast.IsJsxAttribute(attr) { continue } nameNode := attr.AsJsxAttribute().Name() if nameNode == nil { continue } if nameNode.Kind != ast.KindIdentifier { continue } name := nameNode.AsIdentifier().Text if ignoreCase { name = strings.ToLower(name) } if _, dup := seen[name]; dup { ctx.ReportNode(attr, rule.RuleMessage{ Id: "noDuplicateProps", Description: "No duplicate props allowed", }) continue } seen[name] = struct{}{} } } return rule.RuleListeners{ ast.KindJsxOpeningElement: check, ast.KindJsxSelfClosingElement: check, } }, }
Functions ¶
This section is empty.
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.