Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Bypass ESLint's `no-unused-var` for Should in a Mocha test

I'm using ESLint on all my files, including the test files, with a no-unused-var: true rule. I'm using Should.js in my Mocha tests, and in one of the files, I'm getting an error on the should variable. A quick comparison to the other tests shows, that in other files I have at least one line that starts with should (i.e. should.not.exist(err);), whereas in this particular file, I only use it in property form (i.e. a.should.equal(b)).

Short of turning the rule off for the entire file, or coercing perfectly readable tests into the variable use of should, is there any way around this? Can I turn off the rule just for the should variable? Perhaps add an exception for it? Or (hopefully) a more elegant solution?

like image 687
Traveling Tech Guy Avatar asked Dec 24 '22 18:12

Traveling Tech Guy


1 Answers

In this particular file you can just require instead of declaring.

var should = require('should');

instead do

require('should');
like image 134
Yan Avatar answered Feb 12 '23 19:02

Yan