This repository contains a collection of codemod scripts based on JSCodeshift.
npm install -g js-codemodjs-codemod <codemod-script> <file>- Use the
-doption for a dry-run and use-pto print the output for comparison
use-strict adds a top-level 'use strict' statement to JavaScript files
js-codemod use-strict <file>
arrow-function transforms functions to arrow functions
js-codemod arrow-function <file>
It will transform function() { }.bind(this) calls to () => {}. If the only
statement in the body is a ReturnStatement it will remove the curly braces.
If you are feeling lucky and you know that returning the value of
single-expression functions will not affect the behavior of your application you
can specify the --inline-single-expressions=true option and it will transform
function() { relay(); }.bind(this) to () => relay() instead of
() => { relay(); }.
Options to recast's printer can be provided
through the printOptions command line argument
js-codemod use-strict <file> --printOptions='{"quote":"double"}'