Skip to content

Instantly share code, notes, and snippets.

@ludofischer
Last active April 13, 2017 21:22
Show Gist options
  • Save ludofischer/b31c6627ad0a319e4b9c13703f4e2338 to your computer and use it in GitHub Desktop.
Save ludofischer/b31c6627ad0a319e4b9c13703f4e2338 to your computer and use it in GitHub Desktop.
codemod to remove proptypes declarations from React components
module.exports = function(fileInfo, api) {
const j = api.jscodeshift;
const root = j(fileInfo.source);
root
.find(j.AssignmentExpression, {
left: {
type: 'MemberExpression',
property: {
name: 'propTypes'
}
}
})
.remove();
root.find(j.ImportDeclaration, {
specifiers: [{local: { name: 'PropTypes'}}]
}).remove();
return root.toSource();
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment