Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save rosswarren/3d340a78223e8452a737773d2efc180a to your computer and use it in GitHub Desktop.
Save rosswarren/3d340a78223e8452a737773d2efc180a to your computer and use it in GitHub Desktop.
// Press ctrl+space for code completion
export default function transformer(file, api) {
const j = api.jscodeshift;
return j(file.source)
.find(j.CallExpression)
.filter(x => x.node.callee.object && x.node.callee.object.name === "assert")
.filter(x => x.node.callee.property && x.node.callee.property.name === "isFalse")
.filter(x => x.node.arguments.length > 0 && x.node.arguments[0].property && x.node.arguments[0].property.name === "called")
.forEach(path => {
j(path).replaceWith(
j.callExpression(j.memberExpression(j.identifier("assert"), j.identifier("isTrue")), [
j.memberExpression(path.node.arguments[0].object, j.identifier("notCalled"))
])
);
})
.toSource();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment