@putout/plugin-nodejs 20.1.0 → 20.2.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
|
@@ -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-useless-process-exit](#remove-useless-process-exit);
|
|
36
37
|
- ✅ [remove-useless-strict-mode](#remove-useless-strict-mode);
|
|
37
38
|
- ✅ [remove-illegal-strict-mode](#remove-useless-strict-mode);
|
|
38
39
|
|
|
@@ -223,6 +224,15 @@ In most cases `process.exit()` is called from `bin` directory, if not - disable
|
|
|
223
224
|
-process.exit();
|
|
224
225
|
```
|
|
225
226
|
|
|
227
|
+
## remove-useless-process-exit
|
|
228
|
+
|
|
229
|
+
Top level `process.exit()` have no sense.
|
|
230
|
+
Checkout in 🐊[**Putout Editor**](https://putout.cloudcmd.io/#/gist/3aa8331269e49266d60914984027f9ed/6866eb78a0c1dd7f6e1f1e722c7c581b92f3b477).
|
|
231
|
+
|
|
232
|
+
```diff
|
|
233
|
+
-process.exit();
|
|
234
|
+
```
|
|
235
|
+
|
|
226
236
|
## convert-exports-to-module-exports
|
|
227
237
|
|
|
228
238
|
Since `exports = 5` wan't make any export, just change value of variable.
|
|
@@ -7,7 +7,9 @@ export const report = () => `Use 'process.exit()' instead of top-level 'return'`
|
|
|
7
7
|
export const filter = (path) => !path.findParent(isFunction);
|
|
8
8
|
|
|
9
9
|
export const replace = () => ({
|
|
10
|
-
'return __a(__args)': '{__a(__args); process.exit()}',
|
|
11
|
-
'return __a': 'process.exit()',
|
|
12
10
|
'return': 'process.exit()',
|
|
11
|
+
'return __a': `{
|
|
12
|
+
__a;
|
|
13
|
+
process.exit();
|
|
14
|
+
}`,
|
|
13
15
|
});
|
package/lib/index.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import * as removeUselessProcessExit from './remove-useless-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-useless-process-exit': removeUselessProcessExit,
|
|
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.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",
|