Nitzan Tomer
Nitzan Tomer

Reputation: 164307

How to configure WebStorm to work with nx lint instead of ESLint?

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?

Upvotes: 4

Views: 2924

Answers (1)

lena
lena

Reputation: 93848

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

Upvotes: 5

Related Questions