diff --git a/src/printer.js b/src/printer.js index a4e368cb..d7ec07e2 100644 --- a/src/printer.js +++ b/src/printer.js @@ -989,6 +989,9 @@ function genericPrintNoParens(path, options, print) { case "ForStatement": { const body = adjustClause(path.call(print, "body"), options); + // We want to keep dangling comments above the loop to stay consistent. + // Any comment positioned between the for statement and the parentheses + // is going to be printed before the statement. const dangling = comments.printDanglingComments(path, options, /* sameLine */ true); const printedComments = dangling ? concat([dangling, softline]) : "";