Repository: jlongster/prettier (js)

Issue:
Missing parenthesis around arrow functions in method calls
```js
(a => {}).length
```

outputs

```js
a => {}.length;
```

which is incorrect

https://jlongster.github.io/prettier/#%7B%22content%22%3A%22(a%20%3D%3E%20%7B%7D).length%5Cn%22%2C%22options%22%3A%7B%22printWidth%22%3A80%2C%22tabWidth%22%3A2%2C%22singleQuote%22%3Afalse%2C%22trailingComma%22%3Afalse%2C%22bracketSpacing%22%3Atrue%7D%7D

Pull request description:
Fix issue with ArrowFunctionExpression parens
Fixes #235 

Patch:
diff --git a/src/fast-path.js b/src/fast-path.js
index 634bdda63..5fd30d163 100644
--- a/src/fast-path.js
+++ b/src/fast-path.js
@@ -362,6 +362,10 @@ FPp.needsParens = function(assumeExpressionContext) {
         return true;
       }
 
+      if (parent.type === "MemberExpression") {
+        return true;
+      }
+
       return isBinary(parent);
 
     case "ClassExpression":


Test patch:
diff --git a/tests/arrows/__snapshots__/jsfmt.spec.js.snap b/tests/arrows/__snapshots__/jsfmt.spec.js.snap
index f1b48892b..24c85d6b9 100644
--- a/tests/arrows/__snapshots__/jsfmt.spec.js.snap
+++ b/tests/arrows/__snapshots__/jsfmt.spec.js.snap
@@ -25,6 +25,13 @@ var ident = <T>(x: T): T => x;
 "
 `;
 
+exports[`test arrow_function_expression.js 1`] = `
+"(a => {}).length
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+(a => {}).length;
+"
+`;
+
 exports[`test arrows.js 1`] = `
 "function selectBestEffortImageForWidth(
     maxWidth: number,
diff --git a/tests/arrows/arrow_function_expression.js b/tests/arrows/arrow_function_expression.js
new file mode 100644
index 000000000..ecea2142f
--- /dev/null
+++ b/tests/arrows/arrow_function_expression.js
@@ -0,0 +1,1 @@
+(a => {}).length