{"name":"@putout/plugin-new","version":"1.0.1","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/-new.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":"^5.0.0","c8":"^7.5.0","eslint":"^8.0.1","eslint-plugin-node":"^11.0.0","madrun":"^9.0.0"},"peerDependencies":{"putout":">=26"},"license":"MIT","engines":{"node":">=16"},"publishConfig":{"access":"public"},"gitHead":"6d9d10d157d31bf13d16de1b4dbef1298f690139","bugs":{"url":"https://github.com/coderaiser/putout/issues"},"_id":"@putout/plugin-new@1.0.1","_nodeVersion":"18.0.0","_npmVersion":"8.3.0","dist":{"integrity":"sha512-BXDn6OrVgzaCG0W5HCcKXVGswQfzsfYSqNEC+G1aIgB0Jdgqf3mzXo2T/Z5XeeSAvKX1gCAhOr3HYwYeVUk6rw==","shasum":"ff027c1f4c9ac29fb7214adac9bfff47ef924828","tarball":"http://registry-npm.ywwl.com/@putout/plugin-new/download/@putout/plugin-new-1.0.1.tgz","fileCount":6,"unpackedSize":6716,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQC3DtKcpQnjGBFIzQSczEZ8Xv6MmIiTg1WCC2Hvme9V9wIgeVDMD8V0G0/phmuXY7qX4Lv04VvgiOYyzFlNuYUDta4="}],"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJid36YACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2VmrsyQ//e/ewkj/2JtvhdI/hRXU12FjGve2YcJwytt5i70b5rqM9yXWQ\r\nl6GAhnP0Tur6MDHemC5EMcKsyk1v9ub1JJA7gzAaVWDZOHq8bygiUPF5kbxm\r\naiabFPoQdgOxyyLXgUa+CL6k+Z+CTGavep7g+h13s31zkx+r+g+mTiMtxhgh\r\nQSIbQbkXtTm/NORiz0fVog7U9wV9pW7ORnPlOH7AAphMHFAYLcxpZRmkdTYs\r\nbIbas4GCeHyeAPUaZiHLdvFjDrq851UGlFbYaTiUTauasQzsg2vcpEFSlGHi\r\nAEQXApySdnIsAtLP2s8O4aAt9ct+BCjYrnDdQVCsXxDBw3wcvIhBu8n19Cgc\r\nXsMIIkRobjIrE9sqSvGBj36eSRdNTZ1+xI5NW4XQFXacRKxwZs9xFIwFTybv\r\nFiaQSA4KSDPCSabSTdC8bKtIzB6TveiFPedZ08CfzN2lUoQhw7Rp8OfK62Cy\r\na0esG3Q8bEse1HZN7Ssua1Hg24IrS84rxDHDM+aj17hcYkw8uDwNpNcLsIqp\r\najLiFyZh9m55NLyBBc8fBqksFE+TtIqgj/k0WgU7DG3SmXsxM6EDFA/BBHOp\r\n/PFzK4GVLSs9j+aeMnrVvpY7gXoXfz7sP3wuipfpDuocdln0PmIwCvH3mrVi\r\nrqeMBaHsCJkO8c+QoLxSi8CObCGIL+et5E8=\r\n=ZQl2\r\n-----END PGP SIGNATURE-----\r\n","size":2800,"noattachment":false,"key":"/@putout/plugin-new/-/@putout/plugin-new-1.0.1.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_1.0.1_1651998360279_0.4904979165879375"},"_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":1651998360406,"_cnpm_publish_time":1651998360406,"dist-tags":{"latest":"5.1.0"}}