# `deslop/unused-file`

Flag a source file unreachable from any configured entry point (deslop unusedFiles / detectOrphanFiles), likely dead — delete it.

- **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 from deslop's detectOrphanFiles pass: it traces reachability from resolved entry points across the import graph and reports any module (as unusedFiles, just a bare { path }) that is not reachable, is not itself an entry point, is not a declaration or config file, is not opaque-to-parse, is not a barrel re-exporting reachable sources, and has no reachable direct importer. False positive: the file IS used but deslop could not see the edge because the import specifier is not a plain string literal — collectDynamicImports resolves Literal import() and require()/require.resolve()/vi.mock()/jest.mock() string literals, plus relative ./ or ../ template-literal globs (quasis joined with '*'), but drops every computed/identifier/BinaryExpression specifier and any non-relative interpolated template like import(`@scope/${name}`), so the real cut is literal-vs-computed regardless of import/require form; also suppress when its only importer is an entry point resolveEntries did not discover (a custom script/framework/html entry outside package.json scripts or the known-entry list), it is a side-effect-only module pulled in for its top-level effects, or it is consumed by build tooling, a bundler config, or a glob the scan does not traverse.

## Fix prompt

Use this once validation confirms the diagnostic is real.

Confirm the file is truly orphaned (grep the repo for its basename and for any computed/identifier dynamic import or non-relative template like import(`@scope/${x}`) or require(variable) that the literal-only resolver would have dropped), then delete it along with any now-dead dependencies it was the last consumer of. If it is actually a real entry point, register it instead of deleting — add it to your config's entry list (or the package.json script/html/framework entry deslop discovers) so reachability traces through it; if it is loaded only via a computed import path or purely for side effects, add it to the scan's exclude/entry config so it stops being flagged. See https://github.com/millionco/deslop-js
