flow / flow-codemod

Flow codemod scripts
MIT License
15 stars 3 forks source link

jscodeshift fails to parse strict-type-args.js #4

Closed jedwards1211 closed 8 years ago

jedwards1211 commented 8 years ago

I just installed latest jscodeshift today.

jscodeshift: 0.3.25

I get a bunch of errors like this:

$ jscodeshift -t flow-codemod/transforms/strict-type-args/strict-type-args.js toy-factory-tracker --errors=toy-factory-tracker/flowerrors.json --extensions=js,jsx,flow
Processing 23036 files... 
Spawning 7 workers...
Sending 50 files to free worker...
Sending 50 files to free worker...
Sending 50 files to free worker...
Sending 50 files to free worker...
Sending 50 files to free worker...
Sending 50 files to free worker...
Sending 50 files to free worker...
/Users/andy/.nvm/versions/node/v5.5.0/lib/node_modules/jscodeshift/node_modules/babel-register/node_modules/babel-core/lib/transformation/file/index.js:591
      throw err;
      ^

SyntaxError: /Users/andy/flow-codemod/transforms/strict-type-args/strict-type-args.js: The keyword 'interface' is reserved (21:0)
  19 | // minimal API type info in lieu of full libdef
  20 | //
> 21 | interface Collection {
     | ^
jedwards1211 commented 8 years ago

Do the maintainers have a .babelrc lurking in a parent directory?

mroch commented 8 years ago

this may be because jscodeshift uses babel5 which has an outdated parser. this is mentioned in the README, but doesn't say what things are known to not parse... not sure if this is one of them. @bhosmer?

mroch commented 8 years ago

oh, maybe i misread. this isn't even able to parse the transform? i thought you were saying it hit one of your files that it couldn't transform, not that the transform itself doesn't load.

jedwards1211 commented 8 years ago

Right, I saw that note in the README but it's the codemod script itself that jscodeshift fails to parse. I figure something external in your local dev environment must be getting it to work?

bhosmer commented 8 years ago

Hi Andy - I think this is due to a recent change in jscodeshift. I've logged an issue there; if I haven't heard within the next day or so I'll add a stripped version of the transform here. Thanks for reporting this!

gabelevi commented 8 years ago

Personally, I worked around this with

npm install jscodeshift@0.3.20

but we definitely should fix this generally.

bhosmer commented 8 years ago

Updated strict-type-args.js to stripped version (original is in a src subdir - see here), so should run fine now. Let's revisit if jscodeshift makes it possible to pick up colocated .babelrcs.

fkling commented 8 years ago

jscodeshift v0.3.26 removes type annotations form the transformer again. Sorry!