@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 +6 -0
- package/lib/tokenize/expressions/assignment-expression.js +0 -1
- package/lib/tokenize/expressions/member-expressions.js +8 -2
- package/lib/tokenize/is.js +1 -2
- package/lib/tokenize/statements/expression-statement.js +2 -2
- package/lib/tokenize/statements/variable-declaration.js +6 -2
- package/package.json +1 -1
package/ChangeLog
CHANGED
|
@@ -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
|
-
|
|
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
|
+
|
package/lib/tokenize/is.js
CHANGED
|
@@ -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
|
-
|
|
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
|
|
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
|
-
|
|
125
|
-
|
|
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.
|
|
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",
|