@putout/printer 18.8.3 → 18.8.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 +5 -0
- package/lib/tokenize/expressions/object-pattern/has.js +4 -6
- package/lib/tokenize/expressions/object-pattern/is-more-then-max-properties-length-in-one-line.js +6 -7
- package/lib/tokenize/expressions/object-pattern/is.js +4 -7
- package/lib/tokenize/expressions/object-pattern/object-pattern.js +1 -1
- package/lib/tokenize/expressions/object-pattern/should-add-new-line.js +4 -2
- package/package.json +1 -1
- package/lib/tokenize/expressions/object-pattern/is-less-then-max-properties-in-one-line.js +0 -7
package/ChangeLog
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import {types} from '@putout/babel';
|
|
2
|
+
import {isAssignObject} from './is.js';
|
|
2
3
|
|
|
3
4
|
const {
|
|
4
5
|
isAssignmentPattern,
|
|
5
6
|
isObjectPattern,
|
|
6
|
-
isObjectExpression,
|
|
7
7
|
} = types;
|
|
8
8
|
|
|
9
9
|
export function hasObjectPattern(path) {
|
|
@@ -24,15 +24,13 @@ export function hasAssign(path) {
|
|
|
24
24
|
return false;
|
|
25
25
|
}
|
|
26
26
|
|
|
27
|
-
export function hasAssignObject(path
|
|
27
|
+
export function hasAssignObject(path) {
|
|
28
28
|
const properties = path.get('properties');
|
|
29
29
|
const n = properties.length;
|
|
30
30
|
|
|
31
31
|
for (const prop of properties) {
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
if (isAssignmentPattern(value) && isObjectExpression(value.right))
|
|
35
|
-
return n > 1 || maxPropertiesLengthInOneLine <= value.left;
|
|
32
|
+
if (isAssignObject(prop))
|
|
33
|
+
return n > 1;
|
|
36
34
|
}
|
|
37
35
|
|
|
38
36
|
return false;
|
package/lib/tokenize/expressions/object-pattern/is-more-then-max-properties-length-in-one-line.js
CHANGED
|
@@ -25,13 +25,12 @@ export const isMoreThenMaxPropertiesLengthInOneLine = (path, {maxPropertiesLengt
|
|
|
25
25
|
return true;
|
|
26
26
|
}
|
|
27
27
|
|
|
28
|
-
if (
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
return true;
|
|
28
|
+
if (isIdentifier(key)) {
|
|
29
|
+
const {name} = key;
|
|
30
|
+
|
|
31
|
+
if (name.length >= maxPropertiesLengthInOneLine)
|
|
32
|
+
return true;
|
|
33
|
+
}
|
|
35
34
|
}
|
|
36
35
|
|
|
37
36
|
return false;
|
|
@@ -42,13 +42,10 @@ export const isCoupleProperties = ({path, valuePath, property}) => {
|
|
|
42
42
|
return !isObjectProperty(parentPath);
|
|
43
43
|
};
|
|
44
44
|
|
|
45
|
-
export const
|
|
45
|
+
export const isAssignObject = createTypeChecker([
|
|
46
46
|
'-: node.value -> !AssignmentPattern',
|
|
47
47
|
'+: node.value.right -> ObjectExpression',
|
|
48
|
-
])
|
|
48
|
+
]);
|
|
49
49
|
|
|
50
|
-
export const
|
|
51
|
-
|
|
52
|
-
'-: node.value -> !AssignmentPattern',
|
|
53
|
-
'+: node.value.right -> ObjectExpression',
|
|
54
|
-
]));
|
|
50
|
+
export const isPrevAssignObject = callWithPrev(isAssignObject);
|
|
51
|
+
export const isNextAssignObject = callWithNext(isAssignObject);
|
|
@@ -1,15 +1,16 @@
|
|
|
1
1
|
import {types} from '@putout/babel';
|
|
2
2
|
import {callWithParent, isForOf} from '#is';
|
|
3
3
|
import {createTypeChecker} from '#type-checker';
|
|
4
|
-
import {isLessThenMaxPropertiesInOneLine} from './is-less-then-max-properties-in-one-line.js';
|
|
5
4
|
import {isMoreThenMaxPropertiesLengthInOneLine} from './is-more-then-max-properties-length-in-one-line.js';
|
|
6
5
|
import {
|
|
7
6
|
hasAssign,
|
|
8
7
|
hasObjectPattern,
|
|
9
8
|
} from './has.js';
|
|
10
9
|
|
|
10
|
+
const getMaxPropertiesInOneLine = (a, {maxPropertiesInOneLine}) => maxPropertiesInOneLine;
|
|
11
|
+
|
|
11
12
|
const isMoreCountLessLength = createTypeChecker([
|
|
12
|
-
['-:
|
|
13
|
+
['-: node.properties.length', '>', getMaxPropertiesInOneLine],
|
|
13
14
|
['-', isMoreThenMaxPropertiesLengthInOneLine],
|
|
14
15
|
['+: parentPath -> VariableDeclarator'],
|
|
15
16
|
]);
|
|
@@ -104,3 +105,4 @@ function hasComputed(path) {
|
|
|
104
105
|
|
|
105
106
|
return false;
|
|
106
107
|
}
|
|
108
|
+
|
package/package.json
CHANGED
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import {createTypeChecker} from '#type-checker';
|
|
2
|
-
|
|
3
|
-
const getMaxPropertiesInOneLine = (a, {maxPropertiesInOneLine}) => maxPropertiesInOneLine;
|
|
4
|
-
|
|
5
|
-
export const isLessThenMaxPropertiesInOneLine = createTypeChecker([
|
|
6
|
-
['+: node.properties.length', '<=', getMaxPropertiesInOneLine],
|
|
7
|
-
]);
|