Non-binding destructuring assignment

Rick Waldron waldron.rick at gmail.com
Wed Apr 29 17:44:23 UTC 2015


On Wed, Apr 29, 2015 at 12:54 PM Tab Atkins Jr. <jackalmage at gmail.com>
wrote:

> On Wed, Apr 29, 2015 at 4:39 AM, Elie Rotenberg <elie at rotenberg.io> wrote:
> > Using array destructuring assignment and constraining linting rules, I
> often
> > find myself having to chose names for bindings I don't intent on using. I
> > usually end up using a conventional ignore name, such as _ignore, which I
> > "void" to shut up the linter without adding exceptions. Besides the
> linting
> > problem (which can be solved by refining the linting rules), it's still a
> > conceptually useless binding.
> >
> > Here's a contrived example:
> >
> > const lastOfThree = ([first, second, third])  => third;
> >
> > Which I usually end up rewriting:
> >
> > const lastOfThree = ([_ignore1, _ignore2, third]) => {
> >   void _ignore1;
> >   void _ignore2;
> >   return third;
> > }
>
> Honestly, this should probably be answered by fixing the linter, so it
> doesn't give linting errors when a variable named "_" is unused.  (In
> fact, it should probably do the opposite, and give a lint error when _
> *is* used. This'll make users of underscore or lo-dash unhappy,
> though. ^_^)
>
>
Why "_"? A linter can just allow the end developer to define the binding
name.

https://github.com/jshint/jshint/issues/2352

Rick



> ~TJ
> _______________________________________________
> es-discuss mailing list
> es-discuss at mozilla.org
> https://mail.mozilla.org/listinfo/es-discuss
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20150429/18b78c58/attachment.html>


More information about the es-discuss mailing list