@putout/printer 1.83.0 → 1.84.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.05.08, v1.84.0
2
+
3
+ feature:
4
+ - 5770f6d @putout/printer: add support of couple VariableDeclarators inside VariableDeclaration
5
+
6
+ 2023.05.08, v1.83.1
7
+
8
+ fix:
9
+ - ddff9e0 description
10
+
1
11
  2023.05.08, v1.83.0
2
12
 
3
13
  feature:
@@ -19,26 +19,36 @@ module.exports.VariableDeclaration = {
19
19
  before(path, {print}) {
20
20
  print.breakline();
21
21
  },
22
- print(path, {maybe, print, store, write}) {
22
+ print(path, {maybe, store, write, traverse}) {
23
23
  maybe.indent(isParentBlock(path));
24
- print(`${path.node.kind} `);
25
- print('__declarations.0.id');
24
+ write(`${path.node.kind} `);
26
25
 
27
- const initPath = path.get('declarations.0.init');
26
+ const declarations = path.get('declarations');
27
+ const n = declarations.length - 1;
28
28
 
29
- if (exists(initPath)) {
30
- write.space();
31
- write('=');
32
- write.space();
29
+ for (const [index, declaration] of declarations.entries()) {
30
+ const id = declaration.get('id');
31
+ const init = declaration.get('init');
32
+
33
+ traverse(id);
34
+
35
+ if (exists(init)) {
36
+ const notLast = index < n;
37
+ write.space();
38
+ write('=');
39
+ write.space();
40
+ traverse(init);
41
+ maybe.write(notLast, ',');
42
+ maybe.write.space(notLast);
43
+ }
33
44
  }
34
45
 
35
- print('__declarations.0.init');
36
- maybe.print(isParentBlock(path), ';');
46
+ maybe.write(isParentBlock(path), ';');
37
47
 
38
48
  let wasNewline = false;
39
49
 
40
50
  if (isParentBlock(path) && isNext(path) && (noTrailingComment(path) || isNewlineBetweenSiblings(path))) {
41
- print.newline();
51
+ write.newline();
42
52
  wasNewline = true;
43
53
  }
44
54
 
package/package.json CHANGED
@@ -1,9 +1,9 @@
1
1
  {
2
2
  "name": "@putout/printer",
3
- "version": "1.83.0",
3
+ "version": "1.84.0",
4
4
  "type": "commonjs",
5
5
  "author": "coderaiser <mnemonic.enemy@gmail.com> (https://github.com/coderaiser)",
6
- "description": "Simplest possible opinionated Babel AST printer fro 🐊Putout",
6
+ "description": "Simplest possible opinionated Babel AST printer for 🐊Putout",
7
7
  "homepage": "https://github.com/putoutjs/printer#readme",
8
8
  "main": "./lib/printer.js",
9
9
  "exports": {