Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 2a7beb4

Browse filesBrowse files
authored
Merge pull request #503 from cefn/patch-1
Update no-then.md
2 parents ea48f83 + 8abd830 commit 2a7beb4
Copy full SHA for 2a7beb4

File tree

Expand file treeCollapse file tree

1 file changed

+19
-5
lines changed
Filter options
Expand file treeCollapse file tree

1 file changed

+19
-5
lines changed

‎docs/rules/no-then.md

Copy file name to clipboardExpand all lines: docs/rules/no-then.md
+19-5Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,26 +12,40 @@ https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/asy
1212

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

15+
```js
16+
function countData(url) {
17+
return downloadData(url).then(data => {
18+
return data.length
19+
})
20+
}
21+
```
22+
1523
```js
1624
function getProcessedData(url) {
1725
return downloadData(url).catch(e => {
1826
console.log('Error occurred!', e)
27+
return null;
1928
})
2029
}
2130
```
2231

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

34+
```js
35+
async function countProcessedData(url) {
36+
const data = await downloadData(url);
37+
return data.length
38+
}
39+
```
40+
2541
```js
2642
async function getProcessedData(url) {
27-
let v
2843
try {
29-
v = await downloadData(url)
44+
return await downloadData(url)
3045
} catch (e) {
31-
console.log('Error occurred!', e)
32-
return
46+
console.log('Error occurred!', e);
47+
return null;
3348
}
34-
return v
3549
}
3650
```
3751

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.