💼 This rule is enabled in the ✅ recommended
config.
🔧 This rule is automatically fixable by the --fix
CLI option.
Mocha discourages passing it arrow functions as arguments. This rule prevents their use on the Mocha globals.
This rule looks for occurrences of the Mocha functions (describe
, it
, beforeEach
, etc.) within the source code.
The following patterns are considered warnings:
it(() => {
assert(something, false);
});
it('should be false', () => {
assert(something, false);
});
beforeEach(() => {
doSomething();
});
beforeEach((done) => {
doSomething();
done();
});
These patterns would not be considered warnings:
it();
it(function () {
assert(something, false);
});
it('should be false', function () {
assert(something, false);
});
This does not check usage of the require
interface for Mocha, only the globals.
- If you want to pass arrow functions to mocha, turn this rule off.
- If you have other globals which share names with mocha globals, you should turn this rule off, because it would raise warnings.