@putout/printer 15.25.0 → 15.26.1

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
@@ -1,3 +1,13 @@
1
+ 2025.10.31, v15.26.1
2
+
3
+ feature:
4
+ - c929351 @putout/printer: ObjectPattern: calculateLongAssignPattern: simplify
5
+
6
+ 2025.10.31, v15.26.0
7
+
8
+ feature:
9
+ - 366a0ca @putout/printer: ObjectPattern: computed: maxPropertiesLengthInOneLine check
10
+
1
11
  2025.10.30, v15.25.0
2
12
 
3
13
  feature:
@@ -5,6 +5,7 @@ const {
5
5
  isAssignmentPattern,
6
6
  isArrayExpression,
7
7
  isObjectExpression,
8
+ isIdentifier,
8
9
  } = types;
9
10
 
10
11
  module.exports.calculateAssigns = (property, semantics) => {
@@ -22,12 +23,17 @@ module.exports.calculateAssigns = (property, semantics) => {
22
23
  module.exports.isLongAssignPattern = isLongAssignPattern;
23
24
 
24
25
  function isLongAssignPattern(path, semantics) {
25
- if (!isAssignmentPattern(path.node.value))
26
+ const {key, value} = path.node;
27
+
28
+ if (!isAssignmentPattern(value))
26
29
  return false;
27
30
 
31
+ if (!isIdentifier(key))
32
+ return true;
33
+
28
34
  const {maxPropertiesLengthInOneLine} = semantics;
29
35
 
30
- return path.node.key.name.length > maxPropertiesLengthInOneLine;
36
+ return key.name.length > maxPropertiesLengthInOneLine;
31
37
  }
32
38
 
33
39
  function isComplexObject(node) {
@@ -227,6 +227,17 @@ function hasAssign(properties) {
227
227
  return false;
228
228
  }
229
229
 
230
+ function hasComputed(properties) {
231
+ for (const prop of properties) {
232
+ const {computed} = prop.node;
233
+
234
+ if (computed)
235
+ return true;
236
+ }
237
+
238
+ return false;
239
+ }
240
+
230
241
  function hasAssignObject(path, maxPropertiesLengthInOneLine) {
231
242
  const {parentPath} = path;
232
243
 
@@ -280,6 +291,9 @@ function shouldAddNewline(path, semantics) {
280
291
  maxPropertiesInOneLine,
281
292
  });
282
293
 
294
+ if (hasComputed(properties))
295
+ return COUPLE_LINES;
296
+
283
297
  const fnParam = isFunctionParam(path);
284
298
 
285
299
  if (hasObjectPattern(properties))
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@putout/printer",
3
- "version": "15.25.0",
3
+ "version": "15.26.1",
4
4
  "type": "commonjs",
5
5
  "author": "coderaiser <mnemonic.enemy@gmail.com> (https://github.com/coderaiser)",
6
6
  "description": "Simplest possible opinionated Babel AST printer for 🐊Putout",