parent
e58dd2bf0b
commit
a255977009
|
@ -1166,6 +1166,16 @@ function genericPrintNoParens(path, options, print, args) {
|
|||
return print(childPath);
|
||||
}, "declarations");
|
||||
|
||||
// We generally want to terminate all variable declarations with a
|
||||
// semicolon, except when they in the () part of for loops.
|
||||
const parentNode = path.getParentNode();
|
||||
|
||||
const isParentForLoop =
|
||||
parentNode.type === "ForStatement" ||
|
||||
parentNode.type === "ForInStatement" ||
|
||||
parentNode.type === "ForOfStatement" ||
|
||||
parentNode.type === "ForAwaitStatement";
|
||||
|
||||
const hasValue = n.declarations.some(decl => decl.init);
|
||||
|
||||
parts = [
|
||||
|
@ -1176,21 +1186,13 @@ function genericPrintNoParens(path, options, print, args) {
|
|||
concat(
|
||||
printed
|
||||
.slice(1)
|
||||
.map(p => concat([",", hasValue ? hardline : line, p]))
|
||||
.map(p =>
|
||||
concat([",", hasValue && !isParentForLoop ? hardline : line, p])
|
||||
)
|
||||
)
|
||||
)
|
||||
];
|
||||
|
||||
// We generally want to terminate all variable declarations with a
|
||||
// semicolon, except when they in the () part of for loops.
|
||||
const parentNode = path.getParentNode();
|
||||
|
||||
const isParentForLoop =
|
||||
parentNode.type === "ForStatement" ||
|
||||
parentNode.type === "ForInStatement" ||
|
||||
parentNode.type === "ForOfStatement" ||
|
||||
parentNode.type === "ForAwaitStatement";
|
||||
|
||||
if (!(isParentForLoop && parentNode.body !== n)) {
|
||||
parts.push(semi);
|
||||
}
|
||||
|
|
|
@ -11,6 +11,8 @@ const eloBar = require("elo-bar")
|
|||
var a, b, c;
|
||||
|
||||
let superSuperSuperLong1, superSuperSuperLong2, superSuperSuperLong3, superSuperSuperLong4;
|
||||
|
||||
for (var i = 0, len = arr.length; i < len; i++) {}
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
var assert = require("assert"),
|
||||
lookup = require("../lookup");
|
||||
|
@ -26,6 +28,8 @@ let superSuperSuperLong1,
|
|||
superSuperSuperLong3,
|
||||
superSuperSuperLong4;
|
||||
|
||||
for (var i = 0, len = arr.length; i < len; i++) {}
|
||||
|
||||
`;
|
||||
|
||||
exports[`string.js 1`] = `
|
||||
|
|
|
@ -8,3 +8,5 @@ const eloBar = require("elo-bar")
|
|||
var a, b, c;
|
||||
|
||||
let superSuperSuperLong1, superSuperSuperLong2, superSuperSuperLong3, superSuperSuperLong4;
|
||||
|
||||
for (var i = 0, len = arr.length; i < len; i++) {}
|
||||
|
|
Loading…
Reference in New Issue