{"_id":"@putout/plugin-return@4.2.0","tag":false,"bugs":{"url":"https://github.com/coderaiser/putout/issues"},"dist":{"shasum":"b61ce924747ae8f9c83f730b98f19b5c31d212d3","tarball":"http://registry-npm.ywwl.com/@putout/plugin-return/download/@putout/plugin-return-4.2.0.tgz","fileCount":12,"integrity":"sha512-RFuCaJuJtLMtg+lx2E5kkpKeU1ow8NAy0V0nQwlVl61xfFyMwnyFXB8y5fBtApGwsXjD7yzNZRWihQ8k/EWvbw==","signatures":[{"sig":"MEQCID1bumzL/c09xzmYO21qV6GeJIDc49C9eZbxSnYn9VuEAiBbOlj0DciewWUryr23Z4ZnAwOi5dKCQpuy9VunDQr+GQ==","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"},{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEQCIFLplDktaSZGgx4eow9dZ7v8Hm/tLWLpfh2UoD1b0Bn5AiADbMGjMTRBDun2sUsgAElZ/Lc0NXLMpRzod41iTFhBig=="}],"unpackedSize":15817,"size":5129,"noattachment":false,"key":"/@putout/plugin-return/-/@putout/plugin-return-4.2.0.tgz"},"main":"lib/index.js","name":"@putout/plugin-return","type":"module","author":{"url":"https://github.com/coderaiser","name":"coderaiser","email":"mnemonic.enemy@gmail.com"},"engines":{"node":">=22"},"gitHead":"c0d7acd791b58422ef71691a62ddf0e2d398191d","license":"MIT","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"},"version":"4.2.0","_npmUser":{"name":"coderaiser","email":"mnemonic.enemy@gmail.com"},"homepage":"https://github.com/coderaiser/putout/tree/master/packages/plugin-return#readme","keywords":["putout","putout-plugin","plugin","return"],"changelog":false,"repository":{"url":"git+https://github.com/coderaiser/putout.git","type":"git"},"_npmVersion":"12.1.0","description":"🐊Putout plugin adds ability to transform code related to return","directories":{},"maintainers":[{"name":"coderaiser","email":"mnemonic.enemy@gmail.com"}],"_nodeVersion":"26.13.0","dependencies":{},"publishConfig":{"access":"public"},"_hasShrinkwrap":false,"devDependencies":{"eslint":"^10.0.0","madrun":"^13.0.0","montag":"^2.0.0","nodemon":"^3.0.1","superc8":"^12.0.0","@putout/test":"^15.0.0","eslint-plugin-putout":"^31.0.0","@putout/plugin-putout":"*","@putout/plugin-declare":"*","@putout/plugin-variables":"*","@putout/plugin-typescript":"*","@putout/plugin-reuse-duplicate-init":"*","@putout/plugin-declare-before-reference":"*"},"peerDependencies":{"putout":">=42"},"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/plugin-return_4.2.0_1794378865375_0.7819866875512147"},"readme":"# @putout/plugin-return [![NPM version][NPMIMGURL]][NPMURL]\n\n[NPMIMGURL]: https://img.shields.io/npm/v/@putout/plugin-return.svg?style=flat&longCache=true\n[NPMURL]: https://npmjs.org/package/@putout/plugin-return \"npm\"\n\n> The `return` statement ends function execution and specifies a value to be returned to the function caller.\n>\n> (c) [MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/return)\n\n🐊[**Putout**](https://github.com/coderaiser/putout) plugin adds ability to transform to new **Node.js** API and apply best practices.\n\n## Install\n\n```\nnpm i putout @putout/plugin-return -D\n```\n\n## Rules\n\n- ✅ [apply-early-return](#apply-early-return);\n- ✅ [convert-from-break](#convert-from-continue);\n- ✅ [convert-from-continue](#convert-from-continue);\n- ✅ [merge-with-next-sibling](#merge-with-next-sibling);\n- ✅ [remove-last-empty](#remove-last-empty);\n- ✅ [remove-useless](#remove-useless);\n- ✅ [simplify-boolean](#simplify-boolean);\n\n## Config\n\n```json\n{\n    \"rules\": {\n        \"return/apply-early-return\": \"on\",\n        \n        \"return/convert-from-break\": \"on\",\n        \"return/convert-from-continue\": \"on\",\n        \n        \"return/merge-with-next-sibling\": \"on\",\n        \n        \"return/remove-last-empty\": \"on\",\n        \"return/remove-useless\": \"on\",\n        \n        \"return/simplify-boolean\": \"on\"\n    }\n}\n```\n\n## apply-early-return\n\n> In short, an **early return** provides functionality so the result of a conditional statement can be returned as soon as a result is available, rather than wait until the rest of the function is run.\n>\n> (c) [dev.to](https://dev.to/jenniferlynparsons/early-returns-in-javascript-5hfb)\n\n### ❌ Example of incorrect code\n\n```js\nfunction get(a) {\n    const b = 0;\n    \n    if (a > 0)\n        return 5;\n    \n    return 7;\n}\n```\n\n### ✅ Example of correct code\n\n```js\nfunction get(a) {\n    if (a > 0)\n        return 5;\n    \n    return 7;\n}\n```\n\n## convert-from-continue\n\n> The `continue` statement terminates execution of the statements in the current iteration of the current or labeled loop, and continues execution of the loop with the next iteration.\n>\n> (c) [MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/continue)\n\n> `SyntaxError: Illegal continue statement: no surrounding iteration statement`\n>\n> (c) [MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Errors/Bad_continue)\n\nCheckout in 🐊[**Putout Editor**](https://putout.cloudcmd.io/#/gist/a321ee4d76a066c17835b4aa50f91499/e0d161c7bd8b0d63ebf8d5a5026529c2fb8e0cb3).\n\n### ❌ Example of incorrect code\n\n```ts\nfunction x() {\n    if (a)\n        continue;\n    \n    return b;\n}\n```\n\n### ✅ Example of correct code\n\n```js\nfunction x() {\n    if (a)\n        return;\n    \n    return b;\n}\n```\n\n## convert-from-break\n\n> The `break` statement terminates the current loop or switch statement and transfers program control to the statement following the terminated statement.\n>\n> (c) [MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Spread_syntax)\n\n> `SyntaxError: unlabeled break must be inside loop or switch`\n>\n> (c) [MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Errors/Bad_break)\n\nCheckout in 🐊[**Putout Editor**](https://putout.cloudcmd.io/#/gist/a321ee4d76a066c17835b4aa50f91499/10646f7383b8d58cda02417485d5281955da95be).\n\n### ❌ Example of incorrect code\n\n```ts\nfunction x() {\n    if (a)\n        break;\n    \n    return false;\n}\n```\n\n### ✅ Example of correct code\n\n```js\nfunction x() {\n    if (a)\n        return;\n    \n    return false;\n}\n```\n\n## merge-with-next-sibling\n\nCheckout in 🐊[**Putout Editor**](https://putout.cloudcmd.io/#/gist/2cb7e8836ce0adb6009f21859f8a0c15/9eea5b36a4f6664b05f2f9f0abd271a62a4dbbbe).\n\n### ❌ Example of incorrect code\n\n```js\nfunction x() {\n    return;\n    {\n        hello: 'world';\n    }\n    \n    return;\n    5;\n    \n    return;\n    a ? 2 : 3;\n}\n```\n\n### ✅ Example of correct code\n\n```js\nfunction x() {\n    return {\n        hello: 'world',\n    };\n    \n    return 5;\n    \n    return a ? 2 : 3;\n}\n```\n\n### remove-useless\n\n### ❌ Example of incorrect code\n\n```js\nconst traverse = ({push}) => {\n    return {\n        ObjectExpression(path) {\n            push(path);\n        },\n    };\n};\n```\n\n### ✅ Example of correct code\n\n```js\nconst traverse = ({push}) => ({\n    ObjectExpression(path) {\n        push(path);\n    },\n});\n```\n\n### remove-last-empty\n\nCheckout in 🐊[**Putout Editor**](https://putout.cloudcmd.io/#/gist/111549a3e6d61f8637ea12217062ea80/10e7842f9fbbf7fb0712d3b41cdcc707ae410fe5).\n\n### ❌ Example of incorrect code\n\n```js\nconst exit = (vars, path, {push}) => {\n    push(path);\n    return;\n};\n```\n\n### ✅ Example of correct code\n\n```js\nconst exit = (vars, path, {push}) => {\n    push(path);\n};\n```\n\n## simplify-boolean\n\nCheck out in 🐊[**Putout Editor**](https://putout.cloudcmd.io/#/gist/304035b9529830cf20e76e9a1f35f14c/39c743921c6bfad3984a3989f25c2986ab51e8c8).\n\n### ❌ Example of incorrect code\n\n```js\nfunction isA(a, b) {\n    if (a.length === b.length)\n        return true;\n    \n    return false;\n}\n```\n\n### ✅ Example of correct code\n\n```js\nfunction isA(a, b) {\n    return a.length !== b.length;\n}\n```\n\n## License\n\nMIT\n","publish_time":1794378865461,"_cnpm_publish_time":1794378865461,"dist-tags":{"latest":"4.2.0"}}