deslop/redundant-alias

Disallow an alias that renames a symbol to itself or round-trips with no net change, e.g. `import { X as X }`.

  • 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 on six redundant-alias shapes, five at high confidence and reexport-aliased-not-used at medium: high-confidence import-self-alias and export/reexport-self-alias whose reason is import { X as X } / export { X as X } [from ...] aliases an identifier to its own name; high-confidence variable-alias whose reason is const a = b is the only consumer of b — rename or inline (a module-level non-exported const whose initializer is a bare identifier referenced nowhere else); high-confidence roundtrip-alias whose reason is import { X as Y } renames back to the original declaration name — the upstream rename can be removed (the local name equals the original declaration's real name); and the lone medium-confidence reexport-aliased-not-used whose reason is export { X as Y } from ... renames the symbol but no consumer imports it as Y — either drop the alias or have consumers use the new name. Treat that medium kind as the weak signal: it is exactly where the legitimate false positives cluster. False positive to SUPPRESS: a variable-alias or roundtrip-alias whose local name deliberately disambiguates a genuine name collision in scope (two same-named imports, or a local that would otherwise shadow the original), OR a reexport-aliased-not-used that is a deliberate public-API name remap consumed outside the analyzed graph (a barrel or published entry point) where the alias is load-bearing even with no in-repo consumer.

Fix prompt

Use this once validation confirms the diagnostic is real.

For self-aliases collapse the redundant pair: import { X as X } becomes import { X }, same for export { X as X } and export { X as X } from "./m". For variable-alias delete const a = b and either rename b to a at its declaration or replace the few uses of a with b. For roundtrip-alias drop the rename so it reads import { Y }, since Y is already the original name. For reexport-aliased-not-used, if Y is dead either drop the alias to export { X } from ... or update consumers to import Y; keep the alias only when it is an intentional public name remap consumed outside the graph. Unless it disambiguates a real collision or is a deliberate published rename, the alias is pure noise that forces the next reader to resolve an indirection for nothing. See https://github.com/millionco/deslop-js