Glavin001 / Glavin001/tslint-clean-code

no-unnecessary-push

Open
#25 0 comments 0 reactions 0 assignees View on GitHub
rule
Dominant language
TypeScript
Stars
175
Forks
15
PR merge metrics
No merged PRs in 30d

Description

```
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);
}
```

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.