Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var NoUselessConcatRule = rule.Rule{ Name: "no-useless-concat", Run: func(ctx rule.RuleContext, options any) rule.RuleListeners { sourceFile := ctx.SourceFile lineMap := sourceFile.ECMALineMap() return rule.RuleListeners{ ast.KindBinaryExpression: func(node *ast.Node) { if !utils.IsPlusBinaryExpression(node) { return } bin := node.AsBinaryExpression() left := getRightmostLeaf(bin.Left) right := getLeftmostLeaf(bin.Right) if !utils.IsStringLiteralOrTemplate(left) || !utils.IsStringLiteralOrTemplate(right) { return } leftEndLine := scanner.ComputeLineOfPosition(lineMap, left.End()) rightStartLine := scanner.ComputeLineOfPosition(lineMap, utils.TrimNodeTextRange(sourceFile, right).Pos()) if leftEndLine != rightStartLine { return } ctx.ReportRange( utils.TrimNodeTextRange(sourceFile, bin.OperatorToken), rule.RuleMessage{ Id: "unexpectedConcat", Description: "Unexpected string concatenation of literals.", }, ) }, } }, }
Functions ¶
This section is empty.
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.