@putout/printer 18.37.2 → 18.38.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.07.15, v18.38.0
2
+
3
+ feature:
4
+ - 9965a02b @putout/printer: jsx: inside call
5
+
1
6
  2026.07.14, v18.37.2
2
7
 
3
8
  feature:
@@ -20,6 +20,12 @@ export const chain = (path) => {
20
20
  ];
21
21
  };
22
22
 
23
+ function isPartOfSameChain(current) {
24
+ const {operator} = current.node;
25
+
26
+ return operator === '||' || operator === '&&';
27
+ }
28
+
23
29
  function down(current) {
24
30
  let count = 0;
25
31
 
@@ -32,9 +38,7 @@ function down(current) {
32
38
 
33
39
  current = current.get('left');
34
40
 
35
- const {operator} = current.node;
36
-
37
- if (operator !== '||' && operator !== '&&')
41
+ if (!isPartOfSameChain(current))
38
42
  break;
39
43
  } while (current.isLogicalExpression());
40
44
 
@@ -6,6 +6,7 @@ const {isFunction} = types;
6
6
  export const isNeedIndent = createTypeChecker([
7
7
  ['-', hasComplexAttribute],
8
8
  ['+: parentPath -> JSXElement'],
9
+ ['+: parentPath -> CallExpression'],
9
10
  ['-: parentPath.parentPath -> !CallExpression'],
10
11
  ['+: parentPath -> ArrowFunctionExpression'],
11
12
  ]);
@@ -17,6 +17,7 @@ const condition = createTypeChecker([
17
17
  const {
18
18
  isJSXElement,
19
19
  isArrowFunctionExpression,
20
+ isCallExpression,
20
21
  } = types;
21
22
 
22
23
  const isInsideArrow = ({parentPath}) => isArrowFunctionExpression(parentPath);
@@ -36,15 +37,19 @@ export const JSXElement = {
36
37
  }
37
38
  },
38
39
  print(path, {print, traverse, maybe}) {
40
+ const {parentPath} = path;
39
41
  const needIndent = isNeedIndent(path);
42
+ const parentCall = isCallExpression(parentPath);
43
+
40
44
  maybe.indent.inc(needIndent);
45
+ maybe.print.breakline(parentCall);
41
46
 
42
47
  print('__openingElement');
43
48
  path.get('children').map(traverse);
44
-
45
49
  print('__closingElement');
46
50
 
47
51
  maybe.indent.dec(needIndent);
52
+ maybe.print.breakline(parentCall);
48
53
  },
49
54
  after(path, {write, indent, maybe}) {
50
55
  const {leadingComments} = path.node;
@@ -61,3 +66,4 @@ export const JSXElement = {
61
66
  maybe.write(!leadingComments?.length, ')');
62
67
  },
63
68
  };
69
+
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@putout/printer",
3
- "version": "18.37.2",
3
+ "version": "18.38.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",