-
Notifications
You must be signed in to change notification settings - Fork 148
feat(no-render-in-setup): adds no-render-in-setup rule, closes #207 #209
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(no-render-in-setup): adds no-render-in-setup rule, closes #207 #209
Conversation
Thanks for your first PR ❤️ 🚀 For the styling changes, we've seen something similar in other PRs, so I just opened a ticket to review that #210 so it's ok - don't worry about it. For the code in general, it looks great to me. Perhaps my only suggestion is about the error message (both in the rule and in the docs). They said
I used to work in a project where we would use It's an open suggestion so I want to also hear everyone else's thoughts and yours too. Other than that, everything looks good to me so we can probably merge this soon. |
Thanks @gndelia! I totally agree, and I've had a similar experience refactoring tests as the one you've described. I'm also now wondering if this rule should only be applied to
If the goal is moving render closer to assertions more generally:
Curious to hear your and others' thoughts! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for your first contribution! Looks good so far, I asked couple of naming improvements and adding some extra tests. As mentioned in one of the comments, let me know if you need help or more indications!
@gndelia @alessbell I agree on updating the error message to make it more generic and not so attached to the assert combination. Good point about if it makes sense to report when used within |
I think I remember there were some issues with using Assuming it can be used properly, I believe it makes sense to report it. |
Thanks for the reviews @gndelia @Belco90! I've attempted to address most of your comments, with the exception of this one regarding ignoring render methods that don't come from testing library. I will add that in a follow-on commit shortly :) I've made the docs/error language more general, and added an enum config option |
@alessbell awesome! The rule implementation is looking really good. No rush with the import check one. Thanks for your work! |
Co-authored-by: Tim Deschryver <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for applying the changes! Looks great for me. Thanks for your contribution! 🎸 🚀
Thanks @gndelia! I believe I just have one more fix to make, and it's related to the commented out test that is still failing. Per @Belco90's advice, I will need to adjust the rule so that e.g.: import { render } from 'imNoTestingLibrary';
beforeAll(() => {
render(<Component/>)
})`, does not trigger the error. I believe that's all that is left, and I should be able to add it soon :) Thanks for all the comments! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, thanks!
@@ -50,6 +50,22 @@ export function isVariableDeclarator( | |||
return node && node.type === AST_NODE_TYPES.VariableDeclarator; | |||
} | |||
|
|||
export function isRenderFunction( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I thought this one was already moved to node-utils.ts
but that was done in v4 of course 😓
@all-contributors please add @alessbell for code, tests and doc. |
I've put up a pull request to add @alessbell! 🎉 |
🎉 This PR is included in version 3.5.0 🎉 The release is available on: Your semantic-release bot 📦🚀 |
Added a
no-render-in-setup
rule with tests to address #207.The rule looks for uses of
render
(or a custom render function who name can be passed in via config options) inside of two "before hooks":beforeEach
andbeforeAll
.