@putout/printer 18.2.7 → 18.2.8

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.03.08, v18.2.8
2
+
3
+ feature:
4
+ - 39d5af8 @putout/printer: ArrayExpression: isNeedIndent
5
+
1
6
  2026.03.08, v18.2.7
2
7
 
3
8
  feature:
@@ -15,12 +15,11 @@ import {
15
15
  isCurrentNewLine,
16
16
  isMultiLine,
17
17
  } from './newline.js';
18
+ import {isObjectAfterSimple} from './is-object-after-simple.js';
18
19
  import {
19
20
  isArrayInsideArray,
20
- isIncreaseIndent,
21
- isIndentElement,
21
+ isNeedIndent,
22
22
  } from './indent.js';
23
- import {isObjectAfterSimple} from './is-object-after-simple.js';
24
23
  import {
25
24
  beforeIf,
26
25
  isInsideOneElementArray,
@@ -89,13 +88,12 @@ export const ArrayExpression = {
89
88
  } = semantics;
90
89
 
91
90
  const elements = path.get('elements');
92
- const shouldIncreaseIndent = !isIncreaseIndent(path);
93
91
 
94
92
  print('[');
95
93
 
96
- const indented = isIndentElement(path);
94
+ const needIndent = isNeedIndent(path);
97
95
 
98
- maybe.indent.inc(indented && shouldIncreaseIndent);
96
+ maybe.indent.inc(needIndent);
99
97
 
100
98
  const needsNewline = isMultiLine(path, {
101
99
  maxElementsInOneLine,
@@ -132,7 +130,7 @@ export const ArrayExpression = {
132
130
  }
133
131
  }
134
132
 
135
- maybe.indent.dec(indented && shouldIncreaseIndent);
133
+ maybe.indent.dec(needIndent);
136
134
 
137
135
  const parentElements = path.parentPath.get('elements');
138
136
 
@@ -53,13 +53,6 @@ const isObjectAfterString = (path) => {
53
53
  return isTemplateLiteral(first);
54
54
  };
55
55
 
56
- export const isIndentElement = createTypeChecker([
57
- ['-', isArrayInsideArray],
58
- ['-', isObjectAfterString],
59
- ['+: -> !', isTwoLongStrings],
60
- ['+: -> !', isInsideArray],
61
- ]);
62
-
63
56
  export const isIncreaseIndent = createTypeChecker([
64
57
  ['-: node.elements.length -> !', Boolean],
65
58
  ['+', isBooleanAndObject],
@@ -69,6 +62,18 @@ export const isIncreaseIndent = createTypeChecker([
69
62
  ['+', isStringAndObject],
70
63
  ]);
71
64
 
65
+ export const isIndentElement = createTypeChecker([
66
+ ['-', isArrayInsideArray],
67
+ ['-', isObjectAfterString],
68
+ ['+: -> !', isTwoLongStrings],
69
+ ['+: -> !', isInsideArray],
70
+ ]);
71
+
72
+ export const isNeedIndent = createTypeChecker([
73
+ ['-: -> !', isIndentElement],
74
+ ['+: -> !', isIncreaseIndent],
75
+ ]);
76
+
72
77
  export function isArrayInsideArray(path) {
73
78
  if (!path.isArrayExpression() || !path.parentPath.isArrayExpression())
74
79
  return false;
@@ -84,4 +89,3 @@ export function isArrayInsideArray(path) {
84
89
 
85
90
  return length <= 3 && length !== 1;
86
91
  }
87
-
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@putout/printer",
3
- "version": "18.2.7",
3
+ "version": "18.2.8",
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",