@putout/printer 8.19.0 → 8.20.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.
package/ChangeLog
CHANGED
|
@@ -7,8 +7,6 @@ const {
|
|
|
7
7
|
isIdentifierAndIdentifier,
|
|
8
8
|
isStringAndArray,
|
|
9
9
|
isSimpleAndEmptyObject,
|
|
10
|
-
isNext,
|
|
11
|
-
|
|
12
10
|
} = require('../../is');
|
|
13
11
|
|
|
14
12
|
const {
|
|
@@ -38,11 +36,18 @@ const isPrevObject = (a) => a.getPrevSibling().isObjectExpression();
|
|
|
38
36
|
const isObjectAfterSpread = (a) => isSpreadElement(a) && isNextObject(a) && !isPrevObject(a);
|
|
39
37
|
const isObjectAfterIdentifier = (a) => isIdentifier(a) && isNextObject(a) && !isPrevObject(a);
|
|
40
38
|
const isObjectAfterSimple = (a) => isObjectAfterSpread(a) || isObjectAfterIdentifier(a);
|
|
41
|
-
const
|
|
39
|
+
const isNextSimple = (a) => {
|
|
40
|
+
const next = a.getNextSibling();
|
|
41
|
+
|
|
42
|
+
if (next.isSpreadElement())
|
|
43
|
+
return true;
|
|
44
|
+
|
|
45
|
+
return next.isIdentifier();
|
|
46
|
+
};
|
|
42
47
|
|
|
43
|
-
const
|
|
48
|
+
const isNextSimpleBetweenObjects = (a) => {
|
|
44
49
|
const next = a.getNextSibling();
|
|
45
|
-
const is = next.isSpreadElement();
|
|
50
|
+
const is = next.isSpreadElement() || next.isIdentifier();
|
|
46
51
|
|
|
47
52
|
if (!is)
|
|
48
53
|
return true;
|
|
@@ -101,7 +106,7 @@ module.exports.ArrayExpression = {
|
|
|
101
106
|
for (const [index, element] of elements.entries()) {
|
|
102
107
|
const is = isNewLine && isCurrentNewLine(element);
|
|
103
108
|
|
|
104
|
-
if (
|
|
109
|
+
if (isSimpleAfterObject(element))
|
|
105
110
|
print.newline();
|
|
106
111
|
|
|
107
112
|
maybe.indent(is);
|
|
@@ -116,7 +121,8 @@ module.exports.ArrayExpression = {
|
|
|
116
121
|
if (!is && index < n) {
|
|
117
122
|
print(',');
|
|
118
123
|
|
|
119
|
-
if (
|
|
124
|
+
if (isNextSimpleBetweenObjects(element) || !(element.isObjectExpression() && isNextSimple(element)))
|
|
125
|
+
//if (!(element.isObjectExpression() && isNextSimple(element)))
|
|
120
126
|
print.space();
|
|
121
127
|
}
|
|
122
128
|
}
|
|
@@ -166,8 +172,8 @@ module.exports.ArrayExpression = {
|
|
|
166
172
|
},
|
|
167
173
|
};
|
|
168
174
|
|
|
169
|
-
function
|
|
170
|
-
if (!isSpreadElement(path))
|
|
175
|
+
function isSimpleAfterObject(path) {
|
|
176
|
+
if (!isSpreadElement(path) && !isIdentifier(path))
|
|
171
177
|
return;
|
|
172
178
|
|
|
173
179
|
const prev = path.getPrevSibling();
|
package/package.json
CHANGED