I actually realized that I had an enforcing option enabled.
To fix it I only had to set:
"es3": false
(Since it is the default, the same can be obtained removing the option completely)
Question
I am running Mocha tests (with Chai as an assertion library).
At the moment JSHint fires a warning every time it encounters a line like this one:
expect(err).to.be.null;
The reported problem is:
Expected an identifier and instead saw 'null' (a reserved word).
Is there any relax option for JSHint to fix this issue? At the moment the only solution I have only found is to include the special option at the beginning of the file:
/*jshint -W024 */
The problem with that is that it needs to be included in every test file (and I would rather separate JSHint options from the code itself). I do not seem to have found much in the options list.
Solution 2
I actually realized that I had an enforcing option enabled.
To fix it I only had to set:
"es3": false
(Since it is the default, the same can be obtained removing the option completely)
OTHER TIPS
You can put the following settings:
{
"expr": true,
"es5": true
}
in a .jshintrc
file at the top level of your test suite. I'm still on version 1.1.0 of jshint and thus need both settings but apparently version 2.0.0 and above has es5
set to true by default. The expr
setting is documented here. There no longer a reference for es5
probably because it is default and cannot be turned off. (Jshint 2.0.0 will raise an error if you try to set it manually.)
The way jshint operates when checking a file is by looking for a .jshintrc
file in the same directory as your file. If not found, then it looks one level up. If not found there, then it looks one more level up, etc.