JSLint is suddenly reporting: Use the function form of “use strict”

Include ‘use strict’; as the first statement in a wrapping function, so it only affects that function. This prevents problems when concatenating scripts that aren’t strict. See Douglas Crockford’s latest blog post Strict Mode Is Coming To Town. Example from that post: Update: In case you don’t want to wrap in immediate function (e.g. it … Read more

Empty functions in Javascript

I don’t know what jsLint thinks but if this is a problem and you need a solution then you can do something like the following: Update : I think, Bergi‘s guess is right because, on the jslint site in the Required Blocks section : JSLint expects that if, while, do and for statements will be made with blocks {that is, with statements enclosed … Read more

How to initialize an array’s length in JavaScript?

Why do you want to initialize the length? Theoretically there is no need for this. It can even result in confusing behavior, because all tests that use the length to find out whether an array is empty or not will report that the array is not empty.Some tests show that setting the initial length of large arrays can be more efficient … Read more

Why does JSHint throw a warning if I am using const?

When relying upon ECMAScript 6 features such as const, you should set this option so JSHint doesn’t raise unnecessary warnings. /*jshint esnext: true */ (Edit 2015.12.29: updated syntax to reflect @Olga’s comments) This option, as the name suggests, tells JSHint that your code uses ECMAScript 6 specific syntax. http://jshint.com/docs/options/#esversion Edit 2017.06.11: added another option based on this answer. While inline … Read more

Should I use JSLint or JSHint JavaScript validation?

[EDIT]This answer has been edited. I’m leaving the original answer below for context (otherwise the comments wouldn’t make sense). When this question was originally asked, JSLint was the main linting tool for JavaScript. JSHint was a new fork of JSLint, but had not yet diverged much from the original. Since then, JSLint has remained pretty … Read more