Skip to content

react: component not detected when import path contains trailing space #102

@async3619

Description

@async3619

Summary

When a directory or file name contains a trailing space, and the import path also includes that trailing space, foresthouse fails to resolve the module path. As a result, the component is completely missing from the react usage tree.

Reproduction

Given a directory structure where the folder name has a trailing space:

src/features/Hero /        ← note trailing space
  ├── index.ts
  └── Hero.tsx

And an import like:

import Hero from 'Features/Hero '   // trailing space matches the directory name

Running foresthouse react on a file that renders <Hero /> will not include it in the output.

Expected: <Hero /> appears in the tree
Actual: <Hero /> is completely absent

Notes

While having a trailing space in a directory name is unusual, it does happen in real-world projects. The import resolves correctly at build time (Next.js/TypeScript), so foresthouse should handle it as well.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions