Skip to content
This repository has been archived by the owner on Jul 10, 2024. It is now read-only.

ESLint no-floating-promises #8

Open
clouedoc opened this issue Apr 19, 2021 · 1 comment
Open

ESLint no-floating-promises #8

clouedoc opened this issue Apr 19, 2021 · 1 comment

Comments

@clouedoc
Copy link

Did you ever forget to await something and it made you loose a lot of time? Or perhaps you forgot to handle a promise rejection and it made you want to quit JavaScript? I bet you did at some point, and maybe you still do to this date. It feels like a design flaw in JavaScript, and I thought that TypeScript couldn't do anything about it, until...

... I've found out that there is a way to prevent unhandledPromiseRejections. I noticed that your project doesn't seem to have it configured so I couldn't help but open this issue.

What I'm talking about is the no-floating-promises rule.

Here is my .eslintrc.js for reference:

module.exports = {
  env: {
    es2021: true,
    node: true,
  },
  extends: ["eslint:recommended", "plugin:@typescript-eslint/recommended"],
  parser: "@typescript-eslint/parser",
  parserOptions: { // you need to have this for `no-floating-promises` to work
    ecmaVersion: 12,
    sourceType: "module",
    project: "tsconfig.json",
  },
  plugins: ["@typescript-eslint"],
  rules: {
    "@typescript-eslint/no-floating-promises": "error", // holy rule
  },
};

You have to try it.

@Xetera
Copy link
Owner

Xetera commented Apr 19, 2021

Interesting, I haven't updated this repo in a while but I'll look into this thanks

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants