@@ -19,7 +19,7 @@ const forbiddenTypes = [
19
19
'UpdateExpression'
20
20
]
21
21
22
- const isForbiddenType = nodeType => forbiddenTypes . indexOf ( nodeType ) > - 1
22
+ const isForbiddenType = node => forbiddenTypes . indexOf ( node . type ) > - 1 && node . raw !== 'null'
23
23
24
24
module . exports = {
25
25
meta : {
@@ -46,7 +46,7 @@ module.exports = {
46
46
}
47
47
48
48
const checkPropertyNode = ( p ) => {
49
- if ( isForbiddenType ( p . value . type ) ) {
49
+ if ( isForbiddenType ( p . value ) ) {
50
50
context . report ( {
51
51
node : p . value ,
52
52
message,
@@ -57,7 +57,7 @@ module.exports = {
57
57
} )
58
58
} else if ( p . value . type === 'ArrayExpression' ) {
59
59
p . value . elements
60
- . filter ( prop => isForbiddenType ( prop . type ) )
60
+ . filter ( prop => isForbiddenType ( prop ) )
61
61
. forEach ( prop => context . report ( {
62
62
node : prop ,
63
63
message,
@@ -79,20 +79,21 @@ module.exports = {
79
79
80
80
if ( ! node ) return
81
81
82
- node . value . properties . forEach ( p => {
83
- if ( isForbiddenType ( p . value . type ) || p . value . type === 'ArrayExpression' ) {
84
- checkPropertyNode ( p )
85
- } else if ( p . value . type === 'ObjectExpression' ) {
86
- const typeProperty = p . value . properties . find ( prop =>
87
- prop . type === 'Property' &&
88
- prop . key . name === 'type'
89
- )
82
+ node . value . properties
83
+ . forEach ( p => {
84
+ if ( isForbiddenType ( p . value ) || p . value . type === 'ArrayExpression' ) {
85
+ checkPropertyNode ( p )
86
+ } else if ( p . value . type === 'ObjectExpression' ) {
87
+ const typeProperty = p . value . properties . find ( prop =>
88
+ prop . type === 'Property' &&
89
+ prop . key . name === 'type'
90
+ )
90
91
91
- if ( ! typeProperty ) return
92
+ if ( ! typeProperty ) return
92
93
93
- checkPropertyNode ( typeProperty )
94
- }
95
- } )
94
+ checkPropertyNode ( typeProperty )
95
+ }
96
+ } )
96
97
} )
97
98
}
98
99
}
0 commit comments