delete-react-zombies icon indicating copy to clipboard operation
delete-react-zombies copied to clipboard

Support .tsx files

Open tkrotoff opened this issue 6 years ago • 7 comments

I have a large React code base written in TypeScript (with files named like src/common/components/MyComponent.tsx).

delete-react-zombies does not detect any component:

$ ./node_modules/.bin/delete-react-zombies 
⠋ Searching zombie components

0 components found! 

0 unused components found! 


Bye bye!

I've tried to add .tsx extension here: https://github.com/CVarisco/delete-react-zombies/blob/15cdc2f9f35a48875c698acfd972ef95a99a7bd9/src/index.ts#L38 and here: https://github.com/CVarisco/delete-react-zombies/blob/15cdc2f9f35a48875c698acfd972ef95a99a7bd9/src/utils.ts#L16 without luck

tkrotoff avatar Jul 17 '19 14:07 tkrotoff

Hi @tkrotoff !

I'll publish a new version with tsx extension included Thank you for the feedback!

CVarisco avatar Jul 17 '19 14:07 CVarisco

Hi @tkrotoff! Published the new version of the package. If you have a problem, I'm here to help you with.

CVarisco avatar Jul 17 '19 14:07 CVarisco

Hey @tkrotoff, do you have any news?

CVarisco avatar Jul 18 '19 12:07 CVarisco

Tested with [email protected], "0 components found!" :-/

tkrotoff avatar Jul 19 '19 08:07 tkrotoff

You only detect default exports: https://github.com/CVarisco/delete-react-zombies/blob/22aaaab93b77cb1de874ecf710efb13f265904da/src/utils.ts#L6

That's why.

We don't use them, here some reasons: https://basarat.gitbooks.io/typescript/docs/tips/defaultIsBad.html

tkrotoff avatar Jul 19 '19 08:07 tkrotoff

Hi @tkrotoff !

sorry for the delay in the response. Anyway, I'm not using that line of code to detect if a component is exported. I'm using https://github.com/reactjs/react-docgen that should find also the not default exported components (I tried with the examples and in my test code).

Are you sure that are you executing the tool in the right directory? If you want I'm available to see with you what's the problem.

CVarisco avatar Jul 29 '19 09:07 CVarisco

Im also having a similar issue. A .js component is being imported by a tsx component, but DRZ recognises it as being unused

andrico1234 avatar Feb 04 '20 14:02 andrico1234