@putout/printer 18.10.0 → 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,8 @@
1
+ 2026.04.15, v18.11.0
2
+
3
+ feature:
4
+ - 43aeb75b @putout/printer: ArrayExpression: indent
5
+
1
6
  2026.04.14, v18.10.0
2
7
 
3
8
  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
+
@@ -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.10.0",
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",