2.3.2 β€’ Published 2 years ago

@putout/plugin-remove-useless-new v2.3.2

Weekly downloads
-
License
MIT
Repository
github
Last release
2 years ago

@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

LinterRuleFix
🐊 Putoutremove-useless-newβœ…
πŸ¦• ESLintno-new-wrappers❌
β €no-new-object❌
β €no-array-constructor❌
β €no-new-symbol❌

License

MIT

2.3.0

2 years ago

2.2.0

2 years ago

2.3.2

2 years ago

2.3.1

2 years ago

2.1.1

2 years ago

2.1.0

2 years ago

2.0.0

2 years ago

1.0.1

3 years ago

1.0.0

3 years ago