-
Notifications
You must be signed in to change notification settings - Fork 22
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
Catch arrow functions for modules #149
Comments
I'm inclined to think we should enforce this if we know that there are undesirable side effects from doing this in modules. @bmish Can you speak to that? Even if there are no actual problems, I could understand wanting this for consistency reasons. But understanding the true scope of the issue will help me prioritize this in relation to the release roadmap that is floating in my head somewhere. 😄 |
The downside of doing this is that it means users cannot make use of the module context as the module's context is not available inside an arrow function. You're not required to use QUnit module context, and the module docs even discuss using lexical context instead of module context: see where it says
Personally I feel that module context is preferable to lexical scope, particularly for tests with lots of nested modules that alter setup values, where lexical scope can run into issues. |
I'm open to having a way to enforce this. I think to avoid confusion, let's have a new rule for this What are we doing for module hooks (beforeEach, etc.)? Do we have a rule for those (maybe under There's a part of me that wishes we had a catch-all rule Thoughts? |
If you access https://codepen.io/raycohen/pen/mdONpgB
|
So this seems like a larger scope than I had originally understood. It seems as though you want to flag the following:
Am I understanding correctly? |
Yes and even an arrow function passed as a module callback would be safe as long as it doesn't access For thoroughness we'd need to check recursively through nested arrow functions to see if
This rule could have two modes - mode 1 is disallow arrow callbacks accessing *all functions passed as QUnit module/test/hook callbacks, and as immediate children of a module callback |
Should the qunit/no-arrow-tests rule also catch modules with arrow functions? Or should we have a new separate rule
no-arrow-modules
?Bad:
Good:
The text was updated successfully, but these errors were encountered: