Skip to content

must-colocate-fragment-spreads fails on sibling index.js imports #105

@JonathanUsername

Description

@JonathanUsername

I've described it in some detail in the PR that fixes this issue here #104, but I'm opening an issue to track it. If that's not the right way to do this, then feel free to close this issue.

The problem code:

        import MyComponent from './';

        graphql`fragment foo on Page {
          ...MyComponent_foo
        }`

Currently throws the error:

This spreads the fragment MyComponent_foo but this module does not use it directly. If a different module needs this information, that module should directly define a fragment querying for that data, colocated next to where the data is used.

Which is highly confusing, as it is imported.

I believe this is an edge-case surfaced by our pattern of importing relative components in the same directory, so I've tried to tweak the module parser to handle this by checking the name of the parent directory in my PR.

Another option would be to operate on the variable name but that seems far worse and too much like the strict horrors of Relay compat.

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