@putout/printer 18.11.0 → 18.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 +13 -0
- package/lib/tokenize/expressions/array-expression/array-expression.js +0 -1
- package/lib/tokenize/expressions/array-expression/indent.js +9 -3
- package/lib/tokenize/expressions/array-expression/is.js +19 -0
- package/lib/tokenize/expressions/array-expression/newline.js +6 -1
- package/package.json +4 -4
package/ChangeLog
CHANGED
|
@@ -1,3 +1,16 @@
|
|
|
1
|
+
2026.05.22, v18.13.0
|
|
2
|
+
|
|
3
|
+
feature:
|
|
4
|
+
- 26783f0b @putout/printer: ArrayExpression: newline: strings and object
|
|
5
|
+
- e6d930c3 @putout/printer: supertape v13.2.0
|
|
6
|
+
- 15bd1f83 @putout/printer: montag v2.0.1
|
|
7
|
+
- 6a74d29a @putout/printer: @putout/plugin-promises v20.0.0
|
|
8
|
+
|
|
9
|
+
2026.04.15, v18.12.0
|
|
10
|
+
|
|
11
|
+
feature:
|
|
12
|
+
- 4e38b16a ArrayExpression: indent
|
|
13
|
+
|
|
1
14
|
2026.04.15, v18.11.0
|
|
2
15
|
|
|
3
16
|
feature:
|
|
@@ -28,10 +28,17 @@ const isTwoLongStrings = (path) => {
|
|
|
28
28
|
return a.value.length > LONG_STRING;
|
|
29
29
|
};
|
|
30
30
|
|
|
31
|
+
const isAllStrings = (path) => {
|
|
32
|
+
const stringsCount = path.node.elements.filter(isStringLiteral).length;
|
|
33
|
+
return path.node.elements.length === stringsCount;
|
|
34
|
+
};
|
|
35
|
+
|
|
31
36
|
const isTwoLongStringsInsideArray = createTypeChecker([
|
|
37
|
+
['-: parentPath.parentPath -> ObjectProperty'],
|
|
38
|
+
['-: node.elements.0 -> !StringLiteral'],
|
|
32
39
|
['-: parentPath -> !ArrayExpression'],
|
|
33
|
-
['-: parentPath.node.elements.
|
|
34
|
-
['+',
|
|
40
|
+
['-: parentPath.node.elements.length', '=', 2],
|
|
41
|
+
['+', isAllStrings],
|
|
35
42
|
]);
|
|
36
43
|
|
|
37
44
|
const isInsideCallLoop = createTypeChecker([
|
|
@@ -135,4 +142,3 @@ export function maybeAdditionalIndent(path, printer, semantics, options) {
|
|
|
135
142
|
maybe.indent.inc(needsToHideIndent);
|
|
136
143
|
}
|
|
137
144
|
}
|
|
138
|
-
|
|
@@ -1,6 +1,25 @@
|
|
|
1
|
+
import {types} from '@putout/babel';
|
|
2
|
+
|
|
3
|
+
const {
|
|
4
|
+
isStringLiteral,
|
|
5
|
+
isObjectExpression,
|
|
6
|
+
} = types;
|
|
7
|
+
|
|
1
8
|
export const isMultilineOption = (a, {multiline}) => multiline;
|
|
2
9
|
export const isNeedsToHideIndentOption = (a, {needsToHideIndent}) => needsToHideIndent;
|
|
3
10
|
export const isLastOption = (a, {isLast}) => isLast;
|
|
4
11
|
|
|
5
12
|
export const isTrailingCommaOption = (a, {trailingComma}) => trailingComma;
|
|
6
13
|
export const isNeedsIndentBeforeElementOption = (a, {needsIndentBeforeElement}) => needsIndentBeforeElement;
|
|
14
|
+
|
|
15
|
+
export const isStringsAndObject = (path) => {
|
|
16
|
+
const elements = path.get('elements');
|
|
17
|
+
|
|
18
|
+
if (!isObjectExpression(elements.at(-1)))
|
|
19
|
+
return false;
|
|
20
|
+
|
|
21
|
+
const strings = elements.filter(isStringLiteral);
|
|
22
|
+
|
|
23
|
+
return strings.length === elements.length - 1;
|
|
24
|
+
};
|
|
25
|
+
|
|
@@ -13,7 +13,10 @@ import {
|
|
|
13
13
|
isInsideArray,
|
|
14
14
|
} from '#is';
|
|
15
15
|
import {isIncreaseIndent} from './indent.js';
|
|
16
|
-
import {
|
|
16
|
+
import {
|
|
17
|
+
isMultilineOption,
|
|
18
|
+
isStringsAndObject,
|
|
19
|
+
} from './is.js';
|
|
17
20
|
|
|
18
21
|
const {
|
|
19
22
|
isObjectExpression,
|
|
@@ -253,6 +256,7 @@ const isMixedTuples = (path, {maxElementLengthInOneLine}) => {
|
|
|
253
256
|
|
|
254
257
|
export const isMultiLine = createTypeChecker([
|
|
255
258
|
['-: node.elements.length -> -'],
|
|
259
|
+
['-', isStringsAndObject],
|
|
256
260
|
['-', isTupleInsideArray],
|
|
257
261
|
['+', isMixedTuples],
|
|
258
262
|
['+', isBodyWithOneElement],
|
|
@@ -351,3 +355,4 @@ export const isIndentBeforeElement = createTypeChecker([
|
|
|
351
355
|
['+: -> SpreadElement'],
|
|
352
356
|
['+: -> !ObjectExpression'],
|
|
353
357
|
]);
|
|
358
|
+
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@putout/printer",
|
|
3
|
-
"version": "18.
|
|
3
|
+
"version": "18.13.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"author": "coderaiser <mnemonic.enemy@gmail.com> (https://github.com/coderaiser)",
|
|
6
6
|
"description": "Simplest possible opinionated Babel AST printer for 🐊Putout",
|
|
@@ -81,7 +81,7 @@
|
|
|
81
81
|
"@putout/eslint-flat": "^4.0.0",
|
|
82
82
|
"@putout/plugin-minify": "^12.0.0",
|
|
83
83
|
"@putout/plugin-printer": "^8.0.0",
|
|
84
|
-
"@putout/plugin-promises": "^
|
|
84
|
+
"@putout/plugin-promises": "^20.0.0",
|
|
85
85
|
"@putout/plugin-react-hook-form": "^6.0.0",
|
|
86
86
|
"@putout/plugin-react-hooks": "^9.0.0",
|
|
87
87
|
"@supertape/operator-strip": "^1.0.0",
|
|
@@ -95,13 +95,13 @@
|
|
|
95
95
|
"goldstein": "^7.0.0",
|
|
96
96
|
"just-kebab-case": "^4.2.0",
|
|
97
97
|
"madrun": "^13.0.0",
|
|
98
|
-
"montag": "^
|
|
98
|
+
"montag": "^2.0.1",
|
|
99
99
|
"nodemon": "^3.0.1",
|
|
100
100
|
"putout": "^42.0.1",
|
|
101
101
|
"redlint": "^6.0.0",
|
|
102
102
|
"samadhi": "^4.0.2",
|
|
103
103
|
"superc8": "^12.2.4",
|
|
104
|
-
"supertape": "^
|
|
104
|
+
"supertape": "^13.2.0",
|
|
105
105
|
"try-catch": "^4.0.6",
|
|
106
106
|
"typescript": "^6.0.2"
|
|
107
107
|
},
|