File tree Expand file tree Collapse file tree 1 file changed +36
-36
lines changed Expand file tree Collapse file tree 1 file changed +36
-36
lines changed Original file line number Diff line number Diff line change @@ -9,53 +9,53 @@ If you need async computed properties you might want to consider using additiona
9
9
10
10
This rule is aimed at preventing asynchronous methods from being called in computed properties.
11
11
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']} " >
35
13
```
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
+ },
36
28
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(() => {})
49
47
}
50
48
}
51
49
}
50
+ </script>
52
51
```
52
+ </eslint-code-block >
53
53
54
54
## :wrench : Options
55
55
56
56
Nothing.
57
57
58
- ## Related links
58
+ ## : books : Further reading
59
59
60
60
- [ vue-async-computed] ( https://github.com/foxbenjaminfox/vue-async-computed )
61
61
You can’t perform that action at this time.
0 commit comments