@putout/printer 8.12.0 → 8.12.1
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 +5 -0
- package/README.md +4 -1
- package/lib/tokenize/expressions/array-expression/array-expression.js +6 -0
- package/lib/tokenize/expressions/array-expression/newline.js +0 -1
- package/lib/tokenize/expressions/object-expression/object-expression.js +4 -17
- package/lib/tokenize/statements/variable-declaration/variable-declaration.js +0 -1
- package/package.json +1 -1
package/ChangeLog
CHANGED
package/README.md
CHANGED
|
@@ -183,7 +183,10 @@ When you want to improve support of existing visitor or extend **Printer** with
|
|
|
183
183
|
When you need to override behavior of existing visitor use:
|
|
184
184
|
|
|
185
185
|
```js
|
|
186
|
-
import {
|
|
186
|
+
import {
|
|
187
|
+
print,
|
|
188
|
+
visitors as v,
|
|
189
|
+
} from '@putout/printer';
|
|
187
190
|
|
|
188
191
|
print(ast, {
|
|
189
192
|
visitors: {
|
|
@@ -6,6 +6,7 @@ const {
|
|
|
6
6
|
isStringAndIdentifier,
|
|
7
7
|
isIdentifierAndIdentifier,
|
|
8
8
|
isStringAndArray,
|
|
9
|
+
isIdentifierAndObject,
|
|
9
10
|
} = require('../../is');
|
|
10
11
|
|
|
11
12
|
const {
|
|
@@ -115,6 +116,11 @@ module.exports.ArrayExpression = {
|
|
|
115
116
|
maybe.indent(elements.length && isNewLine);
|
|
116
117
|
}
|
|
117
118
|
|
|
119
|
+
if (isIdentifierAndObject(elements)) {
|
|
120
|
+
print(',');
|
|
121
|
+
print.breakline();
|
|
122
|
+
}
|
|
123
|
+
|
|
118
124
|
print(']');
|
|
119
125
|
},
|
|
120
126
|
afterIf(path) {
|
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
+
const {types} = require('@putout/babel');
|
|
4
|
+
const {isIdentifier} = types;
|
|
5
|
+
|
|
3
6
|
const {
|
|
4
7
|
isCoupleLines,
|
|
5
8
|
isForOf,
|
|
@@ -9,7 +12,6 @@ const {
|
|
|
9
12
|
noLeadingComment,
|
|
10
13
|
hasLeadingComment,
|
|
11
14
|
exists,
|
|
12
|
-
isIdentifierAndObject,
|
|
13
15
|
} = require('../../is');
|
|
14
16
|
|
|
15
17
|
const {parseComments} = require('../../comment/comment');
|
|
@@ -89,24 +91,10 @@ module.exports.ObjectExpression = (path, printer, semantics) => {
|
|
|
89
91
|
}
|
|
90
92
|
|
|
91
93
|
indent.dec();
|
|
92
|
-
const isInsideArrayWithIdentifierFirst = ({parentPath}) => {
|
|
93
|
-
if (!parentPath.isArrayExpression())
|
|
94
|
-
return false;
|
|
95
|
-
|
|
96
|
-
return isIdentifierAndObject(parentPath.get('elements'));
|
|
97
|
-
};
|
|
98
94
|
|
|
99
95
|
maybe.indent(manyLines);
|
|
100
96
|
|
|
101
|
-
|
|
102
|
-
print('},');
|
|
103
|
-
indent.dec();
|
|
104
|
-
print.breakline();
|
|
105
|
-
indent.inc();
|
|
106
|
-
} else {
|
|
107
|
-
print('}');
|
|
108
|
-
}
|
|
109
|
-
|
|
97
|
+
print('}');
|
|
110
98
|
maybe.print(parens, ')');
|
|
111
99
|
|
|
112
100
|
maybe.indent.dec(isMemberExpressionCallee(path));
|
|
@@ -166,4 +154,3 @@ function isParens(path) {
|
|
|
166
154
|
|
|
167
155
|
return isParentExpression(path);
|
|
168
156
|
}
|
|
169
|
-
|
package/package.json
CHANGED