@putout/printer 1.81.3 → 1.81.5
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/functions/function-declaration.js +5 -4
- package/lib/tokenize/expressions/object-expression.js +1 -1
- package/lib/tokenize/expressions/object-pattern.js +4 -3
- package/package.json +1 -1
package/ChangeLog
CHANGED
|
@@ -1,3 +1,13 @@
|
|
|
1
|
+
2023.05.05, v1.81.5
|
|
2
|
+
|
|
3
|
+
feature:
|
|
4
|
+
- b8367bc @putout/printer: improve support of newline in FunctionDeclaration inside of ExportDeclaration
|
|
5
|
+
|
|
6
|
+
2023.05.04, v1.81.4
|
|
7
|
+
|
|
8
|
+
feature:
|
|
9
|
+
- a6bd038 @putout/printer: improve support of comments inside ObjectProperty
|
|
10
|
+
|
|
1
11
|
2023.05.04, v1.81.3
|
|
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
|
};
|
|
@@ -1,7 +1,10 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
const {markAfter} = require('../../mark');
|
|
4
|
-
const {
|
|
4
|
+
const {
|
|
5
|
+
isNext,
|
|
6
|
+
isNextParent,
|
|
7
|
+
} = require('../../is');
|
|
5
8
|
|
|
6
9
|
module.exports.FunctionDeclaration = {
|
|
7
10
|
print(path, {print, maybe}) {
|
|
@@ -27,9 +30,7 @@ module.exports.FunctionDeclaration = {
|
|
|
27
30
|
print(') ');
|
|
28
31
|
print('__body');
|
|
29
32
|
},
|
|
30
|
-
afterSatisfy: () => [
|
|
31
|
-
isNext,
|
|
32
|
-
],
|
|
33
|
+
afterSatisfy: () => [isNext, isNextParent],
|
|
33
34
|
after(path, {write}) {
|
|
34
35
|
write.newline();
|
|
35
36
|
markAfter(path);
|
|
@@ -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,7 @@ const {isIdentifier} = require('@babel/types');
|
|
|
5
5
|
const {
|
|
6
6
|
isForOf,
|
|
7
7
|
isCoupleLines,
|
|
8
|
+
exists,
|
|
8
9
|
} = require('../is');
|
|
9
10
|
|
|
10
11
|
module.exports.ObjectPattern = (path, {indent, print, maybe}) => {
|
|
@@ -27,16 +28,16 @@ module.exports.ObjectPattern = (path, {indent, print, maybe}) => {
|
|
|
27
28
|
const keyPath = property.get('key');
|
|
28
29
|
const isAssign = valuePath.isAssignmentPattern();
|
|
29
30
|
const {shorthand} = property.node;
|
|
31
|
+
const couple = isCoupleLines(valuePath) && !exists(property.getPrevSibling());
|
|
30
32
|
|
|
31
33
|
maybe.indent(is);
|
|
32
|
-
maybe.print(
|
|
34
|
+
maybe.print.breakline(couple);
|
|
35
|
+
print(keyPath);
|
|
33
36
|
|
|
34
37
|
if (!shorthand) {
|
|
35
38
|
print(': ');
|
|
36
39
|
print(valuePath);
|
|
37
40
|
} else if (isAssign) {
|
|
38
|
-
const couple = isCoupleLines(valuePath);
|
|
39
|
-
maybe.print.breakline(couple);
|
|
40
41
|
print(valuePath);
|
|
41
42
|
|
|
42
43
|
maybe.print(couple, ',');
|
package/package.json
CHANGED