@putout/printer 18.46.0 → 18.47.1
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 +13 -1
- package/lib/tokenize/expressions/object-pattern/is.js +23 -32
- package/lib/tokenize/expressions/object-pattern/object-pattern.js +4 -8
- package/lib/tokenize/literals/index.js +1 -1
- package/package.json +1 -1
- /package/lib/tokenize/literals/{string-literal.js → string-literal/string-literal.js} +0 -0
package/ChangeLog
CHANGED
|
@@ -1,3 +1,15 @@
|
|
|
1
|
+
2026.10.01, v18.47.1
|
|
2
|
+
|
|
3
|
+
feature:
|
|
4
|
+
- 44a6ce0f @putout/printer: StringLiteral: move out
|
|
5
|
+
|
|
6
|
+
2026.09.30, v18.47.0
|
|
7
|
+
|
|
8
|
+
feature:
|
|
9
|
+
- fda0e2f3 @putout/printer: ObjectPattern: hasCoupleProperties: apply type checker
|
|
10
|
+
- 3301db7c @putout/printer: ObjectPattern: apply type checker
|
|
11
|
+
- 805d58d3 @putout/printer: ObjectPattern: nested array pattern
|
|
12
|
+
|
|
1
13
|
2026.09.16, v18.46.0
|
|
2
14
|
|
|
3
15
|
feature:
|
|
@@ -678,7 +690,7 @@ feature:
|
|
|
678
690
|
- c6783ee @putout/printer: ExpressionStatement: hasTrailingCommentNotCoupleLines
|
|
679
691
|
- 8e08572 @putout/printer: ExpressionStatement: isTopParentLast: simplify
|
|
680
692
|
- fe1b0ca @putout/printer: ExpressionStatement: isTopParentLast
|
|
681
|
-
- b84b9a6 @putout/printer: ExpressionStatement:
|
|
693
|
+
- b84b9a6 @putout/printer: ExpressionStatement: isInsideArrayPattern
|
|
682
694
|
- d4d0106 @putout/printer: ExpressionStatement: beforeIf: simplify
|
|
683
695
|
- 9a4721a @putout/printer: ExpressionStatement: afterIf: simplify
|
|
684
696
|
- 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();
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
export {TemplateLiteral} from './template-literal.js';
|
|
2
2
|
export {Identifier} from './identifier.js';
|
|
3
3
|
export {Decorator} from './decorator/decorator.js';
|
|
4
|
-
export {StringLiteral} from './string-literal.js';
|
|
4
|
+
export {StringLiteral} from './string-literal/string-literal.js';
|
|
5
5
|
export {DirectiveLiteral} from './directive-literal.js';
|
|
6
6
|
export {VoidPattern} from './void-pattern/void-pattern.js';
|
|
7
7
|
export {RegExpLiteral} from './regexp-literal/regexp-literal.js';
|
package/package.json
CHANGED
|
File without changes
|