Skip to content

Commit a23fe20

Browse files
committed
Add doc
1 parent 3261b9a commit a23fe20

File tree

3 files changed

+66
-3
lines changed

3 files changed

+66
-3
lines changed

Diff for: docs/rules/no-mutating-props.md

+63
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
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)

Diff for: lib/rules/no-mutating-props.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/**
2-
* @fileoverview Check if component props are not mutated
2+
* @fileoverview disallow mutation component props
33
* @author 2018 Armano
44
*/
55
'use strict'
@@ -13,7 +13,7 @@ const utils = require('../utils')
1313
module.exports = {
1414
meta: {
1515
docs: {
16-
description: 'disallow mutation of props',
16+
description: 'disallow mutation of component props',
1717
category: undefined,
1818
url: 'https://github.com/vuejs/eslint-plugin-vue/blob/v5.0.0-beta.3/docs/rules/no-mutating-props.md'
1919
},

Diff for: tests/lib/rules/no-mutating-props.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/**
2-
* @fileoverview Check if component props are not mutated
2+
* @fileoverview disallow mutation of component props
33
* @author 2018 Armano
44
*/
55
'use strict'

0 commit comments

Comments
 (0)