Last active
April 13, 2017 21:22
-
-
Save ludofischer/b31c6627ad0a319e4b9c13703f4e2338 to your computer and use it in GitHub Desktop.
codemod to remove proptypes declarations from React components
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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