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

False positive from no-assert-equal rule with unrelated function #182

Closed
bmish opened this issue May 5, 2021 · 3 comments · Fixed by #183
Closed

False positive from no-assert-equal rule with unrelated function #182

bmish opened this issue May 5, 2021 · 3 comments · Fixed by #183

Comments

@bmish
Copy link
Member

bmish commented May 5, 2021

In this code sample, the custom equal function below is flagged as a violation of the qunit/no-assert-equal, even though this equal function is not the QUnit assert equal function.

import { module, test } from 'qunit';
import { equal } from 'my-custom-library'; // `equal` could come from an import

function equal(a,b) {} // or `equal` could be locally defined

module('My Test Suite', function () {
  test('it works', function (assert) {
    assert.notOk(equal(123, 456));
  });
});
@platinumazure
Copy link
Collaborator

platinumazure commented May 5, 2021

Thanks @bmish for the issue. I agree this is a bug on the surface.

I'm not sure we have any other way of solving it besides enhancing the rule with an option to check for global or not. I don't think the rule should look at the import line and assume that all QUnit assertions must be imported. But if you think we can solve this as a bug fix, please share any ideas you have.

@bmish
Copy link
Member Author

bmish commented May 6, 2021

@platinumazure I just clarified the example in this ticket to show that equal is either imported from elsewhere or a custom function defined locally. So the problem with the rule is actually that the rule simply does not properly check for the global. We should assume global equal is the qunit assertion that we want to disallow, but in my example, equal is clearly not a global. This is a relatively easy fix that I opened in #183.

@platinumazure
Copy link
Collaborator

That works for me, I'm happy to accept #183 after review.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

Successfully merging a pull request may close this issue.

2 participants