Unused - not failing if assigned but not used

78 views
Skip to first unread message

sch...@yahoo.com

unread,
Sep 6, 2013, 12:03:02 PM9/6/13
to jsh...@googlegroups.com
Hi all,

we recently switched our projects JS-Linting from JSLint to JSHint since it had many advantages for us. So far there is just one thing I miss:

function f() {
    var x;
    x = 12;
}
f();

JSLint was warning that x is defined but never used (which might be a bit short at first sight - but the issue (which I would like to get warned about) is that x is defined and assigned a value but that x is never read). JSHint is not warning about that - did I oversee an option for that or would it be possible to add that as option (or to include it into the unused option)?

Thanks a lot!

Cheers,
schibbi

Peter deHaan

unread,
Sep 6, 2013, 12:26:34 PM9/6/13
to jsh...@googlegroups.com
schibbi,

Check out the `unused` flag, http://jshint.com/docs/options/#unused

-peter




--
You received this message because you are subscribed to the Google Groups "JSHint" group.
To unsubscribe from this group and stop receiving emails from it, send an email to jshint+un...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Sebastian Schipplick

unread,
Sep 6, 2013, 12:43:13 PM9/6/13
to jsh...@googlegroups.com
hi peter,
 
thanks for your reply - and sorry that I forgot to mention that even with /*jshint unused: strict*/ JSHint will not warn in the case at hand.
 
cheers,
schibbi

To unsubscribe from this group and stop receiving emails from it, send an email to mailto:jshint%2Bunsu...@googlegroups.com.

For more options, visit https://groups.google.com/groups/opt_out.

--
You received this message because you are subscribed to a topic in the Google Groups "JSHint" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/jshint/a33p0FyeO68/unsubscribe.
To unsubscribe from this group and all its topics, send an email to jshint+un...@googlegroups.com.

Anton Kovalyov

unread,
Sep 6, 2013, 1:10:21 PM9/6/13
to jsh...@googlegroups.com
In your example, you define a variable and then use it by assigning a value to it. So technically your variable is being used. That said, we should probably be smarter about that.

Anton

To unsubscribe from this group and stop receiving emails from it, send an email to jshint+un...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages