File tree Expand file tree Collapse file tree 5 files changed +1974
-0
lines changed Expand file tree Collapse file tree 5 files changed +1974
-0
lines changed Original file line number Diff line number Diff line change @@ -319,6 +319,7 @@ For example:
319
319
| [ vue/no-static-inline-styles] ( ./no-static-inline-styles.md ) | disallow static inline ` style ` attributes | |
320
320
| [ vue/no-template-target-blank] ( ./no-template-target-blank.md ) | disallow target="_ blank" attribute without rel="noopener noreferrer" | |
321
321
| [ vue/no-this-in-before-route-enter] ( ./no-this-in-before-route-enter.md ) | disallow ` this ` usage in a ` beforeRouteEnter ` method | |
322
+ | [ vue/no-undef-properties] ( ./no-undef-properties.md ) | disallow undefined properties | |
322
323
| [ vue/no-unregistered-components] ( ./no-unregistered-components.md ) | disallow using components that are not registered inside templates | |
323
324
| [ vue/no-unsupported-features] ( ./no-unsupported-features.md ) | disallow unsupported Vue.js syntax on the specified version | :wrench : |
324
325
| [ 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
+ Note that there are many false positives if you are using mixins.
21
+ :::
22
+
23
+ <eslint-code-block :rules =" {'vue/no-undef-properties': ['error']} " >
24
+
25
+ ``` vue
26
+ <template>
27
+ <!-- ✓ GOOD -->
28
+ <div>{{ name }}: {{ count }}</div>
29
+ <!-- ✗ BAD -->
30
+ <div>{{ label }}: {{ cnt }}</div>
31
+ </template>
32
+ <script>
33
+ export default {
34
+ props: ['name'],
35
+ data () {
36
+ return {
37
+ count: 0
38
+ }
39
+ },
40
+ methods: {
41
+ click() {
42
+ /* ✓ GOOD */
43
+ this.count++
44
+
45
+ /* ✗ BAD */
46
+ this.cnt++
47
+ }
48
+ }
49
+ }
50
+ </script>
51
+ ```
52
+
53
+ </eslint-code-block >
54
+
55
+ ## :wrench : Options
56
+
57
+ ``` json
58
+ {
59
+ "vue/no-undef-properties" : [" error" , {
60
+ "ignores" : [" /^\\ $/" ]
61
+ }]
62
+ }
63
+ ```
64
+
65
+ - ` ignores ` (` string[] ` ) ... An array of property names or patterns that have already been defined property, or property to ignore from the check. Default is ` ["/^\\$/"] ` .
66
+
67
+ ### ` "ignores": ["/^\\$/"] ` (default)
68
+
69
+ <eslint-code-block :rules =" {'vue/no-undef-properties': ['error', {ignores: ['/^\\$/']}]} " >
70
+
71
+ ``` vue
72
+ <template>
73
+ <!-- ✓ GOOD -->
74
+ <div>{{ $t('foo') }}</div>
75
+ </template>
76
+ <script>
77
+ export default {
78
+ mounted() {
79
+ /* ✓ GOOD */
80
+ const hash = this.$route.hash
81
+ }
82
+ }
83
+ </script>
84
+ ```
85
+
86
+ </eslint-code-block >
87
+
88
+ ## :mag : Implementation
89
+
90
+ - [ Rule source] ( https://github.com/vuejs/eslint-plugin-vue/blob/master/lib/rules/no-undef-properties.js )
91
+ - [ 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 @@ -119,6 +119,7 @@ module.exports = {
119
119
'no-template-target-blank' : require ( './rules/no-template-target-blank' ) ,
120
120
'no-textarea-mustache' : require ( './rules/no-textarea-mustache' ) ,
121
121
'no-this-in-before-route-enter' : require ( './rules/no-this-in-before-route-enter' ) ,
122
+ 'no-undef-properties' : require ( './rules/no-undef-properties' ) ,
122
123
'no-unregistered-components' : require ( './rules/no-unregistered-components' ) ,
123
124
'no-unsupported-features' : require ( './rules/no-unsupported-features' ) ,
124
125
'no-unused-components' : require ( './rules/no-unused-components' ) ,
You can’t perform that action at this time.
0 commit comments