Re: [jslint] JSLint doesn't check if global variables are used.
- --- In firstname.lastname@example.org, "Jakob Kruse" <kruse@...> wrote:
>I agree, but the idea was to be more of a helpful hint. If you declare a variable but don't use it, JSLint doesn't throw an error. Instead, it lists the Unused variables in the useful summary at the bottom.
> Yes, really. I fail to see why I would want to reference the global from within its own declaration?
> That said, this discussion has gotten quite a bit off track. The only possible purpose of declaring a global variable/function/object/whatever is so that it can be accessed globally â" from everywhere, and in particular, from elsewhere. I find the current behavior of JSLint (not forcing me to declare globals twice for clarity) to be correct. Declaring a global in some file and not using it in that file (but possibly in every other file loaded) should not result in errors or warnings.
Although it would be great to have this same helpful hint with global variables, it's been shown in this thread that such a system would almost certainly be needlessly complex, without very much gain.