@putout/printer 8.28.0 → 8.29.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
package/lib/printer.d.ts
CHANGED
|
@@ -24,8 +24,8 @@ type Traverse = (input: types.Node) => void;
|
|
|
24
24
|
|
|
25
25
|
declare function MaybeIndent(condition: boolean): void;
|
|
26
26
|
declare namespace MaybeIndent {
|
|
27
|
-
type inc = (condition: boolean) => void;
|
|
28
|
-
type dec = (condition: boolean) => void;
|
|
27
|
+
type inc = (condition: boolean) => void;
|
|
28
|
+
type dec = (condition: boolean) => void;
|
|
29
29
|
|
|
30
30
|
export {
|
|
31
31
|
inc,
|
|
@@ -13,6 +13,7 @@ const {
|
|
|
13
13
|
|
|
14
14
|
const {parseComments} = require('../../comment/comment');
|
|
15
15
|
const {likeChain} = require('../member-expression/member-expressions');
|
|
16
|
+
const {isStringLiteral} = require('@putout/babel').types;
|
|
16
17
|
|
|
17
18
|
const isBodyOfArrow = (path) => path.parentPath.node.body === path.node;
|
|
18
19
|
const isLogical = (path) => path.get('argument').isLogicalExpression();
|
|
@@ -43,9 +44,20 @@ function isInsideNestedArrayCall({parentPath}) {
|
|
|
43
44
|
return isInsideCall(parentPath.parentPath);
|
|
44
45
|
}
|
|
45
46
|
|
|
47
|
+
function isInsideNestedTuple({parentPath}) {
|
|
48
|
+
const {elements} = parentPath.parentPath.node;
|
|
49
|
+
const [first] = elements;
|
|
50
|
+
|
|
51
|
+
return isStringLiteral(first);
|
|
52
|
+
}
|
|
53
|
+
|
|
46
54
|
module.exports.ObjectExpression = (path, printer, semantics) => {
|
|
47
55
|
const {trailingComma} = semantics;
|
|
48
|
-
const {
|
|
56
|
+
const {
|
|
57
|
+
print,
|
|
58
|
+
maybe,
|
|
59
|
+
indent,
|
|
60
|
+
} = printer;
|
|
49
61
|
|
|
50
62
|
const insideNestedArrayCall = isInsideNestedArrayCall(path);
|
|
51
63
|
|
|
@@ -95,8 +107,14 @@ module.exports.ObjectExpression = (path, printer, semantics) => {
|
|
|
95
107
|
}
|
|
96
108
|
}
|
|
97
109
|
|
|
98
|
-
|
|
99
|
-
|
|
110
|
+
if (!insideNestedArrayCall) {
|
|
111
|
+
indent.dec();
|
|
112
|
+
maybe.indent(manyLines);
|
|
113
|
+
} else if (isInsideNestedTuple(path)) {
|
|
114
|
+
indent.dec();
|
|
115
|
+
indent();
|
|
116
|
+
indent.inc();
|
|
117
|
+
}
|
|
100
118
|
|
|
101
119
|
print('}');
|
|
102
120
|
maybe.print(parens, ')');
|
package/package.json
CHANGED