Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I declare globals for jshint to ignore in ember-cli?

I'm using sinon in my specs and including it in the Brocfile as describe in the ember-cli docs. This works and I can use sinon in my specs. But, jshint is complaining that sinon is not defined:

1 error: expected false to be truthy
    AssertionError: unit/views/edit-todo-test.js should pass jshint.
    unit/views/edit-todo-test.js: line 11, col 18, 'sinon' is not defined.

I can fix this by declaring sinon a global in the spec:

/* global sinon */

But, I'll have to add that to every spec (along with beforeEach, afterEach, etc....). I'd much rather just configure this once globally but when I add these globals to the predef array in .jshintrc, they aren't ignored and I still get the errors. For example:

.jshintrc:

{
  "predef": [
    "document",
    "window",
    "-Promise",
    "sinon"
  ],
<-- snip -->

still fails with the error 'sinon' is not defined.

Any help would be greatly appreciated. Thanks!

like image 731
spinlock Avatar asked Dec 20 '22 04:12

spinlock


1 Answers

You're editing the wrong .jshintrc file. The one located in the root directory is for the app.

There is an additional .jshintrc file for the tests. Edit the one located at /tests/.jshintrc.

like image 171
rog Avatar answered Dec 28 '22 03:12

rog