sasaplus1 / js-codemod

codemod collection for jscodeshift

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

js-codemod

test renovate

codemod collection for jscodeshift

lodash-to-lodash-es

replace to import _ from 'lodash-es' from import _ from 'lodash'.

source

How to use

write configuration

write configuration file for the parser:

config.json

{
  "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

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

change output quotation

$ 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

License

The MIT license.

About

codemod collection for jscodeshift

License:MIT License


Languages

Language:JavaScript 100.0%