@putout/printer 12.0.0 → 12.1.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 +10 -0
- package/lib/tokenize/jsx/jsx-element.js +17 -8
- package/package.json +1 -1
package/ChangeLog
CHANGED
|
@@ -17,20 +17,16 @@ module.exports.JSXElement = {
|
|
|
17
17
|
write.newline();
|
|
18
18
|
}
|
|
19
19
|
},
|
|
20
|
-
print(path, {print, traverse,
|
|
21
|
-
const
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
if (insideFn && insideCall)
|
|
25
|
-
indent.inc();
|
|
20
|
+
print(path, {print, traverse, maybe}) {
|
|
21
|
+
const needIndent = isNeedIndent(path);
|
|
22
|
+
maybe.indent.inc(needIndent);
|
|
26
23
|
|
|
27
24
|
print('__openingElement');
|
|
28
25
|
path.get('children').map(traverse);
|
|
29
26
|
|
|
30
27
|
print('__closingElement');
|
|
31
28
|
|
|
32
|
-
|
|
33
|
-
indent.dec();
|
|
29
|
+
maybe.indent.dec(needIndent);
|
|
34
30
|
},
|
|
35
31
|
after(path, {write, indent, maybe}) {
|
|
36
32
|
const {leadingComments} = path.node;
|
|
@@ -60,3 +56,16 @@ function condition(path) {
|
|
|
60
56
|
|
|
61
57
|
return path.parentPath.isVariableDeclarator();
|
|
62
58
|
}
|
|
59
|
+
|
|
60
|
+
function isNeedIndent(path) {
|
|
61
|
+
const attributesCount = path.node.openingElement.attributes.length;
|
|
62
|
+
|
|
63
|
+
if (attributesCount > 2)
|
|
64
|
+
return false;
|
|
65
|
+
|
|
66
|
+
const insideFn = path.parentPath.isArrowFunctionExpression();
|
|
67
|
+
const insideJSX = path.parentPath.isJSXElement();
|
|
68
|
+
const insideCall = path.parentPath.parentPath.isCallExpression();
|
|
69
|
+
|
|
70
|
+
return insideJSX || insideFn && insideCall;
|
|
71
|
+
}
|
package/package.json
CHANGED