@putout/printer 15.3.1 → 15.3.2
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
|
@@ -23,6 +23,7 @@ const {
|
|
|
23
23
|
isFunction,
|
|
24
24
|
isObjectPattern,
|
|
25
25
|
isForOfStatement,
|
|
26
|
+
isVariableDeclaration,
|
|
26
27
|
} = types;
|
|
27
28
|
|
|
28
29
|
const isInsideFn = (path) => {
|
|
@@ -188,7 +189,7 @@ module.exports.ObjectPattern = {
|
|
|
188
189
|
|
|
189
190
|
indent.dec();
|
|
190
191
|
|
|
191
|
-
maybe.indent(is ||
|
|
192
|
+
maybe.indent(is || hasAssignObject(path));
|
|
192
193
|
maybe.indent.inc(!shouldIndent);
|
|
193
194
|
print('}');
|
|
194
195
|
}),
|
|
@@ -219,6 +220,28 @@ function hasAssign(properties) {
|
|
|
219
220
|
return false;
|
|
220
221
|
}
|
|
221
222
|
|
|
223
|
+
function hasAssignObject(path) {
|
|
224
|
+
const {parentPath} = path;
|
|
225
|
+
|
|
226
|
+
if (isVariableDeclaration(parentPath.parentPath)) {
|
|
227
|
+
const {declarations} = parentPath.parentPath.node;
|
|
228
|
+
|
|
229
|
+
if (declarations.length > 1)
|
|
230
|
+
return false;
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
const properties = path.get('properties');
|
|
234
|
+
|
|
235
|
+
for (const prop of properties) {
|
|
236
|
+
const {value} = prop.node;
|
|
237
|
+
|
|
238
|
+
if (isAssignmentPattern(value) && isObjectExpression(value.right))
|
|
239
|
+
return true;
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
return false;
|
|
243
|
+
}
|
|
244
|
+
|
|
222
245
|
function hasObjectPattern(properties) {
|
|
223
246
|
for (const property of properties) {
|
|
224
247
|
if (isObjectPattern(property.node.value))
|
package/package.json
CHANGED