Repository: jlongster/prettier (js)

Issue:
Unneeded parenthesis around await in ternary
```js
async function f() {
  const result = typeof fn === 'function' ? await fn() : null;
}
```

outputs

```js
async function f() {
  const result = typeof fn === "function" ? (await fn()) : null;
}
```

but the parenthesis is not needed.

https://jlongster.github.io/prettier/#%7B%22content%22%3A%22async%20function%20f()%20%7B%5Cn%20%20const%20result%20%3D%20typeof%20fn%20%3D%3D%3D%20'function'%20%3F%20await%20fn()%20%3A%20null%3B%5Cn%7D%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:
Remove parens around AwaitExpression in ternary
Fixes #313

Patch:
diff --git a/src/fast-path.js b/src/fast-path.js
index c8479f66f..9c2797b06 100644
--- a/src/fast-path.js
+++ b/src/fast-path.js
@@ -298,7 +298,6 @@ FPp.needsParens = function(assumeExpressionContext) {
         case "SpreadElement":
         case "SpreadProperty":
         case "NewExpression":
-        case "ConditionalExpression":
         case "MemberExpression":
           return true;
 


Test patch:
diff --git a/tests/async/__snapshots__/jsfmt.spec.js.snap b/tests/async/__snapshots__/jsfmt.spec.js.snap
index d4b1a9e02..2f264651c 100644
--- a/tests/async/__snapshots__/jsfmt.spec.js.snap
+++ b/tests/async/__snapshots__/jsfmt.spec.js.snap
@@ -550,3 +550,14 @@ async function g() {
 }
 "
 `;
+
+exports[`test conditional-expression.js 1`] = `
+"async function f() {
+  const result = typeof fn === \'function\' ? await fn() : null;
+}
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+async function f() {
+  const result = typeof fn === \"function\" ? await fn() : null;
+}
+"
+`;
diff --git a/tests/async/conditional-expression.js b/tests/async/conditional-expression.js
new file mode 100644
index 000000000..532c66d6a
--- /dev/null
+++ b/tests/async/conditional-expression.js
@@ -0,0 +1,3 @@
+async function f() {
+  const result = typeof fn === 'function' ? await fn() : null;
+}