Skip to content

nobi1007/understanding-codemods

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Uderstanding Codemods

Installation

  1. Clone the repo and cd into understanding-codemods.
  2. update deps - yarn install
  3. install jscodeshift globally - npm install -g jscodeshift

Run codemods

  1. No comment blocks - Remove all comments from the files
jscodeshift -t transformers/remove-comments.js index.js
  1. Adopt arrow functions - Replace all function definitions with arrow functions
jscodeshift -t transformers/to-arrow-functions.js index.js
  1. Replace require statements - Replace all “require” imports with es6 “import” statements
jscodeshift -t transformers/to-es6-imports.js index.js

Resources

  1. jscodeshift
  2. AST examples gist
  3. Slides - Should we care about CodeMods?