I came across this subtle ES2015 problem:
const {foo} = someObject.sub.bar || {}
The idea being that foo would be safe to test attributes on. Of course,
what you get is that foo is being assigned from {} and not set to {}, which
means it is undefined.
It seems to me that this is an easy error to make and I wonder if some
amazing person here could make a rule for it :)
I am just not sure what the rule would be - perhaps destructured assignment
from the result of a || should be discouraged? Of course,
const {foo} = someObject.sub.bar || otherOne.bar
is not a problem… but maybe this is also too error prone?
Thanks,
Wout.
--
You received this message because you are subscribed to the Google Groups
"ESLint" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.