Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
mwgamble opened this issue Aug 7, 2020 · 0 comments

Comments

@mwgamble
Copy link

mwgamble commented Aug 7, 2020

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;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant