Yes, thanks, someone pointed that out in email. I find it pretty odd, 
though. Obviously I can't add console.log() to quiet eslint. And it doesn't 
really make sense that a global that is written to is not "used": it 
plainly is. A global, after all, is a property on an object in the outer 
scope. eslint can't possibly know how it is used, same as it can't say 
property 'bar' is unused in an assignment 'foo.bar = 5', where foo is an 
object that is passed in.

So, 'window.foo = 5' and 'foo = 5' mean the same thing, but are treated 
differently by eslint.

For now I've disabled the warning on this line.

On Thursday, April 30, 2015 at 2:39:30 PM UTC-7, Ilya Volodin wrote:
>
> The reason you are getting “never used” message is because you actually 
> haven’t used foo anywhere. You declared it, and you set a value for it, but 
> you haven’t read it anywhere or done anything with it. Try the following 
> code in a demo and it’s not going to throw any errors:
>
>  
>
> /*global foo: true */
>
> /*eslint no-console: 0*/
>
> /*eslint-env browser*/
>
> foo = 5;
>
> console.log(foo);
>
>  
>
> Thanks,
>
>  
>
>                                 Ilya Volodin
>
>  
>
> *From:* [email protected] <javascript:> [mailto:
> [email protected] <javascript:>] *On Behalf Of *Brian Craft
> *Sent:* Thursday, April 30, 2015 3:11 PM
> *To:* [email protected] <javascript:>
> *Subject:* [ESLint] "never used" error on used global
>
>  
>
> Reproducible in the demo, at http://eslint.org/demo/
>
>  
>
> Enter this:
>
>  
>
> /*global foo: true */
> foo = 5;
>
>  
>
>  
>
> w/o the global directive, eslint throws "foo undefined". With global true, 
> it throws "never used". With global false it throws "foo is read only".
>
>  
>
> Is this a bug?
>
>  
>
>  
>
>  
>
> -- 
> 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] <javascript:>.
> 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