{"name":"@putout/plugin-new","version":"1.0.2","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.2","_nodeVersion":"16.14.2","_npmVersion":"8.3.0","dist":{"integrity":"sha512-unZrAGeX9mtcK73sdKeHEKvI3Ro6DQokY+6dI7tuc1maHCDdMRy3HKQkHBNabDrTMuX+hWgLYmxvGDw3OEiT1Q==","shasum":"0ff44322eec1ae9b3930975226e0c79d10adbd33","tarball":"http://registry-npm.ywwl.com/@putout/plugin-new/download/@putout/plugin-new-1.0.2.tgz","fileCount":6,"unpackedSize":6717,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQCoFW4R+4CY7qUzWXYpvgrQe68x6Hx4tpRQkWSZZJ+MaAIgYkcaUPjwhuGTMJfHZ5ya+2YneEn0wxKq3dbXshJW70E="}],"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJid38PACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2Vmr6RA/9HAEOIH3PDbr8hapOLBVho0RR5XHzgYVpkrIYWPjxFs00poUf\r\nyTS7XfU+KeyvFL5CAizm0qpnTpppahtcg014XZY8N/V2fb2ixRvx4rmfs3+S\r\nnBwRkGI8x4QNyZLU0iuDv9mxperU6XEjeYXusiwyue+rHaWRQQtSkkstFFKq\r\ngv5zXqimpqaX90tCwFhqJSvalmFNHPUMRWMRlrVJ+1JW0LmSnyE7izuxQOP/\r\nNCtZknCnp2e+g2paoo+hoglme1drtJBE7PbQHQP8dIwKSjRrPR8JnE9Uydm4\r\npnxe4XC98Eh2EhKW5zPlLPKA53K2C2m70jyNPkmpEYOhf4NHl3dDkPgqd8K2\r\nAOa9nkM2ADafbPF8pn5i7l2L27iUJRIhNljnBG6Eh0j5BGym+FtkgBhP/qFg\r\nHywdjdh0fFC8yEmRL/Ekbcqni2AvKkvrvfkws8+DXrjVOPv1FEZwylPd6+NL\r\nreQWPmx5gsIFtQYmoUaOAV2orWi2rH6NR99PRpuU/MCcVWL1lccWPNtQ91Ud\r\nD5bmC+sT1MTGoG0n82o3Lotlpfj0EV+L239G2DPju6DTS3S+HUsaMGwL72Ai\r\nNYHQHcFHhTk4pzxwy7h+zghcJKdcxOQB3PeTxqQWUGcVtOScV2lu7e8Id0I3\r\nMJYZj0hHwmVNbpt82Peg/QPQen9hvBuaV2U=\r\n=WNLw\r\n-----END PGP SIGNATURE-----\r\n","size":2807,"noattachment":false,"key":"/@putout/plugin-new/-/@putout/plugin-new-1.0.2.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.2_1651998479233_0.01795432364317784"},"_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":1651998479409,"_cnpm_publish_time":1651998479409,"dist-tags":{"latest":"5.1.0"}}