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

ESLint no-floating-promises #8

@clouedoc

Description

@clouedoc

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions