@putout/printer 18.37.2 → 18.38.1

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.07.16, v18.38.1
2
+
3
+ fix:
4
+ - d0db3655 @putout/printer: jsx: CallExpression
5
+
6
+ 2026.07.15, v18.38.0
7
+
8
+ feature:
9
+ - 9965a02b @putout/printer: jsx: inside call
10
+
1
11
  2026.07.14, v18.37.2
2
12
 
3
13
  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
  ]);
@@ -21,6 +21,11 @@ const {
21
21
 
22
22
  const isInsideArrow = ({parentPath}) => isArrowFunctionExpression(parentPath);
23
23
 
24
+ const isInsideCallWithOneArg = createTypeChecker([
25
+ ['-: parentPath -> !CallExpression'],
26
+ ['+: parentPath.node.arguments.length', '=', 1],
27
+ ]);
28
+
24
29
  export const JSXElement = {
25
30
  condition,
26
31
  before(path, {write, indent, maybe}) {
@@ -37,14 +42,17 @@ export const JSXElement = {
37
42
  },
38
43
  print(path, {print, traverse, maybe}) {
39
44
  const needIndent = isNeedIndent(path);
45
+ const parentCall = isInsideCallWithOneArg(path);
46
+
40
47
  maybe.indent.inc(needIndent);
48
+ maybe.print.breakline(parentCall);
41
49
 
42
50
  print('__openingElement');
43
51
  path.get('children').map(traverse);
44
-
45
52
  print('__closingElement');
46
53
 
47
54
  maybe.indent.dec(needIndent);
55
+ maybe.print.breakline(parentCall);
48
56
  },
49
57
  after(path, {write, indent, maybe}) {
50
58
  const {leadingComments} = path.node;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@putout/printer",
3
- "version": "18.37.2",
3
+ "version": "18.38.1",
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",