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

no-unnecessary-push #25

Open
Glavin001 opened this issue Nov 30, 2017 · 0 comments
Open

no-unnecessary-push #25

Glavin001 opened this issue Nov 30, 2017 · 0 comments
Labels

Comments

@Glavin001
Copy link
Owner

Glavin001 commented Nov 30, 2017

myMethod(myInput) {
    const promises = [];
    promises.push(this.aMethod());
    promises.push(this.anotherMethod());
    return Promise.all(promises);
}

should be

myMethod(myInput) {
    return Promise.all([
      this.aMethod(),
      this.anotherMethod(),
    ]);
}

For version 1, .push inside of if statement should be ignored and pass for the array:

myMethod(myInput) {
    const promises = [];
    promises.push(this.aMethod());
    if (myInput.someProp) {
      promises.push(this.anotherMethod());
    }
    return Promise.all(promises);
}
@Glavin001 Glavin001 added the rule label Nov 30, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant