@putout/printer 2.67.0 → 2.68.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
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
const {
|
|
4
4
|
isIdentifier,
|
|
5
5
|
isObjectPattern,
|
|
6
|
+
isAssignmentPattern,
|
|
6
7
|
} = require('@babel/types');
|
|
7
8
|
|
|
8
9
|
const {wrongShorthand} = require('./wrong-shortand');
|
|
@@ -22,6 +23,7 @@ const isOneParentProperty = ({parentPath}) => parentPath.parentPath.node.propert
|
|
|
22
23
|
module.exports.ObjectPattern = {
|
|
23
24
|
print(path, {indent, print, maybe}, semantics) {
|
|
24
25
|
const {maxPropertiesInOneLine} = semantics;
|
|
26
|
+
|
|
25
27
|
indent.inc();
|
|
26
28
|
print('{');
|
|
27
29
|
|
|
@@ -51,7 +53,6 @@ module.exports.ObjectPattern = {
|
|
|
51
53
|
const isAssign = valuePath.isAssignmentPattern();
|
|
52
54
|
|
|
53
55
|
const {shorthand, computed} = property.node;
|
|
54
|
-
|
|
55
56
|
const couple = isCoupleLines(valuePath) && !exists(property.getPrevSibling()) && !path.parentPath.isObjectProperty();
|
|
56
57
|
|
|
57
58
|
maybe.indent(is);
|
|
@@ -117,6 +118,17 @@ function checkLength(properties) {
|
|
|
117
118
|
return false;
|
|
118
119
|
}
|
|
119
120
|
|
|
121
|
+
function hasAssign(properties) {
|
|
122
|
+
for (const prop of properties) {
|
|
123
|
+
const {value} = prop.node;
|
|
124
|
+
|
|
125
|
+
if (isAssignmentPattern(value))
|
|
126
|
+
return true;
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
return false;
|
|
130
|
+
}
|
|
131
|
+
|
|
120
132
|
function hasObjectPattern(properties) {
|
|
121
133
|
for (const property of properties) {
|
|
122
134
|
if (isObjectPattern(property.node.value))
|
|
@@ -140,5 +152,8 @@ function shouldAddNewline(path, {maxPropertiesInOneLine}) {
|
|
|
140
152
|
if (!isForOf(path) && !path.parentPath.isFunction() && n && checkLength(properties))
|
|
141
153
|
return COUPLE_LINES;
|
|
142
154
|
|
|
155
|
+
if (hasAssign(properties))
|
|
156
|
+
return COUPLE_LINES;
|
|
157
|
+
|
|
143
158
|
return parentPath.isObjectProperty();
|
|
144
159
|
}
|
package/package.json
CHANGED