@putout/printer 1.77.0 → 1.78.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
package/README.md
CHANGED
|
@@ -81,13 +81,13 @@ print(ast, {
|
|
|
81
81
|
},
|
|
82
82
|
visitors: {
|
|
83
83
|
AssignmentPattern(path, {print}) {
|
|
84
|
-
print('
|
|
84
|
+
print('/* [hello world] */= ');
|
|
85
85
|
print('__right');
|
|
86
86
|
},
|
|
87
87
|
},
|
|
88
88
|
});
|
|
89
89
|
// returns
|
|
90
|
-
'const {
|
|
90
|
+
'const {/* [hello world] */= 5} = b;\n';
|
|
91
91
|
```
|
|
92
92
|
|
|
93
93
|
### `print`
|
|
@@ -103,7 +103,7 @@ print(ast, {
|
|
|
103
103
|
visitors: {
|
|
104
104
|
AssignmentPattern(path, {print, maybe}) {
|
|
105
105
|
maybe.print.newline(path.parentPath.isCallExpression());
|
|
106
|
-
print('
|
|
106
|
+
print('/* [hello world] */= ');
|
|
107
107
|
print('__right');
|
|
108
108
|
},
|
|
109
109
|
},
|
|
@@ -2,21 +2,21 @@
|
|
|
2
2
|
|
|
3
3
|
const isArg = (path) => path.parentPath.isFunction();
|
|
4
4
|
|
|
5
|
-
module.exports.AssignmentPattern =
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
5
|
+
module.exports.AssignmentPattern = {
|
|
6
|
+
print(path, {print, maybe}) {
|
|
7
|
+
maybe.print(shouldPrint(path), '__left');
|
|
8
|
+
print(' = ');
|
|
9
|
+
print('__right');
|
|
10
|
+
},
|
|
9
11
|
};
|
|
10
12
|
|
|
11
13
|
function shouldPrint(path) {
|
|
12
|
-
if (path.parentPath.isObjectProperty()
|
|
14
|
+
if (path.parentPath.isObjectProperty())
|
|
13
15
|
return true;
|
|
14
16
|
|
|
15
17
|
if (isArg(path))
|
|
16
18
|
return true;
|
|
17
19
|
|
|
18
|
-
|
|
19
|
-
return true;
|
|
20
|
-
|
|
21
|
-
return false;
|
|
20
|
+
return path.parentPath.isArrayPattern();
|
|
22
21
|
}
|
|
22
|
+
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
const {isIdentifier} = require('@babel/types');
|
|
4
|
-
const {isForOf} = require('../is');
|
|
4
|
+
const {isForOf, isCoupleLines} = require('../is');
|
|
5
5
|
|
|
6
6
|
module.exports.ObjectPattern = (path, {indent, print, maybe}) => {
|
|
7
7
|
indent.inc();
|
|
@@ -25,13 +25,19 @@ module.exports.ObjectPattern = (path, {indent, print, maybe}) => {
|
|
|
25
25
|
const {shorthand} = property.node;
|
|
26
26
|
|
|
27
27
|
maybe.indent(is);
|
|
28
|
-
print(keyPath);
|
|
28
|
+
maybe.print(!isAssign || !shorthand, keyPath);
|
|
29
29
|
|
|
30
30
|
if (!shorthand) {
|
|
31
31
|
print(': ');
|
|
32
32
|
print(valuePath);
|
|
33
|
-
} else if (isAssign)
|
|
33
|
+
} else if (isAssign) {
|
|
34
|
+
const couple = isCoupleLines(valuePath);
|
|
35
|
+
maybe.print.breakline(couple);
|
|
34
36
|
print(valuePath);
|
|
37
|
+
|
|
38
|
+
maybe.print(couple, ',');
|
|
39
|
+
maybe.print.newline(couple);
|
|
40
|
+
}
|
|
35
41
|
|
|
36
42
|
if (is) {
|
|
37
43
|
print(',');
|
|
@@ -4,6 +4,8 @@ const {
|
|
|
4
4
|
isNext,
|
|
5
5
|
isCoupleLines,
|
|
6
6
|
isNewlineBetweenSiblings,
|
|
7
|
+
exists,
|
|
8
|
+
|
|
7
9
|
} = require('../is');
|
|
8
10
|
|
|
9
11
|
const {hasPrevNewline} = require('../mark');
|
|
@@ -23,7 +25,7 @@ module.exports.VariableDeclaration = {
|
|
|
23
25
|
print('__declarations.0.id');
|
|
24
26
|
|
|
25
27
|
const initPath = path.get('declarations.0.init');
|
|
26
|
-
maybe.print(initPath
|
|
28
|
+
maybe.print(exists(initPath), ' = ');
|
|
27
29
|
print('__declarations.0.init');
|
|
28
30
|
maybe.print(isParentBlock(path), ';');
|
|
29
31
|
|
package/package.json
CHANGED