@putout/printer 1.6.3 → 1.6.5

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.03.21, v1.6.5
2
+
3
+ feature:
4
+ - 18dbd76 @putout/printer: improve intergration with recast: consistent newline befor EOF
5
+
6
+ 2023.03.21, v1.6.4
7
+
8
+ feature:
9
+ - aa1590c @putout/printer: add support of ForStatement
10
+
1
11
  2023.03.20, v1.6.3
2
12
 
3
13
  feature:
package/README.md CHANGED
@@ -60,7 +60,7 @@ print(ast, {
60
60
  });
61
61
 
62
62
  // returns
63
- 'const {a /* [hello world] */= 5} = b;\n';
63
+ 'const {a /* [hello world] */= 5} = b;\n\n';
64
64
  ```
65
65
 
66
66
  ## License
@@ -0,0 +1,36 @@
1
+ 'use strict';
2
+
3
+ module.exports.ForStatement = (path, {print, maybe, indent}) => {
4
+ const {
5
+ test,
6
+ update,
7
+ body,
8
+ } = path.node;
9
+
10
+ print('for (');
11
+ print('__init');
12
+ print(';');
13
+ maybe.print(test, ' ');
14
+ print('__test');
15
+ print(';');
16
+ maybe.print(update, ' ');
17
+ print('__update');
18
+ print(')');
19
+
20
+ if (body.body) {
21
+ print(' ');
22
+ print('__body');
23
+ print.newline();
24
+
25
+ return;
26
+ }
27
+
28
+ if (!body.body) {
29
+ print.newline();
30
+ indent.inc();
31
+ print('__body');
32
+ indent.dec();
33
+ print.newline();
34
+ }
35
+ };
36
+
@@ -8,12 +8,14 @@ const {BlockStatement} = require('./block-statement');
8
8
  const {ReturnStatement} = require('./return-statement');
9
9
  const TryStatements = require('./try-statements');
10
10
  const {DebuggerStatement} = require('./debugger-statement');
11
+ const {ForStatement} = require('./for-statement');
11
12
 
12
13
  module.exports = {
13
14
  BlockStatement,
14
15
  ExpressionStatement,
15
16
  VariableDeclaration,
16
17
  IfStatement,
18
+ ForStatement,
17
19
  ForOfStatement,
18
20
  ReturnStatement,
19
21
  DebuggerStatement,
@@ -34,6 +34,9 @@ module.exports.VariableDeclaration = (path, {maybe, print}) => {
34
34
  print.linebreak();
35
35
  markAfter(path);
36
36
  }
37
+
38
+ if (path.parentPath.isProgram() && !isNext(path))
39
+ print.linebreak();
37
40
  };
38
41
 
39
42
  function shouldAddNewLine(path) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@putout/printer",
3
- "version": "1.6.3",
3
+ "version": "1.6.5",
4
4
  "type": "commonjs",
5
5
  "author": "coderaiser <mnemonic.enemy@gmail.com> (https://github.com/coderaiser)",
6
6
  "description": "Easiest possible opinionated Babel AST printer made with ❤️ to use in 🐊Putout",