@putout/printer 14.3.1 → 14.3.3

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
+ 2025.03.28, v14.3.3
2
+
3
+ feature:
4
+ - 385615c @putout/printer: IfStatement: newline after
5
+
6
+ 2025.03.28, v14.3.2
7
+
8
+ feature:
9
+ - 9319338 @putout/printer: ArrayExpression: nested triple
10
+
1
11
  2025.03.28, v14.3.1
2
12
 
3
13
  feature:
@@ -31,12 +31,14 @@ function isArrayInsideArray(path) {
31
31
 
32
32
  const parentElements = path.parentPath.node.elements;
33
33
  const parentHasArrays = parentElements.filter(isArrayExpression).length;
34
- const lastIsArray = !isArrayExpression(parentElements.at(-1));
34
+ const lastNotArray = !isArrayExpression(parentElements.at(-1));
35
35
 
36
- if (parentHasArrays && lastIsArray)
36
+ if (parentHasArrays && lastNotArray)
37
37
  return false;
38
38
 
39
- return parentElements.length <= 3;
39
+ const {length} = parentElements;
40
+
41
+ return length <= 3 && length !== 1;
40
42
  }
41
43
 
42
44
  const isTwoLongStrings = ([a, b]) => {
@@ -166,4 +166,3 @@ function isNextCallWithLeadingComment(path) {
166
166
 
167
167
  return isCallExpression(expression);
168
168
  }
169
-
@@ -12,10 +12,10 @@ const {
12
12
  const {
13
13
  isBlockStatement,
14
14
  isFunctionDeclaration,
15
- isExpressionStatement,
15
+ isStatement,
16
16
  } = types;
17
17
 
18
- const isInside = ({parentPath}) => !parentPath.parentPath.isProgram();
18
+ const isTopLevel = ({parentPath}) => parentPath.parentPath.isProgram();
19
19
  const isEmptyConsequent = (path) => path.get('consequent').isEmptyStatement();
20
20
 
21
21
  const isInsideNestedBody = ({parentPath}) => {
@@ -106,7 +106,7 @@ module.exports.IfStatement = {
106
106
 
107
107
  const nextPath = path.parentPath.getNextSibling();
108
108
 
109
- if (path === partOfAlternate && isInside(path) && !isExpressionStatement(nextPath))
109
+ if (path === partOfAlternate && !isTopLevel(path) && !isStatement(nextPath))
110
110
  print.newline();
111
111
 
112
112
  if (isLastEmptyInsideBody(path))
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@putout/printer",
3
- "version": "14.3.1",
3
+ "version": "14.3.3",
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",