Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var AutocompleteValidRule = rule.Rule{ Name: "jsx-a11y/autocomplete-valid", Run: func(ctx rule.RuleContext, rawOptions any) rule.RuleListeners { opts := parseOptions(rawOptions) inputTypes := map[string]struct{}{"input": {}} for _, c := range opts.inputComponents { inputTypes[c] = struct{}{} } check := func(node *ast.Node) { elType := jsxa11yutil.GetElementType(node, ctx.Settings) if _, ok := inputTypes[elType]; !ok { return } attrs := reactutil.GetJsxElementAttributes(node) autocompleteAttr := jsxa11yutil.FindAttributeByName(attrs, "autocomplete") if autocompleteAttr == nil { return } autocompleteValue, ok := jsxa11yutil.LiteralPropStringValue(autocompleteAttr) if !ok { return } if typeAttr := jsxa11yutil.FindAttributeByName(attrs, "type"); typeAttr != nil { if typeValue, ok := jsxa11yutil.LiteralPropStringValue(typeAttr); ok { if _, excluded := excludedInputTypes[strings.ToLower(typeValue)]; excluded { return } } } if isValidAutocomplete(autocompleteValue) { return } ctx.ReportNode(node, rule.RuleMessage{ Id: "autocompleteValid", Description: failMessage, }) } 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.