@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
|
@@ -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
|
-
['+',
|
|
36
|
+
['+', isFunction],
|
|
39
37
|
['-: -> !AssignmentPattern'],
|
|
40
|
-
['+: parentPath',
|
|
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
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
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
|
|
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
|
|
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