This repository contains a collection of codemod scripts for use with JSCodeshift.
named-import
If you are using babel-plugin-lodash, this codemod converts cherry-pick Lodash import to named import.
from
import camelCase from 'lodash/camelCase';
import omit from 'lodash/omit';
import map from 'lodash/fp/map';
import mapKeys from 'lodash/fp/mapKeys';
to
import { camelCase, omit } from 'lodash';
import { map, mapKeys } from 'lodash/fp';
npx jscodeshift -t transforms/named-import.js <file/folder>
Options to recast's printer can be provided
through the printOptions
command line argument
jscodeshift -t transforms/named-import.js <file/folder> --printOptions='{"quote":"double"}'
Use the -d
option for a dry-run and use -p
to print the output for comparison.
npx jscodeshift -t transforms/named-import.js <file/folder> -d -p