Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var NoNewRule = rule.Rule{ Name: "no-new", Run: func(ctx rule.RuleContext, options any) rule.RuleListeners { return rule.RuleListeners{ ast.KindExpressionStatement: func(node *ast.Node) { stmt := node.AsExpressionStatement() if stmt == nil { return } expr := ast.SkipParentheses(stmt.Expression) if expr == nil || expr.Kind != ast.KindNewExpression { return } ctx.ReportNode(node, rule.RuleMessage{ Id: "noNewStatement", Description: "Do not use 'new' for side effects.", }) }, } }, }
https://eslint.org/docs/latest/rules/no-new
ESLint's selector `ExpressionStatement > NewExpression` relies on ESTree stripping parentheses from the AST. tsgo keeps `ParenthesizedExpression` nodes, so walk through them with `ast.SkipParentheses` to match ESLint on forms like `(new Foo());`.
Functions ¶
This section is empty.
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.