@putout/plugin-nodejs 20.2.1 → 20.3.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
@@ -227,7 +227,7 @@ In most cases `process.exit()` is called from `bin` directory, if not - disable
227
227
 
228
228
  ## remove-top-level-process-exit
229
229
 
230
- Top-level `process.exit()` has no sense (except debuggin).
230
+ Top-level `process.exit()` has no sense (except debugging).
231
231
 
232
232
  Checkout in ✅[**Putout Editor**](https://putout.cloudcmd.io/#/gist/3aa8331269e49266d60914984027f9ed/9909ac2c07534299f64fee5ebf95cfc37ef04f11).
233
233
 
@@ -1,4 +1,13 @@
1
- import {template, operator} from 'putout';
1
+ import {
2
+ template,
3
+ operator,
4
+ types,
5
+ } from 'putout';
6
+
7
+ const {
8
+ isProgram,
9
+ isCallExpression,
10
+ } = types;
2
11
 
3
12
  const {
4
13
  getPathAfterImports,
@@ -24,14 +33,13 @@ export const fix = ({scope}) => {
24
33
  export const include = () => [
25
34
  '__filename',
26
35
  '__dirname',
27
- 'require',
36
+ 'require(__b)',
28
37
  ];
29
38
 
30
- export const filter = ({parentPath, scope}) => {
31
- if (parentPath.isMemberExpression())
32
- return false;
39
+ export const filter = (path) => {
40
+ const {scope} = path;
33
41
 
34
- if (parentPath.isObjectProperty())
42
+ if (isCallExpression(path) && isProgram(scope.block))
35
43
  return false;
36
44
 
37
45
  const isDirname = scope.hasBinding('__dirname');
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@putout/plugin-nodejs",
3
- "version": "20.2.1",
3
+ "version": "20.3.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",