I'm wanting to add @typescript-eslint/no-floating-promises to my rules and 
am having difficulties.

That requires parserOptions.

Here's my .eslintrc.js:

module.exports = {
  root: true,
  parser: '@typescript-eslint/parser',
  parserOptions: {
    ecmaVersion: 2017,
    project: './tsconfig.json'
  },
  plugins: [
    '@typescript-eslint',
  ],
  extends: [
    'eslint:recommended',
    'plugin:@typescript-eslint/eslint-recommended',
    'plugin:@typescript-eslint/recommended',
    'prettier'
  ],
  rules: {
    '@typescript-eslint/no-floating-promises': ['error'],
    '@typescript-eslint/no-explicit-any': 'off'
  }
};

and my tsconfig.json:

{
  "compilerOptions": {
    "target": "ES2017",
    "lib": ["ES2017"],
    "module": "commonjs",
    "declaration": true,
    "outDir": "lib",
    "removeComments": true,
    "strict": true,
    "noUnusedLocals": true,
    "noUnusedParameters": true,
    "noImplicitReturns": true,
    "noFallthroughCasesInSwitch": true,
    "moduleResolution": "node",
    "esModuleInterop": true,
    "forceConsistentCasingInFileNames": true
  },
  "include": ["src/**/*"],
  "exclude": ["src/**/*.spec.ts"]
}

The catch is the *exclude*. I don't want my tests (specs) to be compiled to 
the outDir. But this causes the following error when I run ESLint:

error  Parsing error: "parserOptions.project" has been set for 
> @typescript-eslint/parser.
> The file does not match your project config: src/index.spec.ts.
> The file must be included in at least one of the projects provided


(Script is "lint": "eslint \"src/**/*.ts\"" )

I *do* want to lint my tests.

Everything worked fine until I added parserOptions - and I need that for 
the no-floating-promises rule.

Any suggestions?

-- 
You received this message because you are subscribed to the Google Groups 
"ESLint" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/eslint/bf953e69-4a8c-481c-87de-a7850e0952f7%40googlegroups.com.

Reply via email to