Skip to content

Fix FelaComponent codemod bugs#691

Merged
robinweser merged 2 commits intomasterfrom
fix/codemods
Apr 4, 2019
Merged

Fix FelaComponent codemod bugs#691
robinweser merged 2 commits intomasterfrom
fix/codemods

Conversation

@TxHawks
Copy link
Copy Markdown
Collaborator

@TxHawks TxHawks commented Mar 16, 2019

Description

  1. Instead of checking the type of render to determine if it should be
    converted to an as or to children, which is problematic when the value of
    render is a variable, simply check if the FelaComponent has children,
    which is both simpler and should be more robust.

  2. Limit the conversion scope of function arguments in the style prop to only
    affect the outer-most instance, so that if a callback is used inside the
    style object, it is not affected.

  3. For completeness, in addition to arrow functions, also convert function
    expressions in the style prop (though, they are converted to arrow
    functions, so may potetially still cause bugs, so print a warning)

  4. Print a warning when style is a reference to an external variable
    that cannot be validated and converted

fixes #672

Packages

fela-codemods

Versioning

Patch

Checklist

Quality Assurance

You can also run yarn run check to run all 4 commands at once.

  • The code was formatted using Prettier (yarn run format)
  • The code has no linting errors (yarn run lint)
  • All tests are passing (yarn run test)
  • There are no flow-type errors (yarn run flow)

Changes

If one of the following checks doesn't make sense due to the type of PR, just check them.

  • Tests have been added/updated
  • Documentation has been added/updated
  • My changes have proper flow-types

TxHawks added 2 commits March 16, 2019 21:04
… style functions

1. Instead of checking the type of `render` to determine if it should be
   converted to an `as` or to children, which is problematic when the value of
   render is a variable, simply check if the `FelaComponent` has children,
   which is both simpler and should be more robust.

2. Limit the conversion scope of function arguments in the `style` prop to only
   affect the outer-most instance, so that if a callback is used inside the
   style object, it is not affected.

3. For completeness, in addition to arrow functions, also convert function
   expressions in the `style` prop (though, they are converted to arrow
   functions, so may potetially still cause bugs, so print a warning)

4. Print a warning when `style` is a reference to an external variable
   that cannont be validated and converted

fixes #672
@TxHawks TxHawks requested a review from robinweser March 16, 2019 19:17
Copy link
Copy Markdown
Owner

@robinweser robinweser left a comment

Choose a reason for hiding this comment

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

LGTM

@robinweser robinweser merged commit c02fc90 into master Apr 4, 2019
@TxHawks TxHawks deleted the fix/codemods branch April 4, 2019 09:22
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.

codemod breakes when render is a non-function variable

2 participants