import-js / import-js/eslint-plugin-import

no-cycle reports circular dependencies, but doesn't say what they are

Open
#2,383 10 comments 0 reactions 0 assignees View on GitHub
Dominant language
JavaScript
Stars
5.9k
Forks
1.5k
PR merge metrics
No merged PRs in 30d

Description

Here's some output I get with `"import/no-cycle": ["error", { ignoreExternal: true }]`:
```
$ eslint .

./app.ts
29:1 error Dependency cycle detected import/no-cycle
32:1 error Dependency cycle detected import/no-cycle
35:1 error Dependency cycle detected import/no-cycle

./src/home.ts
4:1 error Dependency cycle detected import/no-cycle

./src/html/render.ts
4:1 error Dependency cycle detected import/no-cycle

./src/ledger/reports.ts
7:1 error Dependency cycle detected import/no-cycle

./src/ui_records.ts
4:1 error Dependency cycle detected import/no-cycle

✖ 7 problems (7 errors, 0 warnings)

```

As you can see, it's complaining about dependency cycles (probably legitimate ones), but not giving any details on which things depend on what, which makes it difficult to fix them. I know it *sometimes* reports what the cycles are, at least, because I've seen it output that for other files. But I cleared out all of the ones it explained and I'm still left with some unexplained cycles.

Any idea what might be going wrong here/how I can diagnose? (I can try making a minimal example if needed but this codebase is kind of complicated so I'd like to not spend that time if there's another way to figure out the problem.)

Contributor guide

Open the contributing guide

Research direction

Start by reproducing the supplied ESLint output with import/no-cycle configured with ignoreExternal: true, comparing the reported app.ts and src files with cycles that include details. Trace the rule's diagnostic path to determine why some cycles omit their dependency chain, then add regression coverage showing the expected diagnostic details.

Written by the indexing model from the issue text.

Assessment

Tech stack
eslint, javascript
Domain
tooling
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.