@putout/printer 1.52.4 → 1.53.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
|
@@ -39,7 +39,15 @@ module.exports.VariableDeclaration = {
|
|
|
39
39
|
|
|
40
40
|
store(wasNewline);
|
|
41
41
|
},
|
|
42
|
-
|
|
42
|
+
afterSatisfy: () => [
|
|
43
|
+
noNextParentBlock,
|
|
44
|
+
notLastCoupleLines,
|
|
45
|
+
isNextAssign,
|
|
46
|
+
isNextCoupleLines,
|
|
47
|
+
notLastPrevVarNotNextVar,
|
|
48
|
+
isNewlineBetweenStatements,
|
|
49
|
+
notLastParentExport,
|
|
50
|
+
],
|
|
43
51
|
after(path, {maybe, store}) {
|
|
44
52
|
const wasNewline = store();
|
|
45
53
|
maybe.print.linebreak(wasNewline);
|
|
@@ -59,36 +67,23 @@ function notLastParentExport(path) {
|
|
|
59
67
|
return path.parentPath.isExportDeclaration();
|
|
60
68
|
}
|
|
61
69
|
|
|
62
|
-
function
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
return false;
|
|
68
|
-
|
|
69
|
-
if (isCoupleLines(path))
|
|
70
|
-
return true;
|
|
71
|
-
|
|
72
|
-
if (isNextAssign(path))
|
|
73
|
-
return true;
|
|
74
|
-
|
|
75
|
-
const next = path.getNextSibling();
|
|
70
|
+
function notLastCoupleLines(path) {
|
|
71
|
+
return !isLast(path) && isCoupleLines(path);
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
function notLastPrevVarNotNextVar(path) {
|
|
76
75
|
const prev = path.getPrevSibling();
|
|
76
|
+
const next = path.getNextSibling();
|
|
77
77
|
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
if (isNewlineBetweenStatements(path))
|
|
85
|
-
return true;
|
|
86
|
-
|
|
87
|
-
if (notLastParentExport(path))
|
|
88
|
-
return true;
|
|
78
|
+
return !isLast(path) && prev.isVariableDeclaration() && !next.isVariableDeclaration();
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
function isNextCoupleLines(path) {
|
|
82
|
+
const next = path.getNextSibling();
|
|
89
83
|
|
|
90
|
-
return
|
|
84
|
+
return isCoupleLines(next);
|
|
91
85
|
}
|
|
86
|
+
|
|
92
87
|
const isLast = (path) => path.parentPath?.isProgram() && !isNext(path);
|
|
93
88
|
|
|
94
89
|
function shouldAddNewlineBefore(path) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@putout/printer",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.53.0",
|
|
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",
|