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

Add rename-identifier and rename-property #139

Merged
merged 1 commit into from
May 26, 2016

Conversation

lemonmade
Copy link
Member

Fixes #102 and #126. This PR adds two new transforms, rename-identifier and rename-property, to handle arbitrary renaming of identifiers and member expressions, respectively.

cc/ @GoodForOneFare @Fandy


export default function renameProperty({source}, {jscodeshift: j}, {printOptions = {quote: 'single'}, renameProperties = {}}) {
function hasPropertyThatShouldBeRenamed({node: {computed, object, property}}) {
return !computed && renameProperties[object.name].hasOwnProperty(property.name);
Copy link
Member

Choose a reason for hiding this comment

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

Could you add a sanity test for the !computed, please?

Copy link
Member Author

Choose a reason for hiding this comment

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

I think _[each]() tests this, does it not?

Copy link
Member

Choose a reason for hiding this comment

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

It sure does! Ignore me :)

@GoodForOneFare
Copy link
Member

Nice and concise! Looks great 👍 🚢

It looks like we don't have to worry about translating window.$, etc because any files doing that have/should be converted to .js manually.

@lemonmade lemonmade merged commit e2f960c into master May 26, 2016
@lemonmade lemonmade deleted the allow-arbitrary-renaming branch May 26, 2016 17:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants