@@ -29,23 +29,29 @@ function create (context) {
29
29
30
30
let nodes = [ ]
31
31
const type = node . value . type
32
- if ( type === 'ObjectExpression' ) {
32
+ if ( type === 'ObjectExpression' ) { // props: {
33
33
nodes = node . value . properties . map ( cp => {
34
34
const key = cp . key . name
35
35
let value
36
- if ( cp . value . type === 'ObjectExpression' ) {
36
+ if ( cp . value . type === 'ObjectExpression' ) { // foo: {
37
37
value = cp . value . properties
38
38
. filter ( p =>
39
39
p . key . type === 'Identifier' &&
40
+ p . key . name === 'type' &&
40
41
p . value . type === 'FunctionExpression'
41
42
)
42
43
. map ( p => p . value . body ) [ 0 ]
43
- } else if ( type === 'ArrayExpression' ) {
44
+ } else if ( cp . value . type === 'ArrayExpression' ) { // foo: [
45
+ if ( cp . value . elements ) {
44
46
45
- } // TODO: literal
47
+ }
48
+ } else if ( cp . value . type === 'FunctionExpression' || cp . value . type === 'ArrowFunctionExpression' ) {
49
+ } else {
50
+ value = cp
51
+ }
46
52
return { key, value }
47
53
} )
48
- } else if ( type === 'ArrayExpression' ) {
54
+ } else if ( type === 'ArrayExpression' ) { // props: [
49
55
// nodes = node.elements
50
56
}
51
57
@@ -67,7 +73,17 @@ function create (context) {
67
73
utils . executeOnVueInstance ( context , properties => {
68
74
const data = getPropTypes ( properties )
69
75
if ( data . type === 'ObjectExpression' ) {
70
-
76
+ data . nodes . forEach ( cp => {
77
+ if ( ! cp . value ) {
78
+ context . report ( {
79
+ node : data . node ,
80
+ message : 'Prop "{{name}}" definitions should always be as detailed with at least type(s).' ,
81
+ data : {
82
+ name : cp . key
83
+ }
84
+ } )
85
+ }
86
+ } )
71
87
} else if ( data . type === 'ArrayExpression' ) {
72
88
context . report ( {
73
89
node : data . node ,
0 commit comments