You're Invited:Meet the Socket Team at BlackHat and DEF CON in Las Vegas, Aug 7-8.RSVP
Socket
Socket
Sign inDemoInstall

@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'


Version published
Weekly downloads
708
increased by31.6%
Maintainers
1
Created
Weekly downloads
 

Readme

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

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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc