Skip to content

Latest commit

 

History

History
41 lines (26 loc) · 1.21 KB

CODEMODS.md

File metadata and controls

41 lines (26 loc) · 1.21 KB

Codemods

We created a CLI tool that runs codemods with jscodeshift to batch refactor code. Usage:

yarn sg-codemod [...options]

where options are:

  • --help - display help
  • --dry - dry run (no changes are made to files)
  • --glob - use glob pattern to match files
  • --jscodeshift - pass options directly to jscodeshift

--glob option

Use this flag to pass file path or directory through glob.

npx react-codemod --glob

You will be asked to type in path string in the next step. If you choose --glob flag, that string (file path) will be interpreted with glob. Remember to include desired file extension(s) within the glob pattern, because all matching files will be passed to jscodeshift.

--jscodeshift option

To pass more options directly to jscodeshift, use --jscodeshift="...". For example:

npx react-codemod --jscodeshift="--verbose=2"

See all available options here.

Included Transforms:

replace-colors-rebranding

Replaces color prop on a component to match new color tokens and/or refactored component API.