@putout/printer 8.18.0 → 8.19.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,6 +7,8 @@ const {
|
|
|
7
7
|
isIdentifierAndIdentifier,
|
|
8
8
|
isStringAndArray,
|
|
9
9
|
isSimpleAndEmptyObject,
|
|
10
|
+
isNext,
|
|
11
|
+
|
|
10
12
|
} = require('../../is');
|
|
11
13
|
|
|
12
14
|
const {
|
|
@@ -37,6 +39,7 @@ const isObjectAfterSpread = (a) => isSpreadElement(a) && isNextObject(a) && !isP
|
|
|
37
39
|
const isObjectAfterIdentifier = (a) => isIdentifier(a) && isNextObject(a) && !isPrevObject(a);
|
|
38
40
|
const isObjectAfterSimple = (a) => isObjectAfterSpread(a) || isObjectAfterIdentifier(a);
|
|
39
41
|
const isNextSpread = (a) => a.getNextSibling().isSpreadElement();
|
|
42
|
+
|
|
40
43
|
const isNextSpreadBetweenObjects = (a) => {
|
|
41
44
|
const next = a.getNextSibling();
|
|
42
45
|
const is = next.isSpreadElement();
|
|
@@ -44,7 +47,9 @@ const isNextSpreadBetweenObjects = (a) => {
|
|
|
44
47
|
if (!is)
|
|
45
48
|
return true;
|
|
46
49
|
|
|
47
|
-
return next
|
|
50
|
+
return next
|
|
51
|
+
.getNextSibling()
|
|
52
|
+
.isObjectExpression();
|
|
48
53
|
};
|
|
49
54
|
|
|
50
55
|
const isInsideOneElementArray = ({parentPath}) => parentPath.node.elements.length === 1;
|
|
@@ -96,7 +101,7 @@ module.exports.ArrayExpression = {
|
|
|
96
101
|
for (const [index, element] of elements.entries()) {
|
|
97
102
|
const is = isNewLine && isCurrentNewLine(element);
|
|
98
103
|
|
|
99
|
-
if (
|
|
104
|
+
if (isSpreadAfterObject(element))
|
|
100
105
|
print.newline();
|
|
101
106
|
|
|
102
107
|
maybe.indent(is);
|
|
@@ -160,3 +165,16 @@ module.exports.ArrayExpression = {
|
|
|
160
165
|
indent.inc();
|
|
161
166
|
},
|
|
162
167
|
};
|
|
168
|
+
|
|
169
|
+
function isSpreadAfterObject(path) {
|
|
170
|
+
if (!isSpreadElement(path))
|
|
171
|
+
return;
|
|
172
|
+
|
|
173
|
+
const prev = path.getPrevSibling();
|
|
174
|
+
const next = path.getNextSibling();
|
|
175
|
+
|
|
176
|
+
if (next.isObjectExpression())
|
|
177
|
+
return false;
|
|
178
|
+
|
|
179
|
+
return prev.isObjectExpression();
|
|
180
|
+
}
|
package/package.json
CHANGED