@putout/printer 1.92.0 → 1.92.2

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.05.10, v1.92.2
2
+
3
+ feature:
4
+ - e2f6ca0 @putout/printer: VariableDeclaration: couple VariableDeclarators without init
5
+
6
+ 2023.05.10, v1.92.1
7
+
8
+ feature:
9
+ - d6c9e2a @putout/printer: add support of comments inside ObjectExpression
10
+
1
11
  2023.05.10, v1.92.0
2
12
 
3
13
  feature:
@@ -12,13 +12,14 @@ const {
12
12
  } = require('../is');
13
13
 
14
14
  const {isFunction} = require('@babel/types');
15
+ const {parseComments} = require('../comments');
15
16
 
16
17
  const isBodyOfArrow = (path) => path.parentPath.node.body === path.node;
17
18
  const isLogical = (path) => path.get('argument').isLogicalExpression();
18
19
  const isValue = (path) => path.get('properties.0.value').node;
19
20
  const isParentExpression = (path) => path.parentPath.isExpressionStatement();
20
21
 
21
- module.exports.ObjectExpression = (path, {print, maybe, indent}) => {
22
+ module.exports.ObjectExpression = (path, {print, maybe, indent, write}) => {
22
23
  indent.inc();
23
24
 
24
25
  const properties = path.get('properties');
@@ -28,6 +29,9 @@ module.exports.ObjectExpression = (path, {print, maybe, indent}) => {
28
29
 
29
30
  maybe.print(parens, '(');
30
31
  print('{');
32
+ parseComments(path, {
33
+ write,
34
+ });
31
35
  maybe.print.newline(manyLines);
32
36
 
33
37
  for (const property of properties) {
@@ -9,6 +9,7 @@ const {
9
9
  markAfter,
10
10
  isMarkedAfter,
11
11
  } = require('../../mark');
12
+
12
13
  const {isExportNamespaceSpecifier} = require('@babel/types');
13
14
 
14
15
  const isDeclarationNewline = (path) => isMarkedAfter(path.get('declaration'));
@@ -110,4 +111,3 @@ module.exports.ExportNamedDeclaration = {
110
111
  markAfter(path);
111
112
  },
112
113
  };
113
-
@@ -30,18 +30,19 @@ module.exports.VariableDeclaration = {
30
30
  for (const [index, declaration] of declarations.entries()) {
31
31
  const id = declaration.get('id');
32
32
  const init = declaration.get('init');
33
+ const notLast = index < n;
33
34
 
34
35
  traverse(id);
35
36
 
36
37
  if (exists(init)) {
37
- const notLast = index < n;
38
38
  write.space();
39
39
  write('=');
40
40
  write.space();
41
41
  traverse(init);
42
- maybe.write(notLast, ',');
43
- maybe.write.space(notLast);
44
42
  }
43
+
44
+ maybe.write(notLast, ',');
45
+ maybe.write.space(notLast);
45
46
  }
46
47
 
47
48
  maybe.write(isParentBlock(path), ';');
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@putout/printer",
3
- "version": "1.92.0",
3
+ "version": "1.92.2",
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",