@putout/printer 11.2.0 → 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 +5 -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/ts-union-type/ts-union-type.js +3 -11
- package/package.json +1 -1
- package/lib/tokenize/expressions/unary-expression/parens.js +0 -13
package/ChangeLog
CHANGED
|
@@ -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
|
},
|
|
@@ -1,25 +1,17 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
const {
|
|
4
|
-
maybeParenOpen,
|
|
5
|
-
maybeParenClose,
|
|
6
|
-
} = require('../../expressions/unary-expression/parens');
|
|
7
|
-
|
|
3
|
+
const {maybeParens} = require('../../maybe/maybe-parens');
|
|
8
4
|
const insideTypeDeclaration = ({parentPath}) => parentPath.isTSTypeAliasDeclaration();
|
|
9
5
|
|
|
10
|
-
module.exports.TSUnionType = (path, printer, {maxTypesInOneLine}) => {
|
|
6
|
+
module.exports.TSUnionType = maybeParens((path, printer, {maxTypesInOneLine}) => {
|
|
11
7
|
const types = path.get('types');
|
|
12
8
|
const {length} = types;
|
|
13
9
|
|
|
14
|
-
maybeParenOpen(path, printer);
|
|
15
|
-
|
|
16
10
|
if (!insideTypeDeclaration(path) || length <= maxTypesInOneLine)
|
|
17
11
|
printInOneLine(types, printer);
|
|
18
12
|
else
|
|
19
13
|
printInCoupleLines(types, printer);
|
|
20
|
-
|
|
21
|
-
maybeParenClose(path, printer);
|
|
22
|
-
};
|
|
14
|
+
});
|
|
23
15
|
|
|
24
16
|
function printInOneLine(types, {traverse, write}) {
|
|
25
17
|
const n = types.length - 1;
|
package/package.json
CHANGED
|
@@ -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
|
-
};
|