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:

(function () {
   'use strict';
   // this function is strict...
}());

(function () {
   // but this function is sloppy...
}());

Update:
In case you don’t want to wrap in immediate function (e.g. it is a node module), then you can disable the warning.

For JSLint (per Zhami):

/*jslint node: true */

For JSHint:

/*jshint strict:false */

or (per Laith Shadeed)

/* jshint -W097 */

To disable any arbitrary warning from JSHint, check the map in JSHint source code (details in docs).

Update 2: JSHint supports node:boolean option. See .jshintrc at github.

/* jshint node: true */

Leave a Comment