@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
@@ -1,3 +1,8 @@
1
+ 2025.07.02, v15.7.0
2
+
3
+ feature:
4
+ - 54874b0 @putout/printer: ObjectPattern: useless indent inside VariableDeclaration
5
+
1
6
  2025.06.26, v15.6.0
2
7
 
3
8
  feature:
@@ -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 true;
240
+ return n > 1 || maxPropertiesLengthInOneLine <= value.left;
240
241
  }
241
242
 
242
243
  return false;
@@ -46,4 +46,3 @@ module.exports = {
46
46
  write('super');
47
47
  },
48
48
  };
49
-
@@ -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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@putout/printer",
3
- "version": "15.6.0",
3
+ "version": "15.7.0",
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",