deslop/duplicate-export
Flag a name exported more than once from a single file, e.g. `export { x } from "./a"` plus a later `export const x`, collapsing to one canonical export.
- Category: Architecture
- 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 (confidence high) when deslop's detectDuplicateExports finds one name appearing 2+ times in a single non-declaration module's export list with at least one occurrence being a re-export (the nameHasReExport gate), emitting the reason '"name" is exported N times from the same module' with per-occurrence isReExport/reExportSource markers; it counts each export line physically present in the file and skips synthetic exports and bare export * from namespace re-exports. Suppress when the duplicates are two sibling re-export lines that build tooling later resolves to exactly one (e.g. export { impl } from "./node" and export { impl } from "./browser" that package.json exports conditions or a bundler collapse to a single target — both lines really exist and are both counted, nothing was flattened at parse time), or when a value and a same-named type legitimately coexist (export const Foo alongside export type { Foo } from "./types") — the detector keys only on the name and never reads isTypeOnly, so distinct value/type symbol kinds get reported as a false collision.
Fix prompt
Use this once validation confirms the diagnostic is real.
Keep exactly one export of the name and delete the rest: if a local export const x duplicates a re-export export { x } from "./a", drop whichever is redundant so a single line wins, and if a barrel re-exports the same name from two modules pick the intended source and remove the other export ... from line (or alias one, export { x as xLegacy } from "./b"). Duplicate same-name exports are ambiguous — bundler/barrel resolution picks one arbitrarily so the wrong source can win silently, and strict ESM rejects the duplicate outright. See https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/export