Jason
Jason

Reputation: 11363

jshint reporting variables undefined despite globals property defined in configuration

I have a feature-layer application and am writing a jshint gulp task for it.

This is the grunt task:

jshint : {
    options : {
        reporter : require("jshint-stylish"),
        force : true
    },
    all : ["Gruntfile.js", "develop/modules/**/*.js", "develop/components/**/*.js"]
},

My .jshintrc file:

{
  "curly" : true,
  "eqeqeq": true,
  "forin" : true,
  "globals" : {
      "angular" : false,  <-- is not defined
      "module" : false,
      "console" : false  <-- Is not defined
  },
  "latedef" : true,
  "maxerr" : 150,
  "undef": true,
  "unused": true,
  "strict": true
}

but the output when calling the task on the project is:

C:\Users\jason\Desktop\work\QAngular\angular>grunt jshint
Running "jshint:all" (jshint) task

develop/modules/login/login.js
  line 1    col 1   Use the function form of "use strict".
  line 3    col 1   'angular' is not defined.
  line 12   col 13  'console' is not defined.
  line 20   col 21  'angular' is not defined.
  line 21   col 34  'angular' is not defined.
  line 27   col 29  'console' is not defined.
  line 31   col 29  'console' is not defined.

According to the documentation, the globals setting in .jshintrc is supposed to handle this. Its not. Are there any possibilities I missed

Upvotes: 0

Views: 245

Answers (1)

Xavier Priour
Xavier Priour

Reputation: 2121

grunt-contrib-jshint does not use .jshintrc by default, you have to ask for it explicitly by setting jshint.options.jshintrc to true or a filepath (https://www.npmjs.com/package/grunt-contrib-jshint#jshintrc):

jshint : {
    options : {
        jshintrc: true,
        reporter : require("jshint-stylish"),
        force : true
    },
    all : ["Gruntfile.js", "develop/modules/**/*.js", "develop/components/**/*.js"]
},

Upvotes: 1

Related Questions