Skip to content

Commit 54ca713

Browse files
committed
Update readme
1 parent abd5a89 commit 54ca713

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

README.md

+4-5
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,12 @@ Now assume you don't know what `foo` does. Or you don't want to read every async
2424
```typescript
2525
try { await foo() } catch (e) { }
2626
```
27-
When/how do you propgate an error to the caller? or do you silence everything throuh a try catch? What if you have a series of async functions. But you don't want one throw to stop everything. Do you just wrap every single one in a try-catch. Or worse, use `.catch` nesting hell. There are many other examples of how bad this trycatching can get, amongst other issues with throwing in an async func.
27+
When/how do you propgate an error to the caller? or do you silence everything throuh a try catch? What if you have a series of async functions. But you don't want one throw to stop everything. Do you just wrap every single one in a try-catch. Or worse, use `.catch` for a quick nesting hell trip. There are many other examples of how bad this trycatching can get, amongst other issues with throwing in an async func.
2828

29-
The goal of this plugin is to treat every promise as unsafe, which they are, and only allow awaiting a safe promise. A safe promise in this case means one that will not crash the application if left outside of a try-catch (will never throw). To to that, a linter rule will prevent you from awaiting a promise unless it's wrapped by a `awaitable` function.
29+
The goal of this plugin is to treat every promise as unsafe, which they are, and only allow awaiting a safe promise. A safe promise in this case means one that will not crash the application if left outside of a try-catch (will never throw). To to that, a linter rule will prevent you from awaiting a promise unless it's wrapped by an `awaitable` function.
3030

3131
## awaitable
32-
A function that turns unsafe promises into safe promises. One implementation (golang like error handling):
32+
Turns any unsafe promise into safe promise. One implementation (golang like error handling):
3333
```typescript
3434
/**
3535
* Guarantees that a promise throw will be handled and returned gracefully as an error if any
@@ -44,9 +44,8 @@ A function that turns unsafe promises into safe promises. One implementation (go
4444
async function awaitable<R, E = Error> (
4545
fn: Promise<R>
4646
): Promise<[R | null, E | null]> {
47-
// eslint-disable-next-line no-try-catch/no-try-catch
4847
try {
49-
// eslint-disable-next-line no-try-catch/no-direct-await
48+
// eslint-disable-next-line no-throw-await/no-direct-await
5049
const data: R = await fn
5150
return [data, null]
5251
} catch (error: any) {

0 commit comments

Comments
 (0)