{"name":"@putout/plugin-new","version":"3.0.0","type":"commonjs","author":{"name":"coderaiser","email":"mnemonic.enemy@gmail.com","url":"https://github.com/coderaiser"},"description":"🐊Putout plugin adds ability to remove useless and add missing operator 'new'","homepage":"https://github.com/coderaiser/putout/tree/master/packages/plugin-new#readme","main":"lib/index.js","release":false,"tag":false,"changelog":false,"repository":{"type":"git","url":"git://github.com/coderaiser/putout.git"},"scripts":{"publishOnly":"madrun publishOnly","test":"madrun test","watch:test":"madrun watch:test","lint":"madrun lint","fresh:lint":"madrun fresh:lint","lint:fresh":"madrun lint:fresh","fix:lint":"madrun fix:lint","coverage":"madrun coverage","report":"madrun report"},"dependencies":{},"keywords":["putout","putout-plugin","plugin","new","useless","missing"],"devDependencies":{"@putout/test":"^7.0.0","c8":"^8.0.0","eslint":"^8.0.1","eslint-plugin-n":"^16.0.0","madrun":"^9.0.0"},"peerDependencies":{"putout":">=32"},"license":"MIT","engines":{"node":">=16"},"publishConfig":{"access":"public"},"gitHead":"c569c5123e73bed10dc5557559e3fe1ab92c5476","bugs":{"url":"https://github.com/coderaiser/putout/issues"},"_id":"@putout/plugin-new@3.0.0","_nodeVersion":"20.9.0","_npmVersion":"9.6.6","dist":{"integrity":"sha512-8nkf+mXHJHgt3NT0YllKZ3G2NU1okwAVXrdBkZslwoKqmJ1vkHJi9b87dFaeE270+bRJ3wstwpJZOzTURkYtOQ==","shasum":"d1b579310fdefa1f5a0cf9b5099c4a938dd9da21","tarball":"http://registry-npm.ywwl.com/@putout/plugin-new/download/@putout/plugin-new-3.0.0.tgz","fileCount":6,"unpackedSize":7397,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQDL7jvQHs1cyLOdV9dcSmaxCMRcsPFVcW8IOc27sWKffwIhANCFdcxtRpFIv1sUyv1XkjJqhURG+IC4dzZGLELqu64d"}],"size":2930,"noattachment":false,"key":"/@putout/plugin-new/-/@putout/plugin-new-3.0.0.tgz"},"_npmUser":{"name":"coderaiser","email":"mnemonic.enemy@gmail.com"},"directories":{},"maintainers":[{"name":"coderaiser","email":"mnemonic.enemy@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/plugin-new_3.0.0_1699790242214_0.21708462201620748"},"_hasShrinkwrap":false,"readme":"# @putout/plugin-new [![NPM version][NPMIMGURL]][NPMURL]\n\n[NPMIMGURL]: https://img.shields.io/npm/v/@putout/plugin-new.svg?style=flat&longCache=true\n[NPMURL]: https://npmjs.org/package/@putout/plugin-new \"npm\"\n\n> The `new` operator lets developers create an instance of a user-defined object type or of one of the built-in object types that has a constructor function.\n>\n> (c) [MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/new)\n\n🐊[**Putout**](https://github.com/coderaiser/putout) plugin adds ability to add missing and remove useless operator `new`.\n\n## Install\n\n```\nnpm i @putout/plugin-new\n```\n\n## Rule\n\n```json\n{\n    \"rules\": {\n        \"new/remove-useless\": \"on\",\n        \"new/add-missing\": \"on\"\n    }\n}\n```\n\n## remove-useless\n\nOperator `new` has no sense for `Boolean`, `String`, `Number`, `Object`, `RegExp`, `Math`, `Reflect`, `Error`, `TypeError`:\n\n> Thus the function call `Error(…)` is equivalent to the object creation expression `new Error(…)` with the same arguments.\n>\n> (c) https://262.ecma-international.org/12.0/#sec-error-constructor\n\nAnd [`Symbol`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Symbol), [`BigInt`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/BigInt) cannot be used with `new`, as it is primitive.\n\n### ❌ Example of incorrect code\n\n```js\nnew Error('Something whent wrong');\nnew new Boolean()();\n```\n\n### ✅ Example of correct code\n\n```js\nError('Something whent wrong');\nBoolean();\n```\n\n## add-missing\n\n> The `Set` constructor lets you create Set objects that store unique values of any type, whether primitive values or object references.\n>\n> (c) [MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Set/Set)\n\nMissing operator `new` should be added since built-in objects:\n\n- `Set`;\n- `WeakSet`;\n- `Map`;\n- `WeakMap`;\n- `Int8Array`;\n- `Uint8Array`;\n- `Uint8ClampedArray`;\n- `Int16Array`;\n- `Uint16Array`;\n- `Int32Array`;\n- `Uint32Array`;\n- `Float32Array`;\n- `Float64Array`;\n- `BigInt64Array`;\n- `BigUint64Array`;\n\nProduces [`TypeError`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypeError) when called without `new`:\n\n```\nUncaught TypeError: Constructor Set requires 'new'\n```\n\n### ❌ Example of incorrect code\n\n```js\nconst map = Map();\n```\n\n### ✅ Example of correct code\n\n```js\nconst map = new Map();\n```\n\n## Comparison\n\nLinter | Rule | Fix\n--------|-------|------------|\n🐊 **Putout** | [`remove-useless-new`](https://github.com/coderaiser/putout/tree/master/packages/plugin-remove-useless-new#readme)| ✅\n⏣ **ESLint** | [`no-new-wrappers`](https://eslint.org/docs/rules/no-new-wrappers) | ❌\n⠀| [`no-new-object`](https://eslint.org/docs/rules/no-new-object) | ❌\n⠀| [`no-array-constructor`](https://eslint.org/docs/rules/no-array-constructor) | ❌\n⠀| [`no-new-symbol`](https://eslint.org/docs/rules/no-new-symbol) | ❌\n⠀| [`no-new-native-constructor`](https://eslint.org/docs/rules/https://eslint.org/docs/latest/rules/no-new-native-nonconstructor) | ❌\n\n## License\n\nMIT\n","publish_time":1699790242424,"_cnpm_publish_time":1699790242424,"dist-tags":{"latest":"5.1.0"}}