This code does not trigger the mocha/no-exports rule. It appears this is happening because the isMochaFunctionCall function in lib/util/ast.js thinks the calls to describe() and it() are shadowed references, and therefore doesn't mark them as mocha function calls. Any rule relying on this to detect mocha test files (such as mocha/no-exports) therefore does not work correctly.
import { describe, it } from "mocha";
import { assert } from "chai";
export const rx = 43;
describe("dummy test suite", function () {
it("dummy test", function () {
assert.throws(() => {
throw new Error("y");
});
});
});
export const x = 42;
This code does not trigger the
mocha/no-exports
rule. It appears this is happening because theisMochaFunctionCall
function inlib/util/ast.js
thinks the calls todescribe()
andit()
are shadowed references, and therefore doesn't mark them as mocha function calls. Any rule relying on this to detect mocha test files (such asmocha/no-exports
) therefore does not work correctly.