@putout/plugin-nodejs 19.2.2 → 20.1.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.
@@ -1,6 +1,9 @@
1
1
  export const report = () => '';
2
2
  export const replace = ({options}) => {
3
- const {from = '', to = ''} = options;
3
+ const {
4
+ from = '',
5
+ to = '',
6
+ } = options;
4
7
 
5
8
  if (!from || !to)
6
9
  return {};
@@ -23,7 +23,7 @@ export const createGetPrivateImports = (importsCache = new Map(), emptyMap = new
23
23
  if (importsCache.has(dir))
24
24
  return importsCache.get(dir);
25
25
 
26
- const [packageDirectory, packagePath] = findFileUp(file, 'package.json');
26
+ const packagePath = findFileUp(file, 'package.json');
27
27
 
28
28
  if (!packagePath) {
29
29
  importsCache.set(dir, emptyMap);
@@ -39,6 +39,8 @@ export const createGetPrivateImports = (importsCache = new Map(), emptyMap = new
39
39
  return emptyMap;
40
40
  }
41
41
 
42
+ const packageDirectory = dirname(getFilename(packagePath));
43
+
42
44
  const {imports = {}} = packageJson;
43
45
  const importsEntries = new Map();
44
46
 
@@ -2,12 +2,12 @@ import {types} from 'putout';
2
2
 
3
3
  const {isFunction} = types;
4
4
 
5
- export const report = () => `"process.exit" should be used instead of top-level return`;
5
+ export const report = () => `Use 'process.exit()' instead of top-level 'return'`;
6
6
 
7
7
  export const filter = (path) => !path.findParent(isFunction);
8
8
 
9
9
  export const replace = () => ({
10
- 'return __a()': '{__a(); process.exit()}',
10
+ 'return __a(__args)': '{__a(__args); process.exit()}',
11
11
  'return __a': 'process.exit()',
12
12
  'return': 'process.exit()',
13
13
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@putout/plugin-nodejs",
3
- "version": "19.2.2",
3
+ "version": "20.1.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",