Codemods to transform from or to the export-default-from syntax
-
git clone https://github.com/cangoektas/export-default-from-codemod.git
or download a zip file fromhttps://github.com/cangoektas/export-default-from-codemod/archive/master.zip
-
Run
yarn install
ornpm install
from inside the directory -
jscodeshift -t <codemod-script> <path>
-
codemod-script
- path to the transform file, see available scripts below; -
path
- files or directory to transform -
use the
-d
option for a dry-run and use-p
to print the output for comparison; -
use the
--extensions
option if your files have different extensions than.js
(for example,--extensions js,jsx
); -
see all available jscodeshift options.
-
- Setting the
parser
option forjscodeshift
does not have any effect because the transform script always usesbabylon
- If you need additional Babel plugins enabled, you can update the
BABEL_PLUGINS
array in the transform script
Transforms this:
export { default as hello } from "world";
export { default as foo, bar } from "foo";
into this:
export hello from "world";
export foo, { bar } from "foo";
jscodeshift -t export-default-from-codemod/transforms/default-as-to-default-from.js <path>
COMING SOON
MIT