ESLint Bypass `no-unused-var` for If in Mocha Test

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

Finishing canceling a rule for an entire file or forcing perfectly readable tests to use a variable should, is there any way to do this? Is it possible to disable a rule only for a variable should? Maybe add an exception? Or (hopefully) a more elegant solution?

+4
source share
2 answers

, , , , : before(), should;. , , , , "" , no-op. , should "", ESLint .

- , , .

, .

-2

.

var should = require('should');

require('should');
+11

All Articles