Reputation: 9013
I'm using the globally available navigator
object that the browser exposes in an Ember-CLI project (aka, with ES6 syntax) and I'd like to avoid getting errors when referencing this valid global object.
I saw this suggestion: Ember CLI - Error when using moment.js in route and tried added ['navigator'] to the predef
definition in the .jshintrc
file. Didn't seem to have any impact. I also then put the following into the JS file itself:
/* global navigator: false */
That worked but I still feel the .jshintrc alternative would be nice. Is there a way to achieve this? Why didn't my attempt have the desired results in the same way that the momentjs example did?
BTW, here is the default setting that Ember-CLI puts in:
"predef": [
"document",
"window",
"-Promise"
]
Upvotes: 0
Views: 217
Reputation: 9700
The existing answer isn't wrong, exactly, but it does have the wrong format, and doesn't make clear that there is a seperate .jshintrc
file for tests. In my case, this was the one that needed to be updated.
In tests/.jshintrc
(which is different from the main .jshintrc
) add "navigator"
to the "predef"
array, like so:
{
"predef": [
"document",
"window",
"navigator",
"location",
...
]
}
Upvotes: 1
Reputation: 2824
In .jshintrc
file, you should do it that way:
{
"predef": {
"navigator": true
}
}
Hope this helps! :)
Upvotes: 0