@putout/plugin-nodejs 4.1.0 β 4.4.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
|
@@ -3,7 +3,11 @@
|
|
|
3
3
|
[NPMIMGURL]: https://img.shields.io/npm/v/@putout/plugin-nodejs.svg?style=flat&longCache=true
|
|
4
4
|
[NPMURL]: https://npmjs.org/package/@putout/plugin-nodejs "npm"
|
|
5
5
|
|
|
6
|
-
|
|
6
|
+
> **Node.js** is an open-source, cross-platform, **JavaScript** runtime environment.
|
|
7
|
+
>
|
|
8
|
+
> (c) [nodejs.org](https://nodejs.org/en/)
|
|
9
|
+
|
|
10
|
+
π[**Putout**](https://github.com/coderaiser/putout) plugin adds ability to transform to new **Node.js** API and apply best practices.
|
|
7
11
|
|
|
8
12
|
## Install
|
|
9
13
|
|
|
@@ -30,7 +34,7 @@ npm i putout @putout/plugin-nodejs -D
|
|
|
30
34
|
|
|
31
35
|
### convert-fs-promises
|
|
32
36
|
|
|
33
|
-
Convert [fs.promises](https://nodejs.org/dist/latest-v15.x/docs/api/fs.html#fs_fs_promises_api) into form that will be simpler to use and convert from
|
|
37
|
+
Convert [fs.promises](https://nodejs.org/dist/latest-v15.x/docs/api/fs.html#fs_fs_promises_api) into form that will be simpler to use and convert to and from **ESM**.
|
|
34
38
|
|
|
35
39
|
#### β Example of incorrect code
|
|
36
40
|
|
|
@@ -61,7 +65,7 @@ const {readFile} = require('fs/promises');
|
|
|
61
65
|
|
|
62
66
|
### convert-dirname-to-url
|
|
63
67
|
|
|
64
|
-
Only for
|
|
68
|
+
Only for **ESM**.
|
|
65
69
|
|
|
66
70
|
#### β Example of incorrect code
|
|
67
71
|
|
|
@@ -81,9 +85,9 @@ const file1 = new URL('../../package.json', import.meta.url);
|
|
|
81
85
|
const file2 = new URL('../../package.json', import.meta.url);
|
|
82
86
|
```
|
|
83
87
|
|
|
84
|
-
### convert-
|
|
88
|
+
### convert-url-to-dirname
|
|
85
89
|
|
|
86
|
-
Only for
|
|
90
|
+
Only for **CommonJS**.
|
|
87
91
|
|
|
88
92
|
#### β Example of incorrect code
|
|
89
93
|
|
|
@@ -125,16 +129,17 @@ process.exit();
|
|
|
125
129
|
|
|
126
130
|
Add declarations to built-in node.js modules:
|
|
127
131
|
|
|
128
|
-
- [child_process](https://nodejs.org/dist/latest-
|
|
129
|
-
- [
|
|
130
|
-
- [
|
|
131
|
-
- [
|
|
132
|
-
- [
|
|
133
|
-
- [
|
|
134
|
-
- [
|
|
135
|
-
- [
|
|
136
|
-
- [
|
|
137
|
-
- [
|
|
132
|
+
- [child_process](https://nodejs.org/dist/latest-v18.x/docs/api/child_process.html);
|
|
133
|
+
- [events](https://nodejs.org/dist/latest-v18.x/docs/api/events.html);
|
|
134
|
+
- [fs](https://nodejs.org/dist/latest-v18.x/docs/api/fs.html);
|
|
135
|
+
- [path](https://nodejs.org/dist/latest-v18.x/docs/api/path.html);
|
|
136
|
+
- [process](https://nodejs.org/dist/latest-v18.x/docs/api/process.html);
|
|
137
|
+
- [module](https://nodejs.org/dist/latest-v18.x/docs/api/module.html);
|
|
138
|
+
- [stream](https://nodejs.org/dist/latest-v18.x/docs/api/stream.html);
|
|
139
|
+
- [os](https://nodejs.org/dist/latest-v18.x/docs/api/os.html);
|
|
140
|
+
- [url](https://nodejs.org/dist/latest-v18.x/docs/api/url.html);
|
|
141
|
+
- [util](https://nodejs.org/dist/latest-v18.x/docs/api/util.html);
|
|
142
|
+
- [zlib](https://nodejs.org/dist/latest-v18.x/docs/api/zlib.html);
|
|
138
143
|
|
|
139
144
|
#### β Example of incorrect code
|
|
140
145
|
|
|
@@ -5,7 +5,10 @@ const {
|
|
|
5
5
|
operator,
|
|
6
6
|
} = require('putout');
|
|
7
7
|
|
|
8
|
-
const {
|
|
8
|
+
const {
|
|
9
|
+
replaceWith,
|
|
10
|
+
remove,
|
|
11
|
+
} = operator;
|
|
9
12
|
|
|
10
13
|
const NOT_COMPUTED = false;
|
|
11
14
|
const SHORTHAND = true;
|
|
@@ -20,7 +23,7 @@ module.exports.fix = ({path, promisified}) => {
|
|
|
20
23
|
const {name} = declarator.id;
|
|
21
24
|
|
|
22
25
|
props.push(t.ObjectProperty(t.Identifier(name), t.Identifier(name), NOT_COMPUTED, SHORTHAND));
|
|
23
|
-
|
|
26
|
+
remove(path);
|
|
24
27
|
}
|
|
25
28
|
|
|
26
29
|
const {init} = path.node;
|
package/lib/declare/index.js
CHANGED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
{
|
|
2
|
+
"once": "import {once} from 'events'",
|
|
3
|
+
"on": "import {on} from 'events'",
|
|
4
|
+
"getEventListeners": "import {getEventListeners} from 'events'",
|
|
5
|
+
"EventEmitter": "import {EventEmitter} from 'events'",
|
|
6
|
+
"captureRejectionSymbol": "import {captureRejectionSymbol} from 'events'",
|
|
7
|
+
"captureRejections": "import {captureRejections} from 'events'",
|
|
8
|
+
"EventEmitterAsyncResource": "import {EventEmitterAsyncResource} from 'events'",
|
|
9
|
+
"defaultMaxListeners": "import {defaultMaxListeners} from 'events'",
|
|
10
|
+
"setMaxListeners": "import {setMaxListeners} from 'events'",
|
|
11
|
+
"listenerCount": "import {listenerCount} from 'events'"
|
|
12
|
+
}
|
|
@@ -40,7 +40,6 @@
|
|
|
40
40
|
"seteuid": "import {seteuid} from 'process'",
|
|
41
41
|
"setgid": "import {setgid} from 'process'",
|
|
42
42
|
"setuid": "import {setuid} from 'process'",
|
|
43
|
-
"title": "import {title} from 'process'",
|
|
44
43
|
"argv": "import {argv} from 'process'",
|
|
45
44
|
"execArgv": "import {execArgv} from 'process'",
|
|
46
45
|
"pid": "import {pid} from 'process'",
|
package/package.json
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@putout/plugin-nodejs",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.4.0",
|
|
4
4
|
"type": "commonjs",
|
|
5
5
|
"author": "coderaiser <mnemonic.enemy@gmail.com> (https://github.com/coderaiser)",
|
|
6
|
-
"description": "
|
|
6
|
+
"description": "πPutout plugin adds ability to transform code to new API of Node.js",
|
|
7
7
|
"homepage": "https://github.com/coderaiser/putout/tree/master/packages/plugin-nodejs#readme",
|
|
8
8
|
"main": "lib/index.js",
|
|
9
9
|
"release": false,
|
|
@@ -35,8 +35,8 @@
|
|
|
35
35
|
"c8": "^7.5.0",
|
|
36
36
|
"eslint": "^8.0.1",
|
|
37
37
|
"eslint-plugin-node": "^11.0.0",
|
|
38
|
-
"eslint-plugin-putout": "^
|
|
39
|
-
"lerna": "^
|
|
38
|
+
"eslint-plugin-putout": "^15.0.0",
|
|
39
|
+
"lerna": "^5.0.0",
|
|
40
40
|
"madrun": "^9.0.0",
|
|
41
41
|
"montag": "^1.2.1",
|
|
42
42
|
"nodemon": "^2.0.1"
|