eslint-plugin-typesafe
Version:
ESLint plugin to encourage type-safe practices
47 lines (31 loc) • 1.2 kB
Markdown
in `UnhandledPromiseRejectionWarning`. To avoid this, promise chains should terminate in a `catch` member expression.
This rule disallows promise chains that do not terminate in a `catch` expression, when it can detect it.
Examples of **incorrect** code for this rule:
```js
/*eslint no-await-without-trycatch: "error"*/
async function y() {
return 123
}
y()
```
```js
/*eslint no-await-without-trycatch: "error"*/
const y = async () => {
return 123
}
y().catch(console.error).then(x => x)
```
Examples of **correct** code for this rule:
```js
/*eslint no-await-without-trycatch: "error"*/
async function y() {
return 123
}
y().then(x => x).catch(e => console.error(e))
```
Set this rule to `error` to avoid risking `UnhandledPromiseRejectionWarning`s in the code.
This rule is experimental. For a more robust implementation for TypeScript, check out [typescript-eslint/no-floating-promises](https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/docs/rules/no-floating-promises.md).
Promises may fail, resulting