@putout/printer 2.46.0 → 2.47.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.07.05, v2.47.0
2
+
3
+ feature:
4
+ - dc0ba73 @putout/printer: Program: improve support of inner comments
5
+
1
6
  2023.07.04, v2.46.0
2
7
 
3
8
  feature:
@@ -3,9 +3,9 @@
3
3
  const {
4
4
  hasTrailingComment,
5
5
  isLast,
6
- } = require('./is');
6
+ } = require('../is');
7
7
 
8
- const {markBefore} = require('./mark');
8
+ const {markBefore} = require('../mark');
9
9
  const {isVariableDeclarator} = require('@babel/types');
10
10
 
11
11
  module.exports.parseLeadingComments = (path, {print, maybe, indent}, semantics) => {
@@ -99,6 +99,13 @@ module.exports.parseComments = (path, {write}, semantics) => {
99
99
  write('//');
100
100
  write(value);
101
101
  write.newline();
102
+ continue;
103
+ }
104
+
105
+ if (type === 'CommentBlock') {
106
+ write('/*');
107
+ write(value);
108
+ write('*/');
102
109
  }
103
110
  }
104
111
  };
@@ -11,7 +11,7 @@ const {
11
11
  exists,
12
12
  } = require('../../is');
13
13
 
14
- const {parseComments} = require('../../comments');
14
+ const {parseComments} = require('../../comments/comments');
15
15
  const {isSpreadElement} = require('@babel/types');
16
16
 
17
17
  const isBodyOfArrow = (path) => path.parentPath.node.body === path.node;
@@ -71,4 +71,3 @@ module.exports = {
71
71
  write('super');
72
72
  },
73
73
  };
74
-
@@ -13,7 +13,7 @@ const {
13
13
  } = require('@babel/types');
14
14
 
15
15
  const {markAfter} = require('../../mark');
16
- const {parseComments} = require('../../comments');
16
+ const {parseComments} = require('../../comments/comments');
17
17
  const {insideIfWithNoBody} = require('./inside-if-with-no-body');
18
18
 
19
19
  const isFirstStatement = (path) => path.node.body[0];
@@ -19,6 +19,7 @@ const {ForInStatement} = require('./for-in-statement');
19
19
  const {ExportDefaultDeclaration} = require('./export-declaration/export-default-declaration');
20
20
  const {BreakStatement} = require('./break-statement');
21
21
  const {DoWhileStatement} = require('./do-while-statement');
22
+ const {Program} = require('./program');
22
23
 
23
24
  const {
24
25
  ExportNamespaceSpecifier,
@@ -48,15 +49,7 @@ module.exports = {
48
49
  print.space();
49
50
  print('__body');
50
51
  },
51
- Program(path, {print}) {
52
- print('__interpreter');
53
-
54
- path
55
- .get('body')
56
- .forEach(print);
57
-
58
- print.newline();
59
- },
52
+ Program,
60
53
  EmptyStatement(path, {write}) {
61
54
  write(';');
62
55
  },
@@ -0,0 +1,14 @@
1
+ 'use strict';
2
+
3
+ const {parseComments} = require('../comments/comments');
4
+ module.exports.Program = (path, {print, write}, semantics) => {
5
+ print('__interpreter');
6
+ parseComments(path, {write}, semantics);
7
+
8
+ path
9
+ .get('body')
10
+ .forEach(print);
11
+
12
+ print.newline();
13
+ };
14
+
@@ -13,7 +13,7 @@ const {isExportDeclaration} = require('@babel/types');
13
13
  const {maybeSpaceAfterKeyword} = require('./maybe-space-after-keyword');
14
14
 
15
15
  const {isConcatenation} = require('../../expressions/binary-expression/concatanate');
16
- const {parseLeadingComments} = require('../../comments');
16
+ const {parseLeadingComments} = require('../../comments/comments');
17
17
 
18
18
  const isParentBlock = (path) => /Program|BlockStatement|Export/.test(path.parentPath.type);
19
19
  const isInsideBlock = (path) => /^(Program|BlockStatement)$/.test(path.parentPath.type);
@@ -27,7 +27,7 @@ const {
27
27
  const {
28
28
  parseLeadingComments,
29
29
  parseTrailingComments,
30
- } = require('./comments');
30
+ } = require('./comments/comments');
31
31
 
32
32
  const {parseOverrides} = require('./overrides');
33
33
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@putout/printer",
3
- "version": "2.46.0",
3
+ "version": "2.47.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",