@putout/plugin-nodejs 6.0.0 → 7.0.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
@@ -192,6 +192,7 @@ await readFile('hello.txt', 'utf8');
192
192
 
193
193
  ```js
194
194
  import {readFile} from 'fs/promises';
195
+
195
196
  await readFile('hello.txt', 'utf8');
196
197
  ```
197
198
 
@@ -201,9 +202,7 @@ When you want to skip some declaration use `dismiss`:
201
202
  {
202
203
  "rules": {
203
204
  "nodejs/declare": ["on", {
204
- "dismiss": [
205
- "readFile"
206
- ]
205
+ "dismiss": ["readFile"]
207
206
  }]
208
207
  }
209
208
  }
@@ -30,4 +30,3 @@ function transform(vars, path) {
30
30
 
31
31
  return 'Buffer.from(__a)';
32
32
  }
33
-
@@ -5,4 +5,3 @@ module.exports.report = () => '"fs/promises" should be used instead of "fs.promi
5
5
  module.exports.replace = () => ({
6
6
  'const __a = require("fs").promises': 'const __a = require("fs/promises")',
7
7
  });
8
-
@@ -1,14 +1,8 @@
1
1
  'use strict';
2
2
 
3
- const {
4
- types: t,
5
- operator,
6
- } = require('putout');
3
+ const {types: t, operator} = require('putout');
7
4
 
8
- const {
9
- replaceWith,
10
- remove,
11
- } = operator;
5
+ const {replaceWith, remove} = operator;
12
6
 
13
7
  const NOT_COMPUTED = false;
14
8
  const SHORTHAND = true;
@@ -22,11 +16,17 @@ module.exports.fix = ({path, promisified}) => {
22
16
  const [declarator] = path.node.declarations;
23
17
  const {name} = declarator.id;
24
18
 
25
- props.push(t.ObjectProperty(t.Identifier(name), t.Identifier(name), NOT_COMPUTED, SHORTHAND));
19
+ props.push(t.ObjectProperty(
20
+ t.Identifier(name),
21
+ t.Identifier(name),
22
+ NOT_COMPUTED,
23
+ SHORTHAND,
24
+ ));
26
25
  remove(path);
27
26
  }
28
27
 
29
28
  const {init} = path.node;
29
+
30
30
  init.arguments[0].value = 'fs/promises';
31
31
 
32
32
  replaceWith(path.get('id'), t.ObjectPattern(props));
@@ -58,4 +58,3 @@ module.exports.find = (ast, {push, traverse}) => {
58
58
  promisified,
59
59
  });
60
60
  };
61
-
@@ -12,4 +12,3 @@ module.exports.replace = () => ({
12
12
  'return __a': 'process.exit()',
13
13
  'return': 'process.exit()',
14
14
  });
15
-
@@ -14,4 +14,3 @@ module.exports.declare = () => ({
14
14
  ...require('./modules/util'),
15
15
  ...require('./modules/child_process'),
16
16
  });
17
-
@@ -4,6 +4,7 @@ const {operator} = require('putout');
4
4
  const {
5
5
  remove,
6
6
  compareAny,
7
+ insertAfter,
7
8
  } = operator;
8
9
 
9
10
  const REQUIRE_LIST = [
@@ -21,7 +22,7 @@ module.exports.report = ({path}) => {
21
22
 
22
23
  module.exports.fix = ({path, firstRequire, lastRequire}) => {
23
24
  const {node} = path;
24
- const {comments} = path.node;
25
+ const {comments} = node;
25
26
 
26
27
  delete node.loc;
27
28
  node.__putoutNodeDeclareAfterRequire = true;
@@ -32,7 +33,7 @@ module.exports.fix = ({path, firstRequire, lastRequire}) => {
32
33
  }
33
34
 
34
35
  remove(path);
35
- lastRequire.insertAfter(node);
36
+ insertAfter(lastRequire, node);
36
37
  };
37
38
 
38
39
  module.exports.traverse = ({push, pathStore}) => ({
@@ -123,4 +124,3 @@ function getReferenceLine(path) {
123
124
 
124
125
  return firstReference.node.loc.start.line;
125
126
  }
126
-
package/lib/index.js CHANGED
@@ -15,4 +15,3 @@ module.exports.rules = {
15
15
  ...getRule('declare-after-require'),
16
16
  ...getRule('remove-process-exit'),
17
17
  };
18
-
@@ -6,4 +6,3 @@ module.exports.replace = () => ({
6
6
  'process.exit()': '',
7
7
  'process["exit"]()': '',
8
8
  });
9
-
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@putout/plugin-nodejs",
3
- "version": "6.0.0",
3
+ "version": "7.0.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",
@@ -34,18 +34,18 @@
34
34
  "@putout/plugin-convert-commonjs-to-esm": "*",
35
35
  "@putout/plugin-convert-esm-to-commonjs": "*",
36
36
  "@putout/plugin-putout": "*",
37
- "@putout/test": "^6.0.0",
38
- "c8": "^7.5.0",
37
+ "@putout/test": "^7.0.0",
38
+ "c8": "^8.0.0",
39
39
  "eslint": "^8.0.1",
40
- "eslint-plugin-n": "^15.2.4",
41
- "eslint-plugin-putout": "^16.0.0",
40
+ "eslint-plugin-n": "^16.0.0",
41
+ "eslint-plugin-putout": "^19.0.0",
42
42
  "lerna": "^6.0.1",
43
43
  "madrun": "^9.0.0",
44
44
  "montag": "^1.2.1",
45
- "nodemon": "^2.0.1"
45
+ "nodemon": "^3.0.1"
46
46
  },
47
47
  "peerDependencies": {
48
- "putout": ">=29"
48
+ "putout": ">=31"
49
49
  },
50
50
  "license": "MIT",
51
51
  "engines": {