Skip to content

Conversation

@captbaritone
Copy link
Contributor

@captbaritone captbaritone commented Apr 23, 2025

We had two lint rules which are no-longer relevant.

  • relay/compat-uses-vars was oriented around enabling migration from Relay classic
  • relay/generated-flow-types was used to ensure hooks/functions in Flow were passed type arguments that matched the fragment/query used. Flow can now understands that graphql tagged template literals resolve to Relay imports. This means we don't need to supply these type arguments any more.

I've also tired to at least add a description to for each lint rule. We really need a documentation page for each rule, but this is at least a start.

Copy link

@evanyeung evanyeung left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for updating this! Just few nits/typos to fix before merging but overall looks good

README.md Outdated
Brief descriptions for each rule:

- `relay/graphql-syntax`: Ensures each `graphql\`\`` tagged template literal contains syntactically valid GraphQL. This is also validated by the Relay Compiler, but the ESLint plugin can often provide faster feedback.
- `relay/graphql-naming`: Ensures GraphQL fragments and quries follow Relay's naming conventions. This is also validated by the Relay Compiler, but the ESLint plugin can often provide faster feedback.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"quries" -> "queries"

README.md Outdated

- `relay/graphql-syntax`: Ensures each `graphql\`\`` tagged template literal contains syntactically valid GraphQL. This is also validated by the Relay Compiler, but the ESLint plugin can often provide faster feedback.
- `relay/graphql-naming`: Ensures GraphQL fragments and quries follow Relay's naming conventions. This is also validated by the Relay Compiler, but the ESLint plugin can often provide faster feedback.
- `relay/must-colocate-fragment-spreads`: Ensures that when a fragment spread is added within a module, that module directly imports the module which defines that fragment. This prevents the anit-pattern when one component fetches a fragment that is not used by a direct child component. **Note**: This rule leans heavily on Meta's globally unique module names. It likely won't work well in other environments.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"anit-pattern" -> "anti-pattern"

README.md Outdated
- `relay/graphql-syntax`: Ensures each `graphql\`\`` tagged template literal contains syntactically valid GraphQL. This is also validated by the Relay Compiler, but the ESLint plugin can often provide faster feedback.
- `relay/graphql-naming`: Ensures GraphQL fragments and quries follow Relay's naming conventions. This is also validated by the Relay Compiler, but the ESLint plugin can often provide faster feedback.
- `relay/must-colocate-fragment-spreads`: Ensures that when a fragment spread is added within a module, that module directly imports the module which defines that fragment. This prevents the anit-pattern when one component fetches a fragment that is not used by a direct child component. **Note**: This rule leans heavily on Meta's globally unique module names. It likely won't work well in other environments.
- `relay/no-future-added-value`: Ensures code does not try to explicly handle the `"%future added value"` typename which Relay inserts as a placeholder for types that might be added to the schema while your app is deployed.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"explicly" -> "explicitly"

Also, is this just for enums? Might be nice to specify that

README.md Outdated
- `relay/graphql-naming`: Ensures GraphQL fragments and quries follow Relay's naming conventions. This is also validated by the Relay Compiler, but the ESLint plugin can often provide faster feedback.
- `relay/must-colocate-fragment-spreads`: Ensures that when a fragment spread is added within a module, that module directly imports the module which defines that fragment. This prevents the anit-pattern when one component fetches a fragment that is not used by a direct child component. **Note**: This rule leans heavily on Meta's globally unique module names. It likely won't work well in other environments.
- `relay/no-future-added-value`: Ensures code does not try to explicly handle the `"%future added value"` typename which Relay inserts as a placeholder for types that might be added to the schema while your app is deployed.
- `relay/unused-fields`: Ensures that every GraphQL field that is fetched is used within the module that includes it. This helps enable Relay's [optimal data fetching](https://relay.dev/blog/2023/10/24/how-relay-enables-optimal-data-fetching/)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: maybe subjective, but I think it's slightly clearer to say "the module that fetched it" instead of "the module that includes it"

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

On yeah, that's confusing. Ended up going the other way replacing "fetched" with "referenced".

README.md Outdated
- `relay/must-colocate-fragment-spreads`: Ensures that when a fragment spread is added within a module, that module directly imports the module which defines that fragment. This prevents the anit-pattern when one component fetches a fragment that is not used by a direct child component. **Note**: This rule leans heavily on Meta's globally unique module names. It likely won't work well in other environments.
- `relay/no-future-added-value`: Ensures code does not try to explicly handle the `"%future added value"` typename which Relay inserts as a placeholder for types that might be added to the schema while your app is deployed.
- `relay/unused-fields`: Ensures that every GraphQL field that is fetched is used within the module that includes it. This helps enable Relay's [optimal data fetching](https://relay.dev/blog/2023/10/24/how-relay-enables-optimal-data-fetching/)
- `relay/function-required-argument`: Ensures that `readInlineData` is always passed an explict argument even though that argument is allowed to be `undefined` at runtime.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"explict" -> "explicit"

README.md Outdated
- `relay/no-future-added-value`: Ensures code does not try to explicly handle the `"%future added value"` typename which Relay inserts as a placeholder for types that might be added to the schema while your app is deployed.
- `relay/unused-fields`: Ensures that every GraphQL field that is fetched is used within the module that includes it. This helps enable Relay's [optimal data fetching](https://relay.dev/blog/2023/10/24/how-relay-enables-optimal-data-fetching/)
- `relay/function-required-argument`: Ensures that `readInlineData` is always passed an explict argument even though that argument is allowed to be `undefined` at runtime.
- `relay/hook-required-argument`: Ensures that Relay hooks are always passed an explict argument even though that argument is allowed to be `undefined` at runtime.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"explict" -> "explicit"

README.md Outdated
Comment on lines 55 to 57
Haste?

- `relay/must-colocate-fragment-spreads`: Ensures that for every fragment spread, the module that defines that fragment is imported.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this left in by accident? This is already documented above!

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh I missed this. I don't think "haste" is a thing that people know about outside of meta, so I'll delete this in favor of what I have above.

rules: {
'relay/graphql-syntax': 'error',
'relay/compat-uses-vars': 'error',
'relay/graphql-naming': 'error',

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this line got deleted instead of the compat-uses-vars above

facebook-github-bot pushed a commit to facebook/flow that referenced this pull request Apr 23, 2025
Summary:
I'm trying to deprecate some lint rules which were made obsolete by this amazing integration and would like something public I can point to.

relayjs/eslint-plugin-relay#161

Reviewed By: jbrown215

Differential Revision: D73521437

fbshipit-source-id: e54a519465ec3c1ca966373515bc7f8a70dce349
@captbaritone captbaritone merged commit 5c313c6 into relayjs:main Apr 23, 2025
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants