Skip to content

Commit

Permalink
Add deepData option to vue/no-unused-properties rule (#1387)
Browse files Browse the repository at this point in the history
* Add deepData option to `vue/no-unused-properties`

* update

* update

* update
  • Loading branch information
ota-meshi committed Dec 27, 2020
1 parent 7c0cd3e commit e1cabbb
Show file tree
Hide file tree
Showing 4 changed files with 995 additions and 367 deletions.
30 changes: 29 additions & 1 deletion docs/rules/no-unused-properties.md
Expand Up @@ -54,7 +54,8 @@ This rule cannot be checked for use in other components (e.g. `mixins`, Property
```json
{
"vue/no-unused-properties": ["error", {
"groups": ["props"]
"groups": ["props"],
"deepData": false
}]
}
```
Expand All @@ -65,6 +66,7 @@ This rule cannot be checked for use in other components (e.g. `mixins`, Property
- `"computed"`
- `"methods"`
- `"setup"`
- `"deepData"` (`boolean`) If `true`, the object of the property defined in `data` will be searched deeply. Default is `false`. Include `"data"` in `groups` to use this option.

### `"groups": ["props", "data"]`

Expand Down Expand Up @@ -108,6 +110,32 @@ This rule cannot be checked for use in other components (e.g. `mixins`, Property

</eslint-code-block>

### `{ "groups": ["props", "data"], "deepData": true }`

<eslint-code-block :rules="{'vue/no-unused-properties': ['error', {groups: ['props', 'data'], deepData: true}]}">

```vue
<template>
<Foo :param="state.used">
</template>
<script>
export default {
data() {
return {
state: {
/* ✓ GOOD */
used: null,
/* ✗ BAD (`state.unused` data not used) */
unused: null
}
}
}
}
</script>
```

</eslint-code-block>

### `"groups": ["props", "computed"]`

<eslint-code-block :rules="{'vue/no-unused-properties': ['error', {groups: ['props', 'computed']}]}">
Expand Down

0 comments on commit e1cabbb

Please sign in to comment.