@putout/plugin-nodejs 16.2.0 → 16.4.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.
@@ -27,7 +27,11 @@ export const include = () => [
27
27
  'require',
28
28
  ];
29
29
 
30
- export const filter = ({scope}) => {
30
+ export const filter = (path) => {
31
+ if (path.parentPath.isObjectProperty())
32
+ return false;
33
+
34
+ const {scope} = path;
31
35
  const isDirname = scope.hasBinding('__dirname');
32
36
  const isFilename = scope.hasBinding('__filename');
33
37
  const isRequire = scope.hasBinding('require');
@@ -1,7 +1,10 @@
1
- import {
2
- types as t,
3
- operator,
4
- } from 'putout';
1
+ import {types, operator} from 'putout';
2
+
3
+ const {
4
+ objectProperty,
5
+ identifier,
6
+ objectPattern,
7
+ } = types;
5
8
 
6
9
  const {replaceWith, remove} = operator;
7
10
 
@@ -17,9 +20,9 @@ export const fix = ({path, promisified}) => {
17
20
  const [declarator] = path.node.declarations;
18
21
  const {name} = declarator.id;
19
22
 
20
- props.push(t.ObjectProperty(
21
- t.Identifier(name),
22
- t.Identifier(name),
23
+ props.push(objectProperty(
24
+ identifier(name),
25
+ identifier(name),
23
26
  NOT_COMPUTED,
24
27
  SHORTHAND,
25
28
  ));
@@ -30,7 +33,7 @@ export const fix = ({path, promisified}) => {
30
33
 
31
34
  init.arguments[0].value = 'fs/promises';
32
35
 
33
- replaceWith(path.get('id'), t.ObjectPattern(props));
36
+ replaceWith(path.get('id'), objectPattern(props));
34
37
  };
35
38
 
36
39
  export const find = (ast, {push, traverse}) => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@putout/plugin-nodejs",
3
- "version": "16.2.0",
3
+ "version": "16.4.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",
@@ -49,7 +49,7 @@
49
49
  "c8": "^10.0.0",
50
50
  "eslint": "^9.0.0",
51
51
  "eslint-plugin-n": "^17.0.0",
52
- "eslint-plugin-putout": "^26.0.0",
52
+ "eslint-plugin-putout": "^27.0.0",
53
53
  "madrun": "^11.0.0",
54
54
  "montag": "^1.2.1",
55
55
  "nodemon": "^3.0.1"