@putout/printer 8.31.0 → 8.32.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
+ 2024.05.03, v8.32.0
2
+
3
+ feature:
4
+ - 4c10986 @putout/printer: ObjectPattern: used as Function param
5
+
1
6
  2024.05.03, v8.31.0
2
7
 
3
8
  feature:
@@ -18,4 +18,3 @@ module.exports.isObjectAfterSimple = (a) => {
18
18
 
19
19
  return SIMPLE_TYPES.includes(type);
20
20
  };
21
-
@@ -173,14 +173,28 @@ function shouldAddNewline(path, semantics) {
173
173
  maxPropertiesInOneLine,
174
174
  });
175
175
 
176
+ const fnParam = isFunctionParam(path);
177
+
176
178
  if (moreCount && !moreLength)
177
179
  return ONE_LINE;
178
180
 
179
- if (!isForOf(path) && !path.parentPath.isFunction() && n && checkLength(properties))
181
+ if (!fnParam && n && !isForOf(path) && checkLength(properties))
180
182
  return COUPLE_LINES;
181
183
 
182
- if (hasAssign(properties))
184
+ if (!fnParam && hasAssign(properties))
183
185
  return COUPLE_LINES;
184
186
 
185
187
  return parentPath.isObjectProperty();
186
188
  }
189
+
190
+ function isFunctionParam(path) {
191
+ const {parentPath} = path;
192
+
193
+ if (parentPath.isFunction())
194
+ return true;
195
+
196
+ if (!parentPath.isAssignmentPattern())
197
+ return false;
198
+
199
+ return parentPath.parentPath.isFunction();
200
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@putout/printer",
3
- "version": "8.31.0",
3
+ "version": "8.32.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",