@@ -4,20 +4,28 @@ module.exports = (file, api: j.API) => {
44 const j = api . jscodeshift ;
55 const root = j ( file . source ) ;
66
7- replaceImports ( root , j ) ;
7+ const continueAfterImport = replaceImport ( root , j ) ;
8+ if ( ! continueAfterImport ) {
9+ return root . toSource ( ) ;
10+ }
11+
12+ const continueAfterComponent = replaceComponent ( root , j ) ;
13+ if ( ! continueAfterComponent ) {
14+ return root . toSource ( ) ;
15+ }
816
917 return root . toSource ( { quote : 'single' , lineTerminator : '\n' } ) ;
1018} ;
1119
12- const replaceImports = ( root , j ) => {
20+ const replaceImport = ( root , j ) => {
1321 // Check if there is an import from react-admin
1422 const reactAdminImport = root . find ( j . ImportDeclaration , {
1523 source : {
1624 value : 'react-admin' ,
1725 } ,
1826 } ) ;
1927 if ( ! reactAdminImport . length ) {
20- return root . toSource ( ) ;
28+ return false ;
2129 }
2230
2331 // Check if there is an import of DataGrid from react-admin
@@ -28,10 +36,8 @@ const replaceImports = (root, j) => {
2836 specifier . imported . name === 'Datagrid'
2937 ) ;
3038 } ) ;
31- console . log ( 'toto - 4' , datagridImport ) ;
3239 if ( ! datagridImport . length ) {
33- console . log ( 'toto - 5 - OUT' ) ;
34- return root . toSource ( ) ;
40+ return false ;
3541 }
3642
3743 // Replace import of DataGrid with DataTable
@@ -50,3 +56,8 @@ const replaceImports = (root, j) => {
5056 )
5157 ) ;
5258} ;
59+
60+ const replaceComponent = ( root , j ) => {
61+ // TODO
62+ return true ;
63+ } ;
0 commit comments