@@ -32,24 +32,21 @@ function create (context) {
32
32
if ( type === 'ObjectExpression' ) { // props: {
33
33
nodes = node . value . properties . map ( cp => {
34
34
const key = cp . key . name
35
- let value
35
+ let hasType = true
36
36
if ( cp . value . type === 'ObjectExpression' ) { // foo: {
37
- value = cp . value . properties
37
+ hasType = ! ! ( cp . value . properties
38
38
. filter ( p =>
39
39
p . key . type === 'Identifier' &&
40
40
p . key . name === 'type' &&
41
- p . value . type === 'FunctionExpression'
42
- )
43
- . map ( p => p . value . body ) [ 0 ]
41
+ (
42
+ p . value . type !== 'ArrayExpression' ||
43
+ p . value . elements . length > 0
44
+ )
45
+ ) [ 0 ] )
44
46
} else if ( cp . value . type === 'ArrayExpression' ) { // foo: [
45
- if ( cp . value . elements ) {
46
-
47
- }
48
- } else if ( cp . value . type === 'FunctionExpression' || cp . value . type === 'ArrowFunctionExpression' ) {
49
- } else {
50
- value = cp
47
+ hasType = cp . value . elements . length > 0
51
48
}
52
- return { key, value }
49
+ return { key, node : cp , hasType }
53
50
} )
54
51
} else if ( type === 'ArrayExpression' ) { // props: [
55
52
// nodes = node.elements
@@ -74,9 +71,9 @@ function create (context) {
74
71
const data = getPropTypes ( properties )
75
72
if ( data . type === 'ObjectExpression' ) {
76
73
data . nodes . forEach ( cp => {
77
- if ( ! cp . value ) {
74
+ if ( ! cp . hasType ) {
78
75
context . report ( {
79
- node : data . node ,
76
+ node : cp . node || data . node ,
80
77
message : 'Prop "{{name}}" definitions should always be as detailed with at least type(s).' ,
81
78
data : {
82
79
name : cp . key
0 commit comments