@putout/printer 18.52.5 → 18.52.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,8 @@
1
+ 2026.11.23, v18.52.6
2
+
3
+ fix:
4
+ - 99e2d3ed @putout/printer: loops: inside Function
5
+
1
6
  2026.11.22, v18.52.5
2
7
 
3
8
  feature:
@@ -231,3 +231,13 @@ export const isLastArgInCall = createTypeChecker([
231
231
  ['-: parentPath -> !CallExpression'],
232
232
  ['+', isPathLastArg],
233
233
  ]);
234
+
235
+ const hasBodyStatements = (path) => path.node.body.body.length;
236
+
237
+ export const isLastEmptyInBlock = createTypeChecker([
238
+ ['-', isNext],
239
+ ['-', hasBodyStatements],
240
+ ['+: parentPath -> BlockStatement'],
241
+ ['-: parentPath -> !LabeledStatement'],
242
+ ['+: parentPath.parentPath -> BlockStatement'],
243
+ ]);
@@ -1,5 +1,10 @@
1
- export const ForInStatement = (path, {print, indent}) => {
2
- indent();
1
+ import {
2
+ isInsideLabel,
3
+ isLastEmptyInBlock,
4
+ } from '#is';
5
+
6
+ export const ForInStatement = (path, {print, maybe}) => {
7
+ maybe.indent(!isInsideLabel(path));
3
8
  print('for');
4
9
  print.space();
5
10
  print('(');
@@ -12,4 +17,5 @@ export const ForInStatement = (path, {print, indent}) => {
12
17
  print.space();
13
18
 
14
19
  print('__body');
20
+ maybe.print.newline(isLastEmptyInBlock(path));
15
21
  };
@@ -1,9 +1,10 @@
1
+ import {markAfter} from '#mark';
1
2
  import {
2
3
  isInsideLabel,
3
4
  exists,
4
5
  callWithNext,
6
+ isLastEmptyInBlock,
5
7
  } from '#is';
6
- import {markAfter} from '#mark';
7
8
 
8
9
  export const ForStatement = {
9
10
  print(path, {print, maybe}) {
@@ -30,6 +31,7 @@ export const ForStatement = {
30
31
  if (body.body) {
31
32
  print.space();
32
33
  print('__body');
34
+ maybe.print.newline(isLastEmptyInBlock(path));
33
35
 
34
36
  return;
35
37
  }
@@ -1,4 +1,8 @@
1
- import {isInsideLabel, isNext} from '#is';
1
+ import {
2
+ isInsideLabel,
3
+ isNext,
4
+ isLastEmptyInBlock,
5
+ } from '#is';
2
6
  import {markAfter} from '#mark';
3
7
  import {
4
8
  printTrailingCommentBlock,
@@ -14,7 +18,7 @@ export const WhileStatement = {
14
18
  before: (path, {indent}) => {
15
19
  indent();
16
20
  },
17
- print(path, {print, indent}) {
21
+ print(path, {print, indent, maybe}) {
18
22
  print('while');
19
23
  print.space();
20
24
  print('(');
@@ -24,6 +28,7 @@ export const WhileStatement = {
24
28
  if (path.node.body.body) {
25
29
  print.space();
26
30
  print('__body');
31
+ maybe.print.newline(isLastEmptyInBlock(path));
27
32
 
28
33
  return;
29
34
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@putout/printer",
3
- "version": "18.52.5",
3
+ "version": "18.52.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",