@putout/printer 17.9.0 → 17.10.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
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import {types} from '@putout/babel';
|
|
2
|
+
|
|
3
|
+
const {isBlockStatement} = types;
|
|
4
|
+
|
|
5
|
+
export const printTrailingCommentBlock = (path, printer, semantics, {printComment}) => {
|
|
6
|
+
const {print} = printer;
|
|
7
|
+
print.breakline();
|
|
8
|
+
printComment();
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
export const printTrailingCommentLine = (path, printer, semantics, {printComment}) => {
|
|
12
|
+
const {consequent} = path.node;
|
|
13
|
+
const consequentIsBlock = isBlockStatement(consequent);
|
|
14
|
+
const {print, maybe} = printer;
|
|
15
|
+
|
|
16
|
+
print.indent();
|
|
17
|
+
maybe.print.space(!consequentIsBlock);
|
|
18
|
+
|
|
19
|
+
printComment();
|
|
20
|
+
maybe.print.newline(consequentIsBlock);
|
|
21
|
+
};
|
|
@@ -5,6 +5,10 @@ import {
|
|
|
5
5
|
isInsideIf,
|
|
6
6
|
} from '#is';
|
|
7
7
|
import {markAfter} from '../../mark.js';
|
|
8
|
+
import {
|
|
9
|
+
printTrailingCommentBlock,
|
|
10
|
+
printTrailingCommentLine,
|
|
11
|
+
} from './if-statement-comments.js';
|
|
8
12
|
|
|
9
13
|
const {
|
|
10
14
|
isBlockStatement,
|
|
@@ -56,6 +60,8 @@ const isLastEmptyInsideBody = (path) => {
|
|
|
56
60
|
};
|
|
57
61
|
|
|
58
62
|
export const IfStatement = {
|
|
63
|
+
printTrailingCommentBlock,
|
|
64
|
+
printTrailingCommentLine,
|
|
59
65
|
print: (path, {indent, print, maybe, write, traverse}) => {
|
|
60
66
|
const {parentPath} = path;
|
|
61
67
|
const partOfAlternate = parentPath.get('alternate');
|
package/package.json
CHANGED