Skip to content

Instantly share code, notes, and snippets.

@davidtingsu
Created January 16, 2019 01:28
Show Gist options
  • Save davidtingsu/1550ae83aa05bc841efc59f384025c30 to your computer and use it in GitHub Desktop.
Save davidtingsu/1550ae83aa05bc841efc59f384025c30 to your computer and use it in GitHub Desktop.
gist to add 'configure' to enzyme imports using jscodeshift
// https://astexplorer.net/#/gist/55b79bb6a2287057b4459d5ef87528a1/34173b57c114657bd47b0441ad35cb88037e7832
// Press ctrl+space for code completion
export default function transformer(file, api) {
const j = api.jscodeshift;
return j(file.source)
.find(j.ImportDeclaration)
.forEach(importStatement => {
const specifiers = j(importStatement).find(j.ImportSpecifiers);
importStatement.node.specifiers.push(j.importSpecifier(j.identifier('configure')));
/*j(path).replaceWith(
j.identifier(path.node.name.split('').reverse().join(''))
);*/
return importStatement;
})
.toSource();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment