Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var NoVarRule = rule.Rule{ Name: "no-var", Run: func(ctx rule.RuleContext, options any) rule.RuleListeners { return rule.RuleListeners{ ast.KindVariableDeclarationList: func(node *ast.Node) { if node.Flags&ast.NodeFlagsBlockScoped != 0 { return } if isInDeclareGlobal(node) { return } reportNode := node if node.Parent != nil && node.Parent.Kind == ast.KindVariableStatement && !ast.HasSyntacticModifier(node.Parent, ast.ModifierFlagsExport) { reportNode = node.Parent } msg := rule.RuleMessage{ Id: "unexpectedVar", Description: "Unexpected var, use let or const instead.", } if ctx.TypeChecker != nil && canFix(node, &ctx) { varRange := utils.GetVarKeywordRange(node, ctx.SourceFile) ctx.ReportNodeWithFixes(reportNode, msg, rule.RuleFixReplaceRange(varRange, "let")) } else { ctx.ReportNode(reportNode, msg) } }, } }, }
Functions ¶
This section is empty.
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.