{"name":"@putout/plugin-remove-useless-functions","version":"6.0.0","keywords":["putout","putout-plugin","putout-plugin-remove","plugin","remove","useless","functions"],"author":{"url":"https://github.com/coderaiser","name":"coderaiser","email":"mnemonic.enemy@gmail.com"},"license":"MIT","_id":"@putout/plugin-remove-useless-functions@6.0.0","maintainers":[{"name":"coderaiser","email":"mnemonic.enemy@gmail.com"}],"homepage":"https://github.com/coderaiser/putout/tree/master/packages/plugin-remove-useless-functions#readme","bugs":{"url":"https://github.com/coderaiser/putout/issues"},"tag":false,"dist":{"shasum":"3936272a33beff507e5f9656209b0d78b64c66eb","tarball":"http://registry-npm.ywwl.com/@putout/plugin-remove-useless-functions/download/@putout/plugin-remove-useless-functions-6.0.0.tgz","fileCount":4,"integrity":"sha512-WhNio84hh7g7jrXaD/PIUgO6Huo0whjjfmzQbgvKkwsAUkFe1plU/JfK4cfspwmPT+fpnz2IqqrrsTWpxyBdmw==","signatures":[{"sig":"MEYCIQD2F2a1xJQ5yQNihhq2SXuME852cbgEZFMs3SNE6CH8hQIhAOYUPSJGJg9YjChAaqtfe56NaSXSCWK/j0lo4Apw/Oa0","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":5803,"size":2566,"noattachment":false,"key":"/@putout/plugin-remove-useless-functions/-/@putout/plugin-remove-useless-functions-6.0.0.tgz"},"main":"lib/remove-useless-functions.js","type":"module","engines":{"node":">=22"},"gitHead":"d1f4f1f2c9034f22e71cae3ae7dac353c596c0f7","release":false,"scripts":{"lint":"madrun lint","test":"madrun test","report":"madrun report","coverage":"madrun coverage","fix:lint":"madrun fix:lint","fresh:lint":"madrun fresh:lint","lint:fresh":"madrun lint:fresh","watch:test":"madrun watch:test"},"_npmUser":{"name":"coderaiser","email":"mnemonic.enemy@gmail.com"},"changelog":false,"repository":{"url":"git+https://github.com/coderaiser/putout.git","type":"git"},"_npmVersion":"11.4.2","description":"🐊Putout plugin adds ability to find and remove useless functions","directories":{},"_nodeVersion":"26.2.0","dependencies":{},"publishConfig":{"access":"public"},"_hasShrinkwrap":false,"devDependencies":{"eslint":"^10.0.0","madrun":"^13.0.0","nodemon":"^3.0.1","superc8":"^12.0.0","@putout/test":"^15.0.0","@putout/eslint-flat":"^4.0.0","eslint-plugin-putout":"^31.0.0"},"peerDependencies":{"putout":">=42"},"_npmOperationalInternal":{"tmp":"tmp/plugin-remove-useless-functions_6.0.0_1780607404717_0.39420085257591286","host":"s3://npm-registry-packages-npm-production"},"readme":"# @putout/plugin-remove-useless-functions [![NPM version][NPMIMGURL]][NPMURL]\n\n[NPMIMGURL]: https://img.shields.io/npm/v/@putout/plugin-remove-useless-functions.svg?style=flat&longCache=true\n[NPMURL]: https://npmjs.org/package/@putout/plugin-remove-useless-functions \"npm\"\n\n🐊[**Putout**](https://github.com/coderaiser/putout) plugin adds ability to find and remove `useless functions`.\n\n## Install\n\n```\nnpm i @putout/plugin-remove-useless-functions -D\n```\n\n## Rule\n\n```json\n{\n    \"rules\": {\n        \"remove-useless-functions\": \"on\"\n    }\n}\n```\n\n## ❌ Example of incorrect code\n\n```js\nconst y = (...a) => {\n    alert(...a);\n};\n\n[1, 2, null].filter((a) => a);\n\nconst a = {\n    condition: (path) => isObjectInsideArrow(path),\n};\n```\n\n## ✅ Example of correct code\n\n```js\nconst y = alert;\n[1, 2, null].filter(Boolean);\n\nconst a = {\n    condition: isObjectInsideArrow(path),\n};\n```\n\n## Open Questions\n\nWhy there is no transform for such case:\n\n```js\nconst f = (a) => alert(a);\n```\n\nIsn't is the same as:\n\n```js\nconst f = alert;\n```\n\nActually it is the same, and this example can be converted without an issue,\nbut there is also cases like:\n\n```js\nconst one = (f) => (a) => f(a);\n\n[\n    1,\n    2,\n    3,\n    4,\n].map(one(console.log));\n\n// output\n1;\n2;\n3;\n```\n\nAnd if it will be simplified:\n\n```js\nconst one = (f) => f;\n\n[\n    1,\n    2,\n    3,\n    4,\n].map(one(console.log));\n// output\n'1 0 [1, 2, 3]';\n'2 1 [1, 2, 3]';\n'3 2 [1, 2, 3]';\n```\n\nSo behaviour is totally different. The same result for:\n\n```js\n[\n    1,\n    2,\n    3,\n    4,\n].map(console.log);\n```\n\nBecause `map` calls a function with 3 arguments, and `console.log` receives any count of arguments,\nto cut redundant args there is a need to use something like:\n\n```js\nconst one = (f) => (a) => f(a);\n```\n\nThere is a lot such cases in the wild. While we have no syntax to set the count of `arguments` we are going to receive,\nand a way to avoid returning result we don't want function to return, there is no need in such a dengerous transform.\n\n## License\n\nMIT\n","publish_time":1780607404858,"_cnpm_publish_time":1780607404858,"dist-tags":{"latest":"6.1.0"}}