@putout/printer 1.89.0 → 1.90.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
package/lib/tokenize/comments.js
CHANGED
|
@@ -80,6 +80,22 @@ module.exports.parseTrailingComments = (path, {write, maybe}, format) => {
|
|
|
80
80
|
}
|
|
81
81
|
};
|
|
82
82
|
|
|
83
|
+
module.exports.parseComments = (path, {write}) => {
|
|
84
|
+
const comments = path.node.comments || path.node.innerComments;
|
|
85
|
+
|
|
86
|
+
if (!comments)
|
|
87
|
+
return;
|
|
88
|
+
|
|
89
|
+
for (const {type, value} of comments) {
|
|
90
|
+
if (type === 'CommentLine') {
|
|
91
|
+
write.breakline();
|
|
92
|
+
write('//');
|
|
93
|
+
write(value);
|
|
94
|
+
write.newline();
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
};
|
|
98
|
+
|
|
83
99
|
function isSameLine(path, loc) {
|
|
84
100
|
return path.node.loc.start.line === loc.start.line;
|
|
85
101
|
}
|
|
@@ -13,12 +13,13 @@ const {
|
|
|
13
13
|
} = require('@babel/types');
|
|
14
14
|
|
|
15
15
|
const {markAfter} = require('../mark');
|
|
16
|
+
const {parseComments} = require('../comments');
|
|
16
17
|
|
|
17
18
|
const isFirstStatement = (path) => path.get('body.0')?.isStatement();
|
|
18
19
|
const isMethodOrArrow = (path) => isArrowFunctionExpression(path) || isObjectMethod(path);
|
|
19
20
|
|
|
20
21
|
module.exports.BlockStatement = {
|
|
21
|
-
print(path, {indent, maybe, print}) {
|
|
22
|
+
print(path, {indent, maybe, print, write}) {
|
|
22
23
|
const body = path.get('body');
|
|
23
24
|
|
|
24
25
|
if (path.parentPath.isBlockStatement())
|
|
@@ -34,6 +35,10 @@ module.exports.BlockStatement = {
|
|
|
34
35
|
print(element);
|
|
35
36
|
}
|
|
36
37
|
|
|
38
|
+
parseComments(path, {
|
|
39
|
+
write,
|
|
40
|
+
});
|
|
41
|
+
|
|
37
42
|
indent.dec();
|
|
38
43
|
maybe.indent(body.length);
|
|
39
44
|
print('}');
|
package/package.json
CHANGED