@putout/printer 15.3.0 → 15.3.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,8 @@
1
+ 2025.06.14, v15.3.1
2
+
3
+ feature:
4
+ - a266b51 @putout/printer: ObjectPattern: newline
5
+
1
6
  2025.06.13, v15.3.0
2
7
 
3
8
  feature:
@@ -22,6 +22,7 @@ const {
22
22
  isVariableDeclarator,
23
23
  isFunction,
24
24
  isObjectPattern,
25
+ isForOfStatement,
25
26
  } = types;
26
27
 
27
28
  const isInsideFn = (path) => {
@@ -42,14 +43,21 @@ const isCoupleProperties = ({path, valuePath, property}) => {
42
43
  if (exists(property.getPrevSibling()))
43
44
  return false;
44
45
 
45
- if (path.parentPath.isVariableDeclarator() && !hasAssign(path.get('properties')))
46
+ const properties = path.get('properties');
47
+
48
+ if (path.parentPath.isVariableDeclarator() && !hasAssign(properties))
46
49
  return false;
47
50
 
48
51
  return !path.parentPath.isObjectProperty();
49
52
  };
50
53
 
54
+ function isInsideForOf({parentPath}) {
55
+ return isForOfStatement(parentPath.parentPath.parentPath);
56
+ }
57
+
51
58
  function isPrevAssign(path) {
52
59
  const prev = path.getPrevSibling();
60
+
53
61
  return isAssignmentPattern(prev.node.value);
54
62
  }
55
63
 
@@ -150,7 +158,9 @@ module.exports.ObjectPattern = {
150
158
  maybe.print(couple, ',');
151
159
  maybe.print.newline(couple);
152
160
 
153
- if (i && !isPrevAssign(property)) {
161
+ const {right} = valuePath.node;
162
+
163
+ if (i && !isPrevAssign(property) && !isInsideForOf(path) && isObjectExpression(right)) {
154
164
  print(',');
155
165
  print.newline();
156
166
  continue;
@@ -177,7 +187,8 @@ module.exports.ObjectPattern = {
177
187
  }
178
188
 
179
189
  indent.dec();
180
- maybe.indent(is);
190
+
191
+ maybe.indent(is || hasAssign(properties));
181
192
  maybe.indent.inc(!shouldIndent);
182
193
  print('}');
183
194
  }),
@@ -264,4 +275,3 @@ function isFunctionParam({parentPath}) {
264
275
 
265
276
  return parentPath.parentPath.isFunction();
266
277
  }
267
-
@@ -1,7 +1,8 @@
1
1
  'use strict';
2
2
 
3
3
  module.exports.StringLiteral = (path, {write}, semantics) => {
4
- const {value, raw = `'${value}'`} = path.node;
4
+ const {value, raw = `'${value}'`,
5
+ } = path.node;
5
6
 
6
7
  if (path.parentPath.isJSXAttribute()) {
7
8
  write(raw);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@putout/printer",
3
- "version": "15.3.0",
3
+ "version": "15.3.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",