Skip to content

Conversation

@alangpierce
Copy link
Contributor

As mentioned in #59, the create-element-to-jsx codemod can destroy comments,
so leave a warning in the docs so people know to be careful.

Also add a "Support and Contributing" section at the bottom of the README that
briefly describes the state and purpose of the repo and how contributions are
handled.

As mentioned in reactjs#59 , the `create-element-to-jsx` codemod can destroy comments, so leave a warning in the docs so people know to be careful. Also add a "Support and Contributing" section at the bottom of the README that briefly describes the state and purpose of the repo and how contributions are handled.
@cpojer
Copy link
Member

cpojer commented Jun 28, 2016

I'd really prefer a fix in the codemod itself – are you working on this?

I'll merge this commit but am hoping for a follow-up PR.

@cpojer cpojer merged commit 6c4a2b3 into reactjs:master Jun 28, 2016
@alangpierce
Copy link
Contributor Author

I'm taking a look, and hoping to get something working, although it's not really urgent/blocking for me at the moment.

@reergymerej
Copy link
Contributor

I may give it a go if you're not @alangpierce. Let me know so I don't step on your toes.

@alangpierce
Copy link
Contributor Author

@reergymerej Sure, that would be great. I was mostly just investigating/learning things so far, and I probably wasn't going to continue on it until this weekend anyway.

A few things I noticed when I was initially taking a look at it, which may or may not be helpful:

  • It looks like simply attaching comments to JSX nodes can cause the printer to produce code like <span>/*comment*/</span>, which isn't a valid comment. So it may be necessary to give some block comments their own jsxExpressionContainer node or something like that.
  • I noticed that the JSX formatting was causing multiline React.createElement usages to be converted into single-line JSX. So it may be necessary to convert // comments to /**/ comments (which I, personally, am fine with). But I'm not really sure how all that stuff works in jscodeshift/recast.
@reergymerej
Copy link
Contributor

Cool beans. Can we open an "enhancement" issue so we don't lose track of this or do we need to do that in a fork? Honestly, I'll forget all about it in a couple hours if there's no open issue. :)

@alangpierce
Copy link
Contributor Author

@reergymerej FYI, I ended up implementing this, and sent out PR #61.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

3 participants