@putout/printer 8.48.0 → 9.0.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 +10 -0
- package/README.md +3 -1
- package/lib/tokenize/expressions/index.js +1 -1
- package/lib/tokenize/expressions/sequence-expression/sequence-expression.js +37 -0
- package/lib/tokenize/statements/try-statement/try-statements.js +1 -1
- package/package.json +1 -1
- package/lib/tokenize/expressions/sequence-expression.js +0 -16
package/ChangeLog
CHANGED
package/README.md
CHANGED
|
@@ -174,7 +174,9 @@ Options used to configure logic of output, similar to ESLint rules:
|
|
|
174
174
|
- ✅ `maxVariablesInOneLine` - count of `VariableDeclarators` in one line.
|
|
175
175
|
- ✅ `maxPropertiesInOneLine` - count of `ObjectProperties` in one line.
|
|
176
176
|
- ✅ `maxPropertiesLengthInOneLine` - maximum length of `Object Property`, when violated splits event if `maxPropertiesInOneLine` satisfies;
|
|
177
|
-
- ✅ `roundBraces`
|
|
177
|
+
- ✅ `roundBraces` to output braces or not
|
|
178
|
+
- In a single argument arrow function expressions `(a) => {}` or not `a => {}`;
|
|
179
|
+
- In sequence expressions: `for(let e of l) (a(), b())` or not `for(let e of l) a(), b()`;
|
|
178
180
|
|
|
179
181
|
## Visitors API
|
|
180
182
|
|
|
@@ -33,7 +33,7 @@ const {ArrayPattern} = require('./array-pattern/array-pattern');
|
|
|
33
33
|
const {AssignmentPattern} = require('./assignment-pattern');
|
|
34
34
|
const {RestElement} = require('./rest-element');
|
|
35
35
|
const {SpreadElement} = require('./spread-element');
|
|
36
|
-
const {SequenceExpression} = require('./sequence-expression');
|
|
36
|
+
const {SequenceExpression} = require('./sequence-expression/sequence-expression');
|
|
37
37
|
const {TaggedTemplateExpression} = require('./tagged-template-expression');
|
|
38
38
|
|
|
39
39
|
const {
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
module.exports.SequenceExpression = (path, printer, semantics) => {
|
|
4
|
+
const {maybe, traverse} = printer;
|
|
5
|
+
|
|
6
|
+
const expressions = path.get('expressions');
|
|
7
|
+
const n = expressions.length - 1;
|
|
8
|
+
|
|
9
|
+
maybeWriteBrace(path, printer, semantics, {
|
|
10
|
+
brace: '(',
|
|
11
|
+
});
|
|
12
|
+
|
|
13
|
+
for (const [index, expression] of expressions.entries()) {
|
|
14
|
+
traverse(expression);
|
|
15
|
+
maybe.write(index < n, ',');
|
|
16
|
+
maybe.write.space(index < n);
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
maybeWriteBrace(path, printer, semantics, {
|
|
20
|
+
brace: ')',
|
|
21
|
+
});
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
function maybeWriteBrace(path, printer, semantics, {brace}) {
|
|
25
|
+
const {roundBraces} = semantics;
|
|
26
|
+
const {write} = printer;
|
|
27
|
+
|
|
28
|
+
if (path.parentPath.isArrowFunctionExpression()) {
|
|
29
|
+
write(brace);
|
|
30
|
+
return;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
if (!roundBraces)
|
|
34
|
+
return;
|
|
35
|
+
|
|
36
|
+
write(brace);
|
|
37
|
+
}
|
package/package.json
CHANGED
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
module.exports.SequenceExpression = (path, {maybe, write, traverse}) => {
|
|
4
|
-
const expressions = path.get('expressions');
|
|
5
|
-
const n = expressions.length - 1;
|
|
6
|
-
|
|
7
|
-
write('(');
|
|
8
|
-
|
|
9
|
-
for (const [index, expression] of expressions.entries()) {
|
|
10
|
-
traverse(expression);
|
|
11
|
-
maybe.write(index < n, ',');
|
|
12
|
-
maybe.write.space(index < n);
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
write(')');
|
|
16
|
-
};
|