@putout/printer 1.149.0 → 1.150.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
package/lib/tokenize/expressions/{array-expression.js → array-expression/array-expression.js}
RENAMED
|
@@ -21,7 +21,9 @@ const {
|
|
|
21
21
|
isStringAndIdentifier,
|
|
22
22
|
isIdentifierAndString,
|
|
23
23
|
isStringAndMember,
|
|
24
|
-
} = require('
|
|
24
|
+
} = require('../../is');
|
|
25
|
+
|
|
26
|
+
const MAX_ARRAY_ELEMENTS_WHEN_USED_AS_ARGUMENT = 4;
|
|
25
27
|
|
|
26
28
|
const isForOf = ({parentPath}) => parentPath.isForOfStatement();
|
|
27
29
|
|
|
@@ -38,6 +40,25 @@ const isStringAndArray = ([a, b]) => {
|
|
|
38
40
|
};
|
|
39
41
|
|
|
40
42
|
const isStringAndString = ([a, b]) => isStringLiteral(a) && isStringLiteral(b);
|
|
43
|
+
|
|
44
|
+
const isShortTwoSimplesInsideCall = (path, short) => {
|
|
45
|
+
const {
|
|
46
|
+
node,
|
|
47
|
+
parentPath,
|
|
48
|
+
} = path;
|
|
49
|
+
const {elements} = node;
|
|
50
|
+
const {length} = elements;
|
|
51
|
+
const [a, b] = elements;
|
|
52
|
+
|
|
53
|
+
if (!parentPath.isCallExpression())
|
|
54
|
+
return false;
|
|
55
|
+
|
|
56
|
+
if (!isStringLiteral(a) || !isStringLiteral(b))
|
|
57
|
+
return false;
|
|
58
|
+
|
|
59
|
+
return length < short;
|
|
60
|
+
};
|
|
61
|
+
|
|
41
62
|
const isIdentifierAndIdentifier = ([a, b]) => isIdentifier(a) && isIdentifier(b);
|
|
42
63
|
const isInsideArray = (path) => path.parentPath.isArrayExpression();
|
|
43
64
|
|
|
@@ -165,16 +186,8 @@ function isNumbers(elements) {
|
|
|
165
186
|
return false;
|
|
166
187
|
}
|
|
167
188
|
|
|
168
|
-
function isLastArg(
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
if (!parentPath.isCallExpression())
|
|
172
|
-
return true;
|
|
173
|
-
|
|
174
|
-
const args = parentPath.get('arguments');
|
|
175
|
-
const n = args.length - 1;
|
|
176
|
-
|
|
177
|
-
return path === args[n];
|
|
189
|
+
function isLastArg({parentPath}) {
|
|
190
|
+
return !parentPath.isCallExpression();
|
|
178
191
|
}
|
|
179
192
|
|
|
180
193
|
function isParentProperty(path) {
|
|
@@ -273,6 +286,9 @@ function isNewlineBetweenElements(path, {elements}) {
|
|
|
273
286
|
if (isSimpleAndCall(elements))
|
|
274
287
|
return false;
|
|
275
288
|
|
|
289
|
+
if (isShortTwoSimplesInsideCall(path, MAX_ARRAY_ELEMENTS_WHEN_USED_AS_ARGUMENT))
|
|
290
|
+
return false;
|
|
291
|
+
|
|
276
292
|
if (isTwoStringsDifferentLength(elements))
|
|
277
293
|
return false;
|
|
278
294
|
|
|
@@ -28,7 +28,7 @@ const {
|
|
|
28
28
|
} = require('./class-property');
|
|
29
29
|
|
|
30
30
|
const {AssignmentExpression} = require('./assignment-expression');
|
|
31
|
-
const {ArrayExpression} = require('./array-expression');
|
|
31
|
+
const {ArrayExpression} = require('./array-expression/array-expression');
|
|
32
32
|
const {ArrayPattern} = require('./array-pattern');
|
|
33
33
|
const {AssignmentPattern} = require('./assignment-pattern');
|
|
34
34
|
const {RestElement} = require('./rest-element');
|
|
@@ -29,11 +29,7 @@ const satisfyAfter = satisfy([
|
|
|
29
29
|
isNextUp,
|
|
30
30
|
]);
|
|
31
31
|
|
|
32
|
-
const shouldBreakline = satisfy([
|
|
33
|
-
isNewlineBetweenSiblings,
|
|
34
|
-
isNotLastBody,
|
|
35
|
-
isStrictMode,
|
|
36
|
-
]);
|
|
32
|
+
const shouldBreakline = satisfy([isNewlineBetweenSiblings, isNotLastBody, isStrictMode]);
|
|
37
33
|
|
|
38
34
|
module.exports.ExpressionStatement = {
|
|
39
35
|
print(path, {indent, print, maybe, store}) {
|
package/package.json
CHANGED