Skip to content

Instantly share code, notes, and snippets.

@ryaninvents
Forked from astexplorer/astexplorer.json
Last active February 15, 2019 16:02
Show Gist options
  • Save ryaninvents/27c771e78f44085f92a1ba065dbb241d to your computer and use it in GitHub Desktop.
Save ryaninvents/27c771e78f44085f92a1ba065dbb241d to your computer and use it in GitHub Desktop.
Remove experimental bind syntax from a codebase
{
"v": 2,
"parserID": "babylon7",
"toolID": "jscodeshift",
"settings": {
"babylon7": null
},
"versions": {
"babylon7": "7.3.1",
"jscodeshift": "0.6.3"
}
}
class Foo {
constructor() {
this.bar = ::this.bar;
}
}
export default function transformer(file, api) {
const j = api.jscodeshift;
return j(file.source)
.find(j.BindExpression)
.forEach(path => {
j(path).replaceWith(path =>
j.callExpression(
j.memberExpression(
path.node.callee,
j.identifier("bind")
),
[j.thisExpression()]
)
);
})
.toSource();
}
// module.exports.parser = 'babel';
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment