Skip to content

Commit

Permalink
Add doc
Browse files Browse the repository at this point in the history
  • Loading branch information
armano2 committed Nov 9, 2018
1 parent 3261b9a commit a23fe20
Show file tree
Hide file tree
Showing 3 changed files with 66 additions and 3 deletions.
63 changes: 63 additions & 0 deletions docs/rules/no-mutating-props.md
@@ -0,0 +1,63 @@
# disallow mutation of component props (vue/no-mutating-props)

This rule reports mutation of component props.

## Rule Details

:-1: Examples of **incorrect** code for this rule:

```html
<template>
<div>
<input v-model="value" @click="openModal">
</div>
</template>
<script>
export default {
props: {
value: {
type: String,
required: true
}
},
methods: {
openModal() {
this.value = 'test'
}
}
}
</script>
```

:+1: Examples of **correct** code for this rule:

```html
<template>
<div>
<input :value="value" @input="$emit('input', $event.target.value)" @click="openModal">
</div>
</template>
<script>
export default {
props: {
value: {
type: String,
required: true
}
},
methods: {
openModal() {
this.$emit('input', 'test')
}
}
}
</script>
```

## :wrench: Options

Nothing.

## Related links

- [Style guide - Prop Mutation - deprecated](https://vuejs.org/v2/guide/migration.html#Prop-Mutation-deprecated)
4 changes: 2 additions & 2 deletions lib/rules/no-mutating-props.js
@@ -1,5 +1,5 @@
/**
* @fileoverview Check if component props are not mutated
* @fileoverview disallow mutation component props
* @author 2018 Armano
*/
'use strict'
Expand All @@ -13,7 +13,7 @@ const utils = require('../utils')
module.exports = {
meta: {
docs: {
description: 'disallow mutation of props',
description: 'disallow mutation of component props',
category: undefined,
url: 'https://github.com/vuejs/eslint-plugin-vue/blob/v5.0.0-beta.3/docs/rules/no-mutating-props.md'
},
Expand Down
2 changes: 1 addition & 1 deletion tests/lib/rules/no-mutating-props.js
@@ -1,5 +1,5 @@
/**
* @fileoverview Check if component props are not mutated
* @fileoverview disallow mutation of component props
* @author 2018 Armano
*/
'use strict'
Expand Down

0 comments on commit a23fe20

Please sign in to comment.