Created
June 15, 2017 08:37
-
-
Save romain-h/05d7c491a76ba87aa23ff78e493e89b6 to your computer and use it in GitHub Desktop.
[codemods - Medium post]
This file contains hidden or 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
const collectGBUsages = (refStore, store) => node => | |
node.find(j.MemberExpression, { // XX.XXXX | |
object: { type: 'MemberExpression' }, | |
}) | |
.filter(path => ( | |
path.parentPath.value.type !== 'AssignmentExpression' && | |
isGBNamespaced(path.value) // Check GB.xxx | |
)) | |
.forEach(path => { | |
refStore.add(path); | |
const type = path.value.object.property.name; | |
const name = path.value.property.name; | |
if (!store.has(type)) { | |
store.set(type, new Set()); | |
} | |
store.set(type, store.get(type).add(name)); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment