import-js / import-js/eslint-plugin-import
import/no-cycle does not detect some cycles with side-effect imports
- Dominant language
- JavaScript
- Stars
- 5.9k
- Forks
- 1.5k
- PR merge metrics
- No merged PRs in 30d
Description
Here is the setup (https://codesandbox.io/p/devbox/my57j6):
```js
// a.js
import "./b";
export const f = () => globalThis.x;
// b.js
import "./c";
// c.js
import { f } from "./a";
globalThis.x = f();
```
This seems like a cycle to me (`a.js` expects `globalThis.x` to be set given that it imports `b.js` which imports `c.js` which sets it, but `c.js` uses an import from `a.js` in order to set `globalThis.x`).
Yet this is not detected as a cycle by `eslint-plugin-import`. Note that changing `a.js` to import `./c` instead of `./b` is detected as a cycle, so it seems to be the indirection introduced by `b.js` which confuses `no-cycle`.
Contributor guide
Research direction
Start by reproducing the three-file example from the issue or its CodeSandbox, then compare it with the direct a.js-to-c.js import that is already detected. Trace the no-cycle behavior for side-effect imports through the intermediate b.js module; done means the reported indirect cycle is detected without breaking the existing direct-cycle case.
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
- Mostly clear
- Newbie friendliness
- 38/100