@putout/printer 1.52.4 → 1.54.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,10 +1,22 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
3
|
+
const {isObjectPattern} = require('@babel/types');
|
|
4
|
+
|
|
5
|
+
module.exports.AssignmentExpression = {
|
|
6
|
+
condition: (path) => isObjectPattern(path.node.left),
|
|
7
|
+
before(path, {write}) {
|
|
8
|
+
write('(');
|
|
9
|
+
},
|
|
10
|
+
print(path, {print}) {
|
|
11
|
+
const {operator} = path.node;
|
|
12
|
+
print('__left');
|
|
13
|
+
print(' ');
|
|
14
|
+
print(operator);
|
|
15
|
+
print(' ');
|
|
16
|
+
print('__right');
|
|
17
|
+
},
|
|
18
|
+
after(path, {write}) {
|
|
19
|
+
write(')');
|
|
20
|
+
},
|
|
10
21
|
};
|
|
22
|
+
|
|
@@ -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);
|
|
@@ -49,7 +57,10 @@ module.exports.VariableDeclaration = {
|
|
|
49
57
|
};
|
|
50
58
|
|
|
51
59
|
function noNextParentBlock(path) {
|
|
52
|
-
|
|
60
|
+
if (isNext(path))
|
|
61
|
+
return false;
|
|
62
|
+
|
|
63
|
+
return path.parentPath.isBlockStatement();
|
|
53
64
|
}
|
|
54
65
|
|
|
55
66
|
function notLastParentExport(path) {
|
|
@@ -59,35 +70,24 @@ function notLastParentExport(path) {
|
|
|
59
70
|
return path.parentPath.isExportDeclaration();
|
|
60
71
|
}
|
|
61
72
|
|
|
62
|
-
function
|
|
63
|
-
if (noNextParentBlock(path))
|
|
64
|
-
return true;
|
|
65
|
-
|
|
73
|
+
function notLastCoupleLines(path) {
|
|
66
74
|
if (isLast(path))
|
|
67
75
|
return false;
|
|
68
76
|
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
return true;
|
|
74
|
-
|
|
75
|
-
const next = path.getNextSibling();
|
|
77
|
+
return isCoupleLines(path);
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
function notLastPrevVarNotNextVar(path) {
|
|
76
81
|
const prev = path.getPrevSibling();
|
|
82
|
+
const next = path.getNextSibling();
|
|
77
83
|
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
if (isNewlineBetweenStatements(path))
|
|
85
|
-
return true;
|
|
86
|
-
|
|
87
|
-
if (notLastParentExport(path))
|
|
88
|
-
return true;
|
|
84
|
+
return !isLast(path) && prev.isVariableDeclaration() && !next.isVariableDeclaration();
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
function isNextCoupleLines(path) {
|
|
88
|
+
const next = path.getNextSibling();
|
|
89
89
|
|
|
90
|
-
return
|
|
90
|
+
return isCoupleLines(next);
|
|
91
91
|
}
|
|
92
92
|
const isLast = (path) => path.parentPath?.isProgram() && !isNext(path);
|
|
93
93
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@putout/printer",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.54.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",
|