@@ -11,66 +11,80 @@ description: enforce or forbid parentheses after method calls without arguments
11
11
12
12
## :book : Rule Details
13
13
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>
20
30
```
21
31
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 >
29
33
30
34
## :wrench : Options
31
35
32
36
Default is set to ` never ` .
33
37
34
- ```
35
- 'vue/v-on-function-call': [2, 'always'|'never']
38
+ ``` json
39
+ {
40
+ "vue/v-on-function-call" : [" error" , " always" |"never" ]
41
+ }
36
42
```
37
43
38
44
### ` "always" ` - Always use parentheses in ` v-on ` directives
39
45
40
- : -1 : Example of ** incorrect ** code:
46
+ < eslint-code-block fix :rules = " {'vue/v-on-function-call': ['error', 'always']} " >
41
47
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>
47
54
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>
54
60
```
55
61
62
+ </eslint-code-block >
63
+
56
64
### ` "never" ` - Never use parentheses in ` v-on ` directives for method calls without arguments
57
65
58
- :-1 : Example of ** incorrect** code:
59
66
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']} " >
65
68
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>
67
78
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>
72
84
```
73
85
86
+ </eslint-code-block >
87
+
74
88
## :mag : Implementation
75
89
76
90
- [ Rule source] ( https://github.com/vuejs/eslint-plugin-vue/blob/master/lib/rules/v-on-function-call.js )
0 commit comments