views:

911

answers:

1

So I'm using JSLint to try and detect errors. I turn some options off I don't like, but I don't see any way to enable being able to use the window global variable. Well there is the Yahoo Widget option, but that's overkill.

What's the deal with using 'window', why would jslint say that is causing errors?

+8  A: 

Hi there,

just make a comment in your Script like that:

/*global window */

... your script goes here

This comment will tell JSLint that window is defined somewhere else.

see: http://www.JSLint.com/lint.html

JSLint also recognizes a /*global */ comment that can indicate to JSLint that variables used in this file were defined in other files. The comment can contain a comma separated list of names. Each name can optionally be followed by a colon and either true or false, true indicated that the variable may be assigned to by this file, and false indicating that assignment is not allowed which is the default.

Oh, and I forgot to mention, that when you want window to be global by default without having to apply the Comment to your script, you can add predef:["window"] to the Object literal parameter inside the JSLINT Function of your local jslint.js file.

BTW, I'm using predef:["$","window"] to have jQuery global as well.

bjoernwibben
Thanks that worked.
apphacker