codemod collection for jscodeshift
replace to import _ from 'lodash-es'
from import _ from 'lodash'
.
write configuration file for the parser:
{
"sourceType": "module",
"allowImportExportEverywhere": true,
"allowReturnOutsideFunction": true,
"tokens": true,
"ranges": true,
"plugins": [
"flow",
"jsx",
"asyncGenerators",
"bigInt",
"classProperties",
"classPrivateProperties",
"classPrivateMethods",
[
"decorators",
{
"decoratorsBeforeExport": true
}
],
"doExpressions",
"dynamicImport",
"exportDefaultFrom",
"exportNamespaceFrom",
"functionBind",
"functionSent",
"importMeta",
"logicalAssignment",
"nullishCoalescingOperator",
"numericSeparator",
"objectRestSpread",
"optionalCatchBinding",
"optionalChaining",
"partialApplication",
"throwExpressions"
]
}
for more details: @babel/parser
execute below:
$ npx jscodeshift -t https://raw.githubusercontent.com/sasaplus1/js-codemod/master/transforms/lodash-to-lodash-es.js --ignore-config=.gitignore --parser=babylon --parser-config=config.json ./src
$ npx jscodeshift --quote=single -t https://raw.githubusercontent.com/sasaplus1/js-codemod/master/transforms/lodash-to-lodash-es.js --ignore-config=.gitignore --parser=babylon --parser-config=config.json ./src
for more details: recast/lib/options.ts
The MIT license.