{"name":"@putout/plugin-nodejs","version":"17.1.2","keywords":["putout","putout-plugin","plugin","nodejs"],"author":{"url":"https://github.com/coderaiser","name":"coderaiser","email":"mnemonic.enemy@gmail.com"},"license":"MIT","_id":"@putout/plugin-nodejs@17.1.2","maintainers":[{"name":"coderaiser","email":"mnemonic.enemy@gmail.com"}],"homepage":"https://github.com/coderaiser/putout/tree/master/packages/plugin-nodejs#readme","bugs":{"url":"https://github.com/coderaiser/putout/issues"},"tag":false,"dist":{"shasum":"6a1ad5564477ba89e5cab0182380dea81fe97c2f","tarball":"http://registry-npm.ywwl.com/@putout/plugin-nodejs/download/@putout/plugin-nodejs-17.1.2.tgz","fileCount":42,"integrity":"sha512-89/S7jINDkokAmnVlxy99fpE7hyqdrUd+jnRH4qr84k7OvI/xWHJpih5wtA7YA22CVNbewLGKgQhD6DdP31mzg==","signatures":[{"sig":"MEYCIQDtxLOqh9hSaxJ+Ov89WcsFfDubw14cS3CNucoXW5kseAIhAJ4XJEXXCMLCHZvZ3g0QcB24gzZj8++l0Sj7WpUIOqRG","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":64443,"size":15550,"noattachment":false,"key":"/@putout/plugin-nodejs/-/@putout/plugin-nodejs-17.1.2.tgz"},"main":"lib/index.js","type":"module","engines":{"node":">=20"},"exports":{".":"./lib/index.js","./strict-mode":"./lib/strict-mode/index.js","./convert-commonjs-to-esm":"./lib/convert-commonjs-to-esm.js","./convert-esm-to-commonjs":"./lib/convert-esm-to-commonjs/index.js"},"gitHead":"002382276f4236cd85938a851866cd01efe0af51","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 transform code to new API of Node.js","directories":{},"_nodeVersion":"24.7.0","dependencies":{"just-camel-case":"^6.2.0"},"publishConfig":{"access":"public"},"_hasShrinkwrap":false,"devDependencies":{"c8":"^10.0.0","eslint":"^9.0.0","madrun":"^11.0.0","montag":"^1.2.1","nodemon":"^3.0.1","@putout/test":"^14.0.0","eslint-plugin-n":"^17.0.0","@putout/eslint-flat":"^3.0.0","eslint-plugin-putout":"^28.0.0","@putout/plugin-putout":"*","@putout/plugin-declare":"*","@putout/plugin-typescript":"*","@putout/plugin-reuse-duplicate-init":"*","@putout/plugin-declare-before-reference":"*"},"peerDependencies":{"putout":">=40"},"_npmOperationalInternal":{"tmp":"tmp/plugin-nodejs_17.1.2_1757429422002_0.9636852802905531","host":"s3://npm-registry-packages-npm-production"},"readme":"# @putout/plugin-nodejs [![NPM version][NPMIMGURL]][NPMURL]\n\n[NPMIMGURL]: https://img.shields.io/npm/v/@putout/plugin-nodejs.svg?style=flat&longCache=true\n[NPMURL]: https://npmjs.org/package/@putout/plugin-nodejs \"npm\"\n\n> **Node.js** is an open-source, cross-platform, **JavaScript** runtime environment.\n>\n> (c) [Nodejs.org](https://nodejs.org/en/)\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-nodejs -D\n```\n\n## Rules\n\n- ✅ [add-node-prefix](#add-node-prefix);\n- ✅ [apply-style-text](#apply-style-text);\n- ✅ [apply-inherit](#apply-inherit);\n- ✅ [add-missing-strict-mode](#add-missing-strict-mode);\n- ✅ [convert-buffer-to-buffer-alloc](#convert-buffer-to-buffer-alloc);\n- ✅ [convert-commonjs-to-esm](#convert-commonjs-to-esm);\n- ✅ [convert-dirname-to-url](#convert-dirname-to-url);\n- ✅ [convert-esm-to-commonjs](#convert-esm-to-commonjs);\n- ✅ [convert-exports-to-module-exports](#convert-exports-to-module-exports);\n- ✅ [convert-fs-promises](#convert-fs-promises);\n- ✅ [convert-promisify-to-fs-promises](#convert-promisify-to-fs-promises);\n- ✅ [convert-top-level-return](#convert-top-level-return);\n- ✅ [convert-url-parse-to-new-url](#convert-url-parse-to-new-url);\n- ✅ [convert-url-to-dirname](#convert-url-to-dirname);\n- ✅ [convert-default-export-to-default](#convert-default-export-to-default);\n- ✅ [declare](#declare);\n- ✅ [declare-after-require](#declare-after-require);\n- ✅ [group-require-by-id](#group-require-by-id);\n- ✅ [remove-process-exit](#remove-process-exit);\n- ✅ [remove-useless-promisify](#remove-useless-promisify);\n- ✅ [remove-top-level-process-exit](#remove-top-level-process-exit);\n- ✅ [remove-useless-strict-mode](#remove-useless-strict-mode);\n- ✅ [remove-useless-exports-assign](#remove-useless-exports-assign);\n- ✅ [remove-illegal-strict-mode](#remove-useless-strict-mode);\n\n## File rules\n\n- ✅ [apply-privately-required-file](#apply-privately-required-file);\n- ✅ [cjs-file](#cjs-file);\n- ✅ [mjs-file](#mjs-file);\n- ✅ [rename-file-cjs-to-js](#rename-file-cjs-to-js);\n- ✅ [rename-file-mjs-to-js](#rename-file-mjs-to-js);\n\n## Config\n\n```json\n{\n    \"rules\": {\n        \"nodejs/add-missing-strict-mode\": \"on\",\n        \"nodejs/add-node-prefix\": \"on\",\n        \"nodejs/apply-style-text\": \"on\",\n        \"nodejs/apply-inherit\": \"on\",\n        \"nodejs/apply-privately-required-file\": \"off\",\n        \"nodejs/convert-commonjs-to-esm\": \"off\",\n        \"nodejs/convert-esm-to-commonjs\": \"off\",\n        \"nodejs/cjs-file\": \"off\",\n        \"nodejs/mjs-file\": \"off\",\n        \"nodejs/rename-file-cjs-to-js\": \"off\",\n        \"nodejs/rename-file-mjs-to-js\": \"off\",\n        \"nodejs/convert-buffer-to-buffer-alloc\": \"on\",\n        \"nodejs/convert-fs-promises\": \"on\",\n        \"nodejs/convert-promisify-to-fs-promises\": \"on\",\n        \"nodejs/convert-dirname-to-url\": \"on\",\n        \"nodejs/convert-default-export-to-default\": \"on\",\n        \"nodejs/convert-exportst-to-module-exports\": \"on\",\n        \"nodejs/convert-url-to-dirname\": \"on\",\n        \"nodejs/convert-url-parse-to-new-url\": \"on\",\n        \"nodejs/convert-top-level-return\": \"on\",\n        \"nodejs/declare\": \"on\",\n        \"nodejs/declare-after-require\": \"on\",\n        \"nodejs/group-require-by-id\": \"on\",\n        \"nodejs/remove-process-exit\": \"on\",\n        \"nodejs/remove-illegal-strict-mode\": \"on\",\n        \"nodejs/remove-top-level-process-exit\": \"on\",\n        \"nodejs/remove-useless-promisify\": \"on\",\n        \"nodejs/remove-useless-strict-mode\": \"on\",\n        \"nodejs/remove-useless-exports-assign\": \"on\"\n    }\n}\n```\n\n## add-node-prefix\n\n> `Deno` supports using Node.js built-in modules such as `fs`, `path`, `process`, and many more via `node`: specifiers.\n>\n> (c) [deno.land](https://deno.land/manual@v1.36.3/node/node_specifiers)\n\nCheck out in 🐊[Putout Editor](https://putout.cloudcmd.io/#/gist/534093e0bf0a4407796c08d62bcbcb92/766a1d608f155920b21aa1f53a8e33280a664309).\n\n### ❌ Example of incorrect code\n\n```js\nimport fs from 'fs';\n\nconst path = require('path');\nawait import('path');\n```\n\n### ✅ Example of correct code\n\n```js\nimport fs from 'node:fs';\n\nconst path = require('node:path');\nawait import('node:path');\n```\n\n### Comparison\n\nLinter | Rule | Fix\n--------|-------|------------|\n🐊 **Putout** | [`add-node-prefix`](https://github.com/coderaiser/putout/tree/master/packages/plugin-nodejs/add-node-prefix#readme) | ✅\n⏣ **ESLint** | [`prefer-node-protocol`](https://github.com/eslint-community/eslint-plugin-n/blob/master/docs/rules/prefer-node-protocol.md#readme)  | ✅\n\n## apply-inherit\n\n> `'inherit'` equivalent to `['inherit', 'inherit', 'inherit']` or `[0, 1, 2]`\n>\n> (c) [nodejs.org](https://nodejs.org/api/child_process.html)\n\nCheck out in 🐊[Putout Editor](https://putout.cloudcmd.io/#/gist/4484be0da138f98ee421c088d57b79ef/7da6991556659592e6d85c5fc8a85be1ca952df9).\n\n### ❌ Example of incorrect code\n\n```js\nspawn('ls', [], {\n    stdio: [0, 1, 2],\n});\n```\n\n### ✅ Example of correct code\n\n```js\nspawn('ls', [], {\n    stdio: 'inherit',\n});\n```\n\n## apply-style-text\n\nFixes `TypeError`:\n\n> `TypeError [ERR_INVALID_ARG_VALUE]: The argument 'format' must be one of: 'reset', 'bold', 'dim', 'italic', 'underline', 'blink', 'inverse', 'hidden', 'strikethrough', 'doubleunderline', 'black', 'red', 'green', 'yellow', 'blue', 'magenta', 'cyan', 'white', 'bgBlack', 'bgRed', 'bgGreen', 'bgYellow', 'bgBlue', 'bgMagenta', 'bgCyan', 'bgWhite', 'framed', 'overlined', 'gray', 'redBright', 'greenBright', 'yellowBright', 'blueBright', 'magentaBright', 'cyanBright', 'whiteBright', 'bgGray', 'bgRedBright', 'bgGreenBright', 'bgYellowBright', 'bgBlueBright', 'bgMagentaBright', 'bgCyanBright', 'bgWhiteBright'. Received 'grey'`\n\nCheck out in 🐊[Putout Editor](https://putout.cloudcmd.io/#/gist/7d2ce9da4a4799398e3c110182ab7e7f/10a5878228fcb7486b0faa46713cfb902165d15c).\n\n### ❌ Example of incorrect code\n\n```js\nstyleText('grey', `${line}:${column}`);\n```\n\n### ✅ Example of correct code\n\n```js\nstyleText('gray', `${line}:${column}`);\n```\n\n## convert-buffer-to-buffer-alloc\n\n> The `Buffer()` function and `new Buffer()` constructor are **deprecated** due to API usability issues that can lead to accidental security issues.\n>\n> (c) [DEP0005](https://nodejs.org/api/deprecations.html#deprecations_dep0005_buffer_constructor)\n\nCheck out in 🐊[Putout Editor](https://putout.cloudcmd.io/#/gist/5379bcdfa3d76f7b7121c9671ae48375/2fc2c7f96fc8284788c00914a9b29bfeea8b13d4).\n\n### ❌ Example of incorrect code\n\n```js\nconst n = 100;\nconst buf = [];\n\nnew Buffer(123);\nnew Buffer(n);\nnew Buffer('hello');\n\nnew Buffer([]);\nnew Buffer(buf);\n```\n\n### ✅ Example of correct code\n\n```js\nconst n = 100;\nconst buf = [];\n\nBuffer.alloc(123);\nBuffer.alloc(n);\nBuffer.from('hello');\n\nBuffer.from([]);\nBuffer.from(buf);\n```\n\n## convert-fs-promises\n\nConvert [fs.promises](https://nodejs.org/dist/latest-v15.x/docs/api/fs.html#fs_fs_promises_api) into form that will be simpler to use and convert to and from **ESM**.\n\n### ❌ Example of incorrect code\n\n```js\nconst {readFile} = require('fs').promises;\n```\n\n### ✅ Example of correct code\n\n```js\nconst {readFile} = require('fs/promises');\n```\n\n## convert-promisify-to-fs-promises\n\n### ❌ Example of incorrect code\n\n```js\nconst fs = require('fs');\nconst readFile = promisify(fs.readFile);\n```\n\n### ✅ Example of correct code\n\n```js\nconst {readFile} = require('fs/promises');\n```\n\n## convert-dirname-to-url\n\nOnly for **ESM**.\n\n### ❌ Example of incorrect code\n\n```js\nconst {join} = require('path');\nconst path = require('path');\n\nconst file1 = join(__dirname, '../../package.json');\nconst file2 = path.join(__dirname, '../../package.json');\n```\n\n### ✅ Example of correct code\n\n```js\nconst file1 = new URL('../../package.json', import.meta.url);\nconst file2 = new URL('../../package.json', import.meta.url);\n```\n\n## convert-default-export-to-default\n\n> `MockModuleOptions.defaultExport` and `MockModuleOptions.namedExports` have been consolidated into a single option `lMockModuleOptions.exports` to align with user expectations and other test runners.\n>\n> (c) [Node.js v25.9.0](https://nodejs.org/en/blog/release/v25.9.0):\n\nCheckout in 🐊[**Putout Editor**](https://putout.cloudcmd.io/#/gist/998124eb43b7726033d74ea5935a47e4/eeed3689e491501c54d37fe1b8d57fd6597e3ebc).\n\n### ❌ Example of incorrect code\n\n```js\nmock.module('fs', {\n    defaultExport: hello,\n    namedExports: {\n        foo,\n        hello,\n        abc,\n    },\n});\n```\n\n### ✅ Example of correct code\n\n```js\nmock.module('fs', {\n    default: hello,\n    foo,\n    hello,\n    abc,\n});\n```\n\n## convert-url-to-dirname\n\nOnly for **CommonJS**.\n\n### ❌ Example of incorrect code\n\n```js\nconst {readFile} = require('fs/promises');\nconst file = new URL('../../package.json', import.meta.url);\n```\n\n### ✅ Example of correct code\n\n```js\nconst {readFile} = require('fs/promises');\nconst {join} = require('path');\nconst file = join(__dirname, '../../package.json');\n```\n\n## convert-url-parse-to-new-url\n\n> The legacy URL API is deprecated.  Please use the [WHATWG URL API](https://nodejs.org/docs/latest/api/url.html#the-whatwg-url-api) instead.\n>\n> (c) [nodejs.org](https://nodejs.org/docs/latest/api/deprecations.html#dep0116-legacy-url-api)\n\nCheckout in [**Putout Editor**](https://putout.cloudcmd.io/#/gist/add9bf9ea5e438e44701996fa19ce74f/73e7b94e7243b18c060e1a36781609bb79f90377).\n\n### ❌ Example of incorrect code\n\n```js\nconst parsed = url.parse(req.url);\n```\n\n### ✅ Example of correct code\n\n```js\nconst parsed = new URL(req.url);\n```\n\n## remove-process-exit\n\nIn most cases `process.exit()` is called from `bin` directory, if not - disable this rule using `match`.\n\n```diff\n-process.exit();\n```\n\n## remove-top-level-process-exit\n\nTop-level `process.exit()` has no sense (except debugging).\n\nCheckout in ✅[**Putout Editor**](https://putout.cloudcmd.io/#/gist/3aa8331269e49266d60914984027f9ed/9909ac2c07534299f64fee5ebf95cfc37ef04f11).\n\n```diff\n-process.exit();\n```\n\n## convert-exports-to-module-exports\n\nSince `exports = 5` wan't make any export, just change value of variable.\nCheckout in 🐊[**Putout Editor**](https://putout.cloudcmd.io/#/gist/8b2af2c4ad005ed1c77cde41377caaad/dfdccc794037d7f67bde1e7d7244bf5f14abebce).\n\n### ❌ Example of incorrect code\n\n```js\nexports.x = 5;\n```\n\n### ✅ Example of correct code\n\n```js\nmodule.exports.x = 5;\n```\n\n## convert-top-level-return\n\n### ❌ Example of incorrect code\n\n```js\nreturn;\n```\n\n### ✅ Example of correct code\n\n```js\nprocess.exit();\n```\n\n## declare\n\nAdd declarations to built-in node.js modules:\n\n- [buffer](https://nodejs.org/dist/latest-v24.x/docs/api/buffer.html);\n- [child_process](https://nodejs.org/dist/latest-v24.x/docs/api/child_process.html);\n- [events](https://nodejs.org/dist/latest-v24.x/docs/api/events.html);\n- [fs](https://nodejs.org/dist/latest-v24.x/docs/api/fs.html);\n- [path](https://nodejs.org/dist/latest-v24.x/docs/api/path.html);\n- [process](https://nodejs.org/dist/latest-v24.x/docs/api/process.html);\n- [module](https://nodejs.org/dist/latest-v24.x/docs/api/module.html);\n- [stream](https://nodejs.org/dist/latest-v24.x/docs/api/stream.html);\n- [os](https://nodejs.org/dist/latest-v24.x/docs/api/os.html);\n- [url](https://nodejs.org/dist/latest-v24.x/docs/api/url.html);\n- [util](https://nodejs.org/dist/latest-v24.x/docs/api/util.html);\n- [zlib](https://nodejs.org/dist/latest-v24.x/docs/api/zlib.html);\n- [timers](https://nodejs.org/dist/latest-v24.x/docs/api/timers.html);\n\nBased on [`@putout/operator-declare`](https://github.com/coderaiser/putout/tree/master/packages/operator-declare#putoutoperator-declare-).\n\n### ❌ Example of incorrect code\n\n```js\nawait readFile('hello.txt', 'utf8');\n```\n\n### ✅ Example of correct code\n\n```js\nimport {readFile} from 'fs/promises';\n\nawait readFile('hello.txt', 'utf8');\n```\n\nWhen you want to skip some declaration use `dismiss`:\n\n```json\n{\n    \"rules\": {\n        \"nodejs/declare\": [\"on\", {\n            \"dismiss\": [\"readFile\"]\n        }]\n    }\n}\n```\n\n## declare-after-require\n\n> **Node.js** follows the **CommonJS** module system, and the builtin `require` function is the easiest way to include modules that exist in separate files. The basic functionality of `require` is that it reads a JavaScript file, executes the file, and then proceeds to return the `exports` object.\n>\n> (c) [Nodejs.org](https://nodejs.org/en/knowledge/getting-started/what-is-require/)\n\nCheck out in 🐊[**Putout Editor**](https://putout.cloudcmd.io/#/gist/https://putout.cloudcmd.io/#/gist/ddf5731ae829beec4d3018d4d9ac2150/342738b63337bfa9b4fc08c5b301483ea2b5ba9c).For **ESM** use [`esm/declare-imports-first`](https://github.com/coderaiser/putout/tree/master/packages/plugin-esm#declare-imports-first).\n\n### ❌ Example of incorrect code\n\n```js\nconst name = 'hello.txt';\nconst {readFile} = require('fs/promises');\n```\n\n### ✅ Example of correct code\n\n```js\nconst {readFile} = require('fs/promises');\nconst name = 'hello.txt';\n```\n\n## convert-commonjs-to-esm/require\n\nConvert **CommonJS** **EcmaScript Modules**.\n\n> **EcmaScript module** syntax is the standard way to import and export values between files in **JavaScript**. The `import` statement can be used to reference a value exposed by the `export` statement in another file.\n>\n> (c) [parceljs](https://parceljs.org/languages/javascript/)\n\n### ❌ Example of incorrect code\n\n```js\nconst {join} = require('path');\n\nconst args = require('minimist')({\n    string: ['a', 'b'],\n});\n```\n\n### ✅ Example of correct code\n\n```js\nimport {join} from 'path';\nimport minimist from 'minimist';\n\nconst args = minimist({\n    string: ['a', 'b'],\n});\n```\n\n## convert-commonjs-to-esm/exports\n\nCheckout in 🐊[**Putout Editor**](https://putout.cloudcmd.io/#/gist/39dd730c35e488db3e2cf8d4b4df0c5a/feb042a49539e6b4b2165558a1c636b705726c47).\n\n### ❌ Example of incorrect code\n\n```js\nmodule.exports = () => {};\n```\n\n### ✅ Example of correct code\n\n```js\nexport default () => {};\n```\n\n## convert-commonjs-to-esm/commons\n\n### ❌ Example of incorrect code\n\n```js\nconst {readFile} = require('fs/promises');\n\nawait readFile(__filename);\n```\n\n### ✅ Example of correct code\n\n```js\nimport {readFile} from 'fs/promises';\nimport {fileURLToPath} from 'url';\n\nconst __filename = fileURLToPath(import.meta.url);\nawait readFile(__filename);\n```\n\n## group-require-by-id\n\nCheckout in 🐊[**Putout Editor**](https://putout.cloudcmd.io/#/gist/ff39c5d912d836a25b96772d8045dacb/fa8d8e1ebf8ac5f19a536247536f4bccf4fdac3d). For **ESM** use [`esm/group-imports-by-sources`](https://github.com/coderaiser/putout/tree/master/packages/plugin-esm#group-imports-by-source).\n\n### ❌ Example of incorrect code\n\n```js\nconst ss = require('../../bb/ss');\nconst d = require('../hello');\nconst react = require('react');\nconst {lodash} = require('lodash');\nconst fs = require('node:fs');\nconst b = require('./ss');\nconst m = require(x);\nconst c = 5;\n```\n\n### ✅ Example of correct code\n\n```js\nconst fs = require('node:fs');\nconst react = require('react');\nconst {lodash} = require('lodash');\nconst ss = require('../../bb/ss');\nconst d = require('../hello');\n\nconst b = require('./ss');\nconst m = require(x);\nconst c = 5;\n```\n\n## convert-esm-to-commonjs\n\n> **CommonJS** is a module system supported in Node, it provides a `require` function, which can be used to access the `exports` object exposed by another file.\n>\n> (c) [parceljs](https://parceljs.org/languages/javascript/)\n\nConvert **EcmaScript Modules** to **CommonJS**.\n\n### ❌ Example of incorrect code\n\n```js\nimport hello from 'world';\n```\n\n### ✅ Example of correct code\n\n```js\nconst hello = require('world');\n```\n\n## cjs-file\n\nRun [convert-esm-to-commonjs](#convert-esm-to-commonjs) for all `*.cjs` files with help of [redlint](https://github.com/putoutjs/redlint).\n\nCheck out in 🐊[Putout Editor](https://putout.cloudcmd.io/#/gist/779e7fb720af59afc2d3da082088fd4c/d0b85b07c6aaf2b902a1c7eb7ae121dbcd181033).\n\n## mjs-file\n\nRun [convert-commonjs-to-esm](#convert-commonjs-to-esm) for all `*.cjs` files with help of [redlint](https://github.com/putoutjs/redlint).\n\nCheck out in 🐊[Putout Editor](https://putout.cloudcmd.io/#/gist/779e7fb720af59afc2d3da082088fd4c/d0b85b07c6aaf2b902a1c7eb7ae121dbcd181033).\n\n## rename-file-cjs-to-js\n\nRename `*.cjs` files when `type === \"commonjs\"`:\n\n```diff\n /\n |-- package.json\n `-- lib/\n-     `-- hello.cjs\n+     `-- hello.js\n```\n\nCheck out in 🐊[Putout Editor](https://putout.cloudcmd.io/#/gist/8d8f3cd6662b70abbd5e4a2e4835077f/e43319fd63291ec3a5028b30a83f3c91fe90325e).\n\n## rename-file-mjs-to-js\n\nRename `*.mjs` files when `type === \"module\"`:\n\n```diff\n /\n |-- package.json\n `-- lib/\n-     `-- hello.mjs\n+     `-- hello.js\n```\n\nCheck out in 🐊[Putout Editor](https://putout.cloudcmd.io/#/gist/94fb3298b210e703b01db9a6826942bc/dfe2462451c6b3d4d47da7fd8d39dc8e53bb16eb).\n\n## add-missing-strict-mode\n\n> **Strict mode** makes several changes to normal **JavaScript** semantics:\n>\n> - Eliminates some **JavaScript** silent errors by changing them to throw errors.\n> - Fixes mistakes that make it difficult for **JavaScript** engines to perform optimizations: strict mode code can sometimes be made to run faster than identical code that's not strict mode.\n> - Prohibits some syntax likely to be defined in future versions of **ECMAScript**.\n>\n> (c) [MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Strict_mode)\n\nAdd **strict mode** to **CommonJS**:\n\n### ❌ Example of incorrect code\n\n```js\nconst a = require('b');\n```\n\n### ✅ Example of correct code\n\n```js\n'strict mode';\n\nconst a = require('b');\n```\n\n### ✅ Example of correct code\n\n## remove-useless-strict-mode\n\n> The entire contents of JavaScript modules are automatically in strict mode, with no statement needed to initiate it.\n>\n> (c) [MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Strict_mode)\n\n### ❌ Example of incorrect code\n\n```js\n'strict mode';\n\nimport a from 'b';\n```\n\n### ✅ Example of correct code\n\n```js\nimport a from 'b';\n```\n\n## remove-useless-exports-assign\n\nCheckout in 🐊[**Putout Editor**](https://putout.cloudcmd.io/#/gist/c4dbbdae2d02a11421320d99873ffb48/7d22a36f109125d9750794d881651a24e5d8e4bb).\n\n### ❌ Example of incorrect code\n\n```js\nexports = require('./abc.js');\nmodule.exports = exports;\n```\n\n### ✅ Example of correct code\n\n```js\nmodule.exports = require('./abc.js');\n```\n\n## remove-illegal-strict-mode\n\n> `SyntaxError: \"use strict\" not allowed in function with non-simple parameters`\n> The JavaScript exception `\"use strict\" not allowed in function` occurs when a `use strict` directive is used at the top of a function with default parameters, rest parameters, or destructuring parameters.\n>\n> (c) [MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Errors/Strict_non_simple_params)\n\nCheckout in 🐊[**Putout Editor**](https://putout.cloudcmd.io/#/gist/a2ff9020bd33d11f3927d4d68c830c50/e6732329a0cca03c09ec0d36b43bfaec17966eff).\n\n### ❌ Example of incorrect code\n\n```ts\nfunction x1(...a) {\n    'use strict';\n}\n\nfunction x2(a, b = 3) {\n    'use strict';\n}\n\nfunction x3({a}) {\n    'use strict';\n}\n\nfunction x4([a]) {\n    'use strict';\n}\n\nfunction x5(...a) {\n    'use strict';\n}\n```\n\n### ✅ Example of correct code\n\n```js\nfunction x1(...a) {}\n\nfunction x2(a, b = 3) {}\n\nfunction x3({a}) {}\n\nfunction x4([a]) {}\n\nfunction x5(...a) {}\n```\n\n## remove-useless-promisify\n\n> Takes a function following the common error-first callback style, i.e. taking an (err, value) => ... callback as the last argument, and returns a version that returns promises.\n>\n> (c) [nodejs.org](https://nodejs.org/dist/latest-v21.x/docs/api/util.html#utilpromisifyoriginal)\n\nRemove useless [`promisify()`](https://nodejs.org/dist/latest-v21.x/docs/api/util.html#utilpromisifyoriginal). Checkout in 🐊[**Putout Editor**](https://putout.cloudcmd.io/#/gist/31000391865a36dfec2f8db5c2e98601/ce8867f83a84ecbe073637b9ceae58a443817187).\n\n### ❌ Example of incorrect code\n\n```js\nexport const readSize = promisify(async (dir, options, callback) => {});\n```\n\n### ✅ Example of correct code\n\n```js\nexport const readSize = async (dir, options, callback) => {};\n```\n\n## apply-privately-required-file\n\n> Entries in the imports field must be strings starting with `#`.\n> Package imports permit mapping to external packages.\n> This field defines subpath imports for the current package.\n>\n> (c) [nodejs.org](https://nodejs.org/api/packages.html#imports)\n\nLet's consider file structure:\n\n```\n/\n|-- package.json {\"imports\": {\"#is\": {\"default\": \"./lib/tokenize/is.js\"}}}\n|-- lib/\n|  `-- tokenize/\n|     `-- is.js \"export const isPrev = () => {}\"\n|     `-- expressions/\n        `-- spread-element.js \"const {isPrev} = require('../is.js')\"\n```\n\nIn this case `spread-element.js` can be fixed:\n\n### ❌ Example of incorrect code\n\n```js\nconst {isPrev} = require('../is.js');\n```\n\n### ✅ Example of correct code\n\n```js\nconst {isPrev} = require('#is');\n```\n\n## License\n\nMIT\n","publish_time":1757429422215,"_cnpm_publish_time":1757429422215,"dist-tags":{"latest":"21.14.0"}}