Nx: Webstorm eslint errors in verson 10.0.*

Created on 28 Jul 2020  路  13Comments  路  Source: nrwl/nx

Current Behavior

With the new 10.0.* versions webstorm does not work anymore. I am not sure if this is the right place to post this exactly, but we use nx in production and cannot migrate to newer versions anymore.

All .eslintrc files in libraries and apps are extending the base .eslintrc file which is in the root of the project. That root .eslintrc itself has the parserOptions object and requires a tsconfig.base.json file with a relative path. The bundled automatic eslint resolver from webstorm cannot resolve the tsconfig.base.json, as the path is resolved from the subfolder instead of the root folder which it should be.

The screenshot shows, how webstorm's eslint tries to resolve the .../foobar/apps/fooapp/tsconfig.base.json instead of the .../foobar/tsconfig.base.json

image

Changing all instances of tsconfig.base.json to tsconfig.json does not help, as the IDE then complains about the files not being included in any project. The reason being, that tsconfig.lib.json contains all the files that should be resolved, which the IDE somehow does not pick up. (likely due to the fact that the most relative tsconfig.json is resolved, rather than the in that case correct tsconfig.lib.json. Is any IDE supposed to resolve all the config files correctly? The 9.5.* worked just fine out of the box.

Now I am not sure, if webstorm is doing it wrong or if there is another problem. Surely our company cannot be the only ones that use nx with webstorm? This error prevents us from migrating to the new 10.0.* release, is there any workarounds maybe?

Expected Behavior

The WebStorm IDE should not error out when editing files.

Steps to Reproduce

Create a new workspace like described in the docs. Add any app/lib. Open the project with webstorm and navigate to a file in the lib/app. Obviously using eslint is required in order to see the errors.

Environment

  @nrwl/angular : Not Found
  @nrwl/cli : 10.0.6
  @nrwl/cypress : 10.0.6
  @nrwl/eslint-plugin-nx : 10.0.6
  @nrwl/express : Not Found
  @nrwl/jest : 10.0.6
  @nrwl/linter : 10.0.6
  @nrwl/nest : Not Found
  @nrwl/next : Not Found
  @nrwl/node : Not Found
  @nrwl/react : 10.0.6
  @nrwl/schematics : Not Found
  @nrwl/tao : 10.0.6
  @nrwl/web : 10.0.6
  @nrwl/workspace : 10.0.6
  typescript : 3.9.7

linter bug

Most helpful comment

I'm investigating a fix for this. And I think the best way atm is to change tsconfig.base.json to tsconfig.*.json in the root eslintrc file.

If that works out for you, let me know. Thank you!

All 13 comments

I'm investigating a fix for this. And I think the best way atm is to change tsconfig.base.json to tsconfig.*.json in the root eslintrc file.

If that works out for you, let me know. Thank you!

As far as I could test, changing the setting to tsconfig.*.json seems to work :raised_hands:
CLI commands work fine and IDE features seem to work as well. I will post here, should I find something!
Thank you for your great work!

@zaunermax are you using any rules that require type information from typescript?

Hey guys, I was experiencing the same issue and can confirm that changing tsconfig.base.json to tsconfig.*.json in the root eslintrc file does fix that issue.

I do however then see Parsing error: "parserOptions.project" has been set for @typescript-eslint/parser.. I assume this is unrelated to the first error so I'll look at that separately but thought I'd mention it.

@georgewilde I've seen that error before (especially within this repo) that was actually fixed with tsconfig.*.json. What kind of rules or set up do you have?

Does each of your projects have different rules defined than the root eslintrc? Do they have their own parserOptions?

@Cammisuli I've just seen the fix that @kylecannon has referenced and changing tsconfig.base.json to tsconfig.(base|lib).json in the root eslintrc file does fix both of the issues I've mentioned.

Great work guys 馃憤

@Cammisuli we only use the suggested eslint options that come out of the box by generating libs and apps

@georgewilde thanks, your solution from the comment also works great!

Thank you all for your great work with this great software :raised_hands:

That's strange.
Today I introduced storybook in a nx monorepo, and I got the error

Parsing error: "parserOptions.project" has been set for @typescript-eslint/parser.

Then I changed in my root .eslintrc from

"project": "./tsconfig.*?.json"

to

"project": "./tsconfig.(base|lib).json"

And it worked. Don't know exactly if #3447 covered all cases.

That's strange because *? literally means all or none 馃槷

What type of syntax is there? Glob pattern?

any updates here?

Please reopen this. I can still reproduce with 10.4.4 and latest WebStorm 2020.3

@marcelltoth is this happening in storybook?

Related maybe
https://github.com/nrwl/nx/issues/3867
https://github.com/nrwl/nx/pull/3923

Was this page helpful?
0 / 5 - 0 ratings