# `deslop/re-export-cycle`

Disallow import cycles formed by re-export statements (export * / export { } from).

- **Category:** Dead Code
- **Severity:** warn
- **Source:** deslop-js
- **Framework:** global
- **Enabled when:** react-doctor deadCode analysis enabled (default true); whole-project scan only — skipped in --diff/--staged modes
- **Documentation:** <https://github.com/millionco/deslop-js>

## Validation prompt

Use this to decide whether a fired diagnostic is real or a false positive.

Fires when deslop's detectReExportCycles finds a strongly-connected component in the re-export-only edge graph: kind self-loop reports a single file whose reason is that it 're-exports from itself — the barrel imports its own root, which breaks bundler tree-shaking and risks TDZ runtime errors', while kind multi-node reports a ring whose reason is 'N modules form a re-export cycle — refactor consumers to import from the leaf module instead of the barrel'; both arrive at confidence high. False positive to suppress: the entire ring is type-only re-exports (export type { } from / export type *), since deslop builds the cycle edge without checking isTypeOnly but bundlers erase type re-exports at compile time, so there is no runtime initialization order or TDZ hazard — suppress when every link in the reported files is a type re-export.

## Fix prompt

Use this once validation confirms the diagnostic is real.

Break the cycle by re-pointing consumers at the leaf module instead of routing through the barrel: for a self-loop, delete the barrel's re-export of its own path (e.g. remove `export * from './index'` inside index.ts) so it only re-exports its real submodules; for a multi-node ring, find the file that both produces and re-imports a symbol and have it import directly from the defining leaf file (`import { foo } from './foo'`) rather than from the barrel that re-exports back to it, leaving the barrel as a one-directional aggregation. If the ring is genuinely type-only, convert the offending statements to `export type { ... } from` so the edge is compiled away. See https://github.com/millionco/deslop-js
