@putout/printer 6.11.2 → 6.11.3
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,6 +21,8 @@ const {
|
|
|
21
21
|
isCoupleLines,
|
|
22
22
|
isStringAndArray,
|
|
23
23
|
isIdentifierAndIdentifier,
|
|
24
|
+
satisfy,
|
|
25
|
+
|
|
24
26
|
} = require('../../is');
|
|
25
27
|
|
|
26
28
|
const {round} = Math;
|
|
@@ -47,17 +49,26 @@ const isSimpleAndObject = ([a, b]) => isSimple(a) && isObjectExpression(b);
|
|
|
47
49
|
const ONE_LINE = false;
|
|
48
50
|
const MULTI_LINE = true;
|
|
49
51
|
|
|
52
|
+
const isOneLine = satisfy([
|
|
53
|
+
isOneSimple,
|
|
54
|
+
isOneSpread,
|
|
55
|
+
isIdentifierAndIdentifier,
|
|
56
|
+
isBooleanAndSimple,
|
|
57
|
+
isNullAndSimple,
|
|
58
|
+
isSimpleAndCall,
|
|
59
|
+
isTwoStringsDifferentLength,
|
|
60
|
+
isStringAndArray,
|
|
61
|
+
isStringAndMember,
|
|
62
|
+
isStringAndIdentifier,
|
|
63
|
+
isIdentifierAndString,
|
|
64
|
+
isSimpleAndObject,
|
|
65
|
+
]);
|
|
66
|
+
|
|
50
67
|
module.exports.isMultiLine = (path, {elements, maxElementsInOneLine}) => {
|
|
51
68
|
if (elements.length > 3 && !isObjectExpression(elements[0]))
|
|
52
69
|
return MULTI_LINE;
|
|
53
70
|
|
|
54
|
-
if (
|
|
55
|
-
return ONE_LINE;
|
|
56
|
-
|
|
57
|
-
if (isOneSpread(elements))
|
|
58
|
-
return ONE_LINE;
|
|
59
|
-
|
|
60
|
-
if (elements.length === 2 && isIdentifierAndIdentifier(elements))
|
|
71
|
+
if (isOneLine(elements))
|
|
61
72
|
return ONE_LINE;
|
|
62
73
|
|
|
63
74
|
if (isCallInsideArrow(path))
|
|
@@ -69,39 +80,12 @@ module.exports.isMultiLine = (path, {elements, maxElementsInOneLine}) => {
|
|
|
69
80
|
if (isInsideLoop(path))
|
|
70
81
|
return ONE_LINE;
|
|
71
82
|
|
|
72
|
-
if (isBooleanAndSimple(elements))
|
|
73
|
-
return ONE_LINE;
|
|
74
|
-
|
|
75
|
-
if (isNullAndSimple(elements))
|
|
76
|
-
return ONE_LINE;
|
|
77
|
-
|
|
78
|
-
if (isSimpleAndCall(elements))
|
|
79
|
-
return ONE_LINE;
|
|
80
|
-
|
|
81
83
|
if (isShortTwoSimplesInsideCall(path, maxElementsInOneLine))
|
|
82
84
|
return ONE_LINE;
|
|
83
85
|
|
|
84
|
-
if (isTwoStringsDifferentLength(elements))
|
|
85
|
-
return ONE_LINE;
|
|
86
|
-
|
|
87
86
|
if (isTwoSimplesInsideObjectProperty(path))
|
|
88
87
|
return ONE_LINE;
|
|
89
88
|
|
|
90
|
-
if (isStringAndArray(elements))
|
|
91
|
-
return ONE_LINE;
|
|
92
|
-
|
|
93
|
-
if (isStringAndMember(elements))
|
|
94
|
-
return ONE_LINE;
|
|
95
|
-
|
|
96
|
-
if (isStringAndIdentifier(elements))
|
|
97
|
-
return ONE_LINE;
|
|
98
|
-
|
|
99
|
-
if (isIdentifierAndString(elements))
|
|
100
|
-
return ONE_LINE;
|
|
101
|
-
|
|
102
|
-
if (isSimpleAndObject(elements))
|
|
103
|
-
return ONE_LINE;
|
|
104
|
-
|
|
105
89
|
if (isStringAndString(elements) && isParentIsArrayWithFirstArrayElement(path))
|
|
106
90
|
return ONE_LINE;
|
|
107
91
|
|
|
@@ -159,9 +143,7 @@ const isTwoSimplesInsideObjectProperty = (path) => {
|
|
|
159
143
|
return !isCoupleLines(path);
|
|
160
144
|
};
|
|
161
145
|
|
|
162
|
-
function isOneSimple(
|
|
163
|
-
const elements = path.get('elements');
|
|
164
|
-
|
|
146
|
+
function isOneSimple(elements) {
|
|
165
147
|
if (elements.length !== 1)
|
|
166
148
|
return false;
|
|
167
149
|
|
package/lib/tokenize/is.js
CHANGED
|
@@ -60,7 +60,14 @@ function isStringAndIdentifier([a, b]) {
|
|
|
60
60
|
return isStringLiteral(a) && isIdentifier(b);
|
|
61
61
|
}
|
|
62
62
|
|
|
63
|
-
module.exports.isIdentifierAndIdentifier = (
|
|
63
|
+
module.exports.isIdentifierAndIdentifier = (elements) => {
|
|
64
|
+
if (elements.length !== 2)
|
|
65
|
+
return false;
|
|
66
|
+
|
|
67
|
+
const [a, b] = elements;
|
|
68
|
+
|
|
69
|
+
return isIdentifier(a) && isIdentifier(b);
|
|
70
|
+
};
|
|
64
71
|
module.exports.isStringAndMember = ([a, b]) => isStringLiteral(a) && isMemberExpression(b);
|
|
65
72
|
module.exports.isIdentifierAndString = ([a, b]) => isIdentifier(a) && isStringLiteral(b);
|
|
66
73
|
module.exports.isStringAndArray = ([a, b]) => {
|
package/package.json
CHANGED