Glavin001 / Glavin001/tslint-clean-code
no-return-promise-mixed-type: Do not allow functions to return promises mixed with something non-promise
Open
help wanted
rule
- Dominant language
- TypeScript
- Stars
- 175
- Forks
- 15
- PR merge metrics
- No merged PRs in 30d
Description
# Bad
```
function doStuff(input) {
if (input === "stuff") {
return Promise.resolve(true);
}
return false;
}
```
Consider the following:
```
doStuff("stuff")
.then(result => console.log(result)); // => true
doStuff("other") // *****Cannot call .then on false!*******
.then(result => console.log(result));
```
It should always return a Promise!
# Good
```
function doStuff(input) {
if (input === "doIt") {
return Promise.resolve(true);
}
return Promise.resolve(false);
}
```
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.