@@ -13,9 +13,6 @@ const utils = require('../utils')
1313// ------------------------------------------------------------------------------
1414// Rule Definition
1515// ------------------------------------------------------------------------------
16- /** @type {GroupName[] } */
17- const GROUP_NAMES = [ 'model' ]
18-
1916const VALID_MODEL_KEYS = [ 'prop' , 'event' ]
2017
2118module . exports = {
@@ -31,22 +28,30 @@ module.exports = {
3128 } ,
3229 /** @param {RuleContext } context */
3330 create ( context ) {
34- const groups = new Set ( GROUP_NAMES )
35-
3631 // ----------------------------------------------------------------------
3732 // Public
3833 // ----------------------------------------------------------------------
3934
4035 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+ }
4240
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 ) {
4550 context . report ( {
46- node : o . node ,
51+ node : p ,
4752 message : "Invalid key '{{name}}' in model option." ,
4853 data : {
49- name : o . name
54+ name
5055 }
5156 } )
5257 }
0 commit comments