Try to upgrade to the latest version of ESLint and make sure it's configured properly in .eslintrc.json
» npm install eslint-plugin-promise
» npm install eslint-plugin-no-floating-promise
I wonder why no one mentioned the "No floating promises" rule from "typescript-eslint", which forces all promises to be handled appropriately either with async/await or then/catch — https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/docs/rules/no-floating-promises.md
Probably it should be called "No unhandled promises". :)
ESLint itself does not have the functionality you are looking for, but there is a highly popular plugin called eslint-plugin-promise.
Specifically, the catch-or-return rule does what you are asking for:
Ensure that each time a then() is applied to a promise, a catch() is applied as well. Exceptions are made if you are returning that promise.
Valid
myPromise.then(doSomething).catch(errors)
myPromise
.then(doSomething)
.then(doSomethingElse)
.catch(errors)
function doSomethingElse() {
return myPromise.then(doSomething)
}
Invalid
myPromise.then(doSomething)
myPromise.then(doSomething, catchErrors) // catch() may be a little better
function doSomethingElse() {
return myPromise.then(doSomething)
}
» npm install eslint-plugin-async-promise