@putout/printer 15.20.2 → 15.20.4

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.09.11, v15.20.4
2
+
3
+ feature:
4
+ - a3a3776 @putout/printer: ObjectPattern: simplify
5
+
6
+ 2025.09.11, v15.20.3
7
+
8
+ feature:
9
+ - ff9d636 @putout/printer: ObjectPattern: simplify
10
+
1
11
  2025.09.11, v15.20.2
2
12
 
3
13
  feature:
@@ -61,8 +61,7 @@ module.exports.printLeadingComments = (path, printer, semantics, {currentTravers
61
61
  module.exports.printTrailingComments = (path, printer, semantics, {currentTraverse}) => {
62
62
  const {print} = printer;
63
63
  const {
64
- trailingComments = [],
65
- } = path.node;
64
+ trailingComments = []} = path.node;
66
65
 
67
66
  const {
68
67
  printTrailingCommentLine,
@@ -19,8 +19,7 @@ module.exports.printParams = (path, printer, semantics, customization = {}) => {
19
19
  braceClose = ')',
20
20
  printSpace = print.space,
21
21
  printAfterOpen = noop,
22
- printBeforeClose = noop,
23
- } = customization;
22
+ printBeforeClose = noop} = customization;
24
23
 
25
24
  if (typeParameters)
26
25
  traverse(path.get('typeParameters'));
@@ -1,38 +1,31 @@
1
1
  'use strict';
2
2
 
3
3
  const {types} = require('@putout/babel');
4
- const {isAssignmentPattern} = types;
4
+ const {
5
+ isAssignmentPattern,
6
+ isArrayExpression,
7
+ isObjectExpression,
8
+ } = types;
5
9
 
6
10
  module.exports.calculateAssigns = (property, semantics) => {
7
- const prev = property.getPrevSibling();
8
- const next = property.getNextSibling();
9
-
10
11
  const currentAssign = isLongAssignPattern(property, semantics);
11
- const prevAssign = isLongAssignPattern(prev, semantics);
12
- const nextAssign = isLongAssignPattern(next, semantics);
13
- const bothLongAssigns = currentAssign && (nextAssign || prevAssign);
14
12
 
15
- const oneLongAssign = currentAssign
16
- && (!next.node
17
- || nextAssign
18
- || !isAssignmentPattern(next.node?.value));
13
+ const {right} = property.node.value;
14
+ const isArrayOrObjectRight = isArrayExpression(right) || isObjectExpression(right);
15
+ const complexAssign = currentAssign && isArrayOrObjectRight;
19
16
 
20
17
  return {
21
- bothLongAssigns,
22
- oneLongAssign,
18
+ complexAssign,
23
19
  };
24
20
  };
25
21
 
26
22
  module.exports.isLongAssignPattern = isLongAssignPattern;
27
23
 
28
24
  function isLongAssignPattern(path, semantics) {
29
- if (!path.node)
30
- return false;
31
-
32
25
  if (!isAssignmentPattern(path.node.value))
33
26
  return false;
34
27
 
35
28
  const {maxPropertiesLengthInOneLine} = semantics;
36
29
 
37
- return !(path.node.key.name.length <= maxPropertiesLengthInOneLine);
30
+ return path.node.key.name.length > maxPropertiesLengthInOneLine;
38
31
  }
@@ -179,12 +179,9 @@ module.exports.ObjectPattern = {
179
179
  continue;
180
180
  }
181
181
 
182
- const {
183
- oneLongAssign,
184
- bothLongAssigns,
185
- } = calculateAssigns(property, semantics);
182
+ const {complexAssign} = calculateAssigns(property, semantics);
186
183
 
187
- if ((!oneLongAssign || bothLongAssigns) && (is || hasObject || prevAssignObject && notInsideFn)) {
184
+ if (!complexAssign && (is || hasObject || prevAssignObject && notInsideFn)) {
188
185
  print(',');
189
186
  print.newline();
190
187
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@putout/printer",
3
- "version": "15.20.2",
3
+ "version": "15.20.4",
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",
@@ -69,6 +69,7 @@
69
69
  }
70
70
  },
71
71
  "devDependencies": {
72
+ "@babel/parser": "8.0.0-beta.2",
72
73
  "@putout/eslint": "^4.1.0",
73
74
  "@putout/plugin-minify": "^11.2.1",
74
75
  "@putout/plugin-printer": "^6.0.0",