@putout/printer 17.9.0 → 17.10.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,9 @@
1
+ 2026.03.03, v17.10.0
2
+
3
+ feature:
4
+ - 76458a6 @putout/printer: IfStatement: trailing comments: improve support
5
+ - 8eebdfb @putout/printer: IfStatement: trailing comments
6
+
1
7
  2026.02.22, v17.9.0
2
8
 
3
9
  feature:
@@ -311,4 +311,3 @@ const createAddToken = (tokens) => {
311
311
  tokens.push(token);
312
312
  };
313
313
  };
314
-
@@ -0,0 +1,21 @@
1
+ import {types} from '@putout/babel';
2
+
3
+ const {isBlockStatement} = types;
4
+
5
+ export const printTrailingCommentBlock = (path, printer, semantics, {printComment}) => {
6
+ const {print} = printer;
7
+ print.breakline();
8
+ printComment();
9
+ };
10
+
11
+ export const printTrailingCommentLine = (path, printer, semantics, {printComment}) => {
12
+ const {consequent} = path.node;
13
+ const consequentIsBlock = isBlockStatement(consequent);
14
+ const {print, maybe} = printer;
15
+
16
+ print.indent();
17
+ maybe.print.space(!consequentIsBlock);
18
+
19
+ printComment();
20
+ maybe.print.newline(consequentIsBlock);
21
+ };
@@ -5,6 +5,10 @@ import {
5
5
  isInsideIf,
6
6
  } from '#is';
7
7
  import {markAfter} from '../../mark.js';
8
+ import {
9
+ printTrailingCommentBlock,
10
+ printTrailingCommentLine,
11
+ } from './if-statement-comments.js';
8
12
 
9
13
  const {
10
14
  isBlockStatement,
@@ -56,6 +60,8 @@ const isLastEmptyInsideBody = (path) => {
56
60
  };
57
61
 
58
62
  export const IfStatement = {
63
+ printTrailingCommentBlock,
64
+ printTrailingCommentLine,
59
65
  print: (path, {indent, print, maybe, write, traverse}) => {
60
66
  const {parentPath} = path;
61
67
  const partOfAlternate = parentPath.get('alternate');
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@putout/printer",
3
- "version": "17.9.0",
3
+ "version": "17.10.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",