Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
1,555 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
--- | ||
pageClass: rule-details | ||
sidebarDepth: 0 | ||
title: vue/no-undef-properties | ||
description: disallow undefined properties | ||
--- | ||
# vue/no-undef-properties | ||
|
||
> disallow undefined properties | ||
- :exclamation: <badge text="This rule has not been released yet." vertical="middle" type="error"> ***This rule has not been released yet.*** </badge> | ||
|
||
## :book: Rule Details | ||
|
||
This rule warns of using undefined properties. | ||
This rule can help you locate potential errors resulting from misspellings property names, and implicitly added properties. | ||
|
||
::: warning Note | ||
This rule cannot detect properties defined in other files or components. | ||
::: | ||
|
||
<eslint-code-block :rules="{'vue/no-undef-properties': ['error']}"> | ||
|
||
```vue | ||
<template> | ||
<!-- ✓ GOOD --> | ||
<div>{{ name }}: {{ count }}</div> | ||
<!-- ✗ BAD --> | ||
<div>{{ label }}: {{ cnt }}</div> | ||
</template> | ||
<script> | ||
export default { | ||
props: ['name'], | ||
data () { | ||
return { | ||
count: 0 | ||
} | ||
}, | ||
methods: { | ||
click() { | ||
/* ✓ GOOD */ | ||
this.count++ | ||
/* ✗ BAD */ | ||
this.cnt++ | ||
} | ||
} | ||
} | ||
</script> | ||
``` | ||
|
||
</eslint-code-block> | ||
|
||
## :wrench: Options | ||
|
||
```json | ||
{ | ||
"vue/no-undef-properties": ["error", { | ||
"ignores": ["/^\\$/"] | ||
}] | ||
} | ||
``` | ||
|
||
- `ignores` (`string[]`) ... An array of property names or patterns that have already been defined property, or property to ignore from the check. Default is `["/^\\$/"]`. | ||
|
||
### `"ignores": ["/^\\$/"]` (default) | ||
|
||
<eslint-code-block :rules="{'vue/no-undef-properties': ['error', {ignores: ['/^\\$/']}]}"> | ||
|
||
```vue | ||
<template> | ||
<!-- ✓ GOOD --> | ||
<div>{{ $t('foo') }}</div> | ||
</template> | ||
<script> | ||
export default { | ||
mounted() { | ||
/* ✓ GOOD */ | ||
const hash = this.$route.hash | ||
} | ||
} | ||
</script> | ||
``` | ||
|
||
</eslint-code-block> | ||
|
||
## :mag: Implementation | ||
|
||
- [Rule source](https://github.com/vuejs/eslint-plugin-vue/blob/master/lib/rules/no-undef-properties.js) | ||
- [Test source](https://github.com/vuejs/eslint-plugin-vue/blob/master/tests/lib/rules/no-undef-properties.js) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.