Removes React.PropTypes
and attempts to transform to Flow.
npm install -g jscodeshift
git clone https://github.com/billyvg/codemod-proptypes-to-flow
jscodeshift -t codemod-proptypes-to-flow/src/index.js <path>
- Use the
-d
option for a dry-run and use-p
to print the output for comparison
Behavior of this codemod can be customized by passing options to jscodeshift e.g.:
jscodeshift -t codemod-proptypes-to-flow/src/index.js --flowComment=line <path>
Following options are accepted:
--flowComment=<block|line>
- type of flow comment. Defaults to block
.
--flowComment=block: /* @flow */
--flowComment=line: // @flow
--propsTypeSuffix=<suffix>
- used to customize the type names generated by the codemod. Provided string will be used alone or appended to Component's name when defining props type. Defaults to Props
.
Default:
type Props = {...}
type MyComponentProps = {...}
With --propsTypeSuffix=PropsType
:
type PropsType = {...}
type MyComponentPropsType = {...}
- Custom validators
React.createClass
- Use of importing PropTypes
- Thanks to @skovhus for adding support for functional components and modernizing the codebase a bit (a lot)