JSLint is becoming stricter

J

J.R.

JSLint <http://www.jslint.com> has become more and more intolerant
recently. I have been noticing changes in JSLint in the past few months.
For instance, JSLint has begun to complain about the following pattern:

(function () {
// ...
})();

JSLint outputs an error such as "Problem at line 3 character 3: Move the
invocation into the parens that contain the function.
})();"

So what is wrong with the (function () { })() pattern?
 
L

Lasse Reichstein Nielsen

J.R. said:
JSLint <http://www.jslint.com> has become more and more intolerant
recently. I have been noticing changes in JSLint in the past few
months. For instance, JSLint has begun to complain about the following
pattern:

(function () {
// ...
})();

JSLint outputs an error such as "Problem at line 3 character 3: Move
the invocation into the parens that contain the function.
})();"

So what is wrong with the (function () { })() pattern?

Nothing as such, but I guess Crockford prefers the other way:
(function(){... }())

JSLint is all about picking one coding style and warning if you don't
follow it. You don't have to agree with the coding style.

/L
 
J

Jukka K. Korpela

Lasse said:
JSLint is all about picking one coding style and warning if you don't
follow it.

I wouldn't go that far. It also reports coding errors that violate the rules
of the language, and I have often found it useful. The usefulness is
admittedly reduced by the messages that only relate to coding style.

Do you know some more objective linters for Javascript, or at least linters
that can easily be configured to suppress stylistic warnings?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,774
Messages
2,569,598
Members
45,160
Latest member
CollinStri
Top