@putout/printer 1.13.1 → 1.14.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 +5 -0
- package/lib/tokenize/expressions/array-pattern.js +1 -2
- package/lib/tokenize/expressions/call-expression.js +1 -3
- package/lib/tokenize/expressions/class-declaration.js +1 -3
- package/lib/tokenize/expressions/sequence-expression.js +1 -3
- package/lib/tokenize/literals/index.js +2 -1
- package/lib/tokenize/statements/switch-statement.js +1 -3
- package/lib/tokenize/typescript/index.js +10 -2
- package/package.json +1 -1
package/ChangeLog
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
const {entries} = Object;
|
|
4
3
|
const isForOf = ({parentPath}) => parentPath.parentPath.parentPath.isForOfStatement();
|
|
5
4
|
|
|
6
5
|
module.exports.ArrayPattern = (path, {indent, maybe, print}) => {
|
|
@@ -15,7 +14,7 @@ module.exports.ArrayPattern = (path, {indent, maybe, print}) => {
|
|
|
15
14
|
|
|
16
15
|
maybe.print(isNewLine && elements.length, '\n');
|
|
17
16
|
|
|
18
|
-
for (const [index, element] of entries(
|
|
17
|
+
for (const [index, element] of elements.entries()) {
|
|
19
18
|
maybe.indent(isNewLine);
|
|
20
19
|
print(element);
|
|
21
20
|
maybe.print(isNewLine, ',\n');
|
|
@@ -5,8 +5,6 @@ const {
|
|
|
5
5
|
hasPrevNewline,
|
|
6
6
|
} = require('../mark');
|
|
7
7
|
|
|
8
|
-
const {entries} = Object;
|
|
9
|
-
|
|
10
8
|
const CallExpression = {
|
|
11
9
|
beforeIf(path) {
|
|
12
10
|
return isNewLineBefore(path) && !isMarkedParentBefore(path) && !hasPrevNewline(path.parentPath);
|
|
@@ -28,7 +26,7 @@ const CallExpression = {
|
|
|
28
26
|
|
|
29
27
|
maybe.indent.inc(isParentCall);
|
|
30
28
|
|
|
31
|
-
for (const [i, arg] of entries(
|
|
29
|
+
for (const [i, arg] of args.entries()) {
|
|
32
30
|
if (isParentCall) {
|
|
33
31
|
print.newline();
|
|
34
32
|
indent();
|
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
const {entries} = Object;
|
|
4
|
-
|
|
5
3
|
module.exports.ClassDeclaration = (path, {maybe, print, indent}) => {
|
|
6
4
|
indent();
|
|
7
5
|
print('class ');
|
|
@@ -21,7 +19,7 @@ module.exports.ClassDeclaration = (path, {maybe, print, indent}) => {
|
|
|
21
19
|
const body = path.get('body.body');
|
|
22
20
|
const n = body.length - 1;
|
|
23
21
|
|
|
24
|
-
for (const [i, item] of entries(
|
|
22
|
+
for (const [i, item] of body.entries()) {
|
|
25
23
|
indent();
|
|
26
24
|
print(item);
|
|
27
25
|
maybe.print(i < n, '\n');
|
|
@@ -1,12 +1,10 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
const {entries} = Object;
|
|
4
|
-
|
|
5
3
|
module.exports.SequenceExpression = (path, {maybe, print}) => {
|
|
6
4
|
const expressions = path.get('expressions');
|
|
7
5
|
const n = expressions.length - 1;
|
|
8
6
|
|
|
9
|
-
for (const [index, expression] of entries(
|
|
7
|
+
for (const [index, expression] of expressions.entries()) {
|
|
10
8
|
print(expression);
|
|
11
9
|
maybe.print(index < n, ',');
|
|
12
10
|
maybe.print(index < n, ' ');
|
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
const {entries} = Object;
|
|
4
|
-
|
|
5
3
|
module.exports.SwitchStatement = (path, {print, maybe}) => {
|
|
6
4
|
print('switch');
|
|
7
5
|
print.space();
|
|
@@ -13,7 +11,7 @@ module.exports.SwitchStatement = (path, {print, maybe}) => {
|
|
|
13
11
|
const cases = path.get('cases');
|
|
14
12
|
const n = cases.length - 1;
|
|
15
13
|
|
|
16
|
-
for (const [index, switchCase] of entries(
|
|
14
|
+
for (const [index, switchCase] of cases.entries()) {
|
|
17
15
|
print('case');
|
|
18
16
|
print.space();
|
|
19
17
|
print(switchCase.get('test'));
|
|
@@ -14,8 +14,16 @@ module.exports = {
|
|
|
14
14
|
TSTypeReference(path, {print}) {
|
|
15
15
|
print('__typeName');
|
|
16
16
|
},
|
|
17
|
-
TSTypeParameter(path, {
|
|
18
|
-
|
|
17
|
+
TSTypeParameter(path, {write}) {
|
|
18
|
+
write(path.node.name);
|
|
19
|
+
},
|
|
20
|
+
TSNumberKeyword(path, {write}) {
|
|
21
|
+
write('number');
|
|
22
|
+
},
|
|
23
|
+
TSTypeAnnotation(path, {print}) {
|
|
24
|
+
print(':');
|
|
25
|
+
print.space();
|
|
26
|
+
print('__typeAnnotation');
|
|
19
27
|
},
|
|
20
28
|
TSExpressionWithTypeArguments(path, {print}) {
|
|
21
29
|
print('__expression');
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@putout/printer",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.14.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",
|