styled-components-codemods icon indicating copy to clipboard operation
styled-components-codemods copied to clipboard

No changes to files after running against files containing `.extend`

Open patreeceeo opened this issue 6 years ago • 4 comments

Maybe I'm missing something very obvious, but when I use this codemod as described in the README against files using the .extend API, those files remain unchanged.

image

NPM version: 6.10.2 Node version: v8.12.0 OS: macOS 10.13.6

Would you need any other information?

Thanks for making this!

patreeceeo avatar Jul 31 '19 22:07 patreeceeo

Seems that the root cause is that I'm using Typescript:

Encountered an error while processing ../resources-ui/src/app/components/Buttons/Button/index.tsx:
Error: Cannot combine flow and typescript plugins.
    at validatePlugins (/Users/patrick.canfield/Code/styled-components-codemods/node_modules/@babel/parser/lib/index.js:6080:11)
    at getParser (/Users/patrick.canfield/Code/styled-components-codemods/node_modules/@babel/parser/lib/index.js:11323:5)
    at parse (/Users/patrick.canfield/Code/styled-components-codemods/node_modules/@babel/parser/lib/index.js:11306:12)
    at Object.parse (/Users/patrick.canfield/Code/styled-components-codemods/node_modules/babel-codemod/src/RecastPlugin.ts:14:16)
    at Object.parse (/Users/patrick.canfield/Code/styled-components-codemods/node_modules/recast/lib/parser.js:28:30)
    at parse (/Users/patrick.canfield/Code/styled-components-codemods/node_modules/babel-codemod/src/RecastPlugin.ts:11:17)
    at parser (/Users/patrick.canfield/Code/styled-components-codemods/node_modules/@babel/core/lib/transformation/normalize-file.js:163:23)
    at normalizeFile (/Users/patrick.canfield/Code/styled-components-codemods/node_modules/@babel/core/lib/transformation/normalize-file.js:138:11)
    at runSync (/Users/patrick.canfield/Code/styled-components-codemods/node_modules/@babel/core/lib/transformation/index.js:44:43)
    at runAsync (/Users/patrick.canfield/Code/styled-components-codemods/node_modules/@babel/core/lib/transformation/index.js:35:14)
1 file(s), 0 modified, 1 errors

If I just remove L9 from src/v4/common.js, which adds the flow plugin, it works as expected.

patreeceeo avatar Aug 01 '19 19:08 patreeceeo

Why is the flow plugin included? Can it be not included by default unless, say, the user passes a --with-flow flag or something?

patreeceeo avatar Aug 01 '19 19:08 patreeceeo

I can second that the codemod doesn't work with TypeScript, but removing flow fixes this. It would be good to make this plugin optional.

BretCameron avatar May 18 '20 14:05 BretCameron

I'm trying to run this against a plain JS codebase with npx, no changes for .extend. If I install the codemods in the project and run with yarn, it works!

danieldunderfelt avatar Mar 13 '22 14:03 danieldunderfelt