Skip to content

πŸ“Š Codemod scripts that help gather statistics on your React PropTypes

Notifications You must be signed in to change notification settings

trentrand/react-proptypes-codemod

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

7 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

React PropType Codemods

This repository contains a collection of codemod scripts for use with JSCodeshift that help gather statistics on your React PropTypes.

Setup & Run

  1. npm install --global jscodeshift
  2. git clone https://github.com/trentrand/react-proptype-codemods.git
  3. Run npm install in the 'react-proptype-codemods' directory
  4. `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.

Included Scripts

get-proptype-identifiers

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

get-root-proptype-identifiers

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

get-proptype-shapes

Gathers statistics on all `PropType.shape({}) child identifiers.

Playground: Open your console to see some statistics
https://astexplorer.net/#/gist/f20fe14331a63e1f4d7c8141fa2f5e09/bdd3c1131bd639a3c72446de91896372a9ca57cd

React PropType AST Syntax

PropTypes defined as static class property (es7) and class property (es6)

ClassProperty | ExpressionStatement
  ObjectExpression
    Property

About

πŸ“Š Codemod scripts that help gather statistics on your React PropTypes

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages