@putout/printer 1.72.4 → 1.72.6
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 +10 -0
- package/lib/tokenize/expressions/call-expression.js +4 -3
- package/lib/tokenize/expressions/member-expressions.js +9 -5
- package/lib/tokenize/jsx/jsx-element.js +3 -1
- package/lib/tokenize/jsx/jsx-fragment.js +3 -1
- package/lib/tokenize/statements/variable-declaration.js +1 -2
- package/package.json +1 -1
package/ChangeLog
CHANGED
|
@@ -4,6 +4,7 @@ const {exists} = require('../is');
|
|
|
4
4
|
|
|
5
5
|
function CallExpression(path, {indent, print, maybe, traverse}) {
|
|
6
6
|
const isParentCall = toLong(path) && path.parentPath.isCallExpression();
|
|
7
|
+
|
|
7
8
|
const callee = path.get('callee');
|
|
8
9
|
const typeParameters = path.get('typeParameters');
|
|
9
10
|
const isFn = callee.isFunction();
|
|
@@ -29,14 +30,14 @@ function CallExpression(path, {indent, print, maybe, traverse}) {
|
|
|
29
30
|
for (const [i, arg] of args.entries()) {
|
|
30
31
|
const isObject = arg.isObjectExpression();
|
|
31
32
|
|
|
32
|
-
if (isParentCall && !isObject) {
|
|
33
|
+
if (isParentCall && !isObject && n) {
|
|
33
34
|
print.newline();
|
|
34
35
|
indent();
|
|
35
36
|
}
|
|
36
37
|
|
|
37
38
|
print(arg);
|
|
38
39
|
|
|
39
|
-
if (isParentCall) {
|
|
40
|
+
if (isParentCall && n) {
|
|
40
41
|
print(',');
|
|
41
42
|
continue;
|
|
42
43
|
}
|
|
@@ -46,7 +47,7 @@ function CallExpression(path, {indent, print, maybe, traverse}) {
|
|
|
46
47
|
|
|
47
48
|
if (isParentCall) {
|
|
48
49
|
indent.dec();
|
|
49
|
-
print.breakline();
|
|
50
|
+
maybe.print.breakline(n);
|
|
50
51
|
}
|
|
51
52
|
|
|
52
53
|
print(')');
|
|
@@ -67,6 +67,12 @@ function isLooksLikeChain(path) {
|
|
|
67
67
|
if (path.find(isIfStatement))
|
|
68
68
|
return false;
|
|
69
69
|
|
|
70
|
+
if (compare(parentPath.parentPath.parentPath, '__a.__b(__x).__c(__y)'))
|
|
71
|
+
return true;
|
|
72
|
+
|
|
73
|
+
if (compare(parentPath, '__a.__b(__x).__c(__y)'))
|
|
74
|
+
return true;
|
|
75
|
+
|
|
70
76
|
if (path.find(isUnaryExpression))
|
|
71
77
|
return false;
|
|
72
78
|
|
|
@@ -74,6 +80,7 @@ function isLooksLikeChain(path) {
|
|
|
74
80
|
const isExpression = ({parentPath}) => parentPath.parentPath.isExpressionStatement();
|
|
75
81
|
const itMember = isMember(path);
|
|
76
82
|
const itExpression = isExpression(path);
|
|
83
|
+
const callee = parentPath.get('callee');
|
|
77
84
|
|
|
78
85
|
if (parentPath.isLiteral())
|
|
79
86
|
return false;
|
|
@@ -84,7 +91,7 @@ function isLooksLikeChain(path) {
|
|
|
84
91
|
if (!parentPath.isCallExpression())
|
|
85
92
|
return false;
|
|
86
93
|
|
|
87
|
-
if (
|
|
94
|
+
if (callee !== path)
|
|
88
95
|
return false;
|
|
89
96
|
|
|
90
97
|
if (compare(path.parentPath, '__a.__b(__args)[__c]'))
|
|
@@ -96,9 +103,6 @@ function isLooksLikeChain(path) {
|
|
|
96
103
|
if (compare(path.parentPath.parentPath, '(__args) => __b.__c(__args).__d()'))
|
|
97
104
|
return false;
|
|
98
105
|
|
|
99
|
-
if (compare(parentPath, '__a.__b(__args);') && !itExpression && !itMember)
|
|
100
|
-
return false;
|
|
101
|
-
|
|
102
106
|
if (compare(parentPath, '__a.__b.__c(__args)') && !itMember)
|
|
103
107
|
return false;
|
|
104
108
|
|
|
@@ -118,5 +122,5 @@ function isLooksLikeChain(path) {
|
|
|
118
122
|
if (isThisExpression(__a) && isIdentifier(__b) && itExpression)
|
|
119
123
|
return false;
|
|
120
124
|
|
|
121
|
-
return
|
|
125
|
+
return itExpression;
|
|
122
126
|
}
|
|
@@ -9,7 +9,9 @@ module.exports.JSXFragment = {
|
|
|
9
9
|
},
|
|
10
10
|
print(path, {print, traverse}) {
|
|
11
11
|
print('__openingFragment');
|
|
12
|
-
path
|
|
12
|
+
path
|
|
13
|
+
.get('children')
|
|
14
|
+
.map(traverse);
|
|
13
15
|
print('__closingFragment');
|
|
14
16
|
},
|
|
15
17
|
after(path, {write, indent}) {
|
|
@@ -125,6 +125,5 @@ const isNextAssign = (path) => {
|
|
|
125
125
|
if (parentPath.isBlockStatement() && parentPath.node.body.length < 3)
|
|
126
126
|
return false;
|
|
127
127
|
|
|
128
|
-
return nextPath
|
|
129
|
-
.get('expression').isAssignmentExpression();
|
|
128
|
+
return nextPath.get('expression').isAssignmentExpression();
|
|
130
129
|
};
|
package/package.json
CHANGED