{"name":"@putout/plugin-convert-mock-require-to-mock-import","version":"4.1.1","type":"commonjs","author":{"name":"coderaiser","email":"mnemonic.enemy@gmail.com","url":"https://github.com/coderaiser"},"description":"🐊Putout plugin adds ability to convert mockRequire to mockImport","homepage":"https://github.com/coderaiser/putout/tree/v32.16.0/packages/plugin-convert-mock-require-to-mock-import#readme","main":"lib/convert-mock-require-to-mock-import.js","release":false,"tag":false,"changelog":false,"repository":{"type":"git","url":"git://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","convert","mock-require","mock-import"],"devDependencies":{"@putout/plugin-tape":"*","@putout/test":"^7.0.0","c8":"^8.0.0","eslint":"^8.0.1","eslint-plugin-n":"^16.0.0","eslint-plugin-putout":"^21.0.0","madrun":"^9.0.0"},"peerDependencies":{"putout":">=26"},"license":"MIT","engines":{"node":">=16"},"publishConfig":{"access":"public"},"gitHead":"006c9514eed57953b98381d4a9feacc8df16b031","bugs":{"url":"https://github.com/coderaiser/putout/issues"},"_id":"@putout/plugin-convert-mock-require-to-mock-import@4.1.1","_nodeVersion":"18.16.0","_npmVersion":"9.6.6","dist":{"integrity":"sha512-giw6vaAPDpj/zl9tSZVn/MAThYYacnVYIR4ulIv2rLq8whFGzRA8/K+ti7fo/BZuIzEEnFLtzzer6VAqRoGp/g==","shasum":"bfcfb1780ce8873f83694bc46e3e0bf38b65f918","tarball":"http://registry-npm.ywwl.com/@putout/plugin-convert-mock-require-to-mock-import/download/@putout/plugin-convert-mock-require-to-mock-import-4.1.1.tgz","fileCount":4,"unpackedSize":5471,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQCliaO+KaTbNaDw8q4evBYMLZ0knQ64LfAswFa2SzJgPQIgAIv7UX0k6ECCi+sw0XIe57Wat4ssm5IOEUpbEX8/7yU="}],"size":2366,"noattachment":false,"key":"/@putout/plugin-convert-mock-require-to-mock-import/-/@putout/plugin-convert-mock-require-to-mock-import-4.1.1.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-convert-mock-require-to-mock-import_4.1.1_1699480019068_0.0645551146023593"},"_hasShrinkwrap":false,"readme":"# @putout/plugin-convert-mock-require-to-mock-import [![NPM version][NPMIMGURL]][NPMURL]\n\n[NPMIMGURL]: https://img.shields.io/npm/v/@putout/plugin-convert-mock-require-to-mock-import.svg?style=flat&longCache=true\n[NPMURL]: https://npmjs.org/package/@putout/plugin-convert-mock-require-to-mock-import \"npm\"\n\n🐊[**Putout**](https://github.com/coderaiser/putout) plugin adds ability to convert [mockRequire](https://github.com/boblauer/mock-require) to [mockImport](https://github.com/coderaiser/mock-import). Moved to [`@putout/plugin-tape`](https://www.npmjs.com/package/@putout/plugin-tape).\n\n## Install\n\n```\nnpm i @putout/plugin-convert-mock-require-to-mock-import -D\n```\n\n## Rule\n\nRule `convert-mock-require-to-mock-import` is enabled by default for `*.mjs`, to disable add to `.putout.json`:\nGood complement of [@putout/plugin-tape](https://github.com/coderaiser/putout/tree/master/packages/plugin-tape#putoutplugin-tape-)\n\n```json\n{\n    \"rules\": {\n        \"convert-mock-require-to-mock-import\": \"off\"\n    }\n}\n```\n\n## ❌ Example of incorrect code\n\n```js\nconst mockRequire = require('mock-require');\n\nconst {reRequire, stopAll} = mockRequire;\n\ntest('', (t) => {\n    mockRequire('fs/promises', {\n        unlink: stub(),\n    });\n    \n    const fn = reRequire('..');\n    fn();\n    \n    stopAll();\n    t.end();\n});\n```\n\n## ✅ Example of correct code\n\n```js\nimport {createMockImport} from 'mock-import';\n\nconst {\n    mockImport,\n    reImport,\n    stopAll,\n} = createMockImport(import.meta.url);\n\ntest('', async (t) => {\n    mockImport('fs/promises', {\n        unlink: stub(),\n    });\n    \n    const fn = await reImport('..');\n    fn();\n    \n    stopAll();\n    t.end();\n});\n```\n\n## License\n\nMIT\n","publish_time":1699480019269,"_cnpm_publish_time":1699480019269,"dist-tags":{"latest":"4.1.1"}}