Skip to content

Commit ff6b275

Browse files
ota-meshimysticatea
authored andcommitted
Docs: update docs of require-direct-export.md and v-on-function-call.md (#844)
1 parent febc727 commit ff6b275

File tree

2 files changed

+86
-58
lines changed

2 files changed

+86
-58
lines changed

docs/rules/require-direct-export.md

+34-20
Original file line numberDiff line numberDiff line change
@@ -7,37 +7,51 @@ description: require the component to be directly exported
77
# vue/require-direct-export
88
> require the component to be directly exported
99
10-
## Rule Details
10+
## :book: Rule Details
1111

1212
This rule aims to require that the component object be directly exported.
1313

14-
:-1: Examples of **incorrect** code:
14+
<eslint-code-block :rules="{'vue/require-direct-export': ['error']}">
1515

16-
```js
16+
```vue
17+
<script>
18+
/* ✓ GOOD */
19+
export default {
20+
name: 'ComponentA',
21+
data() {
22+
return {
23+
state: 1
24+
}
25+
}
26+
}
27+
</script>
28+
```
29+
30+
</eslint-code-block>
31+
32+
<eslint-code-block :rules="{'vue/require-direct-export': ['error']}">
33+
34+
```vue
35+
<script>
1736
const ComponentA = {
18-
name: 'ComponentA',
19-
data() {
20-
return {
21-
state: 1
22-
}
23-
}
37+
name: 'ComponentA',
38+
data() {
39+
return {
40+
state: 1
41+
}
42+
}
2443
}
2544
45+
/* ✗ BAD */
2646
export default ComponentA
47+
</script>
2748
```
2849

29-
:+1: Examples of **correct** code:
50+
</eslint-code-block>
3051

31-
```js
32-
export default {
33-
name: 'ComponentA',
34-
data() {
35-
return {
36-
state: 1
37-
}
38-
}
39-
}
40-
```
52+
## :wrench: Options
53+
54+
Nothing.
4155

4256
## :mag: Implementation
4357

docs/rules/v-on-function-call.md

+52-38
Original file line numberDiff line numberDiff line change
@@ -11,66 +11,80 @@ description: enforce or forbid parentheses after method calls without arguments
1111

1212
## :book: Rule Details
1313

14-
:-1: Example of **incorrect** code for this rule:
15-
16-
```html
17-
<button v-on:click="closeModal()">
18-
Close
19-
</button>
14+
This rule aims to enforce to bind methods to `v-on` or call methods on `v-on` when without arguments.
15+
16+
<eslint-code-block fix :rules="{'vue/v-on-function-call': ['error']}">
17+
18+
```vue
19+
<template>
20+
<!-- ✓ GOOD -->
21+
<button v-on:click="closeModal">
22+
Close
23+
</button>
24+
25+
<!-- ✗ BAD -->
26+
<button v-on:click="closeModal()">
27+
Close
28+
</button>
29+
</template>
2030
```
2131

22-
:+1: Example of **correct** code for this rule:
23-
24-
```html
25-
<button v-on:click="closeModal">
26-
Close
27-
</button>
28-
```
32+
</eslint-code-block>
2933

3034
## :wrench: Options
3135

3236
Default is set to `never`.
3337

34-
```
35-
'vue/v-on-function-call': [2, 'always'|'never']
38+
```json
39+
{
40+
"vue/v-on-function-call": ["error", "always"|"never"]
41+
}
3642
```
3743

3844
### `"always"` - Always use parentheses in `v-on` directives
3945

40-
:-1: Example of **incorrect** code:
46+
<eslint-code-block fix :rules="{'vue/v-on-function-call': ['error', 'always']}">
4147

42-
```html
43-
<button v-on:click="closeModal">
44-
Close
45-
</button>
46-
```
48+
```vue
49+
<template>
50+
<!-- ✓ GOOD -->
51+
<button v-on:click="closeModal()">
52+
Close
53+
</button>
4754
48-
:+1: Example of **correct** code:
49-
50-
```html
51-
<button v-on:click="closeModal()">
52-
Close
53-
</button>
55+
<!-- ✗ BAD -->
56+
<button v-on:click="closeModal">
57+
Close
58+
</button>
59+
</template>
5460
```
5561

62+
</eslint-code-block>
63+
5664
### `"never"` - Never use parentheses in `v-on` directives for method calls without arguments
5765

58-
:-1: Example of **incorrect** code:
5966

60-
```html
61-
<button v-on:click="closeModal()">
62-
Close
63-
</button>
64-
```
67+
<eslint-code-block fix :rules="{'vue/v-on-function-call': ['error', 'never']}">
6568

66-
:+1: Example of **correct** code:
69+
```vue
70+
<template>
71+
<!-- ✓ GOOD -->
72+
<button v-on:click="closeModal">
73+
Close
74+
</button>
75+
<button v-on:click="closeModal(arg)">
76+
Close
77+
</button>
6778
68-
```html
69-
<button v-on:click="closeModal">
70-
Close
71-
</button>
79+
<!-- ✗ BAD -->
80+
<button v-on:click="closeModal()">
81+
Close
82+
</button>
83+
</template>
7284
```
7385

86+
</eslint-code-block>
87+
7488
## :mag: Implementation
7589

7690
- [Rule source](https://github.com/vuejs/eslint-plugin-vue/blob/master/lib/rules/v-on-function-call.js)

0 commit comments

Comments
 (0)