Don't force line break in empty loop bodies (#1815)
This makes them consistent with empty function bodies. Fixes https://github.com/prettier/prettier/issues/1356master
parent
eeb8616e3c
commit
ea27846d1f
|
@ -672,6 +672,9 @@ function genericPrintNoParens(path, options, print, args) {
|
|||
parent.type === "FunctionDeclaration" ||
|
||||
parent.type === "ObjectMethod" ||
|
||||
parent.type === "ClassMethod" ||
|
||||
parent.type === "ForStatement" ||
|
||||
parent.type === "WhileStatement" ||
|
||||
parent.type === "DoWhileStatement" ||
|
||||
(parent.type === "CatchClause" && !parentParent.finalizer))
|
||||
) {
|
||||
return "{}";
|
||||
|
|
|
@ -629,14 +629,12 @@ function try_scope() {
|
|||
|
||||
function for_scope_let() {
|
||||
let a: number = 0;
|
||||
for (let a = "" /* ok: local to init */; ; ) {
|
||||
}
|
||||
for (let a = "" /* ok: local to init */; ; ) {}
|
||||
}
|
||||
|
||||
function for_scope_var() {
|
||||
var a: number = 0;
|
||||
for (var a = "" /* error: string ~> number */; ; ) {
|
||||
}
|
||||
for (var a = "" /* error: string ~> number */; ; ) {}
|
||||
}
|
||||
|
||||
function for_in_scope_let(o: Object) {
|
||||
|
|
|
@ -591,8 +591,7 @@ var tests = [
|
|||
function() {
|
||||
let x: { foo: ?string } = { foo: null };
|
||||
if (!x.foo) {
|
||||
while (false) {
|
||||
}
|
||||
while (false) {}
|
||||
x.foo = "foo";
|
||||
}
|
||||
(x.foo: string);
|
||||
|
@ -601,8 +600,7 @@ var tests = [
|
|||
function() {
|
||||
let x: { foo: ?string } = { foo: null };
|
||||
if (!x.foo) {
|
||||
for (var i = 0; i < 0; i++) {
|
||||
}
|
||||
for (var i = 0; i < 0; i++) {}
|
||||
x.foo = "foo";
|
||||
}
|
||||
(x.foo: string);
|
||||
|
|
|
@ -74,10 +74,8 @@ for (var i = 0; i < 10; ++i) {}
|
|||
for (;;) 0;
|
||||
for (var i = 0; i < 10; ++i) 0;
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
for (;;) {
|
||||
}
|
||||
for (var i = 0; i < 10; ++i) {
|
||||
}
|
||||
for (;;) {}
|
||||
for (var i = 0; i < 10; ++i) {}
|
||||
|
||||
for (;;) 0;
|
||||
for (var i = 0; i < 10; ++i) 0;
|
||||
|
@ -98,10 +96,8 @@ async function f() {
|
|||
}
|
||||
for (a in b) 0;
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
for ((x in a); ; ) {
|
||||
}
|
||||
for (a = (a in b); ; ) {
|
||||
}
|
||||
for ((x in a); ; ) {}
|
||||
for (a = (a in b); ; ) {}
|
||||
for (let a = (b in c); ; );
|
||||
for (a && (b in c); ; );
|
||||
for (a => (b in c); ; );
|
||||
|
|
|
@ -8,8 +8,7 @@ exports[`comment.js 1`] = `
|
|||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
{
|
||||
// goto emulation
|
||||
inf_leave: for (;;) {
|
||||
}
|
||||
inf_leave: for (;;) {}
|
||||
}
|
||||
|
||||
`;
|
||||
|
|
|
@ -23,10 +23,8 @@ while (
|
|||
someVeryLongStringB &&
|
||||
someVeryLongStringC &&
|
||||
someVeryLongStringD
|
||||
) {
|
||||
}
|
||||
do {
|
||||
} while (
|
||||
) {}
|
||||
do {} while (
|
||||
someVeryLongStringA &&
|
||||
someVeryLongStringB &&
|
||||
someVeryLongStringC &&
|
||||
|
|
Loading…
Reference in New Issue