@putout/printer 18.8.4 → 18.8.6

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
+ 2026.03.20, v18.8.6
2
+
3
+ feature:
4
+ - 9e0406e2 @putout/printer: type-checker: maybeCutOptions
5
+
6
+ 2026.03.20, v18.8.5
7
+
8
+ feature:
9
+ - a9df5bc7 @putout/printer: ObjectPattern: shouldAddNewline: simplify
10
+
1
11
  2026.03.20, v18.8.4
2
12
 
3
13
  feature:
@@ -8,6 +8,7 @@ import {
8
8
  } from './has.js';
9
9
 
10
10
  const getMaxPropertiesInOneLine = (a, {maxPropertiesInOneLine}) => maxPropertiesInOneLine;
11
+ const getValue = (a) => a.value;
11
12
 
12
13
  const isMoreCountLessLength = createTypeChecker([
13
14
  ['-: node.properties.length', '>', getMaxPropertiesInOneLine],
@@ -31,13 +32,10 @@ function hasPropertyLeadingComment(path) {
31
32
  return false;
32
33
  }
33
34
 
34
- const cutOptions = (fn) => (a) => fn(a);
35
- const isFunctionLike = cutOptions(isFunction);
36
-
37
35
  const isFunctionParam = callWithParent(createTypeChecker([
38
- ['+', isFunctionLike],
36
+ ['+', isFunction],
39
37
  ['-: -> !AssignmentPattern'],
40
- ['+: parentPath', isFunctionLike],
38
+ ['+: parentPath', isFunction],
41
39
  ]));
42
40
 
43
41
  const isOneOfIdentifiersHasMoreLength = createTypeChecker([
@@ -67,21 +65,16 @@ function isCoupleAssigns(path) {
67
65
  if (isFunctionParam(path))
68
66
  return false;
69
67
 
70
- let assignsCount = 0;
71
-
72
- for (const property of path.node.properties) {
73
- if (!isObjectProperty(property))
74
- continue;
75
-
76
- if (isAssignmentPattern(property.value))
77
- ++assignsCount;
78
- }
68
+ const properties = path
69
+ .node
70
+ .properties
71
+ .filter(isObjectProperty)
72
+ .map(getValue)
73
+ .filter(isAssignmentPattern);
79
74
 
80
- return assignsCount > 1;
75
+ return properties.length > 1;
81
76
  }
82
77
 
83
- const getValue = (a) => a.value;
84
-
85
78
  function checkLength(path) {
86
79
  const identifiers = path
87
80
  .node
@@ -105,4 +98,3 @@ function hasComputed(path) {
105
98
 
106
99
  return false;
107
100
  }
108
-
@@ -1,3 +1,5 @@
1
+ import {types} from '@putout/babel';
2
+
1
3
  const isFn = (a) => typeof a === 'function';
2
4
  const isString = (a) => typeof a === 'string';
3
5
  const maybeNot = (not, a) => not ? !a : a;
@@ -18,10 +20,19 @@ export const maybeCall = (fn, not, a, options) => {
18
20
  if (!isFn(fn))
19
21
  return false;
20
22
 
21
- const result = fn(a, options);
23
+ const result = maybeCutOptions(fn, a, options);
22
24
 
23
25
  if (not)
24
26
  return !result;
25
27
 
26
28
  return result;
27
29
  };
30
+
31
+ function maybeCutOptions(fn, a, options) {
32
+ const {name} = fn;
33
+
34
+ if (types[name] === fn)
35
+ return fn(a);
36
+
37
+ return fn(a, options);
38
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@putout/printer",
3
- "version": "18.8.4",
3
+ "version": "18.8.6",
4
4
  "type": "module",
5
5
  "author": "coderaiser <mnemonic.enemy@gmail.com> (https://github.com/coderaiser)",
6
6
  "description": "Simplest possible opinionated Babel AST printer for 🐊Putout",