Skip to content

Commit af5e64d

Browse files
committed
update no-async-in-computed-properties
1 parent dead35e commit af5e64d

File tree

1 file changed

+36
-36
lines changed

1 file changed

+36
-36
lines changed

docs/rules/no-async-in-computed-properties.md

Lines changed: 36 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -9,53 +9,53 @@ If you need async computed properties you might want to consider using additiona
99

1010
This rule is aimed at preventing asynchronous methods from being called in computed properties.
1111

12-
:-1: Examples of **incorrect** code for this rule:
13-
14-
```js
15-
computed: {
16-
pro () {
17-
return Promise.all([new Promise((resolve, reject) => {})])
18-
},
19-
foo: async function () {
20-
return await someFunc()
21-
},
22-
bar () {
23-
return fetch(url).then(response => {})
24-
},
25-
tim () {
26-
setTimeout(() => { }, 0)
27-
},
28-
inter () {
29-
setInterval(() => { }, 0)
30-
},
31-
anim () {
32-
requestAnimationFrame(() => {})
33-
}
34-
}
12+
<eslint-code-block :rules="{'vue/no-async-in-computed-properties': ['error']}">
3513
```
14+
<script>
15+
export default {
16+
computed: {
17+
/* ✓ GOOD */
18+
foo () {
19+
var bar = 0
20+
try {
21+
bar = bar / this.a
22+
} catch (e) {
23+
return 0
24+
} finally {
25+
return bar
26+
}
27+
},
3628
37-
:+1: Examples of **correct** code for this rule:
38-
39-
```js
40-
computed: {
41-
foo () {
42-
var bar = 0
43-
try {
44-
bar = bar / this.a
45-
} catch (e) {
46-
return 0
47-
} finally {
48-
return bar
29+
/* ✗ BAD */
30+
pro () {
31+
return Promise.all([new Promise((resolve, reject) => {})])
32+
},
33+
foo1: async function () {
34+
return await someFunc()
35+
},
36+
bar () {
37+
return fetch(url).then(response => {})
38+
},
39+
tim () {
40+
setTimeout(() => { }, 0)
41+
},
42+
inter () {
43+
setInterval(() => { }, 0)
44+
},
45+
anim () {
46+
requestAnimationFrame(() => {})
4947
}
5048
}
5149
}
50+
</script>
5251
```
52+
</eslint-code-block>
5353

5454
## :wrench: Options
5555

5656
Nothing.
5757

58-
## Related links
58+
## :books: Further reading
5959

6060
- [vue-async-computed](https://github.com/foxbenjaminfox/vue-async-computed)
6161

0 commit comments

Comments
 (0)