-
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
V7 Planned Changes #175
Comments
I'd like to add renaming Also, I believe there's another rule which has made other rules redundant already, but I'll have to dig that up. |
So I'm thinking with Node 15 near end of life, and with a few dependencies having already cut off support for Node 10, I would like to cut a major version in early June with those Node versions removed from our supported engines and those dependencies upgraded. And we can pull in whatever else is ready at that point. @bmish What do you think? |
I've created a 7.0.0 project for tracking progress a little more easily. Let's use that instead of tracking manually in this issue. The project will generally only track breaking changes and other changes we want to block 7.0.0. Semver-minor and semver-patch changes will be decided on a case by case basis. Contributors are encouraged to work on any semver-minor or semver-patch issue important to them, and we will release those changes when they are ready (subject to ease of logistics), which could mean before or after the 7.0.0 release. If anyone has anything they want me to consider adding to the project, comment here or ping me in the relevant issue/PR. cc @bmish |
What do you think about possibly removing Over the past year, I have updated most upstream docs and examples to adopt arrow functions in code examples aimed at modern/ES6 browsers (the classic syntax examples continue to use regular functions of course). I understand that in order to set properties on the In my view, the use of I have no intention of deprecating or otherwise discouraging this pattern in any way, but I do think it'd be better for new users if we don't discourage use of arrow functions going forward. |
My disagreement to @Krinkle here probably boils down to the balance of getting users onboarded with as simple concepts as possible versus preventing people from running into a problem where they need the extra capabilities of using module/test context as a file/module/project grows. There are useful patterns that can only be accomplished with module/test context, and if you eventually want to use one in a big module you've filled with arrow functions, you may have a lot of manual adjustments to make. You can get into the situation where some of your test files are set up to be able to use module context and some don't, meaning you have to mentally switch between the two setups. I also think there are footguns for a long-lived test file when you rely on lexical scoping - variables can be referenced outside of where they were originally intended to be referenced which is easy to miss as a developer and during code review. With module/test context, a variable won't be defined if you didn't set it up in the hierarchy |
@raycohen I agree there can be benefits to the context pattern vs lexical scope pattern for shared variables, however I don't think any use case requires one pattern over the other in order to work. I'm not entirely sure if it's true, but I suspect that for any test that is passing and working as intended, one can swap out the line-for-line without changing or adding anything and it still pass and behave the same. The lexical pattern has as benefit that declaring/initialising upfront is naturally required (and otherwise likely resulting in runtime errors or lint warnings for undeclared variables), which seems to make it more likely that a developer will remember to reset/initialise them correctly in a beforeEach hook. The context pattern has as benefit that one (intentionally or unintentionally) forget to clear the variables and they will naturally get wiped away at the end of the test by virtue of each test having a new object. I have found that the context pattern to be harder to understand and explain for developers and have as such stopped recommending it to people by default. Individual projects can still use it of course, but I think maybe that's where the responsibility of a default preset ends, and project-specific conventions begin. In any given organisation (or repo), one can add this rule if you are familiar with and prefer the context pattern. I realize this gives a slight bias toward the lexical pattern (since it doesn't require a rule override to adopt), but it's not like we're requiring the use of arrow functions either. I imagine anyone using the lexical pattern with a modern build target would likely want to enforce that for consistency and thus enable a rule of sorts for that as well. Having said all that, while I've seen numerous small projects adopt lexical scopes, the biggest projects using QUnit seem to all still be on context vars (including the ones I work on at Wikimedia), so it's possible there are additional hurdles I've not yet run into. I'd like to talk more on this and learn about more experiences here, and would also like to take what we learn from that and write it up in qunitjs.com materials. But.. I don't want to take up too much space in the V7 ticket. Perhaps https://gitter.im/qunitjs/qunit or https://gitter.im/platinumazure/eslint-plugin-qunit would be a good venue.
It sound like this might be one of those hurdles, but I didn't quite understand the scenario you're referring to. In my mind these are actually reversed. Using a lexical variable that isn't set up explicitly as shared variable will throw a ReferenceError or an eslint warning for undeclared local variable, whereas context properties are more tolerating of ad-hoc properties being set in a subset of tests only without declaring them ahead of time. (On the other hand, during teardown the reverse is true in that context properties don't require a teardown if it's only about dereferencing to avoid accidental reuse. But then again, if a test is working as intended it seems unlikely that it would be relying on variables being torn down to behave correctly.) @raycohen For the immediate choice of which rules we enable in the |
@Krinkle appreciate your thoughts. The rule being enabled does not prevent users from choosing to exclusively use lexical scope, so I feel like turning the rule on is not very far from neutral. All of the arrow function examples in the documentation would work the same if converted to non-arrow functions, right? It's not symmetrical with a hypothetical That said if the qunitjs.com documentation is nearly all using arrow functions, I agree that defaulting As for capturing all the details of what patterns are possible and what hiccups each approach can run into, I agree that is out of scope for this ticket. My "variables can be referenced outside" quote is related to your "forget to clear" statement - if you move an entire test referencing a lexical variable out of a module that sets that variable in a beforeEach hook, it can still read the value provided the test runs after that module and the variable isn't cleared. So if you refactor a test file and move something around, you can end up with an unintended test ordering dependency. |
As long as there remain definite benefits/use cases to the test context approach, I tend to agree with @Krinkle that we shouldn't put it in a recommended ruleset. There are a few other rules that are clear best practices, but also opinionated (and using the "other" pattern is valid), though I don't have that list at this time. It might be better to establish a new preset which is either a superset of recommended, or can be combined with recommended, in order to cover those more opinionated rules. I feel Does anyone have a strong objection? Note that you would effectively need to defend the statement, " |
Just a quick update, I'm alive and in decent mental shape but have been extremely busy. I was also out of town for a few weeks in late July. Hoping to revisit this in the next week or two. |
I don't have a strong opinion about the above debate. But PRs are open for all other breaking changes needed in the v7 release, so the release has a green light from me. |
I had thought we were nearly ready to go with the release, but we have a couple of open items that could hold things up a bit longer. How should we proceed?
|
@platinumazure My preference:
|
Sounds good re: Re: renaming ok rules: My goal would be to find new rule names that covers all the assertions without explicitly naming them. I was thinking names like I think we're ready to go with all breaking changes. Would you mind taking a quick look through the 7.0.0 project and the open issue and PR list and let me know if you think I missed anything? If we're good to go, then I can hopefully start merging the breaking changes. |
@platinumazure I like those new rule names. I would be fine if we want to rename them in this release, but also fine if we want to wait to the next release. I personally don't think it's necessary to deprecate the old rules first--I would rather just do a hard-cutover to the new rule names to avoid the deprecation logistics. Deprecating the old rule names doesn't really help anyone, since either way they still just need to do a find-and-replace for the rule names if they mention the rule names anywhere in their codebase. I believe everything is ready for this major release. |
I've published Using a release candidate means we have time to fix any unexpected issues, as well as potentially letting us adapt to ESLint 8.x breaking changes if any arise. |
Closing as we have just published |
Thanks @platinumazure! Not sure if you've considered it, but I would recommend creating a GitHub Release for v7 containing the full v7 changelog as the description. That would help increase the visibility of the release, especially for people who subscribe/watch release notifications for this repository. |
Thanks for the feedback @bmish, that's a good idea. I'll have to look into that. I would love to automate that sort of thing going forward. |
I would definitely recommend release-it for automating the whole release process including creating the GitHub release. I personally use release-it-lerna-changelog (a release-it plugin) myself which is based off github PR tags for categorizing changes (example changelog). But regardless, we could still manually create the GitHub release for v7 now since it's a big release. |
Starting a list of my desired changes, feedback welcome.
Switch to pure ES modules (too big of a task)checkBooleanAssertions
options onno-negated-ok
andno-ok-equality
rules by default (from AddcheckBooleanAssertions
option tono-ok-equality
rule #173 and AddcheckBooleanAssertions
option tono-negated-ok
rule #174)fixToNotOk
option fromno-compare-relation-boolean
andno-negated-ok
rules (RemovefixToNotOk
option fromno-compare-relation-boolean
andno-negated-ok
rules #195)recommended
rules:no-assert-equal
asrecommended
rule in v7? #164)For reference, V6 was release 2021-03 (CHANGELOG, discussion in #114).
The text was updated successfully, but these errors were encountered: