@putout/printer 14.5.1 → 14.6.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
+ 2025.04.29, v14.6.0
2
+
3
+ feature:
4
+ - 15f94af @putout/printer: FunctionExpression inside 3-elements ArrayExpression tuple
5
+
1
6
  2025.04.25, v14.5.1
2
7
 
3
8
  feature:
@@ -22,11 +22,22 @@ const {
22
22
  isExportDeclaration,
23
23
  isDoWhileStatement,
24
24
  isBlockStatement,
25
+ isArrayExpression,
25
26
  } = types;
26
27
 
27
28
  const isFirstStatement = (path) => path.node.body[0];
28
29
  const isFirstDirective = (path) => path.node.directives?.[0];
29
30
  const isMethodOrArrow = (path) => isArrowFunctionExpression(path) || isObjectMethod(path);
31
+ const isInsideArrayTupleOfThree = (path) => {
32
+ const {parentPath} = path.parentPath;
33
+
34
+ if (!isArrayExpression(parentPath))
35
+ return false;
36
+
37
+ const {length} = parentPath.node.elements;
38
+
39
+ return length === 3;
40
+ };
30
41
 
31
42
  const parentIfWithoutElse = ({parentPath}) => {
32
43
  if (!parentPath.isIfStatement())
@@ -50,7 +61,8 @@ module.exports.BlockStatement = {
50
61
  if (path.parentPath.isBlockStatement())
51
62
  indent();
52
63
 
53
- indent.inc();
64
+ const insideArray = isInsideArrayTupleOfThree(path);
65
+ maybe.indent.inc(!insideArray);
54
66
  write('{');
55
67
 
56
68
  if (isFirstStatement(path) || isFirstDirective(path))
@@ -71,8 +83,11 @@ module.exports.BlockStatement = {
71
83
 
72
84
  parseComments(path, printer, semantics);
73
85
 
74
- indent.dec();
86
+ maybe.indent.dec(!insideArray);
87
+
88
+ maybe.indent.dec(insideArray);
75
89
  maybe.indent(body.length);
90
+ maybe.indent.inc(insideArray);
76
91
  write('}');
77
92
 
78
93
  maybe.indent.dec(callInsideChain);
@@ -177,3 +192,4 @@ function isTry({parentPath}) {
177
192
 
178
193
  return parentPath.parentPath?.isTryStatement();
179
194
  }
195
+
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@putout/printer",
3
- "version": "14.5.1",
3
+ "version": "14.6.0",
4
4
  "type": "commonjs",
5
5
  "author": "coderaiser <mnemonic.enemy@gmail.com> (https://github.com/coderaiser)",
6
6
  "description": "Simplest possible opinionated Babel AST printer for 🐊Putout",