@putout/printer 18.50.3 → 18.50.5

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,16 @@
1
+ 2026.11.14, v18.50.5
2
+
3
+ fix:
4
+ - b3a154c9 @putout/printer: NewExpression: multiline concatenation argument
5
+
6
+ 2026.11.14, v18.50.4
7
+
8
+ fix:
9
+ - 0674b591 @putout/printer: MetaProperty: new.target printed as import.meta (#7)
10
+ - 288335cb @putout/printer: ObjectPattern: crash on AssignmentPattern with pattern on the left (#7)
11
+ - 31b5f48e @putout/printer: MemberExpression: parens lost around integer literal (#7)
12
+ - 91630591 @putout/printer: ArrayExpression: trailing hole dropped (#7)
13
+
1
14
  2026.11.14, v18.50.3
2
15
 
3
16
  fix:
@@ -3,6 +3,7 @@ import {createTypeChecker} from '#type-checker';
3
3
  import {callWithNext} from '#is';
4
4
  import {isBreaklineBeforeClosingSquareBrace} from './breakline.js';
5
5
  import {
6
+ isLastHole,
6
7
  isLastOption,
7
8
  isMultilineOption,
8
9
  isNeedsIndentBeforeElementOption,
@@ -18,6 +19,7 @@ const isCommaAfterElementByOption = createTypeChecker([
18
19
  ]);
19
20
 
20
21
  export const isCommaAfterElement = createTypeChecker([
22
+ ['+', isLastHole],
21
23
  ['+', isCommaAfterElementByOption],
22
24
  ['+', isBreaklineBeforeClosingSquareBrace],
23
25
  ]);
@@ -9,6 +9,8 @@ export const isMultilineOption = (a, {multiline}) => multiline;
9
9
  export const isNeedsToHideIndentOption = (a, {needsToHideIndent}) => needsToHideIndent;
10
10
  export const isLastOption = (a, {isLast}) => isLast;
11
11
 
12
+ export const isLastHole = (path, {isLast}) => isLast && !path.node.elements.at(-1);
13
+
12
14
  export const isTrailingCommaOption = (a, {trailingComma}) => trailingComma;
13
15
  export const isNeedsIndentBeforeElementOption = (a, {needsIndentBeforeElement}) => needsIndentBeforeElement;
14
16
 
@@ -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) => {
@@ -8,6 +8,15 @@ const isObjectInsideArrow = createTypeChecker([
8
8
  '+: parentPath -> ArrowFunctionExpression',
9
9
  ]);
10
10
 
11
+ const isComputed = ({node}) => node.computed;
12
+ const isIntegerObject = ({node}) => /^\d+$/.test(node.object.raw);
13
+
14
+ const isIntegerLiteral = createTypeChecker([
15
+ ['-', isComputed],
16
+ ['-: node.object -> !NumericLiteral'],
17
+ ['+', isIntegerObject],
18
+ ]);
19
+
11
20
  export const MemberExpression = maybeParens({
12
21
  condition: isObjectInsideArrow,
13
22
  print: (path, printer) => {
@@ -23,7 +32,11 @@ export const MemberExpression = maybeParens({
23
32
  const {computed} = path.node;
24
33
  const isChain = isLooksLikeChain(path);
25
34
 
35
+ const needsParens = isIntegerLiteral(path);
36
+
37
+ maybe.print(needsParens, '(');
26
38
  traverse(object);
39
+ maybe.print(needsParens, ')');
27
40
 
28
41
  if (computed)
29
42
  return maybePrintComputed(path, property, printer);
@@ -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);
@@ -9,7 +9,10 @@ function getLength(left, right) {
9
9
  if (isIdentifier(left) && isIdentifier(right))
10
10
  return left.name.length + right.name.length;
11
11
 
12
- return left.name.length;
12
+ if (isIdentifier(left))
13
+ return left.name.length;
14
+
15
+ return 0;
13
16
  }
14
17
 
15
18
  export const isMoreThenMaxPropertiesLengthInOneLine = (path, {maxPropertiesLengthInOneLine}) => {
@@ -33,8 +33,10 @@ export const NullLiteral = (path, {write}) => {
33
33
  write('null');
34
34
  };
35
35
 
36
- export const MetaProperty = (path, {write}) => {
37
- write('import.meta');
36
+ export const MetaProperty = (path, {print}) => {
37
+ print('__meta');
38
+ print('.');
39
+ print('__property');
38
40
  };
39
41
 
40
42
  export const Super = (path, {write}) => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@putout/printer",
3
- "version": "18.50.3",
3
+ "version": "18.50.5",
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",