Monday, May 20, 2024
 Popular · Latest · Hot · Upcoming
62
rated 0 times [  63] [ 1]  / answers: 1 / hits: 39693  / 15 Years ago, thu, september 10, 2009, 12:00:00

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?


More From » jslint

 Answers
21
/*jslint browser: true*/


Was the correct solution to this. As of 2017-07-07, you have to set the global directive manually. From the JSLint documentation:




The /*global*/ directive is used to specify a set of globals (usually functions and objects containing functions) that are available to this file. This was commonly used in browsers to link source files together before ES6 modules appeared. Use of global variables is strongly discouraged, but unfortunately web browsers require their use. The /*global*/ directive can only be used when the Assume a browser option is selected.




So you will need to use:



/*jslint browser */
/*global window */

[#98722] Sunday, September 6, 2009, 15 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
larrycodys

Total Points: 394
Total Questions: 93
Total Answers: 78

Location: Romania
Member since Mon, Jun 6, 2022
2 Years ago
;