@putout/printer 1.52.2 → 1.52.3

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
+ 2023.04.17, v1.52.3
2
+
3
+ fix:
4
+ - f316738 @putout/printer: no newline after VariableDeclaration inside ExportDeclaration
5
+
1
6
  2023.04.17, v1.52.2
2
7
 
3
8
  feature:
@@ -7,7 +7,6 @@ const {
7
7
  isParentLast,
8
8
  isNewlineBetweenStatements,
9
9
  satisfy,
10
-
11
10
  } = require('../is');
12
11
 
13
12
  const shouldBreakline = satisfy([
@@ -46,8 +46,19 @@ module.exports.VariableDeclaration = {
46
46
  },
47
47
  };
48
48
 
49
+ function noNextParentBlock(path) {
50
+ return !isNext(path) && path.parentPath.isBlockStatement();
51
+ }
52
+
53
+ function notLastParentExport(path) {
54
+ if (isLast(path.parentPath))
55
+ return false;
56
+
57
+ return path.parentPath.isExportDeclaration();
58
+ }
59
+
49
60
  function shouldAddNewlineAfter(path) {
50
- if (!isNext(path) && path.parentPath.isBlockStatement())
61
+ if (noNextParentBlock(path))
51
62
  return true;
52
63
 
53
64
  if (isLast(path))
@@ -71,9 +82,12 @@ function shouldAddNewlineAfter(path) {
71
82
  if (isNewlineBetweenStatements(path))
72
83
  return true;
73
84
 
85
+ if (notLastParentExport(path))
86
+ return true;
87
+
74
88
  return false;
75
89
  }
76
- const isLast = (path) => path.parentPath.isProgram() && !isNext(path);
90
+ const isLast = (path) => path.parentPath?.isProgram() && !isNext(path);
77
91
 
78
92
  function shouldAddNewlineBefore(path) {
79
93
  if (isFirst(path))
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@putout/printer",
3
- "version": "1.52.2",
3
+ "version": "1.52.3",
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",