@putout/printer 1.134.0 → 1.134.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
CHANGED
|
@@ -21,7 +21,7 @@ const {
|
|
|
21
21
|
} = require('../is');
|
|
22
22
|
|
|
23
23
|
const isForOf = ({parentPath}) => parentPath.isForOfStatement();
|
|
24
|
-
|
|
24
|
+
|
|
25
25
|
const isStringAndArray = ([a, b]) => isStringLiteral(a) && isArrayExpression(b);
|
|
26
26
|
const isStringAndString = ([a, b]) => isStringLiteral(a) && isStringLiteral(b);
|
|
27
27
|
const isIdentifierAndIdentifier = ([a, b]) => isIdentifier(a) && isIdentifier(b);
|
|
@@ -30,6 +30,13 @@ const isSimpleAndCall = ([a, b]) => isSimple(a) && isCallExpression(b);
|
|
|
30
30
|
const isBooleanAndSimple = ([a, b]) => isBooleanLiteral(a) && isSimple(b);
|
|
31
31
|
const isNullAndSimple = ([a, b]) => isNullLiteral(a) && isSimple(b);
|
|
32
32
|
|
|
33
|
+
const isStringAndObject = (elements) => {
|
|
34
|
+
const first = elements.at(0);
|
|
35
|
+
const last = elements.at(-1);
|
|
36
|
+
|
|
37
|
+
return isStringLiteral(first) && isObjectExpression(last);
|
|
38
|
+
};
|
|
39
|
+
|
|
33
40
|
const isTwoLongStrings = ([a, b]) => {
|
|
34
41
|
const LONG_STRING = 20;
|
|
35
42
|
|
|
@@ -63,12 +70,12 @@ module.exports.ArrayExpression = {
|
|
|
63
70
|
},
|
|
64
71
|
print(path, {print, maybe, indent}) {
|
|
65
72
|
const elements = path.get('elements');
|
|
66
|
-
const shouldIncreaseIndent = isIncreaseIndent(path);
|
|
73
|
+
const shouldIncreaseIndent = !isIncreaseIndent(path);
|
|
67
74
|
|
|
68
75
|
print('[');
|
|
69
76
|
|
|
70
77
|
if (!isTwoLongStrings(elements))
|
|
71
|
-
maybe.indent.inc(
|
|
78
|
+
maybe.indent.inc(shouldIncreaseIndent);
|
|
72
79
|
|
|
73
80
|
const isNewLine = isNewlineBetweenElements(path, {
|
|
74
81
|
elements,
|
|
@@ -91,7 +98,7 @@ module.exports.ArrayExpression = {
|
|
|
91
98
|
}
|
|
92
99
|
|
|
93
100
|
if (!isTwoLongStrings(elements))
|
|
94
|
-
maybe.indent.dec(
|
|
101
|
+
maybe.indent.dec(shouldIncreaseIndent);
|
|
95
102
|
|
|
96
103
|
const parentElements = path.parentPath.get('elements');
|
|
97
104
|
|
|
@@ -164,7 +171,7 @@ function isIncreaseIndent(path) {
|
|
|
164
171
|
if (elements[0].isObjectExpression())
|
|
165
172
|
return true;
|
|
166
173
|
|
|
167
|
-
if (elements
|
|
174
|
+
if (isStringAndObject(elements))
|
|
168
175
|
return true;
|
|
169
176
|
|
|
170
177
|
return false;
|
package/package.json
CHANGED