@putout/printer 1.52.2 → 1.52.4
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.17, v1.52.4
|
|
2
|
+
|
|
3
|
+
fix:
|
|
4
|
+
- cda4b9e @putout/printer: newline when VariableDeclaration inside of ExportDeclaration
|
|
5
|
+
|
|
6
|
+
2023.04.17, v1.52.3
|
|
7
|
+
|
|
8
|
+
fix:
|
|
9
|
+
- f316738 @putout/printer: no newline after VariableDeclaration inside ExportDeclaration
|
|
10
|
+
|
|
1
11
|
2023.04.17, v1.52.2
|
|
2
12
|
|
|
3
13
|
feature:
|
|
@@ -11,6 +11,8 @@ const {
|
|
|
11
11
|
markAfter,
|
|
12
12
|
} = require('../mark');
|
|
13
13
|
|
|
14
|
+
const {isExportDeclaration} = require('@babel/types');
|
|
15
|
+
|
|
14
16
|
const isParentBlock = (path) => /Program|BlockStatement|Export/.test(path.parentPath.type);
|
|
15
17
|
|
|
16
18
|
module.exports.VariableDeclaration = {
|
|
@@ -46,8 +48,19 @@ module.exports.VariableDeclaration = {
|
|
|
46
48
|
},
|
|
47
49
|
};
|
|
48
50
|
|
|
51
|
+
function noNextParentBlock(path) {
|
|
52
|
+
return !isNext(path) && path.parentPath.isBlockStatement();
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
function notLastParentExport(path) {
|
|
56
|
+
if (isLast(path.parentPath))
|
|
57
|
+
return false;
|
|
58
|
+
|
|
59
|
+
return path.parentPath.isExportDeclaration();
|
|
60
|
+
}
|
|
61
|
+
|
|
49
62
|
function shouldAddNewlineAfter(path) {
|
|
50
|
-
if (
|
|
63
|
+
if (noNextParentBlock(path))
|
|
51
64
|
return true;
|
|
52
65
|
|
|
53
66
|
if (isLast(path))
|
|
@@ -71,9 +84,12 @@ function shouldAddNewlineAfter(path) {
|
|
|
71
84
|
if (isNewlineBetweenStatements(path))
|
|
72
85
|
return true;
|
|
73
86
|
|
|
87
|
+
if (notLastParentExport(path))
|
|
88
|
+
return true;
|
|
89
|
+
|
|
74
90
|
return false;
|
|
75
91
|
}
|
|
76
|
-
const isLast = (path) => path.parentPath
|
|
92
|
+
const isLast = (path) => path.parentPath?.isProgram() && !isNext(path);
|
|
77
93
|
|
|
78
94
|
function shouldAddNewlineBefore(path) {
|
|
79
95
|
if (isFirst(path))
|
|
@@ -90,8 +106,10 @@ function shouldAddNewlineBefore(path) {
|
|
|
90
106
|
if (prevPath.isStatement() && !prevPath.isExpressionStatement() && !prevPath.isBlockStatement())
|
|
91
107
|
return false;
|
|
92
108
|
|
|
93
|
-
if (isCoupleLines(path))
|
|
109
|
+
if (!isExportDeclaration(path.parentPath) && isCoupleLines(path))
|
|
94
110
|
return true;
|
|
111
|
+
|
|
112
|
+
return false;
|
|
95
113
|
}
|
|
96
114
|
|
|
97
115
|
function isFirst(path) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@putout/printer",
|
|
3
|
-
"version": "1.52.
|
|
3
|
+
"version": "1.52.4",
|
|
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",
|