Repo with some codemod examples for TriangleJS Meetup 9/20/18
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
src
transforms
.eslintrc
.gitignore
.prettierrc
LICENSE
README.md
package.json
yarn.lock

README.md

meetup-codemods

Slides

This repository is a collection of codemod examples. It is meant to be used for academic purposes only. Codemods in this repo are not feature complete and should be used with caution.

Setup & Run

  1. yarn global add jscodeshift
  2. git clone https://github.com/dmiller9911/meetup-codemods or download a zip file from https://github.com/dmiller9911/meetup-codemods/archive/master.zip
  3. Run yarn install in the react-codemod directory
  4. jscodeshift -t <codemod-script> <path>
    • codemod-script - path to the transform file, see available scripts below;
    • path - files or directory to transform;
    • use the -d option for a dry-run and use -p to print the output for comparison;
    • use the --extensions option if your files have different extensions than .js (for example, --extensions js,jsx);
    • see all available jscodeshift options.

Included Scripts

prop-rename

Transforms react-bootstrap buttons to material-ui buttons.

jscodeshift -t transforms/prop-rename.js src/prop-rename/** -d -p

reference-to-selectors

Transforms state.users references in mapStateToProps to use usersSelectors.users(state)

jscodeshift -t transforms/reference-to-selectors.js src/reference-to-selectors/** -d -p