@@ -21,8 +21,6 @@ module.exports = {
2121 messages : {
2222 deepImport :
2323 "'{{importPath}}' React Native deep imports are deprecated. Please use the top level import instead." ,
24- useReplacementSource :
25- "'{{importPath}}' is deprecated. Please import '{{replacementSource}}' instead." ,
2624 } ,
2725 schema : [ ] ,
2826 fixable : 'code' ,
@@ -33,14 +31,12 @@ module.exports = {
3331 ImportDeclaration ( node ) {
3432 if (
3533 ! isDeepReactNativeImport ( node . source ) ||
34+ isInitializeCoreImport ( node . source ) ||
3635 isSecondaryEntryPoint ( node . source ) ||
3736 isFbInternalImport ( node . source )
3837 ) {
3938 return ;
4039 }
41- if ( reportReplacementSource ( node . source ) ) {
42- return ;
43- }
4440 if ( isDefaultImport ( node ) ) {
4541 const reactNativeSource = node . source . value . slice (
4642 'react-native/' . length ,
@@ -92,16 +88,13 @@ module.exports = {
9288 CallExpression ( node ) {
9389 if (
9490 ! isDeepRequire ( node ) ||
91+ isInitializeCoreImport ( node . arguments [ 0 ] ) ||
9592 isSecondaryEntryPoint ( node . arguments [ 0 ] ) ||
9693 isFbInternalImport ( node . arguments [ 0 ] )
9794 ) {
9895 return ;
9996 }
10097
101- if ( reportReplacementSource ( node . arguments [ 0 ] ) ) {
102- return ;
103- }
104-
10598 const parent = node . parent ;
10699 const importPath = node . arguments [ 0 ] . value ;
107100
@@ -130,26 +123,6 @@ module.exports = {
130123 } ,
131124 } ;
132125
133- function reportReplacementSource ( source ) {
134- const reactNativeSource = source . value . slice ( 'react-native/' . length ) ;
135- const mapping = publicAPIMapping [ reactNativeSource ] ;
136- if ( ! mapping || ! mapping . replacementSource ) {
137- return false ;
138- }
139- context . report ( {
140- node : source ,
141- messageId : 'useReplacementSource' ,
142- data : {
143- importPath : source . value ,
144- replacementSource : mapping . replacementSource ,
145- } ,
146- fix ( fixer ) {
147- return fixer . replaceText ( source , `'${ mapping . replacementSource } '` ) ;
148- } ,
149- } ) ;
150- return true ;
151- }
152-
153126 function getStandardReport ( source ) {
154127 return {
155128 node : source ,
@@ -194,15 +167,20 @@ module.exports = {
194167 return parts . length > 1 && parts [ 0 ] === 'react-native' ;
195168 }
196169
170+ function isInitializeCoreImport ( source ) {
171+ if ( source . type !== 'Literal' || typeof source . value !== 'string' ) {
172+ return false ;
173+ }
174+
175+ return source . value === 'react-native/Libraries/Core/InitializeCore' ;
176+ }
177+
197178 function isSecondaryEntryPoint ( source ) {
198179 if ( source . type !== 'Literal' || typeof source . value !== 'string' ) {
199180 return false ;
200181 }
201182
202- return (
203- source . value === 'react-native/asset-registry' ||
204- source . value === 'react-native/setup-env'
205- ) ;
183+ return source . value === 'react-native/asset-registry' ;
206184 }
207185
208186 function isFbInternalImport ( source ) {
0 commit comments