@putout/printer 18.45.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 +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/typescript/function/{ts-method-signature.js → ts-method-signature/ts-method-signature.js} +6 -4
- package/lib/tokenize/typescript/index.js +1 -1
- package/package.json +2 -3
package/ChangeLog
CHANGED
|
@@ -1,3 +1,15 @@
|
|
|
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
|
+
|
|
8
|
+
2026.09.16, v18.46.0
|
|
9
|
+
|
|
10
|
+
feature:
|
|
11
|
+
- fd944e84 @putout/printer: TSMethodSignature: optional
|
|
12
|
+
|
|
1
13
|
2026.09.13, v18.45.0
|
|
2
14
|
|
|
3
15
|
feature:
|
|
@@ -673,7 +685,7 @@ feature:
|
|
|
673
685
|
- c6783ee @putout/printer: ExpressionStatement: hasTrailingCommentNotCoupleLines
|
|
674
686
|
- 8e08572 @putout/printer: ExpressionStatement: isTopParentLast: simplify
|
|
675
687
|
- fe1b0ca @putout/printer: ExpressionStatement: isTopParentLast
|
|
676
|
-
- b84b9a6 @putout/printer: ExpressionStatement:
|
|
688
|
+
- b84b9a6 @putout/printer: ExpressionStatement: isInsideArrayPattern
|
|
677
689
|
- d4d0106 @putout/printer: ExpressionStatement: beforeIf: simplify
|
|
678
690
|
- 9a4721a @putout/printer: ExpressionStatement: afterIf: simplify
|
|
679
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();
|
|
@@ -1,16 +1,18 @@
|
|
|
1
1
|
import {printParams} from '#params';
|
|
2
|
-
import {printKind} from '
|
|
2
|
+
import {printKind} from '../../../expressions/function/kind.js';
|
|
3
3
|
import {
|
|
4
4
|
hasReturnType,
|
|
5
5
|
printReturnType,
|
|
6
|
-
} from '
|
|
7
|
-
import {printKey} from '
|
|
6
|
+
} from '../print-return-type.js';
|
|
7
|
+
import {printKey} from '../../../expressions/object-expression/print-key.js';
|
|
8
8
|
|
|
9
9
|
export const TSMethodSignature = (path, printer, semantics) => {
|
|
10
|
-
const {write} = printer;
|
|
10
|
+
const {write, maybe} = printer;
|
|
11
|
+
const {optional} = path.node;
|
|
11
12
|
|
|
12
13
|
printKind(path, printer);
|
|
13
14
|
printKey(path, printer);
|
|
15
|
+
maybe.print(optional, '?');
|
|
14
16
|
printParams(path, printer, semantics);
|
|
15
17
|
|
|
16
18
|
if (hasReturnType(path)) {
|
|
@@ -24,7 +24,7 @@ export {TSNamedTupleMember} from './tuple/ts-named-tuple-member.js';
|
|
|
24
24
|
export {TSConstructorType} from './function/ts-constructor-type.js';
|
|
25
25
|
export {TSCallSignatureDeclaration} from './function/ts-call-signature-declaration.js';
|
|
26
26
|
export {TSConstructSignatureDeclaration} from './function/ts-construct-signature-declaration.js';
|
|
27
|
-
export {TSMethodSignature} from './function/ts-method-signature.js';
|
|
27
|
+
export {TSMethodSignature} from './function/ts-method-signature/ts-method-signature.js';
|
|
28
28
|
export {TSUnionType} from './ts-union-type/ts-union-type.js';
|
|
29
29
|
export {TSImportType} from './ts-import-type/ts-import-type.js';
|
|
30
30
|
export {TSExportAssignment} from './ts-export-assignment/ts-export-assignment.js';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@putout/printer",
|
|
3
|
-
"version": "18.
|
|
3
|
+
"version": "18.47.0",
|
|
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",
|
|
@@ -89,9 +89,8 @@
|
|
|
89
89
|
"@putout/plugin-react-hook-form": "^6.0.0",
|
|
90
90
|
"@putout/plugin-react-hooks": "^9.0.0",
|
|
91
91
|
"@supertape/operator-strip": "^1.0.0",
|
|
92
|
-
"@typescript/native": "npm:typescript@^7.0.2",
|
|
93
92
|
"acorn": "^8.8.2",
|
|
94
|
-
"check-dts": "^
|
|
93
|
+
"check-dts": "^1.0.0",
|
|
95
94
|
"escover": "^6.0.0",
|
|
96
95
|
"eslint": "^10.0.0",
|
|
97
96
|
"eslint-plugin-putout": "^31.0.0",
|