Reputation: 50140
Many grunt.js-script starts with:
/*global module:false*/
module.exports = function(grunt) {
But what the cause of the comment in the first line?
Upvotes: 9
Views: 2186
Reputation: 166061
It's a directive for JSLint or JSHint. It tells the JSLint/JSHint parser that the identifier module
is defined elsewhere, so it doesn't throw an error telling you that module
is undefined. Without it, the parser will encounter the reference to module
and think that you're trying to refer to an undefined variable.
From the JSLint docs:
JSLint also recognizes a
/*global*/
directive that can indicate to JSLint that variables used in this file were defined in other files. The directive can contain a comma separated list of names.
And the JSHint docs:
In addition to options, you can let JSHint know what global variables it should expect:
/*global DISQUS:true, jQuery:false */
In the example above, JSHint will allow you to override
DISQUS
, but complain if you try to overridejQuery
.
Upvotes: 16