How to add lint rule "no-floating-promises"

Hello,

I am trying to add the “no-floating-promises” rule to my api side codebase.

I added a .eslintrc.js file in /api with the following content.

module.exports = {
  extends: ['@redwoodjs/eslint-config'],
  root: true,
  parserOptions: {
    parser: '@typescript-eslint/parser',
    project: './tsconfig.json',
  },
  rules: {
    '@typescript-eslint/no-floating-promises': ['error'],
  },
}

But I always get this error:
Error: Error while loading rule '@typescript-eslint/no-floating-promises': You have used a rule which requires parserServices to be generated. You must therefore provide a value for the "parserOptions.project" property for @typescript-eslint/parser.

Does anyone know how to configure this?

My collegue solved it:

I have to say:

Part of the solution: it works in the IDE but not for yarn rw lint

Hey @tilmannb, I was able to get the CLI working by adding the tsconfig.json in ./scripts to parserOptions.project:

  {
    "private": true,
    "workspaces": {
      "packages": [
        "api",
        "web"
      ]
    },
    "devDependencies": {
      "@redwoodjs/core": "6.5.1"
    },
    "eslintConfig": {
      "extends": "@redwoodjs/eslint-config",
      "root": true,
      "rules": {
        "@typescript-eslint/no-floating-promises": ["error"]
      },
      "parserOptions": {
        "project": [
          "./api/tsconfig.json",
          "./web/tsconfig.json",
+         "./scripts/tsconfig.json"
        ]
      }
    },
    "engines": {
      "node": "=18.x",
      "yarn": ">=1.15"
    },
    "prisma": {
      "seed": "yarn rw exec seed"
    },
    "packageManager": "yarn@3.7.0"
  }

Thanks for looking into this @dom

Using your package.json I still get the error. What TS version are you using?

@tilmannb v5.3.2 it looks like