File tree Expand file tree Collapse file tree 5 files changed +1973
-0
lines changed Expand file tree Collapse file tree 5 files changed +1973
-0
lines changed Original file line number Diff line number Diff line change @@ -317,6 +317,7 @@ For example:
317
317
| [ vue/no-static-inline-styles] ( ./no-static-inline-styles.md ) | disallow static inline ` style ` attributes | |
318
318
| [ vue/no-template-target-blank] ( ./no-template-target-blank.md ) | disallow target="_ blank" attribute without rel="noopener noreferrer" | |
319
319
| [ vue/no-this-in-before-route-enter] ( ./no-this-in-before-route-enter.md ) | disallow ` this ` usage in a ` beforeRouteEnter ` method | |
320
+ | [ vue/no-undef-properties] ( ./no-undef-properties.md ) | disallow undefined properties | |
320
321
| [ vue/no-unregistered-components] ( ./no-unregistered-components.md ) | disallow using components that are not registered inside templates | |
321
322
| [ vue/no-unsupported-features] ( ./no-unsupported-features.md ) | disallow unsupported Vue.js syntax on the specified version | :wrench : |
322
323
| [ vue/no-unused-properties] ( ./no-unused-properties.md ) | disallow unused properties | |
Original file line number Diff line number Diff line change
1
+ ---
2
+ pageClass : rule-details
3
+ sidebarDepth : 0
4
+ title : vue/no-undef-properties
5
+ description : disallow undefined properties
6
+ ---
7
+ # vue/no-undef-properties
8
+
9
+ > disallow undefined properties
10
+
11
+ - :exclamation : <badge text =" This rule has not been released yet. " vertical =" middle " type =" error " > *** This rule has not been released yet.*** </badge >
12
+
13
+ ## :book : Rule Details
14
+
15
+ This rule warns of using undefined properties.
16
+ This rule can help you locate potential errors resulting from misspellings property names, and implicitly added properties.
17
+
18
+ ::: warning Note
19
+ This rule cannot detect properties defined in other files or components.
20
+ :::
21
+
22
+ <eslint-code-block :rules =" {'vue/no-undef-properties': ['error']} " >
23
+
24
+ ``` vue
25
+ <template>
26
+ <!-- ✓ GOOD -->
27
+ <div>{{ name }}: {{ count }}</div>
28
+ <!-- ✗ BAD -->
29
+ <div>{{ label }}: {{ cnt }}</div>
30
+ </template>
31
+ <script>
32
+ export default {
33
+ props: ['name'],
34
+ data () {
35
+ return {
36
+ count: 0
37
+ }
38
+ },
39
+ methods: {
40
+ click() {
41
+ /* ✓ GOOD */
42
+ this.count++
43
+
44
+ /* ✗ BAD */
45
+ this.cnt++
46
+ }
47
+ }
48
+ }
49
+ </script>
50
+ ```
51
+
52
+ </eslint-code-block >
53
+
54
+ ## :wrench : Options
55
+
56
+ ``` json
57
+ {
58
+ "vue/no-undef-properties" : [" error" , {
59
+ "ignores" : [" /^\\ $/" ]
60
+ }]
61
+ }
62
+ ```
63
+
64
+ - ` ignores ` (` string[] ` ) ... An array of property names or patterns that have already been defined property, or property to ignore from the check. Default is ` ["/^\\$/"] ` .
65
+
66
+ ### ` "ignores": ["/^\\$/"] ` (default)
67
+
68
+ <eslint-code-block :rules =" {'vue/no-undef-properties': ['error', {ignores: ['/^\\$/']}]} " >
69
+
70
+ ``` vue
71
+ <template>
72
+ <!-- ✓ GOOD -->
73
+ <div>{{ $t('foo') }}</div>
74
+ </template>
75
+ <script>
76
+ export default {
77
+ mounted() {
78
+ /* ✓ GOOD */
79
+ const hash = this.$route.hash
80
+ }
81
+ }
82
+ </script>
83
+ ```
84
+
85
+ </eslint-code-block >
86
+
87
+ ## :mag : Implementation
88
+
89
+ - [ Rule source] ( https://github.com/vuejs/eslint-plugin-vue/blob/master/lib/rules/no-undef-properties.js )
90
+ - [ Test source] ( https://github.com/vuejs/eslint-plugin-vue/blob/master/tests/lib/rules/no-undef-properties.js )
Original file line number Diff line number Diff line change @@ -117,6 +117,7 @@ module.exports = {
117
117
'no-template-target-blank' : require ( './rules/no-template-target-blank' ) ,
118
118
'no-textarea-mustache' : require ( './rules/no-textarea-mustache' ) ,
119
119
'no-this-in-before-route-enter' : require ( './rules/no-this-in-before-route-enter' ) ,
120
+ 'no-undef-properties' : require ( './rules/no-undef-properties' ) ,
120
121
'no-unregistered-components' : require ( './rules/no-unregistered-components' ) ,
121
122
'no-unsupported-features' : require ( './rules/no-unsupported-features' ) ,
122
123
'no-unused-components' : require ( './rules/no-unused-components' ) ,
You can’t perform that action at this time.
0 commit comments