@putout/printer 8.47.0 → 8.48.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,8 @@
1
+ 2024.06.07, v8.48.0
2
+
3
+ feature:
4
+ - 715d6f3 @putout/printer: TryStatement: add support of format: space (#15)
5
+
1
6
  2024.06.06, v8.47.0
2
7
 
3
8
  feature:
@@ -8,6 +8,9 @@ module.exports.maybeSpaceAfterKeyword = (path, {print}, semantics) => {
8
8
 
9
9
  const {type} = argument;
10
10
 
11
+ if (type === 'SequenceExpression')
12
+ return print.space();
13
+
11
14
  if (type === 'StringLiteral' || type === 'TemplateLiteral')
12
15
  return print.space();
13
16
 
@@ -1,19 +1,20 @@
1
1
  'use strict';
2
2
 
3
- const {isNext} = require('../../is');
3
+ const {isNext, isParentLast} = require('../../is');
4
4
 
5
5
  module.exports.TryStatement = {
6
6
  print(path, {print}) {
7
7
  const finalizer = path.get('finalizer');
8
8
  print.indent();
9
- print('try ');
9
+ print('try');
10
+ print.space();
10
11
  print('__block');
11
12
  print('__handler');
12
13
 
13
14
  if (finalizer.node) {
14
- print(' ');
15
+ print.space();
15
16
  print('finally');
16
- print(' ');
17
+ print.space();
17
18
  print(finalizer);
18
19
  print.newline();
19
20
  }
@@ -25,18 +26,25 @@ module.exports.TryStatement = {
25
26
  },
26
27
  };
27
28
 
28
- module.exports.CatchClause = (path, {print}) => {
29
+ module.exports.CatchClause = (path, {print, maybe}) => {
29
30
  const param = path.get('param');
30
31
  const body = path.get('body');
31
32
 
32
- print(' ');
33
- print('catch ');
33
+ print.space();
34
+ print('catch');
35
+ print.space();
34
36
 
35
37
  if (param.node) {
36
38
  print('(');
37
39
  print(param);
38
- print(') ');
40
+ print(')');
41
+ print.space();
39
42
  }
40
43
 
41
44
  print(body);
45
+ maybe.print.newline(isInsideBlock(path));
42
46
  };
47
+
48
+ function isInsideBlock(path) {
49
+ return path.parentPath.parentPath.isBlockStatement();
50
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@putout/printer",
3
- "version": "8.47.0",
3
+ "version": "8.48.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",