@putout/printer 1.18.0 → 1.18.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.04.02, v1.18.2
2
+
3
+ feature:
4
+ - dfbe134 @putout/printer: ArrayExpression tuple: improve support
5
+
6
+ 2023.04.02, v1.18.1
7
+
8
+ feature:
9
+ - 37db57c @putout/printer: drop usless newlines after ImportDeclaration
10
+
1
11
  2023.04.02, v1.18.0
2
12
 
3
13
  feature:
@@ -3,8 +3,12 @@
3
3
  module.exports.ClassExpression = classVisitor;
4
4
  module.exports.ClassDeclaration = classVisitor;
5
5
 
6
- function classVisitor(path, {print, indent}) {
6
+ module.exports.ClassDeclaration = (path, {print, indent}) => {
7
7
  indent();
8
+ classVisitor(path, {print, indent});
9
+ };
10
+
11
+ function classVisitor(path, {print, indent}) {
8
12
  print('class ');
9
13
  print('__id');
10
14
  print('__typeParameters');
@@ -16,7 +20,13 @@ function classVisitor(path, {print, indent}) {
16
20
  path.get('implements').forEach(print);
17
21
  }
18
22
 
19
- print(' {\n');
23
+ if (node.superClass) {
24
+ print('extends ');
25
+ print('__superClass');
26
+ }
27
+
28
+ print(' {');
29
+ print.newline();
20
30
  indent.inc();
21
31
 
22
32
  const body = path.get('body.body');
@@ -27,5 +37,6 @@ function classVisitor(path, {print, indent}) {
27
37
  }
28
38
 
29
39
  indent.dec();
40
+ indent();
30
41
  print('}');
31
42
  }
@@ -3,7 +3,7 @@
3
3
  const {hasPrevNewline} = require('../mark');
4
4
  const isFirst = (path) => !path.getPrevSibling().node;
5
5
 
6
- module.exports.FunctionExpression = (path, {print, maybe}) => {
6
+ module.exports.FunctionExpression = (path, {print, maybe, write, traverse}) => {
7
7
  const {node} = path;
8
8
 
9
9
  const {
@@ -14,7 +14,16 @@ module.exports.FunctionExpression = (path, {print, maybe}) => {
14
14
  maybe.print(async, 'async ');
15
15
  print('function');
16
16
  maybe.print(generator, '*');
17
- print(' (');
17
+
18
+ const id = path.get('id');
19
+
20
+ write.space();
21
+
22
+ if (id.node) {
23
+ traverse(id);
24
+ }
25
+
26
+ print('(');
18
27
 
19
28
  const params = path.get('params');
20
29
  const n = params.length;
@@ -1,6 +1,7 @@
1
1
  'use strict';
2
2
 
3
3
  const {markAfter} = require('../mark');
4
+ const {isLast} = require('../is');
4
5
 
5
6
  module.exports.ImportDeclaration = {
6
7
  print(path, {print, maybe}) {
@@ -35,17 +36,21 @@ module.exports.ImportDeclaration = {
35
36
 
36
37
  print('__source');
37
38
  print(';');
38
- print.newline();
39
+
40
+ if (!isLast(path))
41
+ print.newline();
42
+ },
43
+ afterIf(path) {
44
+ if (isLast(path))
45
+ return false;
46
+
47
+ if (path.getNextSibling().isImportDeclaration())
48
+ return false;
49
+
50
+ return true;
39
51
  },
40
- afterIf: shouldAddNewlineAfter,
41
52
  after(path, {print}) {
42
53
  print.newline();
43
54
  markAfter(path);
44
55
  },
45
56
  };
46
- function shouldAddNewlineAfter(path) {
47
- if (path.getNextSibling().isImportDeclaration())
48
- return false;
49
-
50
- return true;
51
- }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@putout/printer",
3
- "version": "1.18.0",
3
+ "version": "1.18.2",
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",