Code Quality

Facebook Twitter

Scott Logic » JSLint vs JSHint. In January of this year Douglas Crockford decided that some of the options in JSLint were generally accepted and should always be on.

Scott Logic » JSLint vs JSHint

One of those options was eqeqeq, the option to show an error if just two equals was used. For some time JSLint has complained about double equal comparisons against null, 0, undefined and empty string, but this change meant that two variables had to be compared without type coercion. His point of view is that having a global style enforced through JSLint is a good thing and that the best way to do this would be to force anyone wanting to use JSLint to conform strictly to rules of his own devising. In his own words, here is a quote from the readme.

This applies to programming as well. JSLint. JSHint, A JavaScript Code Quality Tool. Automatic semi-colon insertion. A semi-colon explicitly placed in the source text must terminate certain statements.

Automatic semi-colon insertion

Your JavaScript interpreter may help by adding some automatically, but this may not work as you expect. As they say, "Your mileage may vary". Semi-colons are used to explicitly terminate certain keywords so that the parser can determine exactly where the fragment of code begins and ends. The semi-colon removes the ambiguity about how a piece of code is intended to execute.