@putout/printer 15.3.0 → 15.3.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
|
@@ -22,6 +22,7 @@ const {
|
|
|
22
22
|
isVariableDeclarator,
|
|
23
23
|
isFunction,
|
|
24
24
|
isObjectPattern,
|
|
25
|
+
isForOfStatement,
|
|
25
26
|
} = types;
|
|
26
27
|
|
|
27
28
|
const isInsideFn = (path) => {
|
|
@@ -42,14 +43,21 @@ const isCoupleProperties = ({path, valuePath, property}) => {
|
|
|
42
43
|
if (exists(property.getPrevSibling()))
|
|
43
44
|
return false;
|
|
44
45
|
|
|
45
|
-
|
|
46
|
+
const properties = path.get('properties');
|
|
47
|
+
|
|
48
|
+
if (path.parentPath.isVariableDeclarator() && !hasAssign(properties))
|
|
46
49
|
return false;
|
|
47
50
|
|
|
48
51
|
return !path.parentPath.isObjectProperty();
|
|
49
52
|
};
|
|
50
53
|
|
|
54
|
+
function isInsideForOf({parentPath}) {
|
|
55
|
+
return isForOfStatement(parentPath.parentPath.parentPath);
|
|
56
|
+
}
|
|
57
|
+
|
|
51
58
|
function isPrevAssign(path) {
|
|
52
59
|
const prev = path.getPrevSibling();
|
|
60
|
+
|
|
53
61
|
return isAssignmentPattern(prev.node.value);
|
|
54
62
|
}
|
|
55
63
|
|
|
@@ -150,7 +158,9 @@ module.exports.ObjectPattern = {
|
|
|
150
158
|
maybe.print(couple, ',');
|
|
151
159
|
maybe.print.newline(couple);
|
|
152
160
|
|
|
153
|
-
|
|
161
|
+
const {right} = valuePath.node;
|
|
162
|
+
|
|
163
|
+
if (i && !isPrevAssign(property) && !isInsideForOf(path) && isObjectExpression(right)) {
|
|
154
164
|
print(',');
|
|
155
165
|
print.newline();
|
|
156
166
|
continue;
|
|
@@ -177,7 +187,8 @@ module.exports.ObjectPattern = {
|
|
|
177
187
|
}
|
|
178
188
|
|
|
179
189
|
indent.dec();
|
|
180
|
-
|
|
190
|
+
|
|
191
|
+
maybe.indent(is || hasAssign(properties));
|
|
181
192
|
maybe.indent.inc(!shouldIndent);
|
|
182
193
|
print('}');
|
|
183
194
|
}),
|
|
@@ -264,4 +275,3 @@ function isFunctionParam({parentPath}) {
|
|
|
264
275
|
|
|
265
276
|
return parentPath.parentPath.isFunction();
|
|
266
277
|
}
|
|
267
|
-
|
package/package.json
CHANGED