@putout/plugin-remove-useless-new
🐊Putout plugin adds ability to remove useless `new` operator
Last updated 4 years ago by coderaiser .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install @putout/plugin-remove-useless-new 
SYNC missed versions from official npm registry.

@putout/plugin-remove-useless-new NPM version

????Putout plugin adds ability to remove useless operator new. Which has no sense for BigInt, Boolean, String, Number, Object, RegExp, Error:

Thus the function call Error(…) is equivalent to the object creation expression new Error(…) with the same arguments.

(c) https://262.ecma-international.org/12.0/#sec-error-constructor

And Symbol cannot be used with new, as it is primitive. Part of @putout/plugin-new.

Install

npm i @putout/plugin-remove-useless-new

Rule

{
    "rules": {
        "remove-useless-new": "on"
    }
}

❌ Example of incorrect code

new Error('Something whent wrong');
new new Boolean();

✅ Example of correct code

Error('Something whent wrong');
Boolean();

Comparison

Linter Rule Fix
???? Putout remove-useless-new
???? ESLint no-new-wrappers
no-new-object
no-array-constructor
no-new-symbol

License

MIT

Current Tags

  • 2.3.2                                ...           latest (4 years ago)

9 Versions

  • 2.3.2                                ...           4 years ago
  • 2.3.1                                ...           4 years ago
  • 2.3.0                                ...           4 years ago
  • 2.2.0                                ...           4 years ago
  • 2.1.1                                ...           4 years ago
  • 2.1.0                                ...           4 years ago
  • 2.0.0                                ...           4 years ago
  • 1.0.1                                ...           5 years ago
  • 1.0.0                                ...           5 years ago
Maintainers (1)
Downloads
Today 0
This Week 0
This Month 0
Last Day 0
Last Week 0
Last Month 1
Dependencies (0)
None
Dev Dependencies (5)
Dependents (1)

Copyright 2013 - present © cnpmjs.org | Home |