@putout/printer 18.50.4 → 18.50.6

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.11.17, v18.50.6
2
+
3
+ fix:
4
+ - 2b3dae97 ArrayPattern: comma after RestElement
5
+
6
+ 2026.11.14, v18.50.5
7
+
8
+ fix:
9
+ - b3a154c9 @putout/printer: NewExpression: multiline concatenation argument
10
+
1
11
  2026.11.14, v18.50.4
2
12
 
3
13
  fix:
@@ -20,7 +20,7 @@ export const ArrayPattern = maybeTypeAnnotation((path, {indent, maybe, print}, s
20
20
  print(element);
21
21
 
22
22
  if (isNewLine) {
23
- print(',\n');
23
+ print(element.isRestElement() ? '\n' : ',\n');
24
24
  } else if (index < n) {
25
25
  print(',');
26
26
  print.space();
@@ -3,6 +3,7 @@ import {createTypeChecker} from '#type-checker';
3
3
  const isInsideBinary = createTypeChecker([
4
4
  '+: parentPath -> BinaryExpression',
5
5
  '+: parentPath -> CallExpression',
6
+ '+: parentPath -> NewExpression',
6
7
  ]);
7
8
 
8
9
  export const maybeInsideBinary = (fn) => (path, printer, semantics) => {
@@ -9,7 +9,7 @@ const isObjectInsideArrow = createTypeChecker([
9
9
  ]);
10
10
 
11
11
  const isComputed = ({node}) => node.computed;
12
- const isIntegerObject = ({node}) => /^\d+$/.test(node.object.extra?.raw);
12
+ const isIntegerObject = ({node}) => /^\d+$/.test(node.object.raw);
13
13
 
14
14
  const isIntegerLiteral = createTypeChecker([
15
15
  ['-', isComputed],
@@ -1,5 +1,6 @@
1
1
  import {types} from '@putout/babel';
2
2
  import {maybeParens} from '#maybe-parens';
3
+ import {isConcatenation} from '#is-concatenation';
3
4
 
4
5
  const {
5
6
  isMemberExpression,
@@ -7,6 +8,7 @@ const {
7
8
  } = types;
8
9
 
9
10
  const isInsideMember = ({parentPath}) => isMemberExpression(parentPath);
11
+ const isMultiline = (path) => path.get('arguments').some(isConcatenation);
10
12
 
11
13
  export const NewExpression = maybeParens({
12
14
  print(path, printer, semantics) {
@@ -23,10 +25,30 @@ export const NewExpression = maybeParens({
23
25
  maybePrintOpenBrace(path, printer, semantics);
24
26
 
25
27
  const n = args.length - 1;
28
+ const multiline = isMultiline(path);
29
+
30
+ if (multiline)
31
+ printer.indent.inc();
26
32
 
27
33
  for (const [i, arg] of args.entries()) {
34
+ maybe.print.breakline(multiline);
28
35
  print(arg);
29
- maybe.print(i < n, ', ');
36
+
37
+ if (multiline) {
38
+ print(',');
39
+ continue;
40
+ }
41
+
42
+ if (i === n)
43
+ continue;
44
+
45
+ print(',');
46
+ print.space();
47
+ }
48
+
49
+ if (multiline) {
50
+ printer.indent.dec();
51
+ print.breakline();
30
52
  }
31
53
 
32
54
  maybePrintCloseBrace(path, printer, semantics);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@putout/printer",
3
- "version": "18.50.4",
3
+ "version": "18.50.6",
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",