Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Docs: clarify correct example in no-return-await (fixes #13656) #13657

Merged
merged 2 commits into from Sep 9, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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"*/
anikethsaha marked this conversation as resolved.
Show resolved Hide resolved

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