@putout/plugin-nodejs 20.1.1 → 20.2.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.
- package/README.md +13 -1
- package/lib/index.js +2 -0
- package/lib/remove-top-level-process-exit/index.js +11 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -33,6 +33,7 @@ npm i putout @putout/plugin-nodejs -D
|
|
|
33
33
|
- ✅ [group-require-by-id](#group-require-by-id);
|
|
34
34
|
- ✅ [remove-process-exit](#remove-process-exit);
|
|
35
35
|
- ✅ [remove-useless-promisify](#remove-useless-promisify);
|
|
36
|
+
- ✅ [remove-top-level-process-exit](#remove-top-level-process-exit);
|
|
36
37
|
- ✅ [remove-useless-strict-mode](#remove-useless-strict-mode);
|
|
37
38
|
- ✅ [remove-illegal-strict-mode](#remove-useless-strict-mode);
|
|
38
39
|
|
|
@@ -70,7 +71,8 @@ npm i putout @putout/plugin-nodejs -D
|
|
|
70
71
|
"nodejs/remove-process-exit": "on",
|
|
71
72
|
"nodejs/remove-useless-strict-mode": "on",
|
|
72
73
|
"nodejs/remove-illegal-strict-mode": "on",
|
|
73
|
-
"nodejs/remove-useless-promisify": "on"
|
|
74
|
+
"nodejs/remove-useless-promisify": "on",
|
|
75
|
+
"nodejs/remove-top-level-process-exit": "on"
|
|
74
76
|
}
|
|
75
77
|
}
|
|
76
78
|
```
|
|
@@ -223,6 +225,16 @@ In most cases `process.exit()` is called from `bin` directory, if not - disable
|
|
|
223
225
|
-process.exit();
|
|
224
226
|
```
|
|
225
227
|
|
|
228
|
+
## remove-top-level-process-exit
|
|
229
|
+
|
|
230
|
+
Top-level `process.exit()` has no sense (except debuggin).
|
|
231
|
+
|
|
232
|
+
Checkout in ✅[**Putout Editor**](https://putout.cloudcmd.io/#/gist/3aa8331269e49266d60914984027f9ed/9909ac2c07534299f64fee5ebf95cfc37ef04f11).
|
|
233
|
+
|
|
234
|
+
```diff
|
|
235
|
+
-process.exit();
|
|
236
|
+
```
|
|
237
|
+
|
|
226
238
|
## convert-exports-to-module-exports
|
|
227
239
|
|
|
228
240
|
Since `exports = 5` wan't make any export, just change value of variable.
|
package/lib/index.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import * as removeTopLevelProcessExit from './remove-top-level-process-exit/index.js';
|
|
1
2
|
import * as applyPrivatelyRequiredFiles from './apply-privately-required-file/index.js';
|
|
2
3
|
import * as convertBufferToBufferAlloc from './convert-buffer-to-buffer-alloc/index.js';
|
|
3
4
|
import * as convertFsPromises from './convert-fs-promises/index.js';
|
|
@@ -50,4 +51,5 @@ export const rules = {
|
|
|
50
51
|
'remove-illegal-strict-mode': strictMode.rules['remove-illegal'],
|
|
51
52
|
'remove-useless-promisify': removeUselessPromisify,
|
|
52
53
|
'group-require-by-id': groupRequireById,
|
|
54
|
+
'remove-top-level-process-exit': removeTopLevelProcessExit,
|
|
53
55
|
};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export const report = () => `Avoid useless 'process.exit()'`;
|
|
2
|
+
|
|
3
|
+
export const match = () => ({
|
|
4
|
+
'process.exit()': (vars, {parentPath}) => {
|
|
5
|
+
return parentPath.parentPath.isProgram();
|
|
6
|
+
},
|
|
7
|
+
});
|
|
8
|
+
|
|
9
|
+
export const replace = () => ({
|
|
10
|
+
'process.exit()': '',
|
|
11
|
+
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@putout/plugin-nodejs",
|
|
3
|
-
"version": "20.
|
|
3
|
+
"version": "20.2.1",
|
|
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",
|