@putout/printer 18.23.0 → 18.25.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,15 @@
|
|
|
1
|
+
2026.06.27, v18.25.0
|
|
2
|
+
|
|
3
|
+
feature:
|
|
4
|
+
- 5478906e @putout/printer: ExportDefaultDeclaration: needsSemicolon: simplify
|
|
5
|
+
- 918525a4 @putout/printer: ExportDeclaration: isNewlineAfter: simplify
|
|
6
|
+
- 9e1ea558 @putout/printer: ExportDefaultDeclaration: inside BlockStatement
|
|
7
|
+
|
|
8
|
+
2026.06.27, v18.24.0
|
|
9
|
+
|
|
10
|
+
feature:
|
|
11
|
+
- 524967f6 @putout/printer: ObjectExpression inside TSAsExpression
|
|
12
|
+
|
|
1
13
|
2026.06.26, v18.23.0
|
|
2
14
|
|
|
3
15
|
feature:
|
|
@@ -8,9 +8,9 @@ import {
|
|
|
8
8
|
isIf,
|
|
9
9
|
hasLeadingComment,
|
|
10
10
|
isInsideCall,
|
|
11
|
-
isInsideBody,
|
|
12
11
|
isInsideExpression,
|
|
13
12
|
hasTrailingComment,
|
|
13
|
+
callWithParent,
|
|
14
14
|
} from '#is';
|
|
15
15
|
import {isInsideTuple} from './is-inside-tuple.js';
|
|
16
16
|
import {isLooksLikeChain} from '../member-expression/is-looks-like-chain/index.js';
|
|
@@ -34,9 +34,17 @@ const notLastArgInsideCall = (path) => {
|
|
|
34
34
|
const hasNoProperties = (path) => !path.node.properties.length;
|
|
35
35
|
const hasValue = (path) => path.node.properties[0].value;
|
|
36
36
|
|
|
37
|
-
const {
|
|
37
|
+
const {
|
|
38
|
+
isMemberExpression,
|
|
39
|
+
isAssignmentExpression,
|
|
40
|
+
isArrowFunctionExpression,
|
|
41
|
+
} = types;
|
|
38
42
|
|
|
39
|
-
const isParens = createTypeChecker([
|
|
43
|
+
const isParens = createTypeChecker([
|
|
44
|
+
['-', callWithParent(isAssignmentExpression)],
|
|
45
|
+
['+', callWithParent(isArrowFunctionExpression)],
|
|
46
|
+
['+', isInsideExpression],
|
|
47
|
+
]);
|
|
40
48
|
|
|
41
49
|
const callWithCallee = (fn) => (a) => fn(a.get('callee'));
|
|
42
50
|
|
|
@@ -75,6 +83,7 @@ const isIndentBeforeProperty = createTypeChecker([
|
|
|
75
83
|
]);
|
|
76
84
|
|
|
77
85
|
export const ObjectExpression = maybeParens({
|
|
86
|
+
checkParens: false,
|
|
78
87
|
condition: isParens,
|
|
79
88
|
print: (path, printer, semantics) => {
|
|
80
89
|
const {trailingComma} = semantics;
|
|
@@ -1,41 +1,46 @@
|
|
|
1
1
|
import {types} from '@putout/babel';
|
|
2
|
-
import {
|
|
2
|
+
import {
|
|
3
|
+
isNext,
|
|
4
|
+
callWithParent,
|
|
5
|
+
callWithNext,
|
|
6
|
+
} from '#is';
|
|
7
|
+
import {createTypeChecker} from '#type-checker';
|
|
3
8
|
|
|
4
9
|
const {
|
|
5
10
|
isVariableDeclaration,
|
|
6
11
|
isFunction,
|
|
12
|
+
isBlockStatement,
|
|
7
13
|
} = types;
|
|
8
14
|
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
+
const needsSemicolon = createTypeChecker([
|
|
16
|
+
'-: -> ClassDeclaration',
|
|
17
|
+
'+: -> !FunctionDeclaration',
|
|
18
|
+
]);
|
|
19
|
+
|
|
20
|
+
const afterIf = createTypeChecker([
|
|
21
|
+
callWithParent(isBlockStatement),
|
|
22
|
+
isNext,
|
|
23
|
+
]);
|
|
15
24
|
|
|
16
25
|
export const ExportDefaultDeclaration = {
|
|
17
26
|
print(path, {print, traverse, maybe}) {
|
|
18
27
|
const declaration = path.get('declaration');
|
|
28
|
+
print.indent();
|
|
19
29
|
print('export default ');
|
|
20
30
|
traverse(declaration);
|
|
21
|
-
maybe.print(
|
|
31
|
+
maybe.print(needsSemicolon(declaration), ';');
|
|
22
32
|
},
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
],
|
|
26
|
-
after(path, {print, maybe}) {
|
|
33
|
+
afterIf,
|
|
34
|
+
after(path, {print}) {
|
|
27
35
|
print.newline();
|
|
28
|
-
|
|
36
|
+
|
|
37
|
+
if (isNewlineAfter(path))
|
|
38
|
+
print.newline();
|
|
29
39
|
},
|
|
30
40
|
};
|
|
31
41
|
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
const {declaration} = path.node;
|
|
39
|
-
|
|
40
|
-
return isFunction(declaration);
|
|
41
|
-
}
|
|
42
|
+
const isNewlineAfter = createTypeChecker([
|
|
43
|
+
['-: parentPath -> BlockStatement'],
|
|
44
|
+
['+: -> !', callWithNext(isVariableDeclaration)],
|
|
45
|
+
['+: node.declaration -> !', isFunction],
|
|
46
|
+
]);
|
|
@@ -1,7 +1,24 @@
|
|
|
1
|
+
import {types} from '@putout/babel';
|
|
1
2
|
import {maybeParens} from '#maybe-parens';
|
|
3
|
+
import {createTypeChecker} from '#type-checker';
|
|
4
|
+
import {callWithParent} from '#is';
|
|
2
5
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
6
|
+
const {
|
|
7
|
+
isCallExpression,
|
|
8
|
+
isVariableDeclarator,
|
|
9
|
+
} = types;
|
|
10
|
+
|
|
11
|
+
const condition = createTypeChecker([
|
|
12
|
+
['-', callWithParent(isCallExpression)],
|
|
13
|
+
['-', callWithParent(isVariableDeclarator)],
|
|
14
|
+
['+: node.expression -> ObjectExpression'],
|
|
15
|
+
]);
|
|
16
|
+
|
|
17
|
+
export const TSAsExpression = maybeParens({
|
|
18
|
+
condition,
|
|
19
|
+
print: (path, {print}) => {
|
|
20
|
+
print('__expression');
|
|
21
|
+
print(' as ');
|
|
22
|
+
print('__typeAnnotation');
|
|
23
|
+
},
|
|
7
24
|
});
|
package/package.json
CHANGED