@putout/printer 9.9.0 → 9.11.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
package/README.md
CHANGED
|
@@ -73,7 +73,7 @@ const a = (b, c) => {
|
|
|
73
73
|
When you need to extend syntax of `@putout/printer` just pass a function which receives:
|
|
74
74
|
|
|
75
75
|
- `path`, Babel Path
|
|
76
|
-
- `
|
|
76
|
+
- `print`, a function to output result of printing into token array;
|
|
77
77
|
|
|
78
78
|
When `path` contains to dashes `__` and name, it is the same as: `write(path.get('right'))`, and this is
|
|
79
79
|
actually `traverse(path.get('right'))` shortened to simplify read and process.
|
|
@@ -11,7 +11,12 @@ const {
|
|
|
11
11
|
isNext,
|
|
12
12
|
} = require('../is');
|
|
13
13
|
|
|
14
|
-
const hasBody = (path) =>
|
|
14
|
+
const hasBody = (path) => {
|
|
15
|
+
if (path.isTSModuleDeclaration())
|
|
16
|
+
return true;
|
|
17
|
+
|
|
18
|
+
return path.node.body?.length;
|
|
19
|
+
};
|
|
15
20
|
|
|
16
21
|
const isFnParam = (path) => {
|
|
17
22
|
const {parentPath} = path;
|
|
@@ -51,6 +56,9 @@ function isCommentOnNextLine(path) {
|
|
|
51
56
|
if (parentPath.isMemberExpression())
|
|
52
57
|
return false;
|
|
53
58
|
|
|
59
|
+
if (path.isClassMethod())
|
|
60
|
+
return false;
|
|
61
|
+
|
|
54
62
|
if (isTrailingIsLeading(path))
|
|
55
63
|
return false;
|
|
56
64
|
|
|
@@ -113,3 +121,4 @@ module.exports.parseTrailingComments = (path, {write, maybe}, semantics) => {
|
|
|
113
121
|
}
|
|
114
122
|
}
|
|
115
123
|
};
|
|
124
|
+
|
|
@@ -1,11 +1,21 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
const {
|
|
3
|
+
const {
|
|
4
|
+
isNext,
|
|
5
|
+
hasTrailingComment,
|
|
6
|
+
} = require('../../is');
|
|
4
7
|
const {printParams} = require('./params');
|
|
5
8
|
const {maybeDecorators} = require('../../maybe/maybe-decorators');
|
|
6
9
|
const {printKey} = require('../object-expression/print-key');
|
|
7
10
|
const {printKind} = require('./kind');
|
|
8
11
|
|
|
12
|
+
const noTrailingCommentAndNext = (path) => {
|
|
13
|
+
if (hasTrailingComment(path))
|
|
14
|
+
return false;
|
|
15
|
+
|
|
16
|
+
return isNext(path);
|
|
17
|
+
};
|
|
18
|
+
|
|
9
19
|
const ClassMethod = {
|
|
10
20
|
print: maybeDecorators((path, printer, semantics) => {
|
|
11
21
|
const {print} = printer;
|
|
@@ -22,6 +32,11 @@ const ClassMethod = {
|
|
|
22
32
|
print(' ');
|
|
23
33
|
}
|
|
24
34
|
|
|
35
|
+
if (node.override) {
|
|
36
|
+
print('override');
|
|
37
|
+
print(' ');
|
|
38
|
+
}
|
|
39
|
+
|
|
25
40
|
if (node.async) {
|
|
26
41
|
print('async');
|
|
27
42
|
print(' ');
|
|
@@ -40,7 +55,7 @@ const ClassMethod = {
|
|
|
40
55
|
print.space();
|
|
41
56
|
print('__body');
|
|
42
57
|
}),
|
|
43
|
-
afterSatisfy: () => [
|
|
58
|
+
afterSatisfy: () => [noTrailingCommentAndNext],
|
|
44
59
|
after(path, {print}) {
|
|
45
60
|
print.linebreak();
|
|
46
61
|
},
|
package/package.json
CHANGED