Nx: ESLint Performance Issue

Created on 22 Oct 2020  路  1Comment  路  Source: nrwl/nx

Current Behavior


I have a mono repo with 20+ libraries and a few storybooks. Each library contains a single component.

When I run Eslint (the new builder) on a single library it takes 22 seconds to lint that single library of 1 component.

From my investigation it appears to be the creation of a TS program based on tsconfig.base.json which includes files in every app and library, not just the ones in the library I want to lint.

If for example I was to add the following to the .eslintrc.json file in the library folder, so it creates the TS program based on the files solely in that library I get a much more respectable 4 second linting time for that single library:

"parserOptions": {
    "project": "./libs/react/box/tsconfig.*?.json"
}

While this workaround works when running the builder my IDE throws warnings so this isn't really a solution, it just demonstrates the issue.

Expected Behavior



Linting a single library should run fast, and not slow down based on the number of other apps and libraries in the repository.

Steps to Reproduce

  • Clone https://github.com/nrwl/nx-examples/pull/119
  • run yarn nx lint sample --skip-nx-cache
  • In the libs/sample/.eslintrc.json file uncomment out the parserOptions section
  • run the linting command above again
  • It should run faster now we are not including all files. Note the speed up is not that significant in this small project, but in a larger repository we are seeing a 5x improvement.

Failure Logs


N/A

Environment


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

Most helpful comment

Yeah, this is the manifestation of why I wrote this TODO when I last touched the workspace lint utils :) https://github.com/nrwl/nx/blob/992013ca0af7676cae3005b308c7496fa77bba9f/packages/workspace/src/utils/lint.ts#L277

We should be able to address this soon I think @FrozenPandaz - it naturally forms part of the overrides update for non-Angular projects that we discussed already

>All comments

Yeah, this is the manifestation of why I wrote this TODO when I last touched the workspace lint utils :) https://github.com/nrwl/nx/blob/992013ca0af7676cae3005b308c7496fa77bba9f/packages/workspace/src/utils/lint.ts#L277

We should be able to address this soon I think @FrozenPandaz - it naturally forms part of the overrides update for non-Angular projects that we discussed already

Was this page helpful?
0 / 5 - 0 ratings