-
-
Notifications
You must be signed in to change notification settings - Fork 209
Fix parent not being set for decorator nodes. #296
Conversation
It makes sense as the babel ast is somewhat different (in the way that you modified), but it show be covered with |
So should I make a PR to |
No because babel doesn't use those ast nodes anymore. Oh wait I see we're adding decorators 😛... Ok this is correct, we might need to add more types from babel-types based on the ast changes. |
So... yes or no? 😄 And if yes, then where in |
No I was just saying your PR should be the correct change |
Ok, misunderstood that :) |
Speaking of a more generic solution, we probably should copy the VisitorKeys for all nodes which were renamed in babylon to their espree name before assigning them to the different tools. Is that what you mean @hzoo? |
Yeah |
Wouldn't it be ok to patch |
Sorry; No reason - just busy and might not be around if we need to revert but we can go ahead do this. |
I was getting strange errors when I put an arrow function into a decorator as an argument (normal function expression was affected as well).
The error was coming from the
no-unused-vars
rule; the complaint was this:Cannot read property 'type' of undefined
, at this line:So it was obvious for me that the
parent
property ofdef.node
was missing.After digging around for quite a long time (I'm unfamiliar with the inner workings of the
eslint
family tools...) I created this solution. Basically this is a monkey patch ofestraverse
that adds visitor key"decorators"
to appropriate node types. That way decorators will be picked up by theenter
hook of theeslint
traverser, and so theparent
property is set for nodes in the decorator node tree.