Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var NoDangerRule = rule.Rule{ Name: "react/no-danger", Run: func(ctx rule.RuleContext, options any) rule.RuleListeners { var customComponentNames []string if optsMap := utils.GetOptionsMap(options); optsMap != nil { if arr, ok := optsMap["customComponentNames"].([]interface{}); ok { for _, item := range arr { if name, ok := item.(string); ok { customComponentNames = append(customComponentNames, name) } } } } return rule.RuleListeners{ ast.KindJsxAttribute: func(node *ast.Node) { attrName := reactutil.GetJsxPropName(node) if !dangerousProps[attrName] { return } parent := reactutil.GetJsxParentElement(node) if parent == nil { return } matched := reactutil.IsDOMComponent(parent) if !matched && len(customComponentNames) > 0 { functionName := getTagNameText(ctx.SourceFile, reactutil.GetJsxTagName(parent)) for _, pattern := range customComponentNames { if ok, err := path.Match(pattern, functionName); ok && err == nil { matched = true break } } } if !matched { return } ctx.ReportNode(node, rule.RuleMessage{ Id: "dangerousProp", Description: "Dangerous property '" + attrName + "' found", }) }, } }, }
Functions ¶
This section is empty.
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.