@putout/printer 18.34.0 → 18.35.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.12, v18.35.0
2
+
3
+ feature:
4
+ - 30405c11 @putout/printer: AssignmentExpression inside ExpressionStatement: trailing comment line
5
+
1
6
  2026.07.11, v18.34.0
2
7
 
3
8
  feature:
@@ -96,11 +96,13 @@ export const printTrailingComments = (path, printer, semantics, {currentTraverse
96
96
  continue;
97
97
  }
98
98
 
99
- isCommentBlock(comment);
100
-
101
- printTrailingCommentBlock?.(path, printer, semantics, {
102
- index,
103
- printComment: createPrintCommentBlock(print, value),
104
- });
99
+ if (isCommentBlock(comment))
100
+ printTrailingCommentBlock?.(path, printer, semantics, {
101
+ index,
102
+ printComment: createPrintCommentBlock(print, value),
103
+ isLast: index === n,
104
+ isSameLine: isSameLine(path, loc),
105
+ });
105
106
  }
106
107
  };
108
+
@@ -10,10 +10,12 @@ import {
10
10
  maybeInsideReturnWithCommentEnd,
11
11
  maybeInsideReturnWithCommentStart,
12
12
  printLeadingCommentBlock,
13
- } from './assignment-expression-comments.js';
13
+ } from './comments.js';
14
14
 
15
15
  export const AssignmentExpression = maybeParens({
16
16
  checkParens: false,
17
+ printLeadingCommentLine,
18
+ printLeadingCommentBlock,
17
19
  condition,
18
20
  print(path, printer) {
19
21
  const {print} = printer;
@@ -35,6 +37,3 @@ export const AssignmentExpression = maybeParens({
35
37
  maybeInsideReturnWithCommentEnd(path, printer);
36
38
  },
37
39
  });
38
-
39
- AssignmentExpression.printLeadingCommentLine = printLeadingCommentLine;
40
- AssignmentExpression.printLeadingCommentBlock = printLeadingCommentBlock;
@@ -20,8 +20,9 @@ const maybeParensPrint = (print) => ({
20
20
  },
21
21
  });
22
22
 
23
- const maybeParensCondition = ({print, condition, checkParens = true}) => ({
23
+ const maybeParensCondition = ({print, condition, checkParens = true, ...rest}) => ({
24
24
  ...maybeParensPrint(print),
25
+ ...rest,
25
26
  condition: (path, print, semantics) => {
26
27
  const is = condition?.(path, print, semantics);
27
28
 
@@ -67,11 +67,12 @@ export const printLeadingCommentBlock = (path, printer, semantics, {printComment
67
67
  printComment();
68
68
  };
69
69
 
70
- export const printTrailingCommentBlock = (path, printer, semantics, {printComment}) => {
71
- const {print} = printer;
70
+ export const printTrailingCommentBlock = (path, printer, semantics, {printComment, isSameLine}) => {
71
+ const {maybe, print} = printer;
72
72
 
73
73
  if (isNext(path))
74
74
  print.breakline();
75
75
 
76
+ maybe.print.space(isSameLine);
76
77
  printComment();
77
78
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@putout/printer",
3
- "version": "18.34.0",
3
+ "version": "18.35.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",