Skip to content

Instantly share code, notes, and snippets.

@romain-h
Created June 15, 2017 08:37
Show Gist options
  • Save romain-h/05d7c491a76ba87aa23ff78e493e89b6 to your computer and use it in GitHub Desktop.
Save romain-h/05d7c491a76ba87aa23ff78e493e89b6 to your computer and use it in GitHub Desktop.
[codemods - Medium post]
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