-
Notifications
You must be signed in to change notification settings - Fork 230
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
feat: prefer importing jest globals [new rule] #1490
Conversation
33146cc
to
c5e577a
Compare
29020c4
to
93157b0
Compare
Is it possible to add an autofix for this? I.e. detecting what globals are used, and add either an I think just flagging global usage can be done by not having |
2398844
to
3b4a038
Compare
3b4a038
to
45af6d2
Compare
Hi @SimenB, I've added an auto fixer in the logic 👨🏻🔧 |
7843eb7
to
15c1f71
Compare
c13bd8c
to
c06ca95
Compare
13adf46
to
3c9c4e5
Compare
c86e12d
to
65c50fe
Compare
@G-Rath can we move forward to Main with this PR? Most of the clean up is done. |
@MadeinFrance I'm waiting to see what's happening with our upcoming major whichll probably get released this week. This PR looks good to me so you can consider it off your plate - I'll handle landing it and doing any revising that might be needed :) |
Thanks again @MadeinFrance! I have done some minor refactoring that I recommend checking out if you're interested but don't feel bad about any of it - you did the grunt work which I've just built on and I've been working with these rules for years so never expected a first-time contributor to have gotten my changes on their first rule. The fixer is still a bit rough but I'm happy to improve that in follow-up PRs since you've already gone through a lot here and I think the roughness is just with very unlikely edge cases e.g.
|
🎉 This PR is included in version 28.1.0 🎉 The release is available on: Your semantic-release bot 📦🚀 |
@G-Rath I'm thrilled to see this landing on the release line. Thank you for your review and patience 🙏 I will use this in our corporate repos and improve the edge cases if required. |
Issue: #1101
Prefer importing Jest globals (
prefer-importing-jest-globals
)🔧 This rule is automatically fixable by the
--fix
CLI option.This rule aims to enforce explicit imports from
@jest/globals
.the codebase.
injectGlobals
configuration property, this rule can help to ensure that the Jest globals
are imported explicitly and facilitate a migration to
@jest/globals
.Rule details
Examples of incorrect code for this rule
Examples of correct code for this rule
Further Reading