Skip to content

Instantly share code, notes, and snippets.

@astexplorer
Created February 15, 2019 16:01
Show Gist options
  • Save astexplorer/417c240080672c450ad937f049af8097 to your computer and use it in GitHub Desktop.
Save astexplorer/417c240080672c450ad937f049af8097 to your computer and use it in GitHub Desktop.
{
"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