How to warn when you forget to `await` an async function in Javascript?

The no-floating-promises ESLint rule requires you to explicitly handle any promises (e.g. with await or void).

Here’s a minimal .eslintrc for use with TypeScript. Note that parserOptions is required for this rule:

{
  "root": true,
  "parser": "@typescript-eslint/parser",
  "parserOptions": { "project": "./tsconfig.json" },
  "plugins": ["@typescript-eslint"],
  "extends": ["eslint:recommended", "plugin:@typescript-eslint/recommended"],
  "rules": {
    "@typescript-eslint/no-floating-promises": ["error"]
  }
}

(ESLint is recommended since TSLint has been deprecated.)

(Credit to @zaboco’s comment)

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)