Skip to content

Commit

Permalink
Check for class expressions in inspectDeclarator and inspectClassMethod
Browse files Browse the repository at this point in the history
  • Loading branch information
MartijnWelker committed Nov 20, 2019
1 parent 70152ff commit 373e292
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion nginject.js
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ function inspectAssignment(path, ctx){

function inspectDeclarator(path, ctx){
const node = path.node;
if(!isFunctionExpressionOrArrow(node.init)){
if(!isFunctionExpressionOrArrow(node.init) && !t.isClassExpression(node.init)){
return;
}

Expand Down Expand Up @@ -270,10 +270,17 @@ function inspectClassMethod(path, ctx){
const ancestry = path.getAncestry();
for(var i=0; i < ancestry.length; i++){
let ancestor = ancestry[i];

if(ancestor.isClassDeclaration()){
addSuspect(ancestor, ctx, !annotation);
return;
}

if (ancestor.isClassExpression()) {
// Add the variable declaration of the class as suspect
addSuspect(ancestor.parentPath.parentPath, ctx, !annotation);
return;
}
}
}

Expand Down

0 comments on commit 373e292

Please sign in to comment.