@putout/printer 8.12.1 → 8.13.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 +5 -0
- package/lib/tokenize/expressions/array-expression/array-expression.js +2 -2
- package/lib/tokenize/expressions/array-expression/newline.js +2 -2
- package/lib/tokenize/expressions/object-expression/object-expression.js +0 -3
- package/lib/tokenize/is.js +5 -3
- package/package.json +1 -1
package/ChangeLog
CHANGED
|
@@ -6,7 +6,7 @@ const {
|
|
|
6
6
|
isStringAndIdentifier,
|
|
7
7
|
isIdentifierAndIdentifier,
|
|
8
8
|
isStringAndArray,
|
|
9
|
-
|
|
9
|
+
isSimpleAndEmptyObject,
|
|
10
10
|
} = require('../../is');
|
|
11
11
|
|
|
12
12
|
const {
|
|
@@ -116,7 +116,7 @@ module.exports.ArrayExpression = {
|
|
|
116
116
|
maybe.indent(elements.length && isNewLine);
|
|
117
117
|
}
|
|
118
118
|
|
|
119
|
-
if (
|
|
119
|
+
if (isSimpleAndEmptyObject(elements)) {
|
|
120
120
|
print(',');
|
|
121
121
|
print.breakline();
|
|
122
122
|
}
|
|
@@ -21,7 +21,7 @@ const {
|
|
|
21
21
|
isCoupleLines,
|
|
22
22
|
isStringAndArray,
|
|
23
23
|
isIdentifierAndIdentifier,
|
|
24
|
-
|
|
24
|
+
isSimpleAndEmptyObject,
|
|
25
25
|
} = require('../../is');
|
|
26
26
|
|
|
27
27
|
const {round} = Math;
|
|
@@ -61,7 +61,7 @@ module.exports.isMultiLine = (path, {elements, maxElementsInOneLine}) => {
|
|
|
61
61
|
if (elements.length > 3 && !isObjectExpression(elements[0]))
|
|
62
62
|
return MULTI_LINE;
|
|
63
63
|
|
|
64
|
-
if (
|
|
64
|
+
if (isSimpleAndEmptyObject(elements))
|
|
65
65
|
return MULTI_LINE;
|
|
66
66
|
|
|
67
67
|
if (isOneSimple(path))
|
package/lib/tokenize/is.js
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
+
const {types} = require('@putout/babel');
|
|
3
4
|
const {
|
|
4
5
|
isStringLiteral,
|
|
6
|
+
isSpreadElement,
|
|
5
7
|
isIdentifier,
|
|
6
8
|
isIfStatement,
|
|
7
9
|
isStatement,
|
|
@@ -10,7 +12,7 @@ const {
|
|
|
10
12
|
isMemberExpression,
|
|
11
13
|
isArrayExpression,
|
|
12
14
|
isObjectExpression,
|
|
13
|
-
} =
|
|
15
|
+
} = types;
|
|
14
16
|
|
|
15
17
|
const isParentProgram = (path) => path.parentPath?.isProgram();
|
|
16
18
|
const isParentBlock = (path) => path.parentPath.isBlockStatement();
|
|
@@ -61,8 +63,8 @@ function isStringAndIdentifier([a, b]) {
|
|
|
61
63
|
return isStringLiteral(a) && isIdentifier(b);
|
|
62
64
|
}
|
|
63
65
|
|
|
64
|
-
module.exports.
|
|
65
|
-
if (!isIdentifier(a))
|
|
66
|
+
module.exports.isSimpleAndEmptyObject = ([a, b]) => {
|
|
67
|
+
if (!isIdentifier(a) && !isSpreadElement(a))
|
|
66
68
|
return false;
|
|
67
69
|
|
|
68
70
|
if (!isObjectExpression(b))
|
package/package.json
CHANGED