@putout/printer 11.1.1 → 11.2.1
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 +12 -0
- package/lib/tokenize/expressions/assignment-expression/maybe-write-brace.js +1 -2
- package/lib/tokenize/expressions/binary-expression/binary-expression.js +1 -1
- package/lib/tokenize/expressions/conditional-expression.js +12 -21
- package/lib/tokenize/maybe/maybe-parens.js +4 -3
- package/lib/tokenize/typescript/index.js +2 -4
- package/lib/tokenize/typescript/ts-type-query/ts-type-query.js +8 -0
- package/lib/tokenize/typescript/ts-union-type/ts-union-type.js +6 -11
- package/package.json +2 -2
- package/lib/tokenize/expressions/unary-expression/parens.js +0 -13
package/ChangeLog
CHANGED
|
@@ -1,3 +1,15 @@
|
|
|
1
|
+
2024.12.12, v11.2.1
|
|
2
|
+
|
|
3
|
+
feature:
|
|
4
|
+
- 56da95d @putout/printer: maybeParens
|
|
5
|
+
|
|
6
|
+
2024.12.12, v11.2.0
|
|
7
|
+
|
|
8
|
+
feature:
|
|
9
|
+
- 523cd24 @putout/printer: TSUnionType: newlines inside of functions
|
|
10
|
+
- 1f99cbb @putout/printer: @putout/plugin-minify v9.0.0
|
|
11
|
+
- 2c507b1 @putout/printer: TSTypeQuery: maybe parens
|
|
12
|
+
|
|
1
13
|
2024.12.11, v11.1.1
|
|
2
14
|
|
|
3
15
|
fix:
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
const {isParens} = require('
|
|
4
|
-
|
|
3
|
+
const {isParens} = require('../../maybe/maybe-parens');
|
|
5
4
|
module.exports.maybePrintLeftBrace = (path, printer, semantics) => {
|
|
6
5
|
maybeWriteBrace(path, printer, semantics, {
|
|
7
6
|
brace: '(',
|
|
@@ -1,24 +1,15 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
const {
|
|
3
|
+
const {maybeParens} = require('../maybe/maybe-parens');
|
|
4
4
|
|
|
5
|
-
module.exports.ConditionalExpression = {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
print(
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
print.space();
|
|
17
|
-
print(':');
|
|
18
|
-
print.space();
|
|
19
|
-
print('__alternate');
|
|
20
|
-
},
|
|
21
|
-
after(path, {print}) {
|
|
22
|
-
print(')');
|
|
23
|
-
},
|
|
24
|
-
};
|
|
5
|
+
module.exports.ConditionalExpression = maybeParens((path, {print}) => {
|
|
6
|
+
print('__test');
|
|
7
|
+
print.space();
|
|
8
|
+
print('?');
|
|
9
|
+
print.space();
|
|
10
|
+
print('__consequent');
|
|
11
|
+
print.space();
|
|
12
|
+
print(':');
|
|
13
|
+
print.space();
|
|
14
|
+
print('__alternate');
|
|
15
|
+
});
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
+
const isParens = (path) => path.node.extra?.parenthesized;
|
|
4
|
+
|
|
5
|
+
module.exports.isParens = isParens;
|
|
3
6
|
module.exports.maybeParens = (print) => ({
|
|
4
|
-
condition
|
|
5
|
-
return path.node.extra?.parenthesized;
|
|
6
|
-
},
|
|
7
|
+
condition: isParens,
|
|
7
8
|
before(path, {write}) {
|
|
8
9
|
write('(');
|
|
9
10
|
},
|
|
@@ -37,6 +37,7 @@ const {TSExportAssignment} = require('./ts-export-assignment/ts-export-assignmen
|
|
|
37
37
|
const {TSTypeReference} = require('./ts-type-reference/ts-type-reference');
|
|
38
38
|
const {TSInferType} = require('./ts-infer-type/ts-infer-type');
|
|
39
39
|
const {TSParameterProperty} = require('./ts-parameter-property/ts-parameter-property');
|
|
40
|
+
const {TSTypeQuery} = require('./ts-type-query/ts-type-query');
|
|
40
41
|
|
|
41
42
|
module.exports = {
|
|
42
43
|
TSAsExpression,
|
|
@@ -52,6 +53,7 @@ module.exports = {
|
|
|
52
53
|
TSIntersectionType,
|
|
53
54
|
TSImportType,
|
|
54
55
|
TSUnionType,
|
|
56
|
+
TSTypeQuery,
|
|
55
57
|
TSBigIntKeyword(path, {write}) {
|
|
56
58
|
write('bigint');
|
|
57
59
|
},
|
|
@@ -61,10 +63,6 @@ module.exports = {
|
|
|
61
63
|
TSSymbolKeyword(path, {write}) {
|
|
62
64
|
write('symbol');
|
|
63
65
|
},
|
|
64
|
-
TSTypeQuery(path, {print}) {
|
|
65
|
-
print('typeof ');
|
|
66
|
-
print('__exprName');
|
|
67
|
-
},
|
|
68
66
|
TSNeverKeyword(path, {write}) {
|
|
69
67
|
write('never');
|
|
70
68
|
},
|
|
@@ -1,22 +1,17 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
const {
|
|
4
|
-
|
|
5
|
-
maybeParenClose,
|
|
6
|
-
} = require('../../expressions/unary-expression/parens');
|
|
3
|
+
const {maybeParens} = require('../../maybe/maybe-parens');
|
|
4
|
+
const insideTypeDeclaration = ({parentPath}) => parentPath.isTSTypeAliasDeclaration();
|
|
7
5
|
|
|
8
|
-
module.exports.TSUnionType = (path, printer,
|
|
6
|
+
module.exports.TSUnionType = maybeParens((path, printer, {maxTypesInOneLine}) => {
|
|
9
7
|
const types = path.get('types');
|
|
8
|
+
const {length} = types;
|
|
10
9
|
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
if (types.length <= semantics.maxTypesInOneLine)
|
|
10
|
+
if (!insideTypeDeclaration(path) || length <= maxTypesInOneLine)
|
|
14
11
|
printInOneLine(types, printer);
|
|
15
12
|
else
|
|
16
13
|
printInCoupleLines(types, printer);
|
|
17
|
-
|
|
18
|
-
maybeParenClose(path, printer);
|
|
19
|
-
};
|
|
14
|
+
});
|
|
20
15
|
|
|
21
16
|
function printInOneLine(types, {traverse, write}) {
|
|
22
17
|
const n = types.length - 1;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@putout/printer",
|
|
3
|
-
"version": "11.
|
|
3
|
+
"version": "11.2.1",
|
|
4
4
|
"type": "commonjs",
|
|
5
5
|
"author": "coderaiser <mnemonic.enemy@gmail.com> (https://github.com/coderaiser)",
|
|
6
6
|
"description": "Simplest possible opinionated Babel AST printer for 🐊Putout",
|
|
@@ -52,7 +52,7 @@
|
|
|
52
52
|
],
|
|
53
53
|
"devDependencies": {
|
|
54
54
|
"@putout/eslint": "^3.5.0",
|
|
55
|
-
"@putout/plugin-minify": "^
|
|
55
|
+
"@putout/plugin-minify": "^9.0.0",
|
|
56
56
|
"@putout/plugin-printer": "^3.0.0",
|
|
57
57
|
"@putout/plugin-promises": "^15.0.0",
|
|
58
58
|
"@putout/plugin-react-hook-form": "^4.0.0",
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
const isParens = (path) => path.node.extra?.parenthesized;
|
|
4
|
-
|
|
5
|
-
module.exports.isParens = isParens;
|
|
6
|
-
|
|
7
|
-
module.exports.maybeParenOpen = (path, {maybe}) => {
|
|
8
|
-
maybe.write(isParens(path), '(');
|
|
9
|
-
};
|
|
10
|
-
|
|
11
|
-
module.exports.maybeParenClose = (path, {maybe}) => {
|
|
12
|
-
maybe.write(isParens(path), ')');
|
|
13
|
-
};
|