{"name":"@putout/plugin-apply-overrides","version":"3.0.0","type":"module","author":{"name":"coderaiser","email":"mnemonic.enemy@gmail.com","url":"https://github.com/coderaiser"},"description":"🐊Putout plugin adds ability apply 'overrides'","homepage":"https://github.com/coderaiser/putout/tree/master/packages/plugin-apply-overrides#readme","main":"lib/apply-overrides.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","plugin","overrides"],"devDependencies":{"@putout/test":"^13.0.0","c8":"^10.0.0","eslint":"^9.0.0","eslint-plugin-n":"^17.0.0","eslint-plugin-putout":"^26.0.0","madrun":"^11.0.0","nodemon":"^3.0.1"},"peerDependencies":{"putout":">=40"},"license":"MIT","engines":{"node":">=20"},"publishConfig":{"access":"public"},"_id":"@putout/plugin-apply-overrides@3.0.0","gitHead":"ade7dca8bf8aa5bf31195c6931e7feee11720365","bugs":{"url":"https://github.com/coderaiser/putout/issues"},"_nodeVersion":"20.19.0","_npmVersion":"11.1.0","dist":{"integrity":"sha512-0fr0SVuZNpUWWGvttHVRxtsmX6/sttF3I0MfbW6TboH/dbBXv4IKfkGB7wLAs7x/lEHWcoxYbsYtm/emsioLvw==","shasum":"b8b1b4f63a8b6b5c253f011002cbacdca9b7f68e","tarball":"http://registry-npm.ywwl.com/@putout/plugin-apply-overrides/download/@putout/plugin-apply-overrides-3.0.0.tgz","fileCount":4,"unpackedSize":6084,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEUCIDb8lEoS45VBvp+s9rx+JyK9DWOdf8qQxIaMTx0CgjtTAiEAxFvBI84XHC7ZJm7LgakZlwPjZZiVZagPHwLCZOe5fFs="}],"size":2738,"noattachment":false,"key":"/@putout/plugin-apply-overrides/-/@putout/plugin-apply-overrides-3.0.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-apply-overrides_3.0.0_1744647038211_0.05029275932220445"},"_hasShrinkwrap":false,"readme":"# @putout/plugin-apply-overrides [![NPM version][NPMIMGURL]][NPMURL]\n\n[NPMIMGURL]: https://img.shields.io/npm/v/@putout/plugin-apply-overrides.svg?style=flat&longCache=true\n[NPMURL]: https://npmjs.org/package/@putout/plugin-apply-overrides \"npm\"\n\n🐊[**Putout**](https://github.com/coderaiser/putout) plugin adds ability to apply `overrides`.\n\nCheckout in 🐊[**Putout Editor**](https://putout.cloudcmd.io/#/gist/2f03cfd6d8dab1431ef388fb9168a017/098a08fd5ba26e5b7dc12e3adcd9766dce6aca0c).\n\nWhen you write testable code and want to avoid mocking `require`d or `import`ed modules, one of a solutions to use simple form\nof dependency injection:\n\n```js\nimport {readDirSync as _readdirSync} from 'node:fs/promises';\n\nexport const readRules = (dirOpt, rulesDir, overrides = {}) => {\n    const {\n        cwd,\n        readdirSync = _readdirSync,\n    } = overrides;\n};\n```\n\nPass `overrides` as last parameter, in this case use can test easily your function `readFules`:\n\n```js\nimport {test, stub} from 'supertape';\n\ntest('readRules', (t) => {\n    const readdirSync = stub().returns([]);\n    const rules = readRules('', '', {\n        readdirSync,\n    });\n    \n    t.equal(rules, []);\n    t.end();\n});\n```\n\nThen only issue is, when you have lots of parameters, your function declaration will be to long, or to hard to read, so recommended way is to use `overrides` variable.\n\n## Install\n\n```\nnpm i @putout/plugin-apply-overrides\n```\n\n## Rule\n\n```json\n{\n    \"rules\": {\n        \"apply-overrides\": \"on\"\n    }\n}\n```\n\n## ❌ Example of incorrect code\n\n```js\nasync function matchToFlatDir(path, config, {readESLintConfig = _readESLintConfig} = {}) {}\n```\n\n## ✅ Example of correct code\n\n```js\nasync function matchToFlatDir(path, config, overrides = {}) {\n    const {\n        readESLintConfig = _readESLintConfig,\n    } = overrides;\n}\n```\n\n## License\n\nMIT\n","publish_time":1744647038370,"_cnpm_publish_time":1744647038370,"dist-tags":{"latest":"3.0.0"}}