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

RFC: fixer for wait (V7) #86

Closed
timdeschryver opened this issue Mar 13, 2020 · 4 comments · Fixed by #88
Closed

RFC: fixer for wait (V7) #86

timdeschryver opened this issue Mar 13, 2020 · 4 comments · Fixed by #88
Labels
new rule New rule to be included in the plugin released

Comments

@timdeschryver
Copy link
Member

Would it be an option to add a fixable rule for the changes made to wait?
The implementation could look like this

export default function(context) {
  return {
    "CallExpression > Identifier[name=wait]"(node) {
      context.report({
        node: node,
        message: "waitForRename",
        fix: fixer => fixer.replaceText(node, "waitFor")
      });
    },
    "CallExpression[callee.name=waitFor][arguments.length=0]"(node) {
      context.report({
        node: node,
        message: "emptyCallBack",
        fix: fixer => fixer.replaceText(node, "waitFor(() => {})")
      });
    }
  };
}

input:

async () => {
	await wait(() => {});
  	await wait();
}

output:

async () => {
	await waitFor(() => {});
  	await waitFor(() => {});
}
@timdeschryver timdeschryver changed the title V7: fixer for wait RFC: fixer for wait (V7) Mar 13, 2020
@Belco90
Copy link
Member

Belco90 commented Mar 13, 2020

This seems really interesting! I guess the rule could be called something like prefer-wait-for and we could also check waitForDomChange right? The replace would be the same I think.

I'll give it a try tomorrow.

@timdeschryver
Copy link
Member Author

timdeschryver commented Mar 13, 2020

@Belco90 yep that should work, see the updated astexplorer for an implementation of the rule

@Belco90
Copy link
Member

Belco90 commented Mar 22, 2020

This will be released on v3

@Belco90 Belco90 closed this as completed Mar 22, 2020
Belco90 added a commit that referenced this issue 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 <28659384+timdeschryver@users.noreply.github.com>
@Belco90
Copy link
Member

Belco90 commented Mar 29, 2020

🎉 This issue has been resolved in version 3.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
new rule New rule to be included in the plugin released
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants