`@typescript-eslint/no-misused-promises` with async listener
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 687
- Forks
- 174
- Avg merge
- 3h 40m
- Merged PRs (30d)
- 14
Description
We've established that listeners can be async but I think the listener type might be wrong:
const interceptor = new XMLHttpRequestInterceptor();
interceptor.on('request', async ({ controller, request }) => {
const response = await getResponse(handlers, request);
controller.respondWith(response ?? Response.json({ error: 'msw interceptor error' }));
});
ESlint is not happy with the async listener:
/Users/hristo/dev/msw-interceptors-listener-type/src/main.tsx
13:27 error Promise returned in function argument where a void return was expected @typescript-eslint/no-misused-promises
✖ 1 problem (1 error, 0 warnings)
Here's a repo to reproduce the issue:
https://github.com/UnsungHero97/msw-interceptors-listener-type
This might be a type issue in strict-event-emitter but I'm seeing it by using XMLHttpRequestInterceptor.
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reproducing the lint error in the linked msw-interceptors-listener-type repository using XMLHttpRequestInterceptor. Inspect the listener type exposed by XMLHttpRequestInterceptor and compare it with the typing in strict-event-emitter. Done means the async listener is accepted without the reported @typescript-eslint/no-misused-promises error.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript
- Domain
- api
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 38/100