From 17b58b528df62bf96813d50c087cafdf83306810 Mon Sep 17 00:00:00 2001 From: Milos Djermanovic Date: Thu, 10 Sep 2020 01:53:55 +0200 Subject: [PATCH] Docs: clarify correct example in no-return-await (fixes #13656) (#13657) * Docs: clarify correct example in no-return-await (fixes #13656) * Revert order of examples --- docs/rules/no-return-await.md | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/docs/rules/no-return-await.md b/docs/rules/no-return-await.md index b1c60f092ae..e3f7be259d7 100644 --- a/docs/rules/no-return-await.md +++ b/docs/rules/no-return-await.md @@ -11,6 +11,8 @@ This rule aims to prevent a likely common performance hazard due to a lack of un Examples of **incorrect** code for this rule: ```js +/*eslint no-return-await: "error"*/ + async function foo() { return await bar(); } @@ -19,6 +21,8 @@ async function foo() { Examples of **correct** code for this rule: ```js +/*eslint no-return-await: "error"*/ + async function foo() { return bar(); } @@ -28,11 +32,13 @@ async function foo() { return; } +// This is essentially the same as `return await bar();`, but the rule checks only `await` in `return` statements async function foo() { const x = await bar(); return x; } +// In this example the `await` is necessary to be able to catch errors thrown from `bar()` async function foo() { try { return await bar(); @@ -40,8 +46,6 @@ async function foo() { } ``` -In the last example the `await` is necessary to be able to catch errors thrown from `bar()`. - ## When Not To Use It There are a few reasons you might want to turn this rule off: