Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var NoRestrictedSyntaxRule = rule.Rule{ Name: "no-restricted-syntax", Run: func(ctx rule.RuleContext, options any) rule.RuleListeners { entries := parseRuleOptions(options) if len(entries) == 0 { return rule.RuleListeners{} } mc := &matchContext{sf: ctx.SourceFile} perKind := make(map[ast.Kind][]ruleEntry) var everyKind []ruleEntry for _, e := range entries { ks := candidateKinds(e.compiled) if ks.universe { everyKind = append(everyKind, e) continue } for k := range ks.kinds { perKind[k] = append(perKind[k], e) } } if len(everyKind) > 0 { for _, k := range allInterestingKinds { perKind[k] = append(perKind[k], everyKind...) } } visit := func(node *ast.Node, bucket []ruleEntry) { for _, e := range bucket { if matches(e.compiled, node, mc) { ctx.ReportNode(node, rule.RuleMessage{ Id: "restrictedSyntax", Description: e.formatMessage(), }) } } } listeners := rule.RuleListeners{} for k, bucket := range perKind { listeners[k] = func(node *ast.Node) { visit(node, bucket) } } return listeners }, }
NoRestrictedSyntaxRule is the rslint port of ESLint's `no-restricted-syntax`.
Configuration mirrors ESLint: the rule accepts a list of strings or `{ selector, message? }` objects. Each selector follows the esquery grammar (the subset implemented in parser.go). At lint time every node is matched against every parsed selector; each match produces one diagnostic with the user-supplied message (or a default).
Functions ¶
This section is empty.
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.