Coder Social home page Coder Social logo

react-proptypes-codemod's Introduction

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

react-proptypes-codemod's People

Contributors

trentrand avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.