@putout/printer 2.42.1 → 2.44.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,15 @@
1
+ 2023.07.03, v2.44.0
2
+
3
+ feature:
4
+ - f02ef14 @putout/printer: DebuggerStatement: newline
5
+
6
+ 2023.07.03, v2.43.0
7
+
8
+ feature:
9
+ - 3362977 @putout/printer: tryStatement: newline
10
+ - 81004a0 @putout/printer: ClassDeclaration: spaces
11
+ - 869323a @putout/printer: ClassDeclaration: spaces
12
+
1
13
  2023.07.03, v2.42.1
2
14
 
3
15
  feature:
@@ -1,11 +1,10 @@
1
1
  'use strict';
2
2
 
3
- const {isNext} = require('../is');
4
- const {markAfter} = require('../mark');
5
- const {maybeDecorators} = require('../maybe-get');
3
+ const {isNext} = require('../../is');
4
+ const {markAfter} = require('../../mark');
5
+ const {maybeDecorators} = require('../../maybe-get');
6
6
 
7
7
  module.exports.ClassExpression = classVisitor;
8
- module.exports.ClassDeclaration = classVisitor;
9
8
 
10
9
  module.exports.StaticBlock = (path, {print, traverse}) => {
11
10
  print('static ');
@@ -33,7 +32,7 @@ module.exports.ClassDeclaration = (path, {print, indent, maybe, write, traverse}
33
32
 
34
33
  if (!path.parentPath.isExportDeclaration() && isNext(path)) {
35
34
  write.newline();
36
- write.newline();
35
+ maybe.write.newline(path.node.body.body.length);
37
36
  markAfter(path);
38
37
  }
39
38
  };
@@ -58,13 +57,14 @@ function classVisitor(path, {print, indent, maybe, traverse}) {
58
57
  }
59
58
 
60
59
  if (node.superClass) {
61
- maybe.print.space(path.node.id);
60
+ maybe.print(path.isStatement(), ' ');
62
61
  print('extends ');
63
62
  print('__superClass');
64
63
  }
65
64
 
66
- print(' {');
67
- print.newline();
65
+ print.space();
66
+ print('{');
67
+ maybe.print.newline(path.node.body.body.length);
68
68
  indent.inc();
69
69
 
70
70
  const body = path.get('body.body');
@@ -75,6 +75,6 @@ function classVisitor(path, {print, indent, maybe, traverse}) {
75
75
  }
76
76
 
77
77
  indent.dec();
78
- indent();
78
+ maybe.indent(body.length);
79
79
  print('}');
80
80
  }
@@ -8,7 +8,7 @@ const {
8
8
  ClassExpression,
9
9
  ClassDeclaration,
10
10
  StaticBlock,
11
- } = require('./class');
11
+ } = require('./class/class');
12
12
 
13
13
  const {
14
14
  CallExpression,
@@ -1,7 +1,20 @@
1
1
  'use strict';
2
2
 
3
- module.exports.DebuggerStatement = (path, {print, indent}) => {
4
- indent();
5
- print('debugger;');
6
- print.newline();
3
+ const {isNext} = require('../is');
4
+ const isInsideBlock = (path) => path.parentPath.isBlockStatement();
5
+ const isInsideIf = (path) => path.parentPath.isIfStatement();
6
+
7
+ module.exports.DebuggerStatement = {
8
+ print(path, {print, indent}) {
9
+ indent();
10
+ print('debugger;');
11
+ },
12
+ afterSatisfy: () => [
13
+ isNext,
14
+ isInsideBlock,
15
+ isInsideIf,
16
+ ],
17
+ after(path, {print}) {
18
+ print.newline();
19
+ },
7
20
  };
@@ -2,22 +2,27 @@
2
2
 
3
3
  const {isNext} = require('../is');
4
4
 
5
- module.exports.TryStatement = (path, {print, maybe}) => {
6
- const finalizer = path.get('finalizer');
7
- print.indent();
8
- print('try ');
9
- print('__block');
10
- print('__handler');
11
-
12
- if (finalizer.node) {
13
- print(' ');
14
- print('finally');
15
- print(' ');
16
- print(finalizer);
17
- }
18
-
19
- print.newline();
20
- maybe.print.breakline(isNext(path));
5
+ module.exports.TryStatement = {
6
+ print(path, {print}) {
7
+ const finalizer = path.get('finalizer');
8
+ print.indent();
9
+ print('try ');
10
+ print('__block');
11
+ print('__handler');
12
+
13
+ if (finalizer.node) {
14
+ print(' ');
15
+ print('finally');
16
+ print(' ');
17
+ print(finalizer);
18
+ print.newline();
19
+ }
20
+ },
21
+ afterSatisfy: () => [isNext],
22
+ after(path, {maybe, print}) {
23
+ maybe.print.newline(!path.node.finalizer);
24
+ print.breakline();
25
+ },
21
26
  };
22
27
 
23
28
  module.exports.CatchClause = (path, {print}) => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@putout/printer",
3
- "version": "2.42.1",
3
+ "version": "2.44.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",