Skip to content

brettjashford/codemods

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 

Repository files navigation

CODEMODS

lodashGetToIdx

converts imports and usages of lodash.get to idx. useful for migration to typescript. works for both cjs & es6 modules.

cjs modules:

// input
const get = require('lodash.get');

const c = get(obj, 'a.b.c');

// output
const idx = require('idx');

const c = idx(obj, o => o.a.b.c);

es6 modules:

// input
import get from 'lodash.get';

const c = get(obj, 'a.b.c');

// output
import idx from 'idx';

const c = idx(obj, o => o.a.b.c);

Known Issues

  • the 3rd argument to lodash.get (get(obj, 'a.b.c', [])) is not supported. it will remain as a 3rd argument to idx, which idx does not support. the idx babel plugin will thrown an error if configured correctly.
  • the 2nd argument to lodash.get must be a string literal, the following will throw an error in the codemod get(obj, 'a.b.c' + foo).

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published