@putout/printer 1.8.2 → 1.8.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
package/lib/print-tokens/cook.js
CHANGED
|
@@ -3,24 +3,7 @@
|
|
|
3
3
|
module.exports.cook = (tokens) => {
|
|
4
4
|
const cookedTokens = [];
|
|
5
5
|
|
|
6
|
-
for (const [i, {
|
|
7
|
-
value,
|
|
8
|
-
}] of tokens.entries()) {
|
|
9
|
-
/*
|
|
10
|
-
if (type !== TYPES.TOKEN)
|
|
11
|
-
console.log(type);
|
|
12
|
-
|
|
13
|
-
if (type === TYPES.NEWLINE && next?.type === TYPES.LINEBREAK) {
|
|
14
|
-
console.log('[skipped]');
|
|
15
|
-
continue;
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
if (type === TYPES.LINEBREAK && next?.type === TYPES.LINEBREAK) {
|
|
19
|
-
console.log('[skipped]');
|
|
20
|
-
continue;
|
|
21
|
-
}
|
|
22
|
-
*/
|
|
23
|
-
|
|
6
|
+
for (const [i, {value}] of tokens.entries()) {
|
|
24
7
|
cookedTokens.push(value);
|
|
25
8
|
}
|
|
26
9
|
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
const {isCoupleLines} = require('../is');
|
|
4
4
|
const isBodyOfArrow = (path) => path.parentPath.node.body === path.node;
|
|
5
|
+
const isLogical = (path) => path.get('argument').isLogicalExpression();
|
|
5
6
|
const isForOf = (path) => {
|
|
6
7
|
if (path.parentPath.isForOfStatement())
|
|
7
8
|
return true;
|
|
@@ -24,7 +25,7 @@ module.exports.ObjectExpression = (path, {print, maybe, indent}) => {
|
|
|
24
25
|
|
|
25
26
|
for (const property of properties) {
|
|
26
27
|
if (property.isSpreadElement()) {
|
|
27
|
-
maybe.indent(length > 1);
|
|
28
|
+
maybe.indent(length > 1 || isLogical(property));
|
|
28
29
|
print(property);
|
|
29
30
|
|
|
30
31
|
if (length > 1) {
|
|
@@ -60,6 +61,7 @@ module.exports.ObjectExpression = (path, {print, maybe, indent}) => {
|
|
|
60
61
|
|
|
61
62
|
maybe.indent(manyLines);
|
|
62
63
|
print('}');
|
|
64
|
+
maybe.print.newline(path.parentPath.isLogicalExpression());
|
|
63
65
|
maybe.print(parens, ')');
|
|
64
66
|
};
|
|
65
67
|
function isOneLine(path) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@putout/printer",
|
|
3
|
-
"version": "1.8.
|
|
3
|
+
"version": "1.8.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",
|