Skip to content

unused-file: directory barrels (index.ts) reached via directory-path imports flagged as unused #1699

Description

@dayrell19

Version: react-doctor 0.9.12

unused-file flags directory barrel files (index.ts re-exports) that are actually reachable through directory-path imports.

Repro shape:

src/features/foo/index.ts   // export * from "./foo-list"; export * from "./foo-card"
src/screens/bar.tsx         // import { FooList } from "@/features/foo"

The barrel is imported via the directory specifier (@/features/foo → resolved by TS/bundler to foo/index.ts), but dead-code analysis reports src/features/foo/index.ts as an unused file. Deleting it breaks the build, so the finding is a false positive.

Likely the resolver isn't applying Node/TS directory-index resolution (or the project's paths aliases) when building the import graph for dead-code analysis. We confirmed this on a Next.js app with @/* path alias in tsconfig.json.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions