Skip to content

feat(prefer-wait-for): new rule prefer-wait-for #88

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

Merged
merged 26 commits into from
Mar 22, 2020

Conversation

Belco90
Copy link
Member

@Belco90 Belco90 commented Mar 14, 2020

This closes #86

@timdeschryver let me know what you think! I had to include the empty callback fixer within the the other selectors fixers as otherwise tests were not passing. It's weird tho, the code was executed but apparently not taken into account for the test result.

@Belco90 Belco90 added the new rule New rule to be included in the plugin label Mar 14, 2020
@benmonro
Copy link
Member

should the docs for the other rules related to async utils be updated as well?

@Belco90
Copy link
Member Author

Belco90 commented Mar 15, 2020

@benmonro that will be addressed here #85

};

return {
'CallExpression > Identifier[name=wait]'(node) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What if the user is using a custom wait util? The rule will report it even if it's not imported from Testing Library?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep. I think it's too much from where it was imported? But I don't know what to do to be honest.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Obviously it would be better to check where it's imported from, but we have been checking this in other rules without caring about it. Could be an improvement for a separated ticket for all the rules within the plugin?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

On the other hand... It would be interesting to check from where it's imported so we can also replace the import itself. Otherwise, the fix of this rule could leave a broken file.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would suggest keep it like this for now and wait for users to ask for it, in case it's a valid use case.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unless it's not too complicated to implement of course 😅

timdeschryver
timdeschryver previously approved these changes Mar 15, 2020
Copy link
Member

@timdeschryver timdeschryver left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 👍
Added a few nits for the docs

@timdeschryver
Copy link
Member

Having the empty callback with the rest makes sense 👍

Copy link
Contributor

@emmenko emmenko left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good overall to me, thanks

- `waitForElement`
- `waitForDomChange`

> This rule will auto fix deprecated async utils for you, including the necessary empty callback for `waitFor`. This means `wait();` will be replaced with `waitFor(() => {});`
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💯

};

return {
'CallExpression > Identifier[name=wait]'(node) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unless it's not too complicated to implement of course 😅

@Belco90 Belco90 changed the base branch from master to v3 March 18, 2020 18:45
@Belco90 Belco90 mentioned this pull request Mar 18, 2020
6 tasks
@Belco90 Belco90 changed the title feat(prefer-wait-for): new rule prefer-wait-for [WIP] feat(prefer-wait-for): new rule prefer-wait-for Mar 19, 2020
@Belco90 Belco90 changed the title [WIP] feat(prefer-wait-for): new rule prefer-wait-for feat(prefer-wait-for): new rule prefer-wait-for Mar 19, 2020
@Belco90 Belco90 self-assigned this Mar 19, 2020
Copy link
Member

@timdeschryver timdeschryver left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, I have added one comment
I think most of the cases won't need this extra check tho

Copy link
Member

@timdeschryver timdeschryver left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like how you did the import thing 👍

@Belco90 Belco90 merged commit ae32b64 into v3 Mar 22, 2020
@Belco90 Belco90 deleted the feature/rule-prefer-wait-for branch March 22, 2020 13:13
Belco90 added a commit that referenced this pull request Mar 29, 2020
feat(await-async-utils): reflect waitFor changes (#89)
feat: new rule no-wait-for-empty-callback (#94)
feat: new rule prefer-wait-for (#88)
feat: new rule prefer-screen-queries (#99)
BREAKING CHANGE: drop support for node v8. Min version allowed is node v10.12 (#96)
BREAKING CHANGE: rule `no-get-by-for-checking-element-not-present` removed in favor of new rule `prefer-presence-queries` (#98)

Closes #85
Closes #86
Closes #90
Closes #92
Closes #95

Co-authored-by: timdeschryver <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
new rule New rule to be included in the plugin
Projects
None yet
Development

Successfully merging this pull request may close these issues.

RFC: fixer for wait (V7)
5 participants