@putout/printer 10.9.0 → 10.11.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
|
@@ -1,3 +1,13 @@
|
|
|
1
|
+
2024.12.04, v10.11.0
|
|
2
|
+
|
|
3
|
+
feature:
|
|
4
|
+
- 7ce10f9 @putout/printer: improve support of comments inside VariableDeclarator
|
|
5
|
+
|
|
6
|
+
2024.12.02, v10.10.0
|
|
7
|
+
|
|
8
|
+
feature:
|
|
9
|
+
- 8273328 @putout/printer: OptionalMemberExpression: parens support
|
|
10
|
+
|
|
1
11
|
2024.12.01, v10.9.0
|
|
2
12
|
|
|
3
13
|
feature:
|
|
@@ -26,6 +26,13 @@ const isProperty = satisfy([
|
|
|
26
26
|
isSpreadElement,
|
|
27
27
|
]);
|
|
28
28
|
|
|
29
|
+
const isInsideVar = ({parentPath}) => {
|
|
30
|
+
if (isVariableDeclarator(parentPath))
|
|
31
|
+
return true;
|
|
32
|
+
|
|
33
|
+
return isVariableDeclarator(parentPath.parentPath);
|
|
34
|
+
};
|
|
35
|
+
|
|
29
36
|
const hasDecorators = (path) => {
|
|
30
37
|
const {parentPath} = path;
|
|
31
38
|
|
|
@@ -79,7 +86,7 @@ module.exports.parseLeadingComments = (path, {print, maybe, indent}, semantics)
|
|
|
79
86
|
if (!looksLikeSwitchCase && hasTrailingComment(path.getPrevSibling()))
|
|
80
87
|
return;
|
|
81
88
|
|
|
82
|
-
const insideFn = path.parentPath.isFunction();
|
|
89
|
+
const insideFn = path.parentPath.isFunction() && !path.isTSTypeParameterDeclaration();
|
|
83
90
|
|
|
84
91
|
const propIs = isProperty(path);
|
|
85
92
|
const isIndent = isFirst(path) || !looksLikeSwitchCase && !path.isClassMethod() && !insideFn && !propIs;
|
|
@@ -102,6 +109,13 @@ module.exports.parseLeadingComments = (path, {print, maybe, indent}, semantics)
|
|
|
102
109
|
|
|
103
110
|
maybe.print.breakline(propIs);
|
|
104
111
|
maybe.print.newline(!propIs);
|
|
112
|
+
|
|
113
|
+
if (isInsideVar(path)) {
|
|
114
|
+
indent.inc();
|
|
115
|
+
indent();
|
|
116
|
+
indent.dec();
|
|
117
|
+
}
|
|
118
|
+
|
|
105
119
|
continue;
|
|
106
120
|
}
|
|
107
121
|
|
|
@@ -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