Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remote transform initial pass #95

Closed
wants to merge 2 commits into from

Conversation

iamdustan
Copy link
Contributor

An initial pass at including remote support for the transform flag.

jscodeshift -t https://raw.githubusercontent.com/reactjs/react-codemod/master/transforms/react-to-react-dom.js .

One constraint is the remote transform must be entirely self-contained.

Closes #94.

if (/^http/.test(transformFile)) {
if (transformFile.indexOf('https') !== 0) {
console.log(
clc.whiteBright.bgRed('ERROR') + ' Remote transforms only support https. %s',
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is that?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No real reason. Maybe security?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

removed this constraint

@fkling
Copy link
Contributor

fkling commented Mar 14, 2016

Merged with 027cd02. The merge conflict was a a bit tricky to solve, I hope I did everything correctly :P (test still pass!)

@fkling fkling closed this Mar 14, 2016
@fkling
Copy link
Contributor

fkling commented Mar 15, 2016

Released with v0.3.15.

euphocat pushed a commit to euphocat/jscodeshift that referenced this pull request Oct 22, 2017
…acebook#95)

See benjamn/recast#365 for more context.

It looks like the recast printer includes all JSX on the same line by default,
which can lead to really ugly code with deeply nested React elements. However,
if we put a `'\n'` text node around all adjacent children, it will format the
JSX in the typical multiline way, properly indented, so this commit changes the
script to do that.

Ideally, we might want to keep some expressions inline, e.g. by determining
whether the child expressions will fit nicely on one line, but that seems sort
of nontrivial with just the AST, so we just use multiline JSX always for now.

To keep strings correct, we need to be a little more careful about translating
child string literals. Since each child will be on its own line, leading and
trailing whitespace will be removed, so if the string literal starts or ends
with whitespace, or is an empty string, we fall back to an expression container
with a normal JS string.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants