Skip to content

Instantly share code, notes, and snippets.

@andrejewski
Last active May 5, 2017 19:04
Show Gist options
  • Select an option

  • Save andrejewski/6e2f6205c91fd099e09b86e309daf642 to your computer and use it in GitHub Desktop.

Select an option

Save andrejewski/6e2f6205c91fd099e09b86e309daf642 to your computer and use it in GitHub Desktop.
landscaper codeshift test
module.exports = function transformer(file, api) {
const j = api.jscodeshift;
return j(file.source)
.find(j.Literal)
.forEach(path => {
var raw = path.node.raw.toLowerCase()
if (raw === '"david"' || raw === "'david'") {
j(path).replaceWith(
j.literal("😿😢👎")
);
}
})
.toSource();
}
module.exports = function transformer(file, api) {
const j = api.jscodeshift;
return j(file.source)
.find(j.Identifier)
.forEach(path => {
j(path).replaceWith(
j.identifier(path.node.name.split('').reverse().join(''))
);
})
.toSource();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment