Skip to content

Latest commit

 

History

History
37 lines (24 loc) · 1.39 KB

no-mocha-arrows.md

File metadata and controls

37 lines (24 loc) · 1.39 KB

Disallow arrow functions as arguments to mocha functions (mocha/no-mocha-arrows)

💼 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.

Rule Details

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.

When Not To Use It

  • 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.