lodash-codemods

Codemods for lodash

MIT License

Stars
1
Committers
1

lodash-codemods Node.js CI

This repository contains a collection of codemod scripts for use with JSCodeshift.

Included Scripts

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>

Recast Options

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"}'

Local Debugging

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