Skip to content

RFC: fixer for wait (V7) #86

@timdeschryver

Description

@timdeschryver

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(() => {});
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    new ruleNew rule to be included in the pluginreleased

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions