Skip to main content

SKY-E005 · Dead code

Duplicate TypeScript/JavaScript export

Low

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 toward max_dead_code, which has no limit by default, so it only fails a gate where you set one.
Finding type
review
Wrong result? Report itA false positive, a missed case or a confusing message: it goes privately to the founder.

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

src/nav.ts · TypeScriptReported on line 2
export const NAV_ITEMS = ["home", "cart"];export const ALL_NAV_ITEMS = NAV_ITEMS;
src/main.ts · TypeScript
import { NAV_ITEMS, ALL_NAV_ITEMS } from "./nav"; console.log(NAV_ITEMS.length, ALL_NAV_ITEMS.length);
package.json · JSON
{"name": "shop-web", "private": true, "main": "src/main.ts"}

What Skylos leaves alone

src/nav.ts · TypeScript
export const NAV_ITEMS = ["home", "cart"];/** @alias Kept for the v1 menu API. */export const ALL_NAV_ITEMS = NAV_ITEMS;

src/main.ts: same as in the flagged example.

package.json: same as in the flagged example.

Why Skylos leaves it alone

The @alias tag marks the second name as deliberate.

How Skylos decides

  1. Reports one binding exported twice: export const B = A where A is an earlier export of the module, and export default A where A was exported by its own declaration.
  2. Requires one unchanging binding: A is a const, function or class that is never reassigned and B is a const. Imported bindings and specifier lists (export { a, a as b }) are not grouped.
  3. 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.ts files, __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.
  4. 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.

src/nav.ts · TypeScript · the fix, against the flagged file
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.

From the Skylos rule handbook, Skylos 5.8.0 (commit 5b880b0). All rules.