@putout/printer 3.2.0 → 3.3.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
+ 2023.08.10, v3.3.0
2
+
3
+ feature:
4
+ - e1396e3 DoWhileStatement: indent, newline
5
+
1
6
  2023.08.10, v3.2.0
2
7
 
3
8
  feature:
@@ -65,6 +65,9 @@ module.exports.BlockStatement = {
65
65
  function shouldAddNewlineAfter(path) {
66
66
  const {parentPath} = path;
67
67
 
68
+ if (parentPath.isDoWhileStatement())
69
+ return false;
70
+
68
71
  if (parentPath.isBlockStatement())
69
72
  return true;
70
73
 
@@ -1,12 +1,22 @@
1
1
  'use strict';
2
2
 
3
- module.exports.DoWhileStatement = (path, {print}) => {
4
- print('do');
5
- print.space();
6
- print('__body');
7
- print.space();
8
- print('while ');
9
- print('(');
10
- print('__test');
11
- print(')');
3
+ const {isLast} = require('../is');
4
+ const notLast = (path) => !isLast(path);
5
+
6
+ module.exports.DoWhileStatement = {
7
+ print(path, {print, indent}) {
8
+ indent();
9
+ print('do');
10
+ print.space();
11
+ print('__body');
12
+ print.space();
13
+ print('while ');
14
+ print('(');
15
+ print('__test');
16
+ print(')');
17
+ },
18
+ afterSatisfy: () => [notLast],
19
+ after(path, {print}) {
20
+ print.newline();
21
+ },
12
22
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@putout/printer",
3
- "version": "3.2.0",
3
+ "version": "3.3.0",
4
4
  "type": "commonjs",
5
5
  "author": "coderaiser <mnemonic.enemy@gmail.com> (https://github.com/coderaiser)",
6
6
  "description": "Simplest possible opinionated Babel AST printer for 🐊Putout",