Skip to content

Commit 0a5aeaf

Browse files
authored
Updated "vue/no-potential-component-option-typo" rule to support Vue 3.x and update docs. (#1150)
1 parent a95b1f2 commit 0a5aeaf

File tree

2 files changed

+40
-30
lines changed

2 files changed

+40
-30
lines changed

Diff for: docs/rules/no-potential-component-option-typo.md

+31-28
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,18 @@ description: disallow a potential typo in your component property
99
1010
## :book: Rule Details
1111

12-
This Rule disallow a potential typo in your component options
12+
This rule disallow a potential typo in your component options
1313

1414
**Here is the config**
15-
```js
16-
{'vue/no-potential-component-option-typo': ['error', {presets: ['all'], custom: ['test']}]}
15+
16+
```json
17+
{
18+
"vue/no-potential-component-option-typo": ["error", {
19+
"presets": ["all"],
20+
"custom": ["test"]
21+
}
22+
]
23+
}
1724
```
1825

1926
<eslint-code-block :rules="{'vue/no-potential-component-option-typo': ['error', {presets: ['all'], custom: ['test']}]}">
@@ -50,8 +57,14 @@ export default {
5057
> we use editdistance to compare two string similarity, threshold is an option to control upper bound of editdistance to report
5158
5259
**Here is the another example about config option `threshold`**
53-
```js
54-
{'vue/no-potential-component-option-typo': ['error', {presets: ['vue', 'nuxt'], threshold: 5}]}
60+
61+
```json
62+
{
63+
"vue/no-potential-component-option-typo": ["error", {
64+
"presets": ["vue", "nuxt"],
65+
"threshold": 5
66+
}]
67+
}
5568
```
5669

5770
<eslint-code-block :rules="{'vue/no-potential-component-option-typo': ['error', {presets: ['vue', 'nuxt'], threshold: 5}]}">
@@ -82,39 +95,29 @@ export default {
8295
</eslint-code-block>
8396

8497
## :wrench: Options
85-
```js
98+
99+
```json
86100
{
87-
"vue/no-unsed-vars": [{
88-
presets: {
89-
type: 'array',
90-
items: {
91-
type: 'string',
92-
enum: ['all', 'vue', 'vue-router', 'nuxt']
93-
},
94-
uniqueItems: true,
95-
minItems: 0
96-
},
97-
custom: {
98-
type: 'array',
99-
minItems: 0,
100-
items: { type: 'string' },
101-
uniqueItems: true
102-
},
103-
threshold: {
104-
type: 'number',
105-
'minimum': 1
106-
}
107-
}]
101+
"vue/no-unsed-vars": ["error", {
102+
"presets": ["vue"],
103+
"custom": [],
104+
"threshold": 1
105+
}]
108106
}
109107
```
110-
- `presets` ... `enum type`, contains several common vue component option set, `['all']` is the same as `['vue', 'vue-router', 'nuxt']`. **default** `[]`
108+
109+
- `presets` ... `enum type`, contains several common vue component option set, `["all"]` is the same as `["vue", "vue-router", "nuxt"]`. **default** `["vue"]`
111110
- `custom` ... `array type`, a list store your custom component option want to detect. **default** `[]`
112111
- `threshold` ... `number type`, a number used to control the upper limit of the reported editing distance, we recommend don't change this config option, even if it is required, not bigger than `2`. **default** `1`
112+
113113
## :rocket: Suggestion
114+
114115
- We provide all the possible component option that editdistance between your vue component option and configuration options is greater than 0 and lessEqual than threshold
115116

116117
## :books: Further reading
118+
117119
- [Edit_distance](https://en.wikipedia.org/wiki/Edit_distance)
120+
118121
## :mag: Implementation
119122

120123
- [Rule source](https://github.com/vuejs/eslint-plugin-vue/blob/master/lib/rules/no-potential-component-option-typo.js)

Diff for: lib/utils/vue-component-options.json

+9-2
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,13 @@
4242
"extends",
4343
"delimiters",
4444
"comments",
45-
"inheritAttrs"
45+
"inheritAttrs",
46+
47+
"setup",
48+
"emits",
49+
"beforeUnmount",
50+
"unmounted",
51+
"renderTracked",
52+
"renderTriggered"
4653
]
47-
}
54+
}

0 commit comments

Comments
 (0)