Skip to content

add typescript-eslint to eslint-config-next to catch floating promises#28181

Closed
kyliau wants to merge 3 commits into
vercel:canaryfrom
kyliau:no-floating-promises
Closed

add typescript-eslint to eslint-config-next to catch floating promises#28181
kyliau wants to merge 3 commits into
vercel:canaryfrom
kyliau:no-floating-promises

Conversation

@kyliau

@kyliau kyliau commented Aug 17, 2021

Copy link
Copy Markdown

This commit (partially) tackles item 3 in #27051:

Forgetting to await an async function inside an API route, works fine
locally but does out of band work which will cause issues if there’s
multiple requests.

The work here is focused on TypeScript for now because typescript-eslint
already provides no-floating-promises rule that precisely targets this
scenario.

This requires adding a new dependency (@typescript-eslint/eslint-plugin)
to eslint-config-next. Although it is a superfluous dependency for
JavaScript projects, it's not a big deal since eslint-config-next already
has a dependency on @typescript-eslint/parser.

Bug

  • Related issues linked using fixes #number
  • Integration tests added
  • Errors have helpful link attached, see contributing.md

Feature

  • Implements an existing feature request or RFC. Make sure the feature request has been accepted for implementation before opening a PR.
  • Related issues linked using fixes #number
  • Integration tests added
  • Documentation added
  • Telemetry added. In case of a feature if it's used or not.
  • Errors have helpful link attached, see contributing.md

Documentation / Examples

  • Make sure the linting passes

This commit (partially) tackles item 3 in vercel#27051:

> Forgetting to await an async function inside an API route, works fine
> locally but does out of band work which will cause issues if there’s
> multiple requests.

The work here is focused on TypeScript for now because `typescript-eslint`
already provides `no-floating-promises` rule that precisely targets this
scenario.

This requires adding a new dependency (`@typescript-eslint/eslint-plugin`)
to `eslint-config-next`. Although it is a superfluous dependency for
JavaScript projects, it's not a big deal since `eslint-config-next` already
has a dependency on `@typescript-eslint/parser`.
@kyliau kyliau force-pushed the no-floating-promises branch from 20c91cf to e738406 Compare August 17, 2021 00:05
@kyliau

kyliau commented Aug 27, 2021

Copy link
Copy Markdown
Author

I realize our ESLint config does not setup the TS parser to use typechecker, so this won't work out of the box.
Need to add some tests for this feature as well.
Closing for now.

@kyliau kyliau closed this Aug 27, 2021
@kyliau kyliau deleted the no-floating-promises branch August 27, 2021 17:28
@adogg43

This comment has been minimized.

@vercel vercel locked as resolved and limited conversation to collaborators Jan 27, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants