github / github/eslint-plugin-github

`github/async-preventdefault` should not flag calls before the first `await`

Open
#599 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
JavaScript
Stars
336
Forks
67
Avg merge
1d 9h
Merged PRs (30d)
6

Description

`preventDefault()` works fine before the first `await` in an async function, so this code works as expected, but if currently flagged:

```js
document.querySelector('a').addEventListener('click', e => {
e.preventDefault();
await fetch('/');
});
```

It's only after the first `await`, where `preventDefault` stops working. I suggest the rule to only flag `preventDefault()` after the first `await`.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.