@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 +2 -3
- package/lib/convert-buffer-to-buffer-alloc/index.js +0 -1
- package/lib/convert-fs-promises/index.js +0 -1
- package/lib/convert-promisify-to-fs-promises/index.js +9 -10
- package/lib/convert-top-level-return/index.js +0 -1
- package/lib/declare/index.js +0 -1
- package/lib/declare-after-require/index.js +3 -3
- package/lib/index.js +0 -1
- package/lib/remove-process-exit/index.js +0 -1
- package/package.json +7 -7
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
|
}
|
|
@@ -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(
|
|
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
|
-
|
package/lib/declare/index.js
CHANGED
|
@@ -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} =
|
|
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
|
-
|
|
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
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@putout/plugin-nodejs",
|
|
3
|
-
"version": "
|
|
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": "^
|
|
38
|
-
"c8": "^
|
|
37
|
+
"@putout/test": "^7.0.0",
|
|
38
|
+
"c8": "^8.0.0",
|
|
39
39
|
"eslint": "^8.0.1",
|
|
40
|
-
"eslint-plugin-n": "^
|
|
41
|
-
"eslint-plugin-putout": "^
|
|
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": "^
|
|
45
|
+
"nodemon": "^3.0.1"
|
|
46
46
|
},
|
|
47
47
|
"peerDependencies": {
|
|
48
|
-
"putout": ">=
|
|
48
|
+
"putout": ">=31"
|
|
49
49
|
},
|
|
50
50
|
"license": "MIT",
|
|
51
51
|
"engines": {
|