@putout/printer 15.20.5 → 15.21.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 +30 -4
- package/package.json +1 -1
package/ChangeLog
CHANGED
|
@@ -1,7 +1,13 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
const {types} = require('@putout/babel');
|
|
4
|
-
const {
|
|
4
|
+
const {
|
|
5
|
+
isJSXElement,
|
|
6
|
+
isJSXExpressionContainer,
|
|
7
|
+
isFunction,
|
|
8
|
+
isJSXSpreadAttribute,
|
|
9
|
+
} = types;
|
|
10
|
+
|
|
5
11
|
const isInsideArrow = ({parentPath}) => parentPath.isArrowFunctionExpression();
|
|
6
12
|
|
|
7
13
|
module.exports.JSXElement = {
|
|
@@ -61,10 +67,29 @@ function condition(path) {
|
|
|
61
67
|
return path.parentPath.isVariableDeclarator();
|
|
62
68
|
}
|
|
63
69
|
|
|
64
|
-
function
|
|
65
|
-
const
|
|
70
|
+
function hasComplexAttribute(path) {
|
|
71
|
+
const {attributes} = path.node.openingElement;
|
|
66
72
|
|
|
67
|
-
|
|
73
|
+
for (const attribute of attributes) {
|
|
74
|
+
const {value} = attribute;
|
|
75
|
+
|
|
76
|
+
if (isJSXSpreadAttribute(attribute))
|
|
77
|
+
return true;
|
|
78
|
+
|
|
79
|
+
if (!isJSXExpressionContainer(value))
|
|
80
|
+
continue;
|
|
81
|
+
|
|
82
|
+
const {expression} = value;
|
|
83
|
+
|
|
84
|
+
if (isFunction(expression))
|
|
85
|
+
return true;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
return false;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
function isNeedIndent(path) {
|
|
92
|
+
if (hasComplexAttribute(path))
|
|
68
93
|
return false;
|
|
69
94
|
|
|
70
95
|
const insideFn = path.parentPath.isArrowFunctionExpression();
|
|
@@ -73,3 +98,4 @@ function isNeedIndent(path) {
|
|
|
73
98
|
|
|
74
99
|
return insideJSX || insideFn && insideCall;
|
|
75
100
|
}
|
|
101
|
+
|
package/package.json
CHANGED