views:

299

answers:

2

This won't pass JSLint in strict mode:

"use strict";
(function (w) {
   w.alert(w);
}(window));

The error--from jslint.com--looks like this:

Problem at line 4 character 3: 'window' is not defined.

}(window));

Implied global: window 4

Do I need to tell JSLint to ignore the error, or am I seriously doing something wrong?

+6  A: 

Try adding /*jslint browser: true */ (or check Assume a browser checkbox).

Edit: Now I see, in documentation:

The browser option does not include the aliases of the global object, window and self.

So you should add /*global window: false */ by yourself

MBO
A: 

Got it, after a false start. I first tried this:

/* global window: false */

... which didn't work. This did:

/*global window: false */

The space after the initial asterisk turns out to be important.

Kent Brewster