@putout/plugin-nodejs 1.1.0 → 2.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 +28 -9
- package/lib/convert-dirname-to-url/index.js +13 -0
- package/package.json +10 -12
package/README.md
CHANGED
|
@@ -1,12 +1,9 @@
|
|
|
1
|
-
# @putout/plugin-nodejs [![NPM version][NPMIMGURL]][NPMURL]
|
|
1
|
+
# @putout/plugin-nodejs [![NPM version][NPMIMGURL]][NPMURL]
|
|
2
2
|
|
|
3
|
-
[NPMIMGURL]:
|
|
4
|
-
[NPMURL]:
|
|
3
|
+
[NPMIMGURL]: https://img.shields.io/npm/v/@putout/plugin-nodejs.svg?style=flat&longCache=true
|
|
4
|
+
[NPMURL]: https://npmjs.org/package/@putout/plugin-nodejs"npm"
|
|
5
5
|
|
|
6
|
-
[
|
|
7
|
-
[DependencyStatusIMGURL]: https://david-dm.org/coderaiser/putout.svg?path=packages/plugin-nodejs
|
|
8
|
-
|
|
9
|
-
`putout` plugin adds ability to transform to new [nodejs.org](https://nodejs.io) API and best practices.
|
|
6
|
+
🐊[`Putout`](https://github.com/coderaiser/putout) plugin adds ability to transform to new [nodejs.org](https://nodejs.io) API and best practices.
|
|
10
7
|
|
|
11
8
|
## Install
|
|
12
9
|
|
|
@@ -20,7 +17,8 @@ npm i putout @putout/plugin-nodejs -D
|
|
|
20
17
|
{
|
|
21
18
|
"rules": {
|
|
22
19
|
"nodejs/convert-fs-promises": "on",
|
|
23
|
-
"nodejs/convert-promisify-to-fs-promises": "on"
|
|
20
|
+
"nodejs/convert-promisify-to-fs-promises": "on",
|
|
21
|
+
"nodejs/convert-dirname-to-promises": "on"
|
|
24
22
|
}
|
|
25
23
|
}
|
|
26
24
|
```
|
|
@@ -60,7 +58,28 @@ const readFile = promisify(fs.readFile);
|
|
|
60
58
|
const {readFile} = require('fs/promises');
|
|
61
59
|
```
|
|
62
60
|
|
|
61
|
+
# convert-dirname-to-promises
|
|
62
|
+
|
|
63
|
+
Only for `EcmaScript Modules`.
|
|
64
|
+
|
|
65
|
+
## ❌ Incorrect code example
|
|
66
|
+
|
|
67
|
+
```js
|
|
68
|
+
import {readFile} from 'fs/promises';
|
|
69
|
+
|
|
70
|
+
const file1 = join(__dirname, '../../package.json');
|
|
71
|
+
const file2 = path.join(__dirname, '../../package.json');
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
## ✅ Correct code Example
|
|
75
|
+
|
|
76
|
+
```js
|
|
77
|
+
import {readFile} from 'fs/promises';
|
|
78
|
+
|
|
79
|
+
const file1 = new URL('../../package.json', import.meta.url);
|
|
80
|
+
const file2 = new URL('../../package.json', import.meta.url);
|
|
81
|
+
```
|
|
82
|
+
|
|
63
83
|
## License
|
|
64
84
|
|
|
65
85
|
MIT
|
|
66
|
-
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const {operator} = require('putout');
|
|
4
|
+
const {isESM} = operator;
|
|
5
|
+
|
|
6
|
+
module.exports.report = () => `Use 'import.meta.url' instead of '__dirname'`;
|
|
7
|
+
|
|
8
|
+
module.exports.filter = isESM;
|
|
9
|
+
|
|
10
|
+
module.exports.replace = () => ({
|
|
11
|
+
'join(__dirname, __a)': 'new URL(__a, import.meta.url)',
|
|
12
|
+
'path.join(__dirname, __a)': 'new URL(__a, import.meta.url)',
|
|
13
|
+
});
|
package/package.json
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@putout/plugin-nodejs",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "2.0.0",
|
|
4
|
+
"type": "commonjs",
|
|
4
5
|
"author": "coderaiser <mnemonic.enemy@gmail.com> (https://github.com/coderaiser)",
|
|
5
6
|
"description": "putout plugin adds ability to transform code to new API of Node.js",
|
|
6
|
-
"homepage": "
|
|
7
|
+
"homepage": "https://github.com/coderaiser/putout/tree/master/packages/plugin-nodejs#readme",
|
|
7
8
|
"main": "lib/index.js",
|
|
8
9
|
"release": false,
|
|
9
10
|
"tag": false,
|
|
@@ -30,20 +31,17 @@
|
|
|
30
31
|
"nodejs"
|
|
31
32
|
],
|
|
32
33
|
"devDependencies": {
|
|
33
|
-
"@putout/
|
|
34
|
-
"
|
|
35
|
-
"
|
|
36
|
-
"coveralls": "^3.0.0",
|
|
37
|
-
"eslint": "^7.6.0",
|
|
34
|
+
"@putout/test": "^4.0.0",
|
|
35
|
+
"c8": "^7.5.0",
|
|
36
|
+
"eslint": "^8.0.1",
|
|
38
37
|
"eslint-plugin-node": "^11.0.0",
|
|
39
|
-
"eslint-plugin-putout": "^
|
|
40
|
-
"lerna": "^
|
|
38
|
+
"eslint-plugin-putout": "^12.0.0",
|
|
39
|
+
"lerna": "^4.0.0",
|
|
41
40
|
"madrun": "^8.0.1",
|
|
42
|
-
"nodemon": "^2.0.1"
|
|
43
|
-
"nyc": "^15.0.1"
|
|
41
|
+
"nodemon": "^2.0.1"
|
|
44
42
|
},
|
|
45
43
|
"peerDependencies": {
|
|
46
|
-
"putout": ">=
|
|
44
|
+
"putout": ">=23"
|
|
47
45
|
},
|
|
48
46
|
"license": "MIT",
|
|
49
47
|
"engines": {
|