@putout/printer 15.2.0 → 15.3.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
|
@@ -48,6 +48,11 @@ const isCoupleProperties = ({path, valuePath, property}) => {
|
|
|
48
48
|
return !path.parentPath.isObjectProperty();
|
|
49
49
|
};
|
|
50
50
|
|
|
51
|
+
function isPrevAssign(path) {
|
|
52
|
+
const prev = path.getPrevSibling();
|
|
53
|
+
return isAssignmentPattern(prev.node.value);
|
|
54
|
+
}
|
|
55
|
+
|
|
51
56
|
function isPrevAssignObject(path) {
|
|
52
57
|
const prev = path.getPrevSibling();
|
|
53
58
|
|
|
@@ -59,6 +64,20 @@ function isPrevAssignObject(path) {
|
|
|
59
64
|
return isObjectExpression(right);
|
|
60
65
|
}
|
|
61
66
|
|
|
67
|
+
function isNextAssignObject(path) {
|
|
68
|
+
const next = path.getNextSibling();
|
|
69
|
+
|
|
70
|
+
if (!next.node)
|
|
71
|
+
return false;
|
|
72
|
+
|
|
73
|
+
if (!isAssignmentPattern(next.node.value))
|
|
74
|
+
return false;
|
|
75
|
+
|
|
76
|
+
const {right} = next.node.value;
|
|
77
|
+
|
|
78
|
+
return isObjectExpression(right);
|
|
79
|
+
}
|
|
80
|
+
|
|
62
81
|
module.exports.ObjectPattern = {
|
|
63
82
|
print: maybeTypeAnnotation((path, printer, semantics) => {
|
|
64
83
|
const shouldIndent = isIndent(path);
|
|
@@ -100,6 +119,7 @@ module.exports.ObjectPattern = {
|
|
|
100
119
|
}
|
|
101
120
|
|
|
102
121
|
const prevAssignObject = i && isPrevAssignObject(property);
|
|
122
|
+
const nextAssignObject = isNextAssignObject(property);
|
|
103
123
|
|
|
104
124
|
const valuePath = property.get('value');
|
|
105
125
|
const keyPath = property.get('key');
|
|
@@ -115,6 +135,9 @@ module.exports.ObjectPattern = {
|
|
|
115
135
|
maybe.indent((prevAssignObject || is) && notInsideFn);
|
|
116
136
|
maybe.print.breakline(couple);
|
|
117
137
|
|
|
138
|
+
if (!isAssign && nextAssignObject)
|
|
139
|
+
print.breakline();
|
|
140
|
+
|
|
118
141
|
printKey(property, printer);
|
|
119
142
|
|
|
120
143
|
if (!shorthand || wrongShorthand({computed, isAssign, keyPath, valuePath})) {
|
|
@@ -126,6 +149,18 @@ module.exports.ObjectPattern = {
|
|
|
126
149
|
|
|
127
150
|
maybe.print(couple, ',');
|
|
128
151
|
maybe.print.newline(couple);
|
|
152
|
+
|
|
153
|
+
if (i && !isPrevAssign(property)) {
|
|
154
|
+
print(',');
|
|
155
|
+
print.newline();
|
|
156
|
+
continue;
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
if (!isAssign && nextAssignObject && notInsideFn) {
|
|
161
|
+
print(',');
|
|
162
|
+
print.breakline();
|
|
163
|
+
continue;
|
|
129
164
|
}
|
|
130
165
|
|
|
131
166
|
if (is || hasObject || prevAssignObject && notInsideFn) {
|
|
@@ -229,3 +264,4 @@ function isFunctionParam({parentPath}) {
|
|
|
229
264
|
|
|
230
265
|
return parentPath.parentPath.isFunction();
|
|
231
266
|
}
|
|
267
|
+
|
package/package.json
CHANGED