This repository contains a collection of codemod scripts for use with JSCodeshift that help gather statistics on your React PropTypes.
npm install --global jscodeshift
git clone https://github.com/trentrand/react-proptype-codemods.git
- Run
npm install
in the 'react-proptype-codemods' directory - `jscodeshift -t --dry --parser babylon --ignore-pattern="tests/*"
codemod-script
- path to the codemod file, see available scripts below;path
- files or directory to process;- see all available jscodeshift options.
Gathers statistics on all unique PropType identifiers and a count of their occurrences.
Playground: Open your console to see some statistics
https://astexplorer.net/#/gist/0e9e7994da190383cdccd6b96c4b8729/b0d5b8a354a99a9113f2d3bbcf8d7a06cdcb8136
Gathers statistics on all unique root PropType identifiers and a count of their occurrences.
This version excludes child PropType identifiers (e.g. logMe: PropTypes.Shape({ butNotMe: PropTypes.any }))
)
Playground: Open your console to see some statistics
https://astexplorer.net/#/gist/4096621e7d95ad4269e5cd29e6135eb7/df70cc7cdcf0f863c441a134597cf2753360177f
Gathers statistics on all `PropType.shape({}) child identifiers.
Playground: Open your console to see some statistics
https://astexplorer.net/#/gist/f20fe14331a63e1f4d7c8141fa2f5e09/bdd3c1131bd639a3c72446de91896372a9ca57cd
ClassProperty | ExpressionStatement
ObjectExpression
Property