globals and options for JSHint seems inaccurate #528

Closed
ghost opened this Issue Nov 15, 2012 · 4 comments

Projects

None yet

2 participants

@ghost
ghost commented Nov 15, 2012

Even though it demonstrates on the documentation for the built in lint task that for example {jQuery: true} should be part of the globals object, in practice this has no effect and instead $ is still marked as undefined.

The same goes for browser inside the globals object. The only way to ensure items such as navigator, document and $ are not marked as undefined is if these are places inside the options object. Also, instead of using jQuery: true it should be jquery: true

It seems to me that this behavior is incorrect and that indeed properties such as browser and jquery needs to be part of the globals object and not the options object.

@shama
Member
shama commented Nov 15, 2012

What does your gruntfile look like?

globals just informs JSHint a variable is globally defined. options are JSHint specific options.
So: globals: { jQuery: true } just says we have a global jQuery variable. options: { jquery: true } informs JSHint we're using jQuery and will set all the jQuery global variables for you.

@ghost
ghost commented Nov 19, 2012

@shama Ok, I get that but, my question then is, when setting globals: { jQuery: true } should the linter still complain about $ not being defined or, should one specifically set { $: true } as well in this case? Using options works just fine though so, I am wondering in which use case one would use globals instead.

@sindresorhus
Member

should the linter still complain about $ not being defined

Both $ and jQuery are globals, you've only set jQuery, if you want to use them both you can set both as globals or just set the jquery option instead.

@ghost
ghost commented Nov 19, 2012

@sindresorhus Yeah, I went with the one in options.

@shama shama closed this Nov 19, 2012
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment