@putout/plugin-nodejs 11.9.1 → 11.11.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -15,7 +15,32 @@
15
15
  npm i putout @putout/plugin-nodejs -D
16
16
  ```
17
17
 
18
- ## Options
18
+ ## Rules
19
+
20
+ - ✅ [add-node-prefix][#add-node-prefix];
21
+ - ✅ [convert-buffer-to-buffer-alloc][#convert-buffer-to-buffer-alloc];
22
+ - ✅ [convert-commonjs-to-esm-commons][#convert-commonjs-to-esm-commons];
23
+ - ✅ [convert-commonjs-to-esm-exports][#convert-commonjs-to-esm-exports];
24
+ - ✅ [convert-commonjs-to-esm-require][#convert-commonjs-to-esm-require];
25
+ - ✅ [convert-commonjs-to-esm.js][#convert-commonjs-to-esm.js];
26
+ - ✅ [convert-dirname-to-url][#convert-dirname-to-url];
27
+ - ✅ [convert-esm-to-commonjs][#convert-esm-to-commonjs];
28
+ - ✅ [convert-exports-to-module-exports][#convert-exports-to-module-exports];
29
+ - ✅ [convert-fs-promises][#convert-fs-promises];
30
+ - ✅ [convert-promisify-to-fs-promises][#convert-promisify-to-fs-promises];
31
+ - ✅ [convert-top-level-return][#convert-top-level-return];
32
+ - ✅ [convert-url-to-dirname][#convert-url-to-dirname];
33
+ - ✅ [declare][#declare];
34
+ - ✅ [declare-after-require][#declare-after-require];
35
+ - ✅ [remove-process-exit][#remove-process-exit];
36
+ - ✅ [remove-useless-promisify][#remove-useless-promisify];
37
+ - ✅ [rename-file-cjs-to-js][#rename-file-cjs-to-js];
38
+ - ✅ [rename-file-mjs-to-js][#rename-file-mjs-to-js];
39
+ - ✅ [strict-mode][#strict-mode];
40
+ - ✅ [cjs-file][#cjs-file];
41
+ - ✅ [mjs-file][#mjs-file];
42
+
43
+ ## Config
19
44
 
20
45
  ```json
21
46
  {
@@ -1,15 +1,22 @@
1
1
  'use strict';
2
2
 
3
- const {types, template} = require('putout');
3
+ const {types} = require('putout');
4
4
  const {isImportDefaultSpecifier} = types;
5
5
 
6
+ const BODY = '{__body}';
7
+ const FN = `function __a(__args) ${BODY}`;
8
+ const GEN_FN = `function* __a(__args) ${BODY}`;
9
+ const ASYNC_FN = `async function __a(__args) ${BODY}`;
10
+ const CLASS = `class __a ${BODY}`;
11
+
6
12
  module.exports.report = () => `Use 'CommonJS' instead of 'ESM'`;
7
13
 
8
14
  module.exports.replace = () => ({
9
15
  'export default __a': 'module.exports = __a',
10
- 'export class __a {}': 'module.exports.__a = class __a {}',
11
- 'export function __a(__args) {}': replaceFn,
12
- 'export async function __a(__args) {}': replaceFn,
16
+ [`export ${CLASS}`]: `module.exports.__a = ${CLASS}`,
17
+ [`export ${FN}`]: `module.epxorts.__a = ${FN}`,
18
+ [`export ${ASYNC_FN}`]: `module.epxorts.__a = ${ASYNC_FN}`,
19
+ [`export ${GEN_FN}`]: `module.epxorts.__a = ${GEN_FN}`,
13
20
  'export const __a = __b': 'module.exports.__a = __b',
14
21
  'export {__exports}': ({__exports}) => {
15
22
  let result = 'module.exports = {\n';
@@ -56,13 +63,3 @@ module.exports.replace = () => ({
56
63
  }`;
57
64
  },
58
65
  });
59
-
60
- function replaceFn({__a}, path) {
61
- const {name} = __a;
62
- const {declaration} = path.node;
63
- const node = template.ast.fresh(`module.exports.${name} = __x`);
64
-
65
- node.right = declaration;
66
-
67
- return node;
68
- }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@putout/plugin-nodejs",
3
- "version": "11.9.1",
3
+ "version": "11.11.0",
4
4
  "type": "commonjs",
5
5
  "author": "coderaiser <mnemonic.enemy@gmail.com> (https://github.com/coderaiser)",
6
6
  "description": "🐊Putout plugin adds ability to transform code to new API of Node.js",
@@ -39,6 +39,7 @@
39
39
  "nodejs"
40
40
  ],
41
41
  "devDependencies": {
42
+ "@putout/eslint-flat": "^2.0.0",
42
43
  "@putout/plugin-declare": "*",
43
44
  "@putout/plugin-putout": "*",
44
45
  "@putout/plugin-typescript": "*",
@@ -57,7 +58,7 @@
57
58
  },
58
59
  "license": "MIT",
59
60
  "engines": {
60
- "node": ">=18"
61
+ "node": ">=18.6"
61
62
  },
62
63
  "publishConfig": {
63
64
  "access": "public"