@putout/printer 11.4.0 → 11.6.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 +11 -0
- package/lib/tokenize/expressions/member-expression/member-expressions.js +1 -1
- package/lib/tokenize/expressions/unary-expression/unary-expressions.js +3 -2
- package/lib/tokenize/maybe/maybe-parens.js +2 -1
- package/lib/tokenize/statements/export-declaration/export-declaration.js +2 -2
- package/lib/tokenize/typescript/enum/ts-enum-declaration.js +15 -2
- package/lib/tokenize/typescript/interface/ts-interface-declaration.js +14 -8
- package/package.json +2 -2
package/ChangeLog
CHANGED
|
@@ -1,3 +1,14 @@
|
|
|
1
|
+
2024.12.16, v11.6.0
|
|
2
|
+
|
|
3
|
+
feature:
|
|
4
|
+
- 77f529d @putout/printer: AwaitExpressions: parens
|
|
5
|
+
|
|
6
|
+
2024.12.15, v11.5.0
|
|
7
|
+
|
|
8
|
+
feature:
|
|
9
|
+
- 2224570 @putout/printer: improve support of TSInterfaceDeclaration
|
|
10
|
+
- d15b999 @putout/printer: putout v37.0.1
|
|
11
|
+
|
|
1
12
|
2024.12.13, v11.4.0
|
|
2
13
|
|
|
3
14
|
feature:
|
|
@@ -23,7 +23,7 @@ module.exports.MemberExpression = (path, printer) => {
|
|
|
23
23
|
|
|
24
24
|
const object = path.get('object');
|
|
25
25
|
const property = path.get('property');
|
|
26
|
-
const isParens = object.
|
|
26
|
+
const isParens = object.isAssignmentExpression();
|
|
27
27
|
const {computed} = path.node;
|
|
28
28
|
|
|
29
29
|
maybe.print(isParens, '(');
|
|
@@ -20,11 +20,11 @@ const unaryExpression = maybeParens((path, printer) => {
|
|
|
20
20
|
module.exports.UnaryExpression = unaryExpression;
|
|
21
21
|
module.exports.UpdateExpression = unaryExpression;
|
|
22
22
|
|
|
23
|
-
module.exports.AwaitExpression = (path, {print}) => {
|
|
23
|
+
module.exports.AwaitExpression = maybeParens((path, {print}) => {
|
|
24
24
|
printUnary(path, 'await', {
|
|
25
25
|
print,
|
|
26
26
|
});
|
|
27
|
-
};
|
|
27
|
+
});
|
|
28
28
|
|
|
29
29
|
module.exports.YieldExpression = maybeParens((path, {print, maybe}) => {
|
|
30
30
|
const {delegate} = path.node;
|
|
@@ -51,3 +51,4 @@ function printUnary(path, name, {print}) {
|
|
|
51
51
|
print(`${name} `);
|
|
52
52
|
print('__argument');
|
|
53
53
|
}
|
|
54
|
+
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
+
const {isExportNamespaceSpecifier} = require('@putout/babel').types;
|
|
4
|
+
const {markAfter, isMarkedAfter} = require('../../mark');
|
|
3
5
|
const {
|
|
4
6
|
isNewlineBetweenSiblings,
|
|
5
7
|
exists,
|
|
@@ -7,8 +9,6 @@ const {
|
|
|
7
9
|
isLast,
|
|
8
10
|
} = require('../../is');
|
|
9
11
|
|
|
10
|
-
const {markAfter, isMarkedAfter} = require('../../mark');
|
|
11
|
-
const {isExportNamespaceSpecifier} = require('@putout/babel').types;
|
|
12
12
|
const isDeclarationNewline = (path) => isMarkedAfter(path.get('declaration'));
|
|
13
13
|
const isInsideNamespace = (path) => path.parentPath.isTSModuleBlock();
|
|
14
14
|
|
|
@@ -1,6 +1,12 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
const {
|
|
3
|
+
const {
|
|
4
|
+
isNext,
|
|
5
|
+
isNextParent,
|
|
6
|
+
isLast,
|
|
7
|
+
} = require('../../is');
|
|
8
|
+
|
|
9
|
+
const {markAfter} = require('../../mark');
|
|
4
10
|
|
|
5
11
|
module.exports.TSEnumDeclaration = {
|
|
6
12
|
beforeIf(path) {
|
|
@@ -25,10 +31,17 @@ module.exports.TSEnumDeclaration = {
|
|
|
25
31
|
}
|
|
26
32
|
|
|
27
33
|
indent.dec();
|
|
34
|
+
indent();
|
|
28
35
|
print('}');
|
|
36
|
+
|
|
37
|
+
if (isLast(path))
|
|
38
|
+
return;
|
|
39
|
+
|
|
40
|
+
print.newline();
|
|
41
|
+
markAfter(path);
|
|
29
42
|
},
|
|
30
43
|
afterSatisfy: () => [isNext, isNextParent],
|
|
31
44
|
after(path, {print}) {
|
|
32
|
-
print.
|
|
45
|
+
print.linebreak();
|
|
33
46
|
},
|
|
34
47
|
};
|
|
@@ -1,18 +1,22 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
+
const {types} = require('@putout/babel');
|
|
3
4
|
const {
|
|
4
5
|
isTSTypeAliasDeclaration,
|
|
5
|
-
|
|
6
|
-
|
|
6
|
+
isExportNamedDeclaration,
|
|
7
|
+
isTSModuleBlock,
|
|
8
|
+
} = types;
|
|
7
9
|
|
|
8
10
|
const {isNext, isNextParent} = require('../../is');
|
|
9
11
|
const {maybeDeclare} = require('../../maybe/maybe-declare');
|
|
12
|
+
const {markAfter} = require('../../mark');
|
|
13
|
+
const isInsideNamespace = (path) => isTSModuleBlock(path.parentPath.parentPath);
|
|
10
14
|
|
|
11
15
|
module.exports.TSInterfaceDeclaration = {
|
|
12
16
|
print: maybeDeclare((path, {print, maybe}) => {
|
|
13
|
-
const {node
|
|
17
|
+
const {node} = path;
|
|
14
18
|
|
|
15
|
-
maybe.indent(!
|
|
19
|
+
maybe.indent(!isExportNamedDeclaration(path.parentPath));
|
|
16
20
|
print('interface ');
|
|
17
21
|
print('__id');
|
|
18
22
|
|
|
@@ -28,11 +32,13 @@ module.exports.TSInterfaceDeclaration = {
|
|
|
28
32
|
}),
|
|
29
33
|
afterSatisfy: () => [isNext, isNextParent],
|
|
30
34
|
after(path, {print}) {
|
|
31
|
-
print.
|
|
35
|
+
print.linebreak();
|
|
36
|
+
const exportNamed = isExportNamedDeclaration(path.parentPath);
|
|
32
37
|
|
|
33
|
-
|
|
38
|
+
if (exportNamed && isInsideNamespace(path))
|
|
39
|
+
markAfter(path);
|
|
34
40
|
|
|
35
|
-
if (!
|
|
36
|
-
print.
|
|
41
|
+
if (!exportNamed && !isTSTypeAliasDeclaration(path))
|
|
42
|
+
print.newline();
|
|
37
43
|
},
|
|
38
44
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@putout/printer",
|
|
3
|
-
"version": "11.
|
|
3
|
+
"version": "11.6.0",
|
|
4
4
|
"type": "commonjs",
|
|
5
5
|
"author": "coderaiser <mnemonic.enemy@gmail.com> (https://github.com/coderaiser)",
|
|
6
6
|
"description": "Simplest possible opinionated Babel AST printer for 🐊Putout",
|
|
@@ -70,7 +70,7 @@
|
|
|
70
70
|
"mock-require": "^3.0.3",
|
|
71
71
|
"montag": "^1.0.0",
|
|
72
72
|
"nodemon": "^3.0.1",
|
|
73
|
-
"putout": "^
|
|
73
|
+
"putout": "^37.0.1",
|
|
74
74
|
"redlint": "^3.16.0",
|
|
75
75
|
"samadhi": "^2.8.0",
|
|
76
76
|
"supertape": "^10.0.0",
|