@putout/printer 15.15.0 → 15.17.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 +10 -0
- package/lib/tokenize/expressions/assignment-expression/assignment-expression-comments.js +32 -0
- package/lib/tokenize/expressions/assignment-expression/assignment-expression.js +13 -0
- package/lib/tokenize/expressions/assignment-expression/maybe-write-brace.js +2 -1
- package/lib/tokenize/literals/index.js +2 -0
- package/lib/tokenize/literals/void-pattern/void-pattern.js +5 -0
- package/package.json +1 -1
package/ChangeLog
CHANGED
|
@@ -1,3 +1,13 @@
|
|
|
1
|
+
2025.08.04, v15.17.0
|
|
2
|
+
|
|
3
|
+
feature:
|
|
4
|
+
- da01c40 @putout/printer: AssignmentExpression: inside ReturnStatement with leadingComments (coderaiser/putout#235)
|
|
5
|
+
|
|
6
|
+
2025.08.01, v15.16.0
|
|
7
|
+
|
|
8
|
+
feature:
|
|
9
|
+
- 3e566b0 @putout/printer: VoidPattern: add
|
|
10
|
+
|
|
1
11
|
2025.07.29, v15.15.0
|
|
2
12
|
|
|
3
13
|
feature:
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const {types} = require('@putout/babel');
|
|
4
|
+
const {hasLeadingComment} = require('#is');
|
|
5
|
+
const {isReturnStatement} = types;
|
|
6
|
+
|
|
7
|
+
module.exports.printLeadingCommentLine = ({parentPath}) => !isReturnStatement(parentPath);
|
|
8
|
+
|
|
9
|
+
module.exports.maybeInsideReturnWithCommentStart = (path, {print, indent}) => {
|
|
10
|
+
const {parentPath} = path;
|
|
11
|
+
|
|
12
|
+
if (isReturnStatement(parentPath) && hasLeadingComment(path)) {
|
|
13
|
+
indent.inc();
|
|
14
|
+
const {leadingComments} = path.node;
|
|
15
|
+
|
|
16
|
+
print.breakline();
|
|
17
|
+
for (const {value} of leadingComments) {
|
|
18
|
+
print(`//${value}`);
|
|
19
|
+
print.breakline();
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
module.exports.maybeInsideReturnWithCommentEnd = (path, {print, indent}) => {
|
|
25
|
+
const {parentPath} = path;
|
|
26
|
+
|
|
27
|
+
if (!isReturnStatement(parentPath) || !hasLeadingComment(path))
|
|
28
|
+
return;
|
|
29
|
+
|
|
30
|
+
indent.dec();
|
|
31
|
+
print.breakline();
|
|
32
|
+
};
|
|
@@ -1,11 +1,18 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
const {types} = require('@putout/babel');
|
|
4
|
+
|
|
4
5
|
const {
|
|
5
6
|
maybePrintLeftBrace,
|
|
6
7
|
maybePrintRightBrace,
|
|
7
8
|
} = require('./maybe-write-brace');
|
|
8
9
|
|
|
10
|
+
const {
|
|
11
|
+
printLeadingCommentLine,
|
|
12
|
+
maybeInsideReturnWithCommentEnd,
|
|
13
|
+
maybeInsideReturnWithCommentStart,
|
|
14
|
+
} = require('./assignment-expression-comments');
|
|
15
|
+
|
|
9
16
|
const {
|
|
10
17
|
isExpressionStatement,
|
|
11
18
|
isAssignmentExpression,
|
|
@@ -18,6 +25,8 @@ module.exports.AssignmentExpression = (path, printer, semantics) => {
|
|
|
18
25
|
const {operator} = path.node;
|
|
19
26
|
|
|
20
27
|
maybePrintLeftBrace(path, printer, semantics);
|
|
28
|
+
maybeInsideReturnWithCommentStart(path, printer);
|
|
29
|
+
|
|
21
30
|
print('__left');
|
|
22
31
|
print.space();
|
|
23
32
|
print(operator);
|
|
@@ -34,9 +43,13 @@ module.exports.AssignmentExpression = (path, printer, semantics) => {
|
|
|
34
43
|
print.breakline();
|
|
35
44
|
}
|
|
36
45
|
|
|
46
|
+
maybeInsideReturnWithCommentEnd(path, printer);
|
|
47
|
+
|
|
37
48
|
maybePrintRightBrace(path, printer, semantics);
|
|
38
49
|
};
|
|
39
50
|
|
|
51
|
+
module.exports.AssignmentExpression.printLeadingCommentLine = printLeadingCommentLine;
|
|
52
|
+
|
|
40
53
|
function isMultiline(path) {
|
|
41
54
|
const {right} = path.node;
|
|
42
55
|
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
+
const {hasLeadingComment} = require('#is');
|
|
3
4
|
const {isParens} = require('../../maybe/maybe-parens');
|
|
4
5
|
|
|
5
6
|
module.exports.maybePrintLeftBrace = (path, printer, semantics) => {
|
|
@@ -40,7 +41,7 @@ function maybeWriteBrace(path, printer, semantics, {brace}) {
|
|
|
40
41
|
return;
|
|
41
42
|
}
|
|
42
43
|
|
|
43
|
-
if (!roundBraces.assign)
|
|
44
|
+
if (!roundBraces.assign && !hasLeadingComment(path))
|
|
44
45
|
return;
|
|
45
46
|
|
|
46
47
|
if (!isParens(path))
|
|
@@ -6,12 +6,14 @@ const {Identifier} = require('./identifier');
|
|
|
6
6
|
const {Decorator} = require('../expressions/decorator/decorator');
|
|
7
7
|
const {StringLiteral} = require('./string-literal');
|
|
8
8
|
const {DirectiveLiteral} = require('./directive-literal');
|
|
9
|
+
const {VoidPattern} = require('./void-pattern/void-pattern');
|
|
9
10
|
|
|
10
11
|
module.exports = {
|
|
11
12
|
Identifier,
|
|
12
13
|
Decorator,
|
|
13
14
|
DirectiveLiteral,
|
|
14
15
|
TemplateLiteral,
|
|
16
|
+
VoidPattern,
|
|
15
17
|
BigIntLiteral(path, {write}) {
|
|
16
18
|
write(path.node.raw);
|
|
17
19
|
},
|
package/package.json
CHANGED