@@ -13,9 +13,6 @@ const utils = require('../utils')
13
13
// ------------------------------------------------------------------------------
14
14
// Rule Definition
15
15
// ------------------------------------------------------------------------------
16
- /** @type {GroupName[] } */
17
- const GROUP_NAMES = [ 'model' ]
18
-
19
16
const VALID_MODEL_KEYS = [ 'prop' , 'event' ]
20
17
21
18
module . exports = {
@@ -31,22 +28,30 @@ module.exports = {
31
28
} ,
32
29
/** @param {RuleContext } context */
33
30
create ( context ) {
34
- const groups = new Set ( GROUP_NAMES )
35
-
36
31
// ----------------------------------------------------------------------
37
32
// Public
38
33
// ----------------------------------------------------------------------
39
34
40
35
return utils . executeOnVue ( context , ( obj ) => {
41
- const properties = utils . iterateProperties ( obj , groups )
36
+ const modelProperty = utils . findProperty ( obj , 'model' )
37
+ if ( ! modelProperty || modelProperty . value . type !== 'ObjectExpression' ) {
38
+ return
39
+ }
42
40
43
- for ( const o of properties ) {
44
- if ( VALID_MODEL_KEYS . indexOf ( o . name ) === - 1 ) {
41
+ for ( const p of modelProperty . value . properties ) {
42
+ if ( p . type !== 'Property' ) {
43
+ continue
44
+ }
45
+ const name = utils . getStaticPropertyName ( p )
46
+ if ( ! name ) {
47
+ continue
48
+ }
49
+ if ( VALID_MODEL_KEYS . indexOf ( name ) === - 1 ) {
45
50
context . report ( {
46
- node : o . node ,
51
+ node : p ,
47
52
message : "Invalid key '{{name}}' in model option." ,
48
53
data : {
49
- name : o . name
54
+ name
50
55
}
51
56
} )
52
57
}
0 commit comments