Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
module.exports = function (fileInfo, api) {
const j = api.jscodeshift;
const root = j(fileInfo.source);
return root.find(j.MethodDefinition)
.filter(method => method.value.kind !== 'constructor')
.replaceWith(method => {
const { key, value: { body, params } } = method.value;
return j.classProperty(
j.identifier(key.name),
j.arrowFunctionExpression(
params,
body,
false
),
null,
false
);
})
.toSource();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.