@putout/printer 10.8.1 → 10.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
|
@@ -26,7 +26,14 @@ const isProperty = satisfy([
|
|
|
26
26
|
isSpreadElement,
|
|
27
27
|
]);
|
|
28
28
|
|
|
29
|
-
const hasDecorators = (
|
|
29
|
+
const hasDecorators = (path) => {
|
|
30
|
+
const {parentPath} = path;
|
|
31
|
+
|
|
32
|
+
if (path.node.decorators?.length)
|
|
33
|
+
return true;
|
|
34
|
+
|
|
35
|
+
return parentPath.node.decorators?.length;
|
|
36
|
+
};
|
|
30
37
|
|
|
31
38
|
function isCommentOfPrevious(path) {
|
|
32
39
|
const [comment] = path.node.leadingComments;
|
|
@@ -105,7 +105,7 @@ module.exports.parseTrailingComments = (path, {write, maybe}, semantics) => {
|
|
|
105
105
|
if (type === 'CommentLine') {
|
|
106
106
|
maybe.write.breakline(commentOnNextLine);
|
|
107
107
|
maybe.write.space(sameLine);
|
|
108
|
-
maybe.indent(!sameLine && !commentOnNextLine);
|
|
108
|
+
maybe.indent(!sameLine && (!commentOnNextLine || path.isDecorator()));
|
|
109
109
|
|
|
110
110
|
if (hasBody(path)) {
|
|
111
111
|
maybe.write.breakline(!isNext(path));
|
|
@@ -10,6 +10,7 @@ const {chain} = require('./chain');
|
|
|
10
10
|
const {satisfy} = require('../../is');
|
|
11
11
|
|
|
12
12
|
const {maybePrintComputed} = require('../object-expression/maybe-print-computed');
|
|
13
|
+
const {maybeParens} = require('../../maybe/maybe-parens');
|
|
13
14
|
|
|
14
15
|
const isArgOfCall = (path) => path.parentPath.isCallExpression() && path.parentPath.get('arguments.0') === path;
|
|
15
16
|
|
|
@@ -44,7 +45,7 @@ module.exports.MemberExpression = (path, printer) => {
|
|
|
44
45
|
maybe.indent.dec(isChain);
|
|
45
46
|
};
|
|
46
47
|
|
|
47
|
-
module.exports.OptionalMemberExpression = (path, {print, maybe}) => {
|
|
48
|
+
module.exports.OptionalMemberExpression = maybeParens((path, {print, maybe}) => {
|
|
48
49
|
const {computed, optional} = path.node;
|
|
49
50
|
|
|
50
51
|
print('__object');
|
|
@@ -61,7 +62,7 @@ module.exports.OptionalMemberExpression = (path, {print, maybe}) => {
|
|
|
61
62
|
}
|
|
62
63
|
|
|
63
64
|
print('__property');
|
|
64
|
-
};
|
|
65
|
+
});
|
|
65
66
|
|
|
66
67
|
const isCall = (a) => a.type === 'CallExpression';
|
|
67
68
|
|
package/package.json
CHANGED