Skip to content

eslint/no-new Suspicious

What it does

Disallow new operators outside of assignments or comparisons.

Why is this bad?

Calling new without assigning or comparing it the reference is thrown away and in many cases the constructor can be replaced with a function.

Example

javascript
new Person();

How to use

To enable this rule in the CLI or using the config file, you can use:

bash
oxlint --deny no-new
json
{
  "rules": {
    "no-new": "error"
  }
}

References

Released under the MIT License.