@putout/printer 8.20.0 → 8.20.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
|
@@ -36,6 +36,24 @@ const isPrevObject = (a) => a.getPrevSibling().isObjectExpression();
|
|
|
36
36
|
const isObjectAfterSpread = (a) => isSpreadElement(a) && isNextObject(a) && !isPrevObject(a);
|
|
37
37
|
const isObjectAfterIdentifier = (a) => isIdentifier(a) && isNextObject(a) && !isPrevObject(a);
|
|
38
38
|
const isObjectAfterSimple = (a) => isObjectAfterSpread(a) || isObjectAfterIdentifier(a);
|
|
39
|
+
|
|
40
|
+
const isSpreadBeforeObject = (a) => {
|
|
41
|
+
if (!a.isObjectExpression())
|
|
42
|
+
return false;
|
|
43
|
+
|
|
44
|
+
const prev = a.getPrevSibling();
|
|
45
|
+
|
|
46
|
+
if (!prev.isSpreadElement())
|
|
47
|
+
return false;
|
|
48
|
+
|
|
49
|
+
if (prev.getPrevSibling().isObjectExpression())
|
|
50
|
+
return false;
|
|
51
|
+
|
|
52
|
+
return prev
|
|
53
|
+
.get('argument')
|
|
54
|
+
.isCallExpression();
|
|
55
|
+
};
|
|
56
|
+
|
|
39
57
|
const isNextSimple = (a) => {
|
|
40
58
|
const next = a.getNextSibling();
|
|
41
59
|
|
|
@@ -115,14 +133,13 @@ module.exports.ArrayExpression = {
|
|
|
115
133
|
if (index < n || trailingComma)
|
|
116
134
|
maybe.print(is, ',');
|
|
117
135
|
|
|
118
|
-
maybe.print.newline(is && !isNextObject(element));
|
|
136
|
+
maybe.print.newline((is || isSpreadBeforeObject(element)) && !isNextObject(element));
|
|
119
137
|
maybe.print.space(is && isObjectAfterSimple(element));
|
|
120
138
|
|
|
121
139
|
if (!is && index < n) {
|
|
122
140
|
print(',');
|
|
123
141
|
|
|
124
142
|
if (isNextSimpleBetweenObjects(element) || !(element.isObjectExpression() && isNextSimple(element)))
|
|
125
|
-
//if (!(element.isObjectExpression() && isNextSimple(element)))
|
|
126
143
|
print.space();
|
|
127
144
|
}
|
|
128
145
|
}
|
package/package.json
CHANGED