8000 Add example to return-in-computed-property · vuejs/eslint-plugin-vue@9221c6f · GitHub
[go: up one dir, main page]

Skip to content

Commit 9221c6f

Browse files
committed
Add example to return-in-computed-property
1 parent 22804af commit 9221c6f

File tree

1 file changed

+34
-3
lines changed

1 file changed

+34
-3
lines changed

docs/rules/return-in-computed-property.md

Lines changed: 34 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,6 @@ export default {
3737

3838
## :wrench: Options
3939

40-
This rule has an object option:
41-
- `"treatUndefinedAsUnspecified"`: `true` (default) disallows implicitly returning undefined with a `return;` statement.
42-
4340
```json
4441
{
4542
"vue/return-in-computed-property": [2, {
@@ -48,6 +45,40 @@ This rule has an object option:
4845
}
4946
```
5047

48+
This rule has an object option:
49+
- `"treatUndefinedAsUnspecified"`: `true` (default) disallows implicitly returning undefined with a `return` statement.
50+
51+
### `treatUndefinedAsUnspecified: false`
52+
53+
<eslint-code-block :rules="{'vue/return-in-computed-property': ['error', { treatUndefinedAsUnspecified: false }]}">
54+
```vue
55+
<script>
56+
export default {
57+
computed: {
58+
/* ✓ GOOD */
59+
foo () {
60+
if (this.bar) {
61+
return undefined
62+
} else {
63+
return
64+
}
65+
},
66+
bar: function () {
67+
return
68+
},
69+
/* ✗ BAD */
70+
baz () {
71+
if (this.baf) {
72+
return this.baf
73+
}
74+
},
75+
baf: function () {}
76+
}
77+
}
78+
</script>
79+
```
80+
</eslint-code-block>
81+
5182
## :mag: Implementation
5283

5384
- [Rule source](https://github.com/vuejs/eslint-plugin-vue/blob/master/lib/rules/return-in-computed-property.js)

0 commit comments

Comments
 (0)
0