Skip to content

Commit

Permalink
Docs: clarify correct example in no-return-await (fixes #13656) (#13657)
Browse files Browse the repository at this point in the history
* Docs: clarify correct example in no-return-await (fixes #13656)

* Revert order of examples
  • Loading branch information
mdjermanovic committed Sep 9, 2020
1 parent 9171f0a commit 17b58b5
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions docs/rules/no-return-await.md
Expand Up @@ -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();
}
Expand All @@ -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();
}
Expand All @@ -28,20 +32,20 @@ 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();
} catch (error) {}
}
```

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:
Expand Down

0 comments on commit 17b58b5

Please sign in to comment.