You're Invited:Meet the Socket Team at BlackHat and DEF CON in Las Vegas, Aug 4-6.RSVP
Socket
Book a DemoInstallSign in
Socket

@putout/plugin-remove-useless-new

Package Overview
Dependencies
Maintainers
1
Versions
9
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@putout/plugin-remove-useless-new

🐊Putout plugin adds ability to remove useless operator 'new'

2.3.2
latest
Source
npm
Version published
Weekly downloads
1.1K
35%
Maintainers
1
Weekly downloads
 
Created
Source

@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

Keywords

putout

FAQs

Package last updated on 08 May 2022

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts