@@ -19,7 +19,7 @@ const forbiddenTypes = [
1919 'UpdateExpression'
2020]
2121
22- const isForbiddenType = nodeType => forbiddenTypes . indexOf ( nodeType ) > - 1
22+ const isForbiddenType = node => forbiddenTypes . indexOf ( node . type ) > - 1 && node . raw !== 'null'
2323
2424module . exports = {
2525 meta : {
@@ -46,7 +46,7 @@ module.exports = {
4646 }
4747
4848 const checkPropertyNode = ( p ) => {
49- if ( isForbiddenType ( p . value . type ) ) {
49+ if ( isForbiddenType ( p . value ) ) {
5050 context . report ( {
5151 node : p . value ,
5252 message,
@@ -57,7 +57,7 @@ module.exports = {
5757 } )
5858 } else if ( p . value . type === 'ArrayExpression' ) {
5959 p . value . elements
60- . filter ( prop => isForbiddenType ( prop . type ) )
60+ . filter ( prop => isForbiddenType ( prop ) )
6161 . forEach ( prop => context . report ( {
6262 node : prop ,
6363 message,
@@ -79,20 +79,21 @@ module.exports = {
7979
8080 if ( ! node ) return
8181
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+ )
9091
91- if ( ! typeProperty ) return
92+ if ( ! typeProperty ) return
9293
93- checkPropertyNode ( typeProperty )
94- }
95- } )
94+ checkPropertyNode ( typeProperty )
95+ }
96+ } )
9697 } )
9798 }
9899}
0 commit comments