@putout/plugin-nodejs 4.6.2 → 4.7.1
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.
|
@@ -55,6 +55,9 @@ module.exports.traverse = ({push, listStore}) => ({
|
|
|
55
55
|
if (path.node.__putoutNodeDeclareAfterRequire)
|
|
56
56
|
continue;
|
|
57
57
|
|
|
58
|
+
if (!path.isVariableDeclaration())
|
|
59
|
+
continue;
|
|
60
|
+
|
|
58
61
|
if (path.node.declarations[0].id.name === 'require')
|
|
59
62
|
continue;
|
|
60
63
|
|
|
@@ -81,7 +84,7 @@ module.exports.traverse = ({push, listStore}) => ({
|
|
|
81
84
|
const {loc} = path.node;
|
|
82
85
|
const line = !loc ? 0 : loc.start.line;
|
|
83
86
|
|
|
84
|
-
if (line < lastRequireLine && lastRequireLine < getReferenceLine(path
|
|
87
|
+
if (line < lastRequireLine && lastRequireLine < getReferenceLine(path)) {
|
|
85
88
|
push({
|
|
86
89
|
path,
|
|
87
90
|
firstRequire,
|
|
@@ -105,7 +108,7 @@ function getName(path) {
|
|
|
105
108
|
return null;
|
|
106
109
|
}
|
|
107
110
|
|
|
108
|
-
function getReferenceLine(path
|
|
111
|
+
function getReferenceLine(path) {
|
|
109
112
|
const name = getName(path);
|
|
110
113
|
const binding = path.scope.bindings[name];
|
|
111
114
|
|
|
@@ -117,9 +120,11 @@ function getReferenceLine(path, constPaths) {
|
|
|
117
120
|
if (!referencePaths.length)
|
|
118
121
|
return Infinity;
|
|
119
122
|
|
|
120
|
-
|
|
121
|
-
|
|
123
|
+
const [firstReference] = referencePaths;
|
|
124
|
+
|
|
125
|
+
if (!firstReference.node.loc)
|
|
126
|
+
return -1;
|
|
122
127
|
|
|
123
|
-
return
|
|
128
|
+
return firstReference.node.loc.start.line;
|
|
124
129
|
}
|
|
125
130
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@putout/plugin-nodejs",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.7.1",
|
|
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",
|
|
@@ -31,6 +31,7 @@
|
|
|
31
31
|
"nodejs"
|
|
32
32
|
],
|
|
33
33
|
"devDependencies": {
|
|
34
|
+
"@putout/plugin-convert-commonjs-to-esm": "*",
|
|
34
35
|
"@putout/plugin-convert-esm-to-commonjs": "*",
|
|
35
36
|
"@putout/plugin-putout": "*",
|
|
36
37
|
"@putout/test": "^5.0.0",
|