@putout/plugin-nodejs 16.3.0 → 17.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.
|
@@ -38,10 +38,6 @@ const isPackage = ({value}) => /package(\.json)?$/.test(value);
|
|
|
38
38
|
|
|
39
39
|
export const match = () => ({
|
|
40
40
|
'const __a = require(__b)': ({__b}, path) => {
|
|
41
|
-
// exclude jsons while not supported
|
|
42
|
-
if (/\.json/.test(__b.value))
|
|
43
|
-
return false;
|
|
44
|
-
|
|
45
41
|
if (path.scope.getBinding('require'))
|
|
46
42
|
return false;
|
|
47
43
|
|
|
@@ -91,12 +87,8 @@ export const replace = () => ({
|
|
|
91
87
|
return applyDynamicImport(path);
|
|
92
88
|
}
|
|
93
89
|
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
//
|
|
97
|
-
// const isJSON = /\.json$/.test(value);
|
|
98
|
-
// const assertion = !isJSON ? '' : 'with { type: "json" }';
|
|
99
|
-
const assertion = '';
|
|
90
|
+
const isJSON = /\.json$/.test(value);
|
|
91
|
+
const assertion = !isJSON ? '' : 'with { type: "json" }';
|
|
100
92
|
|
|
101
93
|
if (isObjectPattern(__a)) {
|
|
102
94
|
const imports = [];
|
|
@@ -1,7 +1,10 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
import {types, operator} from 'putout';
|
|
2
|
+
|
|
3
|
+
const {
|
|
4
|
+
objectProperty,
|
|
5
|
+
identifier,
|
|
6
|
+
objectPattern,
|
|
7
|
+
} = types;
|
|
5
8
|
|
|
6
9
|
const {replaceWith, remove} = operator;
|
|
7
10
|
|
|
@@ -17,9 +20,9 @@ export const fix = ({path, promisified}) => {
|
|
|
17
20
|
const [declarator] = path.node.declarations;
|
|
18
21
|
const {name} = declarator.id;
|
|
19
22
|
|
|
20
|
-
props.push(
|
|
21
|
-
|
|
22
|
-
|
|
23
|
+
props.push(objectProperty(
|
|
24
|
+
identifier(name),
|
|
25
|
+
identifier(name),
|
|
23
26
|
NOT_COMPUTED,
|
|
24
27
|
SHORTHAND,
|
|
25
28
|
));
|
|
@@ -30,7 +33,7 @@ export const fix = ({path, promisified}) => {
|
|
|
30
33
|
|
|
31
34
|
init.arguments[0].value = 'fs/promises';
|
|
32
35
|
|
|
33
|
-
replaceWith(path.get('id'),
|
|
36
|
+
replaceWith(path.get('id'), objectPattern(props));
|
|
34
37
|
};
|
|
35
38
|
|
|
36
39
|
export const find = (ast, {push, traverse}) => {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@putout/plugin-nodejs",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "17.0.0",
|
|
4
4
|
"type": "module",
|
|
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",
|
|
@@ -49,7 +49,7 @@
|
|
|
49
49
|
"c8": "^10.0.0",
|
|
50
50
|
"eslint": "^9.0.0",
|
|
51
51
|
"eslint-plugin-n": "^17.0.0",
|
|
52
|
-
"eslint-plugin-putout": "^
|
|
52
|
+
"eslint-plugin-putout": "^27.0.0",
|
|
53
53
|
"madrun": "^11.0.0",
|
|
54
54
|
"montag": "^1.2.1",
|
|
55
55
|
"nodemon": "^3.0.1"
|