Skip to content

Instantly share code, notes, and snippets.

View chintan9's full-sized avatar

Chintan Prajapati chintan9

View GitHub Profile
@laurenashpole
laurenashpole / lodash-imports-codemod.js
Last active March 26, 2023 10:38
A jscodeshift codemod for converting any Lodash imports into direct imports
export default (fileInfo, api) => {
const j = api.jscodeshift;
const root = j(fileInfo.source);
let specifiers = [];
root
.find(j.ImportDeclaration, isLodashImport)
.forEach((path) => specifiers.push(...path.node.specifiers.map((specifier) => specifier.local.name)))
.remove();