@@ -70,38 +70,42 @@ module.exports = {
70
70
create : ( { options, report, getSourceCode } : ESLintContext ) => {
71
71
// Checks to see if there are valid imports and if so verifies that those imports related to 'react-native' or if a custom module exists
72
72
const { text } = getSourceCode ( ) ;
73
- let hasCustomImage = false ;
73
+ let hasImageImportAlias = false ;
74
74
if ( text . match ( new RegExp ( / i m p o r t / , 'g' ) ) ) {
75
75
const hasReactNativeImage = verifyReactNativeImage ( text ) ;
76
76
if ( ! hasReactNativeImage ) {
77
- hasCustomImage = true ;
77
+ hasImageImportAlias = true ;
78
78
}
79
79
}
80
80
81
81
// avoid directly mutating a constant as it ends up stacking up duplicate strings
82
- const elementsToCheck = ! hasCustomImage
82
+ const elementsToCheck = ! hasImageImportAlias
83
83
? [ ...defaultInvertableComponents ]
84
84
: [ ] ;
85
85
if ( options . length > 0 ) {
86
86
const { invertableComponents } = options [ 0 ] ;
87
87
if ( invertableComponents ) {
88
88
elementsToCheck . push ( ...invertableComponents ) ;
89
89
}
90
- } else if ( hasCustomImage ) {
90
+ } else if ( hasImageImportAlias && options . length === 0 ) {
91
91
// Exit process if there is nothing to check
92
- // return {};
92
+ return { } ;
93
93
}
94
94
95
95
return {
96
96
JSXElement : ( node : JSXElement ) => {
97
- /**
98
- * @description RegExp to select single or multiline 'Image' component and determine if the import origin path is 'react-native' or a custom module
99
- * */
100
97
// $FlowFixMe
101
98
const { children, openingElement, parent } = node ;
102
99
100
+ // $FlowFixMe
101
+ const { name } = openingElement . name ;
102
+
103
+ // escape out if the item is an ignored JSXElement
104
+ if ( hasImageImportAlias && name === 'Image' ) {
105
+ return ;
106
+ }
107
+
103
108
if (
104
- ! hasCustomImage &&
105
109
hasProp ( openingElement . attributes , propName ) &&
106
110
! isNodePropValueBoolean ( getProp ( openingElement . attributes , propName ) )
107
111
) {
0 commit comments