@putout/printer 15.13.0 → 15.14.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
CHANGED
|
@@ -1,3 +1,14 @@
|
|
|
1
|
+
2025.07.26, v15.14.1
|
|
2
|
+
|
|
3
|
+
feature:
|
|
4
|
+
- ab61623 @putout/printer: EmptyStatement: new line
|
|
5
|
+
|
|
6
|
+
2025.07.26, v15.14.0
|
|
7
|
+
|
|
8
|
+
feature:
|
|
9
|
+
- b6adcd1 @putout/printer: types: namespace -> declare
|
|
10
|
+
- eb9c687 @putout/printer: TSModuleDeclaration: ClassDeclaration inside ExportNamedDeclaration
|
|
11
|
+
|
|
1
12
|
2025.07.25, v15.13.0
|
|
2
13
|
|
|
3
14
|
feature:
|
package/lib/printer.d.ts
CHANGED
|
@@ -21,18 +21,14 @@ interface Semantics {
|
|
|
21
21
|
type Print = (input: string | types.Node) => void;
|
|
22
22
|
type Indent = () => void;
|
|
23
23
|
type Traverse = (input: types.Node) => void;
|
|
24
|
+
type MaybeCondition = (condition: boolean) => void;
|
|
24
25
|
|
|
25
|
-
declare
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
export {
|
|
31
|
-
inc,
|
|
32
|
-
dec,
|
|
33
|
-
};
|
|
34
|
-
}
|
|
26
|
+
declare const MaybeIndent: {
|
|
27
|
+
inc: MaybeCondition;
|
|
28
|
+
dec: MaybeCondition;
|
|
29
|
+
};
|
|
35
30
|
|
|
31
|
+
declare function MaybeIndent(condition: boolean): void;
|
|
36
32
|
type MaybePrint = (condition: boolean, input: string | types.Node) => void;
|
|
37
33
|
type MaybeTraverse = (condition: boolean, input: types.Node) => void;
|
|
38
34
|
|
|
@@ -8,7 +8,16 @@ const {markAfter} = require('../../mark');
|
|
|
8
8
|
const {maybeDeclare} = require('../../maybe/maybe-declare');
|
|
9
9
|
const {parseComments} = require('../../comment/comment');
|
|
10
10
|
const {maybeDecorators} = require('../../maybe/maybe-decorators');
|
|
11
|
-
|
|
11
|
+
|
|
12
|
+
const isInsideTSModuleBlock = (path) => {
|
|
13
|
+
return isTSModuleBlock(path.parentPath.parentPath);
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
const {
|
|
17
|
+
isFunction,
|
|
18
|
+
isTSModuleBlock,
|
|
19
|
+
} = types;
|
|
20
|
+
|
|
12
21
|
const isInsideExport = ({parentPath}) => parentPath.isExportDeclaration();
|
|
13
22
|
const isFunctionLike = (path) => isFunction(path.parentPath.parentPath);
|
|
14
23
|
const hasBody = ({node}) => node.body.body.length;
|
|
@@ -72,18 +81,18 @@ module.exports.ClassExpression = classVisitor;
|
|
|
72
81
|
|
|
73
82
|
module.exports.ClassDeclaration = {
|
|
74
83
|
print: maybeDeclare((path, printer, semantics) => {
|
|
75
|
-
const {
|
|
76
|
-
indent();
|
|
84
|
+
const {maybe} = printer;
|
|
85
|
+
maybe.indent(!isInsideExport(path));
|
|
77
86
|
classVisitor(path, printer, semantics);
|
|
78
87
|
}),
|
|
79
88
|
afterIf(path) {
|
|
80
89
|
if (isFunctionLike(path))
|
|
81
90
|
return true;
|
|
82
91
|
|
|
83
|
-
if (
|
|
84
|
-
return
|
|
92
|
+
if (isNext(path))
|
|
93
|
+
return true;
|
|
85
94
|
|
|
86
|
-
return
|
|
95
|
+
return isInsideTSModuleBlock(path);
|
|
87
96
|
},
|
|
88
97
|
after(path, {write}) {
|
|
89
98
|
write.newline();
|
|
@@ -22,6 +22,7 @@ const {DoWhileStatement} = require('./do-while-statement/do-while-statement');
|
|
|
22
22
|
const {Program} = require('./program/program');
|
|
23
23
|
const {ContinueStatement} = require('./continue-statement/continue-statement');
|
|
24
24
|
const {LabeledStatement} = require('./labeled-statement/labeled-statement');
|
|
25
|
+
const {EmptyStatement} = require('./empty-statement/empty-statement');
|
|
25
26
|
|
|
26
27
|
const {
|
|
27
28
|
ExportNamespaceSpecifier,
|
|
@@ -47,9 +48,7 @@ module.exports = {
|
|
|
47
48
|
DebuggerStatement,
|
|
48
49
|
LabeledStatement,
|
|
49
50
|
Program,
|
|
50
|
-
EmptyStatement
|
|
51
|
-
write(';');
|
|
52
|
-
},
|
|
51
|
+
EmptyStatement,
|
|
53
52
|
InterpreterDirective(path, {print}) {
|
|
54
53
|
// shebang, hashbang
|
|
55
54
|
print(`#!${path.node.value}\n`);
|
package/package.json
CHANGED