Skip to content

Updated "vue/no-potential-component-option-typo" rule to support Vue 3.x and update docs. #1150

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 20, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
59 changes: 31 additions & 28 deletions docs/rules/no-potential-component-option-typo.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,18 @@ description: disallow a potential typo in your component property

## :book: Rule Details

This Rule disallow a potential typo in your component options
This rule disallow a potential typo in your component options

**Here is the config**
```js
{'vue/no-potential-component-option-typo': ['error', {presets: ['all'], custom: ['test']}]}

```json
{
"vue/no-potential-component-option-typo": ["error", {
"presets": ["all"],
"custom": ["test"]
}
]
}
```

<eslint-code-block :rules="{'vue/no-potential-component-option-typo': ['error', {presets: ['all'], custom: ['test']}]}">
Expand Down Expand Up @@ -50,8 +57,14 @@ export default {
> we use editdistance to compare two string similarity, threshold is an option to control upper bound of editdistance to report

**Here is the another example about config option `threshold`**
```js
{'vue/no-potential-component-option-typo': ['error', {presets: ['vue', 'nuxt'], threshold: 5}]}

```json
{
"vue/no-potential-component-option-typo": ["error", {
"presets": ["vue", "nuxt"],
"threshold": 5
}]
}
```

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

## :wrench: Options
```js

```json
{
"vue/no-unsed-vars": [{
presets: {
type: 'array',
items: {
type: 'string',
enum: ['all', 'vue', 'vue-router', 'nuxt']
},
uniqueItems: true,
minItems: 0
},
custom: {
type: 'array',
minItems: 0,
items: { type: 'string' },
uniqueItems: true
},
threshold: {
type: 'number',
'minimum': 1
}
}]
"vue/no-unsed-vars": ["error", {
"presets": ["vue"],
"custom": [],
"threshold": 1
}]
}
```
- `presets` ... `enum type`, contains several common vue component option set, `['all']` is the same as `['vue', 'vue-router', 'nuxt']`. **default** `[]`

- `presets` ... `enum type`, contains several common vue component option set, `["all"]` is the same as `["vue", "vue-router", "nuxt"]`. **default** `["vue"]`
- `custom` ... `array type`, a list store your custom component option want to detect. **default** `[]`
- `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`

## :rocket: Suggestion

- 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

## :books: Further reading

- [Edit_distance](https://en.wikipedia.org/wiki/Edit_distance)

## :mag: Implementation

- [Rule source](https://github.com/vuejs/eslint-plugin-vue/blob/master/lib/rules/no-potential-component-option-typo.js)
Expand Down
11 changes: 9 additions & 2 deletions lib/utils/vue-component-options.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,13 @@
"extends",
"delimiters",
"comments",
"inheritAttrs"
"inheritAttrs",

"setup",
"emits",
"beforeUnmount",
"unmounted",
"renderTracked",
"renderTriggered"
]
}
}