moroshko / react-scanner

Extract React components and props usage from code.
MIT License
563 stars 40 forks source link

Feature request: handle styled component #51

Open ethange7 opened 2 years ago

ethange7 commented 2 years ago

Is there anyway we can track the styled component to it's origin? See example below

import {Button} from 'design-system'
import {styled} from 'react-emotion'
...
const StyledButton = styled(Button)`
//some css here
`
const Container = () => {
    return <StyledButton>
}

in this case, I would consider StyledButton IS Button from 'design-system' but in the generated report, I think we are only getting

{
  "StyledButton": 1
}

is there any way we can detect this type of situation?

ethange7 commented 2 years ago
getComponentName: ({ imported, local, moduleName, importType }) => {
    return `${moduleName}: ${imported || local}`;
  },

is what I used in the config, I want to be able to tell where is this component from

smol-honk commented 1 year ago

I sort-of-ish tried to create a PR for this situation. Can definitely get some extra eyes/fingers on it tho. #56