@putout/printer 18.9.3 → 18.11.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
+ 2026.04.15, v18.11.0
2
+
3
+ feature:
4
+ - 43aeb75b @putout/printer: ArrayExpression: indent
5
+
6
+ 2026.04.14, v18.10.0
7
+
8
+ feature:
9
+ - 85c0371d @putout/printer: ArrayExpression: long-lines
10
+
1
11
  2026.04.03, v18.9.3
2
12
 
3
13
  feature:
@@ -10,6 +10,14 @@ import {
10
10
  isNeedsToHideIndentOption,
11
11
  } from './is.js';
12
12
 
13
+ const {
14
+ isStringLiteral,
15
+ isArrayExpression,
16
+ isObjectExpression,
17
+ isTemplateLiteral,
18
+ isBooleanLiteral,
19
+ } = types;
20
+
13
21
  const isTwoLongStrings = (path) => {
14
22
  const [a, b] = path.node.elements;
15
23
  const LONG_STRING = 20;
@@ -20,13 +28,11 @@ const isTwoLongStrings = (path) => {
20
28
  return a.value.length > LONG_STRING;
21
29
  };
22
30
 
23
- const {
24
- isStringLiteral,
25
- isArrayExpression,
26
- isObjectExpression,
27
- isTemplateLiteral,
28
- isBooleanLiteral,
29
- } = types;
31
+ const isTwoLongStringsInsideArray = createTypeChecker([
32
+ ['-: parentPath -> !ArrayExpression'],
33
+ ['-: parentPath.node.elements.0 -> StringLiteral'],
34
+ ['+', isTwoLongStrings],
35
+ ]);
30
36
 
31
37
  const isInsideCallLoop = createTypeChecker([
32
38
  ['-: -> !', isInsideCall],
@@ -78,6 +84,7 @@ export const isIndentElement = createTypeChecker([
78
84
  ]);
79
85
 
80
86
  export const isNeedIndent = createTypeChecker([
87
+ ['+', isTwoLongStringsInsideArray],
81
88
  ['-: -> !', isIndentElement],
82
89
  ['+: -> !', isIncreaseIndent],
83
90
  ]);
@@ -128,3 +135,4 @@ export function maybeAdditionalIndent(path, printer, semantics, options) {
128
135
  maybe.indent.inc(needsToHideIndent);
129
136
  }
130
137
  }
138
+
@@ -148,6 +148,18 @@ const isMoreThenMaxLiteralLength = (path, {maxElementLengthInOneLine}) => {
148
148
  return false;
149
149
  };
150
150
 
151
+ const isTripleMoreThenMaxLiteralLength = (path, {maxElementLengthInOneLine}) => {
152
+ const {elements} = path.node;
153
+ const max = maxElementLengthInOneLine * 3;
154
+
155
+ for (const element of elements.filter(isStringLiteral)) {
156
+ if (element.value.length >= max)
157
+ return true;
158
+ }
159
+
160
+ return false;
161
+ };
162
+
151
163
  const isMoreThenMaxIdentifierLength = (path, {maxElementLengthInOneLine}) => {
152
164
  const [first] = path.node.elements;
153
165
 
@@ -166,6 +178,7 @@ const hasObjects = (path) => {
166
178
 
167
179
  const isMoreThenMaxElementLengthInOneLine = createTypeChecker([
168
180
  ['-: node.elements.length', '<', 2],
181
+ ['+', isTripleMoreThenMaxLiteralLength],
169
182
  ['-: -> !', isInsideCall],
170
183
  ['-', hasObjects],
171
184
  ['+', isMoreThenMaxLiteralLength],
@@ -8,7 +8,11 @@ import {shouldAddNewlineAfter} from './block-statement-newline.js';
8
8
 
9
9
  const isInsideArrayTupleOfThree = createTypeChecker([
10
10
  ['-: parentPath.parentPath -> !ArrayExpression'],
11
- ['+: parentPath.parentPath.node.elements.length', '=', 3],
11
+ [
12
+ '+: parentPath.parentPath.node.elements.length',
13
+ '=',
14
+ 3,
15
+ ],
12
16
  ]);
13
17
 
14
18
  const hasDirectives = (a) => getDirectives(a).length;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@putout/printer",
3
- "version": "18.9.3",
3
+ "version": "18.11.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",