Given the following code: /*jslint browser: true */ var isReady = (function () { ````var poll = setInterval(function () { ````````if...
2018
Douglas Crockford
douglascrock...
Mar 8, 2011 12:08 am
There are some cases where it is troublesome to use a variable while it is being initialized, such as var x = x + 1; JSLint is not able to determine which...
2019
Jordan
ljharb
Mar 8, 2011 12:19 am
Is there an option so that known non-troublesome code can skip that warning? This warning essentially kills automatic linting of code that employs the module...
2020
spence.randall@...
spence.randa...
Mar 8, 2011 12:39 am
Could JSLint skip warning when the variable is referenced inside a function body? These would be the most likely useful cases, but would still allow for a...
2021
spence.randall@...
spence.randa...
Mar 8, 2011 7:00 pm
Jordan is right, this new rule is troublesome with the module pattern. It also seems to be inconsistent. Take the following code for example: var dom =...
2022
Douglas Crockford
douglascrock...
Mar 8, 2011 9:26 pm
... No, it isn't. Declare the variable before giving it a value that depends on the same variable. It is easy....
2023
Ezequiel
thehungerforce
Mar 9, 2011 3:40 am
Because I'm using my own function for the if statement, this doesn't work: example: var isOwnProperty, object, i; isOwnProperty = function(object, key) {....};...
2024
Douglas Crockford
douglascrock...
Mar 9, 2011 1:16 pm
... You turned on the forin option. You can not do that....
2025
John Hawkinson
john.hawkinson
Mar 9, 2011 1:26 pm
... This is a bit more troublesome for event handlers. Leaving the browser world for a moment, I encountered this morning: (function() { var pdfdone =...
2026
Stjepan Rajko
stjepan_rajko
Mar 9, 2011 3:13 pm
Hello, On the following code: function One(a, b, c) { ````this.value = a + b + c; } function Two(a, b, c) { ````this.value = c + b + a; } var which =...
2027
Luke Page
page.luke...
Mar 9, 2011 4:05 pm
jslint cannot determine that the expression One relating to a function will be used to construct a new object. You have three options. This is controlled by...
2028
Stjepan Rajko
stjepan_rajko
Mar 9, 2011 4:42 pm
Luke, thanks for your reply. The warnings were generated by jslint.com with "Require Initial Caps for constructors" turned off, and adding /*jslint newcap:...
2029
Alexandre Morgaut
morgaut_a
Mar 9, 2011 4:58 pm
You may also write the code this way var Which = Math.round(Math.random()) ? One : Two; var x = new Which("1", "2", "3"); ;-)...
2030
Stjepan Rajko
stjepan_rajko
Mar 9, 2011 5:21 pm
... That takes care of the error, thank you! :-) [Non-text portions of this message have been removed]...
2031
Rob Richardson
erobrich@...
Mar 9, 2011 5:22 pm
Your code is a perfect example of "clever" -- one of the best tools a coder has for showing their ingenuity and skill while simultaneously confusing people...
2032
Kent Davidson
kentdavidson
Mar 9, 2011 7:12 pm
I gotta chime here and agree with Douglas. However, I think jslint 2011-03-07 is broken: var dude = 20 * dude; fails to throw an error at all: FireFox 3.6:...
2033
Douglas Crockford
douglascrock...
Mar 9, 2011 7:19 pm
... Global variables are weird and obey different rules. JSLint already reports global variables. A statement like var GLOBAL = GLOBAL || {}; actually makes...
2034
Kent Davidson
kentdavidson
Mar 9, 2011 7:27 pm
Ah. So the canonical error would be: function foo () { var dude = 20 * dude; } Another reason to avoid globals. Chers, -Kent. ... [Non-text portions of this...
2035
John Hawkinson
john.hawkinson
Mar 9, 2011 7:46 pm
Kent Davidson <kent@...> wrote on Wed, 9 Mar 2011 ... Wait, is this not bad advice? You are rewriting the code from a form JSLint detects as bad...
2036
Douglas Crockford
douglascrock...
Mar 9, 2011 8:11 pm
... It seems like good advice....
2037
Kent Davidson
kentdavidson
Mar 9, 2011 8:41 pm
Good advice, bad advice. Matter of opinion. If you think it's bad advice, then ignore that warning. I set up my scripts to run through a local copy of jslint...
2038
John Hawkinson
john.hawkinson
Mar 9, 2011 11:40 pm
Kent Davidson <kent@...> wrote on Wed, 9 Mar 2011 ... Well, help me out here. It seemed like bad advice to me, for the reason I articulated...
2039
Ezequiel
thehungerforce
Mar 10, 2011 1:31 am
... No, I did not have any options turned on when I ran that snippet....
2040
spence.randall@...
spence.randa...
Mar 10, 2011 4:33 am
The "Tolerate unfiltered forin" is off by default, so you would want to check the appropriate box in Options or add /*jslint forin: true */, then you will no...
2041
sharkfx2002
Mar 10, 2011 6:59 am
Hello, I'm new to JSLint, and did not have the time to examine the sources and group messages to a maximum extent; however, I have a question about warnings...
2042
Douglas Crockford
douglascrock...
Mar 10, 2011 12:48 pm
... You are not looking at a recent version. I recommend that you go to Github and get the latest. JSLint produces warnings. In most cases, after giving a...
2043
sharkfx2002
Mar 10, 2011 1:27 pm
Thanks for the reply. I will take a look at the latest version. From your message I understand that the terms "warning" and "error" do not have the same...
2044
Kent Davidson
kentdavidson
Mar 10, 2011 2:18 pm
... Hm. Well. I think so, but you say you want to write it a certain way, yet that way is flagged as an error. So, if you agree with JSLint, then you'd change...
2045
John Hawkinson
john.hawkinson
Mar 10, 2011 2:55 pm
Kent Davidson <kent@...> wrote on Thu, 10 Mar 2011 ... But making the proposed change is no safer than the original code! I agree the warning is...