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

no-identical-names rule false positives with modules inside separate scopes/functions #129

Open
bmish opened this issue Dec 1, 2020 · 1 comment

Comments

@bmish
Copy link
Collaborator

bmish commented Dec 1, 2020

This should be an valid case (but is currently invalid):

function sharedBehavior() {
    module('moduleName', function () {});
}
module('moduleName', function () {}); // This is erroneously considered a violation.

This should be an valid case (but is currently invalid):

export default {
    desktop() {
        module('hourly chart', function () {});
    },

    mobile() {
        module('hourly chart', function () {});
    },
};

This should be an valid case (but is currently invalid):

if (foo) {
    module('module1', function () {});
} else {
    module('module1', function () {});
}

Additional test cases that should be added:

module("name1", function() {
    function sharedBehavior() {
        module("name1", function() {}); // This is fine since it's in its own scope.
    };
    module("name1", function() {}); // This is the violation.
});
function sharedBehavior() {
    module("name1", function() {});
    module("name1", function() {}); // This is the violation.
};
@platinumazure
Copy link
Owner

I'm not sure I agree about separate scopes protecting duplicate module names. The intent of no-invalid-names is to make it so that every test failure can be easily located to the correct module chain and test name. Scopes are just a way to add confusion in the file: Yes, the tests may run in a separated manner, but they are still duplicated in the file itself and make tracing of test errors harder.

If you think this is a compelling case, I think you should either not use the rule, or we should consider enhancing the rule to take scopes into account as an opt-in behavior.

What do you think?

@platinumazure platinumazure changed the title no-invalid-names rule false positives with modules inside separate scopes/functions no-identical-names rule false positives with modules inside separate scopes/functions Jan 3, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants