{"name":"@putout/plugin-remove-useless-functions","version":"6.1.0","type":"module","author":{"name":"coderaiser","email":"mnemonic.enemy@gmail.com","url":"https://github.com/coderaiser"},"description":"🐊Putout plugin adds ability to find and remove useless functions","homepage":"https://github.com/coderaiser/putout/tree/master/packages/plugin-remove-useless-functions#readme","main":"lib/remove-useless-functions.js","release":false,"tag":false,"changelog":false,"repository":{"type":"git","url":"git+https://github.com/coderaiser/putout.git"},"scripts":{"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","putout-plugin-remove","plugin","remove","useless","functions"],"devDependencies":{"@putout/eslint-flat":"^4.0.0","@putout/test":"^15.0.0","eslint":"^10.0.0","eslint-plugin-putout":"^31.0.0","madrun":"^13.0.0","nodemon":"^3.0.1","superc8":"^12.0.0"},"peerDependencies":{"putout":">=42"},"license":"MIT","engines":{"node":">=22"},"publishConfig":{"access":"public"},"_id":"@putout/plugin-remove-useless-functions@6.1.0","gitHead":"27da28c7bbf53f548f345f73103c54338312f945","bugs":{"url":"https://github.com/coderaiser/putout/issues"},"_nodeVersion":"26.4.0","_npmVersion":"11.4.2","dist":{"integrity":"sha512-LdBGGEXGN+PeIeYM8UZAyNMLnHL07IjjJQnE574FjMbN+6wraYuwEZPZkUfSjMmPNru8xcDYsMhdFxytGPhKZg==","shasum":"cf2a64da8068997817a11bac8c90eaca91a3fb79","tarball":"http://registry-npm.ywwl.com/@putout/plugin-remove-useless-functions/download/@putout/plugin-remove-useless-functions-6.1.0.tgz","fileCount":4,"unpackedSize":5885,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEUCIQDwYtubS20IaE8INtdL5QmaAEx5HLCR8h0XhbF0ufcU9AIgVtgjkmPJ/Zml78d/lToZqE6QB0bf3rwgxfahVBGYqAA="}],"size":2587,"noattachment":false,"key":"/@putout/plugin-remove-useless-functions/-/@putout/plugin-remove-useless-functions-6.1.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-npm-production","tmp":"tmp/plugin-remove-useless-functions_6.1.0_1782643777055_0.3178795783722004"},"_hasShrinkwrap":false,"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":1782643777225,"_cnpm_publish_time":1782643777225,"dist-tags":{"latest":"6.1.0"}}