question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

enforce-module-boundaries eslint rule takes ~3min on one file

See original GitHub issue

Current Behavior

Linting one small file of a large project (1000+ files) with the enforce-module-boundaries eslint rule on takes about ~3min. Linting that same file with this rule off it takes, <1s.

Expected Behavior

For the plugin to take slightly longer, not magnitudes longer.

Steps to Reproduce

I don’t have a small repo where this occurs, because it seems to happen at scale.

The time sink happens on this recursive call: https://github.com/nrwl/nx/blob/master/packages/workspace/src/utils/runtime-lint-utils.ts#L170

Eslint config looks like:

{
    plugins: [
        '@nrwl/eslint-plugin-nx'
    ],
    rules: {
        '@nrwl/nx/enforce-module-boundaries': [
            'error',
            {
              "depConstraints": [
                {
                    "sourceTag": "scope:client",
                    "onlyDependOnLibsWithTags": ["scope:libs"]
                }
              ]
            }
        ]
    }
}

nx.json looks like:

        "my-app": {
            "tags": ["scope:client"]
        },
       "my-lib" : { "tags": ["scope:libs"] }

This issue may not be prioritized if details are not provided to help us reproduce the issue.

Failure Logs

Running like: time nx lint my-app

Getting:

my-app/index.js
  2:1  error  Circular dependency between "my-app" and "another-app" detected  @nrwl/nx/enforce-module-boundaries
  3:1  error  Circular dependency between "my-app" and "my-app" detected                     @nrwl/nx/enforce-module-boundaries

✖ 2 problems (2 errors, 0 warnings)

Lint errors found in the listed files.

nx lint my-app  192.34s user 10.69s system 112% cpu 3:00.16 total

Environment

>  NX  Report complete - copy this into the issue template

  @nrwl/angular : Not Found
  @nrwl/cli : 9.4.0-rc.8
  @nrwl/cypress : 9.4.0-rc.8
  @nrwl/eslint-plugin-nx : 9.4.0-rc.8
  @nrwl/express : 9.4.0-rc.8
  @nrwl/jest : 9.4.0-rc.8
  @nrwl/linter : 9.4.0-rc.8
  @nrwl/nest : Not Found
  @nrwl/next : Not Found
  @nrwl/node : 9.4.0-rc.8
  @nrwl/react : 9.4.0-rc.8
  @nrwl/schematics : Not Found
  @nrwl/tao : 9.4.0-rc.8
  @nrwl/web : 9.4.0-rc.8
  @nrwl/workspace : 9.4.0-rc.8
  typescript : 3.8.3

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:1
  • Comments:7 (4 by maintainers)

github_iconTop GitHub Comments

3reactions
FrozenPandazcommented, Jun 13, 2020

Hm you must have a very deep dependency chain. We should probably memoize that function though.

Would you like to contribute a PR? Someone from the community is also welcome to try.

Do you happen to have a repo exhibiting the issue to verify if a fix really speeds things up?

0reactions
meeroslavcommented, May 5, 2022

Try with the latest version or at least some v13 and let me know if it still happens.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Working with Rules - ESLint - Pluggable JavaScript Linter
Each rule in ESLint has three files named with its identifier (for example, no-extra-semi ). in the lib/rules directory: a source file (for...
Read more >
Taming Code Organization with Module Boundaries in Nx
Nx ships with enforce-module-boundaries ESLint rule that helps restrict that possibility.
Read more >
How to deal with the TSLint error "A project without tags ...
By default, the nx-enforce-module-boundaries TSLint rule in nx.json comes with the following boundaries: "nx-enforce-module-boundaries": ...
Read more >
eslint rule @nrwl/nx/enforce-module-boundaries fails [UPDATE]
To get this working: On your base tsconfig.base.json or your local tsconfig.json . I suggest to do it on the tsconfig.base.json.
Read more >
Enforcing Consistent Code in Expo React Native Projects
Improve your team's code quality and efficiency by using ESLint, Prettier, Husky, and lint-staged to automate formatting and consistency ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found