Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable no-floating-promises ESLint rule #41945

Open
3 tasks
ravicious opened this issue May 23, 2024 · 0 comments
Open
3 tasks

Enable no-floating-promises ESLint rule #41945

ravicious opened this issue May 23, 2024 · 0 comments
Labels
developer-experience Addressing these issues will improve the experience of developers working on Teleport

Comments

@ravicious
Copy link
Member

ravicious commented May 23, 2024

https://typescript-eslint.io/rules/no-floating-promises/

There's a minor bug in Connect caused by forgetting to return a promise from a function. This seemed like something which could be caught by a linter, so I looked for relevant rules and found no-floating-promises.

However, after turning it on, there's almost 300 errors in the project. It's mostly due to uses of the run function from useAttempt and useAsync where we don't inspect the resulting promise, because we know that 1) the promise won't fail 2) the error is handled through the attempt object. Such callsites can be fixed by changing run() to void run().

As we won't find time to address all 300 callsites, it'd be best to ignore existing errors and start using the rule to prevent new issues from being created.

This requires a couple of things:

  • Set parserOptions.project to "tsconfig.json" in web/packages/build/.eslintrc.js, otherwise no-floating-promises can't be used.
  • Setting that option makes ESLint significantly slower. Figure out if there's anything we can do to speed it up.
  • Ignore existing issues reported by no-floating-promises.
@ravicious ravicious added the developer-experience Addressing these issues will improve the experience of developers working on Teleport label May 23, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
developer-experience Addressing these issues will improve the experience of developers working on Teleport
Projects
None yet
Development

No branches or pull requests

1 participant