@putout/printer 1.14.0 → 1.14.1

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,11 @@
1
+ 2023.03.30, v1.14.1
2
+
3
+ fix:
4
+ - 1a117af @putout/printer: duplicate comment
5
+
6
+ feature:
7
+ - 260d680 @putout/printer: add support of getters
8
+
1
9
  2023.03.30, v1.14.0
2
10
 
3
11
  feature:
package/README.md CHANGED
@@ -24,7 +24,6 @@ const ast = parse('const a = (b, c) => {const d = 5; return a;}');
24
24
 
25
25
  print(ast);
26
26
 
27
- // returns
28
27
  // returns
29
28
  `
30
29
  const a = (b, c) => {
@@ -32,7 +31,6 @@ const a = (b, c) => {
32
31
  return a;
33
32
  };
34
33
  `;
35
-
36
34
  ```
37
35
 
38
36
  ## Overrides
@@ -62,10 +60,8 @@ print(ast, {
62
60
  },
63
61
  });
64
62
 
65
- // returns
66
63
  // returns
67
64
  'const {a /* [hello world] */= 5} = b;\n';
68
-
69
65
  ```
70
66
 
71
67
  ## License
@@ -1,7 +1,13 @@
1
1
  'use strict';
2
2
 
3
- const {isFirst} = require('./is');
4
- const {markBefore} = require('./mark');
3
+ const {
4
+ isFirst,
5
+ isNext,
6
+ } = require('./is');
7
+ const {
8
+ markBefore,
9
+ hasPrevNewline,
10
+ } = require('./mark');
5
11
 
6
12
  module.exports.parseLeadingComments = (path, {print, indent}) => {
7
13
  const {leadingComments} = path.node;
@@ -41,6 +47,9 @@ module.exports.parseTrailingComments = (path, {print}) => {
41
47
  if (!trailingComments || !trailingComments.length)
42
48
  return;
43
49
 
50
+ if (isNext(path))
51
+ return;
52
+
44
53
  for (const {type, value} of trailingComments) {
45
54
  if (type === 'CommentLine') {
46
55
  print.space();
@@ -52,5 +61,5 @@ module.exports.parseTrailingComments = (path, {print}) => {
52
61
  };
53
62
 
54
63
  function shouldAddNewlineBefore(path) {
55
- return path.isStatement() && !isFirst(path);
64
+ return path.isStatement() && !isFirst(path) && !hasPrevNewline(path);
56
65
  }
@@ -51,6 +51,11 @@ function ArrowFunctionExpression(path, {print, maybe}) {
51
51
  print('__body');
52
52
  }
53
53
  module.exports.ObjectMethod = (path, {print}) => {
54
+ const {kind} = path.node;
55
+
56
+ if (kind !== 'method')
57
+ print(`${kind} `);
58
+
54
59
  print('__key');
55
60
  print('(');
56
61
 
@@ -1,7 +1,6 @@
1
1
  'use strict';
2
2
 
3
3
  const {isCoupleLines} = require('../is');
4
-
5
4
  const isBodyOfArrow = (path) => path.parentPath.node.body === path.node;
6
5
  const isLogical = (path) => path.get('argument').isLogicalExpression();
7
6
 
@@ -90,4 +89,3 @@ function isOneLine(path) {
90
89
 
91
90
  return isForOf(path);
92
91
  }
93
-
@@ -44,6 +44,7 @@ function unaryExpression(path, {print, maybe}) {
44
44
  maybe.print(isWord(
45
45
  operator,
46
46
  ), ' ');
47
+
47
48
  print('__argument');
48
49
 
49
50
  if (!prefix)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@putout/printer",
3
- "version": "1.14.0",
3
+ "version": "1.14.1",
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",