SKY-E005 · Dead code
Duplicate TypeScript/JavaScript export
One binding exported from a module under two names. Typical forms are export const B = A where A is already exported, and a component exported both by name and as export default.
- Languages
- TypeScript, JavaScript
- Turned on by
skylos .(every scan)- Quality gate
- counted toward the gate limits (full and diff scans). Reported in
unused_exports. Counts towardmax_dead_code, which has no limit by default, so it only fails a gate where you set one. - Finding type
- review
Why it matters
Importers split between the two names, so a search for one misses the other and a rename or removal has to chase both. The second name usually survives from an old refactor.
What Skylos flags
export const NAV_ITEMS = ["home", "cart"];export const ALL_NAV_ITEMS = NAV_ITEMS;import { NAV_ITEMS, ALL_NAV_ITEMS } from "./nav"; console.log(NAV_ITEMS.length, ALL_NAV_ITEMS.length);{"name": "shop-web", "private": true, "main": "src/main.ts"}What Skylos leaves alone
export const NAV_ITEMS = ["home", "cart"];/** @alias Kept for the v1 menu API. */export const ALL_NAV_ITEMS = NAV_ITEMS;Why Skylos leaves it alone
The @alias tag marks the second name as deliberate.
How Skylos decides
- Reports one binding exported twice:
export const B = AwhereAis an earlier export of the module, andexport default AwhereAwas exported by its own declaration. - Requires one unchanging binding:
Ais aconst, function or class that is never reassigned andBis aconst. Imported bindings and specifier lists (export { a, a as b }) are not grouped. - Public modules (package entries, tests,
export *targets) are checked too. Internal modules an importer uses whole (Object.keys(ns),import()) and what they forward,.d.tsfiles,__fixtures__/__testfixtures__data, stories and tool configs stay silent, as do@alias-tagged statements. A name already reported as an unused SKY-E004 alias is not repeated here. - Reports the group (
NAV_ITEMS|ALL_NAV_ITEMS) on the alias's line.
How to fix it
Keep one name and point importers of the other at it.
export const NAV_ITEMS = ["home", "cart"];Removed: export const ALL_NAV_ITEMS = NAV_ITEMS;When it can be wrong
- A deliberate compatibility alias, for example a renamed name a package keeps exporting for its users. Tag it with
/** @alias */instead of suppressing the rule.
Seeing a case that isn't listed here? Report the wrong result so the rule can be fixed. Don't paste company code: describe the shape of it.
How to silence it
Add
// skylos: ignore[SKY-E005]on the alias's line.Set
[tool.skylos] ignore = ["SKY-E005"]to disable this rule project-wide.