Do not put spaces on empty for loop (#169)

```js
for (;;) {
```

instead of

```js
for (; ; ) {
```
This commit is contained in:
Christopher Chedeau authored and James Long committed 2017-01-13 13:00:32 -05:00
1 parent 8e0f97e410
commit 3dcf46c77c
3 files changed
+21 -2

No files matched your search

+10 -2
View File
@@ -874,7 +874,15 @@ function genericPrintNoParens(path, options, print) {
return group(concat(parts));
case "ForStatement":
// TODO Get the for (;;) case right.
const body = adjustClause(path.call(print, "body"), options);
if (!n.init && !n.test && !n.update) {
return concat([
'for (;;)',
body,
]);
}
return concat([
"for (",
group(
@@ -896,7 +904,7 @@ function genericPrintNoParens(path, options, print) {
])
),
")",
adjustClause(path.call(print, "body"), options)
body,
]);
case "WhileStatement":
return concat([
@@ -280,3 +280,12 @@ function corge(x: boolean) {
}
"
`;
exports[`test for.js 1`] = `
"for (;;) {}
for (var i = 0; i < 10; ++i) {}
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
for (;;) {}
for (var i = 0; i < 10; ++i) {}
"
`;
+2
View File
@@ -0,0 +1,2 @@
for (;;) {}
for (var i = 0; i < 10; ++i) {}