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

Update no-then.md #503

Merged
merged 3 commits into from
Feb 5, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 18 additions & 5 deletions docs/rules/no-then.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,26 +12,39 @@ https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/asy

👎 Examples of **incorrect** code for this rule:

```js
function countData(url) {
return downloadData(url).then(data => {
return data.length
})
}
```

```js
function getProcessedData(url) {
return downloadData(url).catch(e => {
console.log('Error occurred!', e)
return null;
})
}
```

👍 Examples of **correct** code for this rule:

```js
async function countProcessedData(url) {
const data = await downloadData(url);
return data.length
```
theinterned marked this conversation as resolved.
Show resolved Hide resolved

```js
async function getProcessedData(url) {
let v
try {
v = await downloadData(url)
return await downloadData(url)
} catch (e) {
console.log('Error occurred!', e)
return
console.log('Error occurred!', e);
return null;
}
return v
}
```

Expand Down