fix single-arg async arrows when retainLines=true (#8868)

This commit is contained in:
Ryan Marsh 2018-10-30 00:49:11 -05:00 committed by Nicolò Ribaudo
parent e4929e11f6
commit de80aefece
4 changed files with 42 additions and 1 deletions

View File

@ -111,7 +111,23 @@ export function ArrowFunctionExpression(node: Object) {
t.isIdentifier(firstParam) &&
!hasTypes(node, firstParam)
) {
if (
this.format.retainLines &&
node.loc.start.line < node.body.loc.start.line
) {
this.token("(");
if (firstParam.loc.start.line > node.loc.start.line) {
this.indent();
this.print(firstParam, node);
this.dedent();
this._catchUp("start", node.body.loc);
} else {
this.print(firstParam, node);
}
this.token(")");
} else {
this.print(firstParam, node);
}
} else {
this._params(node);
}

View File

@ -0,0 +1,11 @@
var fn = async (
arg
) => {}
async (x)
=> {}
async x => {}
async (x
) => {};

View File

@ -0,0 +1,3 @@
{
"retainLines": true
}

View File

@ -0,0 +1,11 @@
var fn = async (
arg
) => {};
async (x) =>
{};
async x => {};
async (x) =>
{};