@putout/printer 18.46.0 → 18.47.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,10 @@
|
|
|
1
|
+
2026.09.30, v18.47.0
|
|
2
|
+
|
|
3
|
+
feature:
|
|
4
|
+
- fda0e2f3 @putout/printer: ObjectPattern: hasCoupleProperties: apply type checker
|
|
5
|
+
- 3301db7c @putout/printer: ObjectPattern: apply type checker
|
|
6
|
+
- 805d58d3 @putout/printer: ObjectPattern: nested array pattern
|
|
7
|
+
|
|
1
8
|
2026.09.16, v18.46.0
|
|
2
9
|
|
|
3
10
|
feature:
|
|
@@ -678,7 +685,7 @@ feature:
|
|
|
678
685
|
- c6783ee @putout/printer: ExpressionStatement: hasTrailingCommentNotCoupleLines
|
|
679
686
|
- 8e08572 @putout/printer: ExpressionStatement: isTopParentLast: simplify
|
|
680
687
|
- fe1b0ca @putout/printer: ExpressionStatement: isTopParentLast
|
|
681
|
-
- b84b9a6 @putout/printer: ExpressionStatement:
|
|
688
|
+
- b84b9a6 @putout/printer: ExpressionStatement: isInsideArrayPattern
|
|
682
689
|
- d4d0106 @putout/printer: ExpressionStatement: beforeIf: simplify
|
|
683
690
|
- 9a4721a @putout/printer: ExpressionStatement: afterIf: simplify
|
|
684
691
|
- a9d2cf8 @putout/printer: ExpressionStatement: isBeforeElse: simplify
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import {types} from '@putout/babel';
|
|
2
1
|
import {createTypeChecker} from '#type-checker';
|
|
3
2
|
import {
|
|
4
3
|
isCoupleLines,
|
|
@@ -8,39 +7,31 @@ import {
|
|
|
8
7
|
} from '#is';
|
|
9
8
|
import {hasAssign} from './has.js';
|
|
10
9
|
|
|
11
|
-
const {
|
|
12
|
-
isFunction,
|
|
13
|
-
isVariableDeclarator,
|
|
14
|
-
isObjectProperty,
|
|
15
|
-
} = types;
|
|
16
|
-
|
|
17
10
|
export const hasOptionIs = (a, {is}) => is;
|
|
18
11
|
|
|
19
|
-
export const isInsideFn = (
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
return !isObjectProperty(parentPath);
|
|
43
|
-
};
|
|
12
|
+
export const isInsideFn = createTypeChecker([
|
|
13
|
+
'+: parentPath -> FunctionDeclaration',
|
|
14
|
+
'+: parentPath.parentPath -> FunctionDeclaration',
|
|
15
|
+
]);
|
|
16
|
+
|
|
17
|
+
export const isInsideArrayPattern = createTypeChecker([
|
|
18
|
+
'-: parentPath -> ArrayPattern',
|
|
19
|
+
'+: parentPath.parentPath -> !ArrayPattern',
|
|
20
|
+
]);
|
|
21
|
+
|
|
22
|
+
const callWithValue = (fn) => (path) => fn(path.get('value'));
|
|
23
|
+
|
|
24
|
+
const isVarWithAssign = createTypeChecker([
|
|
25
|
+
['-: parentPath.parentPath -> !VariableDeclarator'],
|
|
26
|
+
['+: parentPath -> !', hasAssign],
|
|
27
|
+
]);
|
|
28
|
+
|
|
29
|
+
export const hasCoupleProperties = createTypeChecker([
|
|
30
|
+
['-: -> !', callWithValue(isCoupleLines)],
|
|
31
|
+
['-', callWithPrev(exists)],
|
|
32
|
+
['-', isVarWithAssign],
|
|
33
|
+
['+: parentPath.parentPath -> !ObjectProperty'],
|
|
34
|
+
]);
|
|
44
35
|
|
|
45
36
|
export const isAssignObject = createTypeChecker([
|
|
46
37
|
'-: node.value -> !AssignmentPattern',
|
|
@@ -17,14 +17,14 @@ import {
|
|
|
17
17
|
isIndentAfterNewline,
|
|
18
18
|
} from './indent.js';
|
|
19
19
|
import {
|
|
20
|
-
|
|
21
|
-
|
|
20
|
+
hasCoupleProperties,
|
|
21
|
+
isInsideArrayPattern,
|
|
22
22
|
isInsideFn,
|
|
23
23
|
} from './is.js';
|
|
24
24
|
|
|
25
25
|
export const ObjectPattern = {
|
|
26
26
|
print: maybeTypeAnnotation((path, printer, semantics) => {
|
|
27
|
-
const shouldIndent =
|
|
27
|
+
const shouldIndent = isInsideArrayPattern(path);
|
|
28
28
|
const {
|
|
29
29
|
maxPropertiesInOneLine,
|
|
30
30
|
maxPropertiesLengthInOneLine,
|
|
@@ -69,11 +69,7 @@ export const ObjectPattern = {
|
|
|
69
69
|
const isAssign = valuePath.isAssignmentPattern();
|
|
70
70
|
|
|
71
71
|
const {shorthand, computed} = property.node;
|
|
72
|
-
const couple =
|
|
73
|
-
path,
|
|
74
|
-
property,
|
|
75
|
-
valuePath,
|
|
76
|
-
});
|
|
72
|
+
const couple = hasCoupleProperties(property);
|
|
77
73
|
|
|
78
74
|
if (isBreaklineBeforeProperty(property, {couple, semantics}))
|
|
79
75
|
print.breakline();
|
package/package.json
CHANGED