@@ -67,6 +67,10 @@ export default function transform(file: FileInfo, api: API): string | undefined
6767 const j : JSCodeshift = api . jscodeshift ;
6868 const root : Collection = j ( file . source ) ;
6969
70+ if ( file . path . includes ( 'node_modules' ) ) {
71+ return undefined ;
72+ }
73+
7074 let isDirty = false ;
7175
7276 packageNames . forEach ( ( pkg ) => {
@@ -76,20 +80,18 @@ export default function transform(file: FileInfo, api: API): string | undefined
7680 if ( spec . type !== 'ImportSpecifier' ) return ;
7781 const importedName = spec . imported . name as string ;
7882 let componentName = importedName ;
79- if ( importPath . node . importKind === 'type' ) {
80- if ( importedName . endsWith ( 'PropTypes' ) ) {
81- componentName = importedName . replace ( / P r o p T y p e s $ / , '' ) ;
82- } else if ( importedName . endsWith ( 'Props' ) ) {
83- componentName = importedName . replace ( / P r o p s $ / , '' ) ;
84- } else if ( importedName . endsWith ( 'DomRef' ) ) {
85- componentName = importedName . replace ( / D o m R e f $ / , '' ) ;
86- }
83+ if ( importedName . endsWith ( 'PropTypes' ) ) {
84+ componentName = importedName . replace ( / P r o p T y p e s $ / , '' ) ;
85+ } else if ( importedName . endsWith ( 'Props' ) ) {
86+ componentName = importedName . replace ( / P r o p s $ / , '' ) ;
87+ } else if ( importedName . endsWith ( 'DomRef' ) ) {
88+ componentName = importedName . replace ( / D o m R e f $ / , '' ) ;
8789 }
8890
8991 let newSource : string ;
9092 if ( pkg === mainPackageName ) {
9193 newSource =
92- importPath . node . importKind === 'type'
94+ componentName !== importedName
9395 ? `${ mainPackageName } /${ componentName } `
9496 : enumNames . has ( importedName )
9597 ? `${ mainPackageName } /enums/${ importedName } `
@@ -119,5 +121,6 @@ export default function transform(file: FileInfo, api: API): string | undefined
119121 } ) ;
120122 } ) ;
121123
122- return isDirty ? root . toSource ( { quote : 'single' } ) : undefined ;
124+ //todo: 'use client' and other string expressions will receive two semicolons. This can be fixed by running prettier - is there a better option?
125+ return isDirty ? root . toSource ( ) : undefined ;
123126}
0 commit comments