Hi Wout,

If you'd like to propose a rule for ESLint, please check out our docs:
http://eslint.org/docs/developer-guide/contributing/new-rules

I'm not sure this case rises to the level of being included in ESLint, but
you can always write custom rules to do whatever you want.

On Wed, Mar 9, 2016, 8:36 AM Wout Mertens <[email protected]> wrote:

> 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.
>

-- 
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.

Reply via email to