4

When working on nx projects with WebStorm (and probably with other JetBrains IDEs) I keep getting this error:

Error: Error while loading rule '@typescript-eslint/await-thenable': 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.

I do have the parserOptions.project defined in the libs/mylibrary/.eslintrs.json:

{
  "extends": ["../../.eslintrc"],
  "parserOptions": {
    "project": "./tsconfig.*?.json",
    "tsconfigRootDir": "./libs/mylibrary"
  },
  ...

The error does not reproduce when I run ESLint manually, via npx eslint ./libs/mylibrary or via nx (nx lint mylibrary).

Any idea how to configure WebStorm to work well with nx lint?

LazyOne
  • 158,824
  • 45
  • 388
  • 391
Nitzan Tomer
  • 155,636
  • 47
  • 315
  • 299

1 Answers1

4

Can be a problem with wrong working folder the linter is run in. With Automatic configuration, the ESlint working folder is set to a folder where the nearest .eslintrc or eslintignore resides (as described in https://www.jetbrains.com/help/webstorm/eslint.html#ws_js_eslint_manual_configuration) If the auto-detected working directory doesn't match your project configuration, you need to specify the working directory (directories) manually: in Settings | Languages & Frameworks | JavaScript | Code Quality Tools | ESLint, change configuration to Manual and specify the directory in which you run eslint --fix in terminal (project root folder?) as a working dir - this should solve the issue

lena
  • 90,154
  • 11
  • 145
  • 150
  • great! thanks, seems to be working properly now – Nitzan Tomer Feb 07 '22 at 20:37
  • 1
    Adding a comment since I wasn't sure what the working directory is supposed to be. I put the path to my root `eslintsrc.js` and it started working, otherwise, it was trying to work with the `eslintsrc.json` in each of the projects in my monorepo and it kept having a problem finding the tsconfig files configured in those subfolders. – Ruan Mendes Jan 02 '23 at 18:34
  • Thank you, you're the one! My experience with Nx and Webstorm was pretty awful, now I can finally run `eslint --fix` on save, wonderful. – DjebbZ Jun 08 '23 at 15:50