diff --git a/src/printer.js b/src/printer.js index 895ef4c7..b0d796eb 100644 --- a/src/printer.js +++ b/src/printer.js @@ -186,11 +186,12 @@ function genericPrintNoParens(path, options, print) { // Avoid indenting sub-expressions in if/etc statements. if ( shouldInlineLogicalExpression(n) || + n !== parent.body && (parent.type === "IfStatement" || parent.type === "WhileStatement" || parent.type === "DoStatement" || - parent.type === "ForStatement") && - n !== parent.body + parent.type === "ForStatement") || + n === parent.body && parent.type === "ArrowFunctionExpression" ) { return group(concat(parts)); } diff --git a/tests/binary-expressions/__snapshots__/jsfmt.spec.js.snap b/tests/binary-expressions/__snapshots__/jsfmt.spec.js.snap index 5ce0e6c9..a836415f 100644 --- a/tests/binary-expressions/__snapshots__/jsfmt.spec.js.snap +++ b/tests/binary-expressions/__snapshots__/jsfmt.spec.js.snap @@ -1,3 +1,22 @@ +exports[`test arrow.js 1`] = ` +"function f() { + const appEntitys = getAppEntitys(loadObject).filter( + entity => entity && entity.isInstallAvailable() && !entity.isQueue() && entity.isDisabled() + ) +} +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +function f() { + const appEntitys = getAppEntitys(loadObject).filter( + entity => + entity && + entity.isInstallAvailable() && + !entity.isQueue() && + entity.isDisabled() + ); +} +" +`; + exports[`test inline-object-array.js 1`] = ` "prevState = prevState || { catalogs: [], diff --git a/tests/binary-expressions/arrow.js b/tests/binary-expressions/arrow.js new file mode 100644 index 00000000..2fbafa9f --- /dev/null +++ b/tests/binary-expressions/arrow.js @@ -0,0 +1,5 @@ +function f() { + const appEntitys = getAppEntitys(loadObject).filter( + entity => entity && entity.isInstallAvailable() && !entity.isQueue() && entity.isDisabled() + ) +}