Skip to content

Instantly share code, notes, and snippets.

@DrewML
Last active July 25, 2018 21:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save DrewML/c590498becf2695193adfb73f81c9ef5 to your computer and use it in GitHub Desktop.
Save DrewML/c590498becf2695193adfb73f81c9ef5 to your computer and use it in GitHub Desktop.
module.exports = function transformer(file, api) {
const j = api.jscodeshift;
const ast = j(file.source);
ast.find(j.CallExpression, {
callee: {
name: 'define'
}
}).forEach(path => {
const args = path.node.arguments;
if (!args.length) return;
const firstArg = args[0];
if (firstArg.type !== 'ArrayExpression') return;
firstArg.elements.forEach(element => {
if (element.type === 'StringLiteral') {
api.stats('Kosher dependency');
return;
}
api.stats(`Dynamic dependency found in define() call. File: ${file.path}`);
});
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment