0

I am using jshint with grunt and using some inline configuration. I am confused at the following. If I run jshint on just the below code.

/* jshint undef: false */
var app = foo;
/* jshint undef: true */

I would expect this to NOT return the error code W117 stating foo is undefined, but it does for some reason. It works if I leave out the last statement like so:

/* jshint undef: false */
var app = foo;

Though this is not the behavior I want. I only want jshint to ignore the undef warning for that one line.

My options are below:

options:{
    curly: true,
    eqeqeq: true,
    eqnull: true,
    browser: true,
    undef: true,
    unused: 'vars',
    globals: {
        jQuery: false,
        $: false
    }
},

What am I doing wrong?

wlingke
  • 4,699
  • 4
  • 36
  • 52
  • 1
    Do you use `foo` later in the code? If so, you've got the same problem, and would have to turn things on and off each time. Without seeing your code, my guess is that you want to call `foo` a global so that its lack of initialization doesn't affect the code. But, again, more code is mo' better. If it's borking at *just* the snippet you have above, that is wack. Can you confirm? – ruffin Nov 24 '13 at 17:30
  • 1
    Yes, I did end up calling it a global. That was the right solution to this. I did call foo elsewhere and must've not noticed it. – wlingke Nov 26 '13 at 20:37

1 Answers1

1

Per ruffin's comment, I was calling foo elsewhere and causing the issue. I decided to set foo to a global.

wlingke
  • 4,699
  • 4
  • 36
  • 52