@putout/printer 1.81.2 → 1.81.4
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/README.md +1 -1
- package/lib/tokenize/comments.js +4 -3
- package/lib/tokenize/expressions/assignment-pattern.js +1 -1
- package/lib/tokenize/expressions/object-expression.js +1 -1
- package/lib/tokenize/expressions/object-pattern.js +5 -3
- package/lib/tokenize/expressions/sequence-expression.js +13 -26
- package/lib/tokenize/expressions/unary-expressions.js +4 -1
- package/lib/tokenize/maybe/satisfy.js +0 -1
- package/package.json +1 -1
package/ChangeLog
CHANGED
|
@@ -1,3 +1,13 @@
|
|
|
1
|
+
2023.05.04, v1.81.4
|
|
2
|
+
|
|
3
|
+
feature:
|
|
4
|
+
- a6bd038 @putout/printer: improve support of comments inside ObjectProperty
|
|
5
|
+
|
|
6
|
+
2023.05.04, v1.81.3
|
|
7
|
+
|
|
8
|
+
feature:
|
|
9
|
+
- ae2c615 @putout/printer: improve support of SequenceExpressions
|
|
10
|
+
|
|
1
11
|
2023.05.04, v1.81.2
|
|
2
12
|
|
|
3
13
|
feature:
|
package/README.md
CHANGED
package/lib/tokenize/comments.js
CHANGED
|
@@ -61,9 +61,9 @@ module.exports.parseTrailingComments = (path, {write, maybe}, format) => {
|
|
|
61
61
|
return;
|
|
62
62
|
|
|
63
63
|
for (const {type, value, loc} of trailingComments) {
|
|
64
|
+
const sameLine = isSameLine(path, loc);
|
|
65
|
+
|
|
64
66
|
if (type === 'CommentLine') {
|
|
65
|
-
const sameLine = isSameLine(path, loc);
|
|
66
|
-
|
|
67
67
|
maybe.write.space(sameLine);
|
|
68
68
|
maybe.indent(!sameLine);
|
|
69
69
|
|
|
@@ -73,8 +73,9 @@ module.exports.parseTrailingComments = (path, {write, maybe}, format) => {
|
|
|
73
73
|
}
|
|
74
74
|
|
|
75
75
|
if (type === 'CommentBlock') {
|
|
76
|
+
maybe.write.space(sameLine);
|
|
76
77
|
write(`/*${value}*/`);
|
|
77
|
-
write.newline();
|
|
78
|
+
maybe.write.newline(!sameLine);
|
|
78
79
|
}
|
|
79
80
|
}
|
|
80
81
|
};
|
|
@@ -28,7 +28,7 @@ module.exports.ObjectExpression = (path, {print, maybe, indent}) => {
|
|
|
28
28
|
|
|
29
29
|
maybe.print(parens, '(');
|
|
30
30
|
print('{');
|
|
31
|
-
maybe.print(manyLines
|
|
31
|
+
maybe.print.newline(manyLines);
|
|
32
32
|
|
|
33
33
|
for (const property of properties) {
|
|
34
34
|
if (property.isSpreadElement()) {
|
|
@@ -5,6 +5,8 @@ const {isIdentifier} = require('@babel/types');
|
|
|
5
5
|
const {
|
|
6
6
|
isForOf,
|
|
7
7
|
isCoupleLines,
|
|
8
|
+
exists,
|
|
9
|
+
|
|
8
10
|
} = require('../is');
|
|
9
11
|
|
|
10
12
|
module.exports.ObjectPattern = (path, {indent, print, maybe}) => {
|
|
@@ -27,16 +29,16 @@ module.exports.ObjectPattern = (path, {indent, print, maybe}) => {
|
|
|
27
29
|
const keyPath = property.get('key');
|
|
28
30
|
const isAssign = valuePath.isAssignmentPattern();
|
|
29
31
|
const {shorthand} = property.node;
|
|
32
|
+
const couple = isCoupleLines(valuePath) && !exists(property.getPrevSibling());
|
|
30
33
|
|
|
31
34
|
maybe.indent(is);
|
|
32
|
-
maybe.print(
|
|
35
|
+
maybe.print.breakline(couple);
|
|
36
|
+
print(keyPath);
|
|
33
37
|
|
|
34
38
|
if (!shorthand) {
|
|
35
39
|
print(': ');
|
|
36
40
|
print(valuePath);
|
|
37
41
|
} else if (isAssign) {
|
|
38
|
-
const couple = isCoupleLines(valuePath);
|
|
39
|
-
maybe.print.breakline(couple);
|
|
40
42
|
print(valuePath);
|
|
41
43
|
|
|
42
44
|
maybe.print(couple, ',');
|
|
@@ -1,29 +1,16 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
const
|
|
5
|
-
const
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
print(path, {maybe, print}) {
|
|
17
|
-
const expressions = path.get('expressions');
|
|
18
|
-
const n = expressions.length - 1;
|
|
19
|
-
|
|
20
|
-
for (const [index, expression] of expressions.entries()) {
|
|
21
|
-
print(expression);
|
|
22
|
-
maybe.print(index < n, ',');
|
|
23
|
-
maybe.print(index < n, ' ');
|
|
24
|
-
}
|
|
25
|
-
},
|
|
26
|
-
after(path, {write}) {
|
|
27
|
-
write(')');
|
|
28
|
-
},
|
|
3
|
+
module.exports.SequenceExpression = (path, {maybe, write, traverse}) => {
|
|
4
|
+
const expressions = path.get('expressions');
|
|
5
|
+
const n = expressions.length - 1;
|
|
6
|
+
|
|
7
|
+
write('(');
|
|
8
|
+
|
|
9
|
+
for (const [index, expression] of expressions.entries()) {
|
|
10
|
+
traverse(expression);
|
|
11
|
+
maybe.write(index < n, ',');
|
|
12
|
+
maybe.write(index < n, ' ');
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
write(')');
|
|
29
16
|
};
|
package/package.json
CHANGED