[no-misused-promises] [DOCS] examples should include a pattern for fixing async callbacks #3892
Labels
documentation
Documentation ("docs") that needs adding/updating
package: eslint-plugin
Issues related to @typescript-eslint/eslint-plugin
(I didn't see a template for Docs issues, and the one I picked for
eslint-plugin
had no relevant fields -- gonna make one up as I go along, sorry.)Affected page
https://github.com/typescript-eslint/typescript-eslint/blob/HEAD/packages/eslint-plugin/docs/rules/no-misused-promises.md
Current examples
Under the
checksVoidReturn
section, there are "bad" examples like this:The "fixes" for these examples look like
Basically, the docs say "just stop using an async function". Obviously, if the previous code was declared async, the dev expected to
await
something and will have to refactor, sometimes very significantly, to use a non-async callback.Suggested improvement
Give more concrete examples, like Brad did in #1637 (comment) :
That's a useful, concrete pattern to follow for refactoring a previously-async callback to safely avoid returning an orphaned Promise to an event manager that didn't expect to get one (and would ignore its rejection).
The text was updated successfully, but these errors were encountered: