Skip to content
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: new rule await-async-utils #69

Merged
merged 6 commits into from
Jan 28, 2020
Merged

feat: new rule await-async-utils #69

merged 6 commits into from
Jan 28, 2020

Conversation

Belco90
Copy link
Member

@Belco90 Belco90 commented Jan 24, 2020

Closes #49

@@ -24,7 +24,7 @@

<!-- ALL-CONTRIBUTORS-BADGE:START - Do not remove or modify this section -->

[![All Contributors](https://img.shields.io/badge/all_contributors-4-orange.svg?style=flat-square)](#contributors)
[![All Contributors](https://img.shields.io/badge/all_contributors-4-orange.svg?style=flat-square)](#contributors-)
Copy link
Member Author

Choose a reason for hiding this comment

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

I removed this by mistake in that PR trying to fix the badges.

@@ -0,0 +1,103 @@
'use strict';
Copy link
Member Author

Choose a reason for hiding this comment

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

This rule implementation is almost the same as await-async-query but I didn't try to optimize this as we may migrate this to TS soon.

emmenko
emmenko previously approved these changes Jan 27, 2020
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.

The test coverage looks good to me, thanks

testingLibraryUtilUsage.push(node);
}
},
'Program:exit'() {
Copy link
Contributor

Choose a reason for hiding this comment

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

Ah interesting, I didn’t know about this

Copy link
Member Author

Choose a reason for hiding this comment

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

Me either! I learnt about it thanks to @thomlom, you can find more info here

function isPromiseResolved(node) {
const parent = node.parent;

const hasAThenProperty = node =>
Copy link
Contributor

Choose a reason for hiding this comment

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

Does this need to be declared inside the isPromiseResolved function? Just to avoid confusion with arg names.

Copy link
Member Author

Choose a reason for hiding this comment

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

Not really, let me move this outside.

@thomaslombart
Copy link
Collaborator

Quick question: why not merging await-async-query with await-async-utils instead of maintaining these two rules?

@Belco90
Copy link
Member Author

Belco90 commented Jan 27, 2020

Quick question: why not merging await-async-query with await-async-utils instead of maintaining these two rules?

Well, even if the implementation looks similar (but it's not the same 100%), the async stuff being checked is different so as we already had a rule for async queries, we would have different rule for async utils to 1) being able to config what you want to lint and 2) not mix different concerns (ones are queries to get elements, others are utils to wait until something happen).

I think mixing both in the same rule would be a mistake because 1) the name of the rule wouldn't make sense with what is checking and 2) we could rename the rule and include everything but then every single async function from testing library should go under that rule and it seems too much.

What I think we should do is merge proper utils these 2 rules implementation have in common, but I commented previously I didn't do that assuming we will migrate this to TS soon so we can abstract this better.

@Belco90
Copy link
Member Author

Belco90 commented Jan 28, 2020

Merging as @thomlom approved outside github (he's busy dealing with personal stuff) and @emmenko approved before my last little change.

@Belco90 Belco90 merged commit 6420867 into master Jan 28, 2020
@Belco90 Belco90 deleted the rule/await-async-utils branch January 28, 2020 14:41
@Belco90
Copy link
Member Author

Belco90 commented Jan 28, 2020

🎉 This PR is included in version 2.0.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Enforce await on async utilities
3 participants