@putout/printer 1.63.0 → 1.64.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
|
+
2023.04.21, v1.64.0
|
|
2
|
+
|
|
3
|
+
feature:
|
|
4
|
+
- 3ffb203 @putout/printer: add support of optional variance annotation
|
|
5
|
+
|
|
6
|
+
2023.04.21, v1.63.1
|
|
7
|
+
|
|
8
|
+
feature:
|
|
9
|
+
- faf1596 @putout/printer: avoid newline between elements of ArrayExpression, when element is CallExpression
|
|
10
|
+
|
|
1
11
|
2023.04.21, v1.63.0
|
|
2
12
|
|
|
3
13
|
feature:
|
|
@@ -7,6 +7,7 @@ const {
|
|
|
7
7
|
isStringLiteral,
|
|
8
8
|
isArrayExpression,
|
|
9
9
|
isIdentifier,
|
|
10
|
+
isCallExpression,
|
|
10
11
|
} = require('@babel/types');
|
|
11
12
|
|
|
12
13
|
const {
|
|
@@ -21,7 +22,6 @@ const isStringAndString = ([a, b]) => isStringLiteral(a) && isStringLiteral(b);
|
|
|
21
22
|
const isIdentifierAndIdentifier = ([a, b]) => isIdentifier(a) && isIdentifier(b);
|
|
22
23
|
const isArrayParent = (path) => path.parentPath.isArrayExpression();
|
|
23
24
|
|
|
24
|
-
const isOneElementCall = (path, {elements}) => path.parentPath.isCallExpression() && elements.length === 1;
|
|
25
25
|
const isTwoElementReturn = (path, {elements}) => path.parentPath.isReturnStatement() && elements.length === 2;
|
|
26
26
|
|
|
27
27
|
const isTwoLongStrings = ([a, b]) => {
|
|
@@ -265,3 +265,13 @@ function isInsideLoop(path) {
|
|
|
265
265
|
|
|
266
266
|
return true;
|
|
267
267
|
}
|
|
268
|
+
|
|
269
|
+
const isOneElementCall = (path, {elements}) => {
|
|
270
|
+
if (!path.parentPath.isCallExpression())
|
|
271
|
+
return false;
|
|
272
|
+
|
|
273
|
+
if (elements.length !== 1)
|
|
274
|
+
return false;
|
|
275
|
+
|
|
276
|
+
return !isCallExpression(elements[0]);
|
|
277
|
+
};
|
|
@@ -23,7 +23,9 @@ module.exports.maybeThrow = (a, path, b) => {
|
|
|
23
23
|
}));
|
|
24
24
|
};
|
|
25
25
|
|
|
26
|
-
const maybeProgram = (ast) => isProgram(ast) ? ast : Program([
|
|
26
|
+
const maybeProgram = (ast) => isProgram(ast) ? ast : Program([
|
|
27
|
+
ExpressionStatement(ast),
|
|
28
|
+
]);
|
|
27
29
|
|
|
28
30
|
module.exports.maybeFile = (ast) => isFile(ast) ? ast : File(maybeProgram(ast));
|
|
29
31
|
|
|
@@ -37,6 +37,12 @@ module.exports = {
|
|
|
37
37
|
},
|
|
38
38
|
TSTypeParameter(path, {write, traverse}) {
|
|
39
39
|
const constraint = path.get('constraint');
|
|
40
|
+
|
|
41
|
+
if (path.node.in)
|
|
42
|
+
write('in ');
|
|
43
|
+
else if (path.node.out)
|
|
44
|
+
write('out ');
|
|
45
|
+
|
|
40
46
|
write(path.node.name);
|
|
41
47
|
|
|
42
48
|
if (exists(constraint)) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@putout/printer",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.64.0",
|
|
4
4
|
"type": "commonjs",
|
|
5
5
|
"author": "coderaiser <mnemonic.enemy@gmail.com> (https://github.com/coderaiser)",
|
|
6
6
|
"description": "Easiest possible opinionated Babel AST printer made with ❤️ to use in 🐊Putout",
|