File tree 3 files changed +66
-3
lines changed
3 files changed +66
-3
lines changed Original file line number Diff line number Diff line change
1
+ # disallow mutation of component props (vue/no-mutating-props)
2
+
3
+ This rule reports mutation of component props.
4
+
5
+ ## Rule Details
6
+
7
+ :-1 : Examples of ** incorrect** code for this rule:
8
+
9
+ ``` html
10
+ <template >
11
+ <div >
12
+ <input v-model =" value" @click =" openModal" >
13
+ </div >
14
+ </template >
15
+ <script >
16
+ export default {
17
+ props: {
18
+ value: {
19
+ type: String ,
20
+ required: true
21
+ }
22
+ },
23
+ methods: {
24
+ openModal () {
25
+ this .value = ' test'
26
+ }
27
+ }
28
+ }
29
+ </script >
30
+ ```
31
+
32
+ :+1 : Examples of ** correct** code for this rule:
33
+
34
+ ``` html
35
+ <template >
36
+ <div >
37
+ <input :value =" value" @input =" $emit('input', $event.target.value)" @click =" openModal" >
38
+ </div >
39
+ </template >
40
+ <script >
41
+ export default {
42
+ props: {
43
+ value: {
44
+ type: String ,
45
+ required: true
46
+ }
47
+ },
48
+ methods: {
49
+ openModal () {
50
+ this .$emit (' input' , ' test' )
51
+ }
52
+ }
53
+ }
54
+ </script >
55
+ ```
56
+
57
+ ## :wrench : Options
58
+
59
+ Nothing.
60
+
61
+ ## Related links
62
+
63
+ - [ Style guide - Prop Mutation - deprecated] ( https://vuejs.org/v2/guide/migration.html#Prop-Mutation-deprecated )
Original file line number Diff line number Diff line change 1
1
/**
2
- * @fileoverview Check if component props are not mutated
2
+ * @fileoverview disallow mutation component props
3
3
* @author 2018 Armano
4
4
*/
5
5
'use strict'
@@ -13,7 +13,7 @@ const utils = require('../utils')
13
13
module . exports = {
14
14
meta : {
15
15
docs : {
16
- description : 'disallow mutation of props' ,
16
+ description : 'disallow mutation of component props' ,
17
17
category : undefined ,
18
18
url : 'https://github.com/vuejs/eslint-plugin-vue/blob/v5.0.0-beta.3/docs/rules/no-mutating-props.md'
19
19
} ,
Original file line number Diff line number Diff line change 1
1
/**
2
- * @fileoverview Check if component props are not mutated
2
+ * @fileoverview disallow mutation of component props
3
3
* @author 2018 Armano
4
4
*/
5
5
'use strict'
You can’t perform that action at this time.
0 commit comments