@putout/printer 18.10.0 → 18.12.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.12.0
2
+
3
+ feature:
4
+ - 4e38b16a ArrayExpression: indent
5
+
6
+ 2026.04.15, v18.11.0
7
+
8
+ feature:
9
+ - 43aeb75b @putout/printer: ArrayExpression: indent
10
+
1
11
  2026.04.14, v18.10.0
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,18 @@ 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 isAllStrings = (path) => {
32
+ const stringsCount = path.node.elements.filter(isStringLiteral).length;
33
+ return path.node.elements.length === stringsCount;
34
+ };
35
+
36
+ const isTwoLongStringsInsideArray = createTypeChecker([
37
+ ['-: parentPath.parentPath -> ObjectProperty'],
38
+ ['-: node.elements.0 -> !StringLiteral'],
39
+ ['-: parentPath -> !ArrayExpression'],
40
+ ['-: parentPath.node.elements.length', '=', 2],
41
+ ['+', isAllStrings],
42
+ ]);
30
43
 
31
44
  const isInsideCallLoop = createTypeChecker([
32
45
  ['-: -> !', isInsideCall],
@@ -78,6 +91,7 @@ export const isIndentElement = createTypeChecker([
78
91
  ]);
79
92
 
80
93
  export const isNeedIndent = createTypeChecker([
94
+ ['+', isTwoLongStringsInsideArray],
81
95
  ['-: -> !', isIndentElement],
82
96
  ['+: -> !', isIncreaseIndent],
83
97
  ]);
@@ -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.12.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",