@putout/printer 1.54.0 → 1.54.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/ChangeLog CHANGED
@@ -1,3 +1,9 @@
1
+ 2023.04.18, v1.54.1
2
+
3
+ feature:
4
+ - 7f6d7d4 @putout/printer: add support of Import used as object of MemberExpression
5
+ - c2b2e4b @putout/printer: VariableDeclaration: drop useless newline
6
+
1
7
  2023.04.18, v1.54.0
2
8
 
3
9
  feature:
@@ -19,4 +19,3 @@ module.exports.AssignmentExpression = {
19
19
  write(')');
20
20
  },
21
21
  };
22
-
@@ -12,9 +12,14 @@ const {
12
12
  getTemplateValues,
13
13
  } = require('@putout/compare');
14
14
 
15
- module.exports.MemberExpression = (path, {print, indent, maybe}) => {
15
+ module.exports.MemberExpression = (path, {print, indent, maybe, traverse}) => {
16
16
  const {computed} = path.node;
17
- print('__object');
17
+ const object = path.get('object');
18
+ const isObjectAwait = object.isAwaitExpression();
19
+
20
+ maybe.print(isObjectAwait, '(');
21
+ traverse(object);
22
+ maybe.print(isObjectAwait, ')');
18
23
 
19
24
  if (computed) {
20
25
  print('[');
@@ -109,3 +114,4 @@ function isLooksLikeChain(path) {
109
114
 
110
115
  return !compare(parentPath, '__a.__b(__args)') || itMember || itExpression;
111
116
  }
117
+
@@ -78,10 +78,9 @@ module.exports.isNewlineBetweenStatements = (path) => {
78
78
  };
79
79
 
80
80
  module.exports.satisfy = (conditions) => (path) => {
81
- for (const condition of conditions) {
81
+ for (const condition of conditions)
82
82
  if (condition(path))
83
83
  return true;
84
- }
85
84
 
86
85
  return false;
87
86
  };
@@ -28,7 +28,7 @@ module.exports.ExpressionStatement = {
28
28
  }
29
29
  },
30
30
  afterSatisfy: () => [
31
- isParentOrNotLastORParentLast,
31
+ isParentBlockOrNotLastOrParentLast,
32
32
  isParentBlock,
33
33
  isNext,
34
34
  isNextUp,
@@ -49,7 +49,7 @@ function isNotLastBody(path) {
49
49
  return path.parentPath.get('body') === path;
50
50
  }
51
51
 
52
- function isParentOrNotLastORParentLast(path) {
52
+ function isParentBlockOrNotLastOrParentLast(path) {
53
53
  return isParentBlock(path) || !(isLast(path) || isParentLast(path));
54
54
  }
55
55
 
@@ -121,6 +121,10 @@ const isNextAssign = (path) => {
121
121
  if (!nextPath.isExpressionStatement())
122
122
  return false;
123
123
 
124
- return nextPath
125
- .get('expression').isAssignmentExpression();
124
+ const {parentPath} = path;
125
+
126
+ if (parentPath.isBlockStatement() && parentPath.node.body.length < 3)
127
+ return false;
128
+
129
+ return nextPath.get('expression').isAssignmentExpression();
126
130
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@putout/printer",
3
- "version": "1.54.0",
3
+ "version": "1.54.1",
4
4
  "type": "commonjs",
5
5
  "author": "coderaiser <mnemonic.enemy@gmail.com> (https://github.com/coderaiser)",
6
6
  "description": "Easiest possible opinionated Babel AST printer made with ❤️ to use in 🐊Putout",