@putout/printer 15.3.1 → 15.3.2

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.2
2
+
3
+ fix:
4
+ - a92c4d3 @putout/printer: ObjectPattern: indent
5
+
1
6
  2025.06.14, v15.3.1
2
7
 
3
8
  feature:
@@ -23,6 +23,7 @@ const {
23
23
  isFunction,
24
24
  isObjectPattern,
25
25
  isForOfStatement,
26
+ isVariableDeclaration,
26
27
  } = types;
27
28
 
28
29
  const isInsideFn = (path) => {
@@ -188,7 +189,7 @@ module.exports.ObjectPattern = {
188
189
 
189
190
  indent.dec();
190
191
 
191
- maybe.indent(is || hasAssign(properties));
192
+ maybe.indent(is || hasAssignObject(path));
192
193
  maybe.indent.inc(!shouldIndent);
193
194
  print('}');
194
195
  }),
@@ -219,6 +220,28 @@ function hasAssign(properties) {
219
220
  return false;
220
221
  }
221
222
 
223
+ function hasAssignObject(path) {
224
+ const {parentPath} = path;
225
+
226
+ if (isVariableDeclaration(parentPath.parentPath)) {
227
+ const {declarations} = parentPath.parentPath.node;
228
+
229
+ if (declarations.length > 1)
230
+ return false;
231
+ }
232
+
233
+ const properties = path.get('properties');
234
+
235
+ for (const prop of properties) {
236
+ const {value} = prop.node;
237
+
238
+ if (isAssignmentPattern(value) && isObjectExpression(value.right))
239
+ return true;
240
+ }
241
+
242
+ return false;
243
+ }
244
+
222
245
  function hasObjectPattern(properties) {
223
246
  for (const property of properties) {
224
247
  if (isObjectPattern(property.node.value))
@@ -1,8 +1,7 @@
1
1
  'use strict';
2
2
 
3
3
  module.exports.StringLiteral = (path, {write}, semantics) => {
4
- const {value, raw = `'${value}'`,
5
- } = path.node;
4
+ const {value, raw = `'${value}'`} = path.node;
6
5
 
7
6
  if (path.parentPath.isJSXAttribute()) {
8
7
  write(raw);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@putout/printer",
3
- "version": "15.3.1",
3
+ "version": "15.3.2",
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",