Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get "should.be.false" syntax pass jslint?

I am writing JS UT for my NodeJS code. I am using Chai as the assertion library, and I prefer the should syntax. I also use jslint to check the JS file syntax, even the JS files for UT.

Now I have a problem with jslint and Chai. In Chai, you can use:

myvalue.should.be.true; 

But jslint give me:

#1 Expected an assignment or function call and instead saw an expression. 

I know jslint comes with many options, but I just cannot find the right one to turn off this check.

like image 819
David S. Avatar asked Dec 11 '12 07:12

David S.


People also ask

What is Jslint used for?

JSLint is a static code analysis tool used in software development for checking if JavaScript source code complies with coding rules. It is provided primarily as a browser-based web application accessible through the domain jslint.com, but there are also command-line adaptations.


1 Answers

Just to make it clear to other readers:

You can add /*jshint expr: true*/ to the top of the test files, so it only allows it in the test files.

In the rare case that you use that kind of expressions in your code, you can add the expr: true option to the jshint config options.

like image 82
Jesús Carrera Avatar answered Oct 09 '22 13:10

Jesús Carrera