@putout/printer 6.4.1 → 6.6.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
|
@@ -14,12 +14,19 @@ const {
|
|
|
14
14
|
isCurrentNewLine,
|
|
15
15
|
} = require('./new-line');
|
|
16
16
|
|
|
17
|
+
const {types} = require('@putout/babel');
|
|
17
18
|
const {
|
|
18
19
|
isObjectExpression,
|
|
19
20
|
isStringLiteral,
|
|
20
|
-
} =
|
|
21
|
+
} = types;
|
|
21
22
|
|
|
22
23
|
const isNextObject = (a) => a.getNextSibling().isObjectExpression();
|
|
24
|
+
const isArrayInsideArray = (path) => {
|
|
25
|
+
if (!path.isArrayExpression() || !path.parentPath.isArrayExpression())
|
|
26
|
+
return false;
|
|
27
|
+
|
|
28
|
+
return path === path.parentPath.get('elements').at(-1);
|
|
29
|
+
};
|
|
23
30
|
|
|
24
31
|
const isInsideOneElementArray = ({parentPath}) => parentPath.node.elements.length === 1;
|
|
25
32
|
const isInsideArray = (path) => path.parentPath.isArrayExpression();
|
|
@@ -63,7 +70,7 @@ module.exports.ArrayExpression = {
|
|
|
63
70
|
|
|
64
71
|
print('[');
|
|
65
72
|
|
|
66
|
-
const indented = !isTwoLongStrings(elements) || !isInsideArray(path) && isIndented(elements[0]);
|
|
73
|
+
const indented = !isArrayInsideArray(path) && (!isTwoLongStrings(elements) || !isInsideArray(path) && isIndented(elements[0]));
|
|
67
74
|
|
|
68
75
|
if (indented)
|
|
69
76
|
maybe.indent.inc(shouldIncreaseIndent);
|
|
@@ -103,7 +110,7 @@ module.exports.ArrayExpression = {
|
|
|
103
110
|
indent.dec();
|
|
104
111
|
maybe.indent(elements.length && isNewLine);
|
|
105
112
|
indent.inc();
|
|
106
|
-
} else if (!isObjectExpression(elements.at(-1))) {
|
|
113
|
+
} else if (!isArrayInsideArray(path) && !isObjectExpression(elements.at(-1))) {
|
|
107
114
|
maybe.indent(elements.length && isNewLine);
|
|
108
115
|
}
|
|
109
116
|
|
package/package.json
CHANGED