@putout/printer 15.1.1 → 15.1.3
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
|
@@ -26,6 +26,7 @@ const {
|
|
|
26
26
|
isIdentifier,
|
|
27
27
|
isObjectPattern,
|
|
28
28
|
isAssignmentPattern,
|
|
29
|
+
isObjectExpression,
|
|
29
30
|
isVariableDeclarator,
|
|
30
31
|
isFunction,
|
|
31
32
|
} = types;
|
|
@@ -47,6 +48,17 @@ const isCoupleProperties = ({path, valuePath, property}) => {
|
|
|
47
48
|
return !path.parentPath.isObjectProperty();
|
|
48
49
|
};
|
|
49
50
|
|
|
51
|
+
function isPrevAssignObject(path) {
|
|
52
|
+
const prev = path.getPrevSibling();
|
|
53
|
+
|
|
54
|
+
if (!isAssignmentPattern(prev.node.value))
|
|
55
|
+
return false;
|
|
56
|
+
|
|
57
|
+
const {right} = prev.node.value;
|
|
58
|
+
|
|
59
|
+
return isObjectExpression(right);
|
|
60
|
+
}
|
|
61
|
+
|
|
50
62
|
module.exports.ObjectPattern = {
|
|
51
63
|
print: maybeTypeAnnotation((path, printer, semantics) => {
|
|
52
64
|
const shouldIndent = isIndent(path);
|
|
@@ -87,8 +99,7 @@ module.exports.ObjectPattern = {
|
|
|
87
99
|
continue;
|
|
88
100
|
}
|
|
89
101
|
|
|
90
|
-
const
|
|
91
|
-
const prevAssign = i && isAssignmentPattern(prev.node.value);
|
|
102
|
+
const prevAssignObject = i && isPrevAssignObject(property);
|
|
92
103
|
|
|
93
104
|
const valuePath = property.get('value');
|
|
94
105
|
const keyPath = property.get('key');
|
|
@@ -101,7 +112,7 @@ module.exports.ObjectPattern = {
|
|
|
101
112
|
valuePath,
|
|
102
113
|
});
|
|
103
114
|
|
|
104
|
-
maybe.indent((
|
|
115
|
+
maybe.indent((prevAssignObject || is) && notInsideFn);
|
|
105
116
|
maybe.print.breakline(couple);
|
|
106
117
|
|
|
107
118
|
printKey(property, printer);
|
|
@@ -117,7 +128,7 @@ module.exports.ObjectPattern = {
|
|
|
117
128
|
maybe.print.newline(couple);
|
|
118
129
|
}
|
|
119
130
|
|
|
120
|
-
if (is || hasObject ||
|
|
131
|
+
if (is || hasObject || prevAssignObject && notInsideFn) {
|
|
121
132
|
print(',');
|
|
122
133
|
print.newline();
|
|
123
134
|
|
|
@@ -218,4 +229,3 @@ function isFunctionParam({parentPath}) {
|
|
|
218
229
|
|
|
219
230
|
return parentPath.parentPath.isFunction();
|
|
220
231
|
}
|
|
221
|
-
|
package/package.json
CHANGED