@putout/printer 15.6.0 → 15.7.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
|
@@ -189,7 +189,7 @@ module.exports.ObjectPattern = {
|
|
|
189
189
|
|
|
190
190
|
indent.dec();
|
|
191
191
|
|
|
192
|
-
maybe.indent(is || hasAssignObject(path));
|
|
192
|
+
maybe.indent(is || hasAssignObject(path, maxPropertiesLengthInOneLine));
|
|
193
193
|
maybe.indent.inc(!shouldIndent);
|
|
194
194
|
print('}');
|
|
195
195
|
}),
|
|
@@ -220,7 +220,7 @@ function hasAssign(properties) {
|
|
|
220
220
|
return false;
|
|
221
221
|
}
|
|
222
222
|
|
|
223
|
-
function hasAssignObject(path) {
|
|
223
|
+
function hasAssignObject(path, maxPropertiesLengthInOneLine) {
|
|
224
224
|
const {parentPath} = path;
|
|
225
225
|
|
|
226
226
|
if (isVariableDeclaration(parentPath.parentPath)) {
|
|
@@ -231,12 +231,13 @@ function hasAssignObject(path) {
|
|
|
231
231
|
}
|
|
232
232
|
|
|
233
233
|
const properties = path.get('properties');
|
|
234
|
+
const n = properties.length;
|
|
234
235
|
|
|
235
236
|
for (const prop of properties) {
|
|
236
237
|
const {value} = prop.node;
|
|
237
238
|
|
|
238
239
|
if (isAssignmentPattern(value) && isObjectExpression(value.right))
|
|
239
|
-
return
|
|
240
|
+
return n > 1 || maxPropertiesLengthInOneLine <= value.left;
|
|
240
241
|
}
|
|
241
242
|
|
|
242
243
|
return false;
|
|
@@ -10,13 +10,14 @@ const {
|
|
|
10
10
|
} = require('../../is');
|
|
11
11
|
|
|
12
12
|
const {hasPrevNewline} = require('../../mark');
|
|
13
|
-
|
|
14
13
|
const {maybeSpaceAfterKeyword} = require('./maybe-space-after-keyword');
|
|
15
14
|
|
|
16
15
|
const {isConcatenation} = require('../../expressions/binary-expression/concatenate');
|
|
17
16
|
const {parseLeadingComments} = require('../../comment/comment');
|
|
18
17
|
const {maybeDeclare} = require('../../maybe/maybe-declare');
|
|
18
|
+
|
|
19
19
|
const {isExportDeclaration} = types;
|
|
20
|
+
|
|
20
21
|
const isParentTSModuleBlock = (path) => path.parentPath.isTSModuleBlock();
|
|
21
22
|
const isParentBlock = (path) => /Program|BlockStatement|Export|LabeledStatement/.test(path.parentPath.type);
|
|
22
23
|
const isInsideBlock = (path) => /^(Program|BlockStatement|TSModuleBlock|SwitchCase)$/.test(path.parentPath.type);
|
package/package.json
CHANGED