@putout/printer 1.26.0 → 1.28.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
|
@@ -1,3 +1,13 @@
|
|
|
1
|
+
2023.04.07, v1.28.0
|
|
2
|
+
|
|
3
|
+
feature:
|
|
4
|
+
- dfa1863 @putout/printer: ObjectExpression: add support of object options passed as last argument of tests
|
|
5
|
+
|
|
6
|
+
2023.04.07, v1.27.0
|
|
7
|
+
|
|
8
|
+
feature:
|
|
9
|
+
- 6afc4de @putout/printer: ArrayExpression: add support of string, string tuple
|
|
10
|
+
|
|
1
11
|
2023.04.06, v1.26.0
|
|
2
12
|
|
|
3
13
|
feature:
|
|
@@ -16,6 +16,7 @@ const {
|
|
|
16
16
|
const isForOf = ({parentPath}) => parentPath.isForOfStatement();
|
|
17
17
|
const SECOND = 1;
|
|
18
18
|
const isStringAndArray = ([a, b]) => isStringLiteral(a) && isArrayExpression(b);
|
|
19
|
+
const isStringAndString = ([a, b]) => isStringLiteral(a) && isStringLiteral(b);
|
|
19
20
|
const isArrayParent = (path) => path.parentPath.isArrayExpression();
|
|
20
21
|
|
|
21
22
|
const isTwoLongStrings = ([a, b]) => {
|
|
@@ -58,6 +59,7 @@ module.exports.ArrayExpression = {
|
|
|
58
59
|
const isNewLine = isNewlineBetweenElements(path, {
|
|
59
60
|
elements,
|
|
60
61
|
});
|
|
62
|
+
|
|
61
63
|
const n = elements.length - 1;
|
|
62
64
|
|
|
63
65
|
maybe.print.newline(isNewLine && elements.length);
|
|
@@ -180,6 +182,9 @@ function isNewlineBetweenElements(path, {elements}) {
|
|
|
180
182
|
if (isStringAndIdentifier(elements))
|
|
181
183
|
return false;
|
|
182
184
|
|
|
185
|
+
if (isStringAndString(elements) && path.parentPath.isArrayExpression() && isArrayExpression(path.parentPath.node.elements[0]))
|
|
186
|
+
return false;
|
|
187
|
+
|
|
183
188
|
if (tooLong(path) || isCoupleLines(path) || !isNumbers(elements) && !isForOf(path) && isLastArg(path) && !isParentProperty(path))
|
|
184
189
|
return true;
|
|
185
190
|
|
|
@@ -197,6 +202,7 @@ function isTwoStringsDifferentLength(strings) {
|
|
|
197
202
|
|
|
198
203
|
const aLength = a
|
|
199
204
|
.node.value.length;
|
|
205
|
+
|
|
200
206
|
const bLength = b
|
|
201
207
|
.node.value.length;
|
|
202
208
|
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
const {isCoupleLines} = require('../is');
|
|
4
|
+
const {isFunction} = require('@babel/types');
|
|
4
5
|
|
|
5
6
|
const isBodyOfArrow = (path) => path
|
|
6
7
|
.parentPath.node.body === path.node;
|
|
@@ -104,6 +105,9 @@ function isOneLine(path) {
|
|
|
104
105
|
if (isIf(path))
|
|
105
106
|
return ONE_LINE;
|
|
106
107
|
|
|
108
|
+
if (path.parentPath.isCallExpression() && isFunction(path.parentPath.node.arguments[1]))
|
|
109
|
+
return ONE_LINE;
|
|
110
|
+
|
|
107
111
|
if (isCoupleLines(path))
|
|
108
112
|
return MANY_LINES;
|
|
109
113
|
|
|
@@ -119,3 +123,4 @@ function isParens(path) {
|
|
|
119
123
|
|
|
120
124
|
return false;
|
|
121
125
|
}
|
|
126
|
+
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@putout/printer",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.28.0",
|
|
4
4
|
"type": "commonjs",
|
|
5
5
|
"author": "coderaiser <mnemonic.enemy@gmail.com> (https://github.com/coderaiser)",
|
|
6
6
|
"description": "Easiest possible opinionated Babel AST printer made with ❤️ to use in 🐊Putout",
|