lo1tuma / eslint-plugin-mocha

ESLint rules for mocha
MIT License
281 stars 61 forks source link

isMochaFunctionCall doesn't account for situation where mocha members are being imported from mocha #264

Open mwgamble opened 4 years ago

mwgamble commented 4 years ago

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;