@putout/printer 3.1.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,13 @@
1
+ 2023.08.10, v3.3.0
2
+
3
+ feature:
4
+ - e1396e3 DoWhileStatement: indent, newline
5
+
6
+ 2023.08.10, v3.2.0
7
+
8
+ feature:
9
+ - 130a43e ClassMethod: async
10
+
1
11
  2023.08.09, v3.1.0
2
12
 
3
13
  feature:
@@ -31,6 +31,11 @@ const ClassMethod = {
31
31
  print(' ');
32
32
  }
33
33
 
34
+ if (node.async) {
35
+ print('async');
36
+ print(' ');
37
+ }
38
+
34
39
  maybe.print(isConstructor, kind);
35
40
 
36
41
  if (isMethod) {
@@ -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.1.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",