Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

It's impossible to disable unused-fields and must-colocate-fragment-spreads with reportUnusedDisableDirectives #152

Open
alecmev opened this issue Sep 24, 2024 · 3 comments

Comments

@alecmev
Copy link
Contributor

alecmev commented Sep 24, 2024

The problem is pretty simple, this plugin has its own handling of eslint-disable directives in GraphQL strings:

if (hasPrecedingEslintDisableComment(node, ESLINT_DISABLE_COMMENT)) {
return;
}

Which is at odds with ESLint's overall approach of "run every rule enabled in the configuration, and then just swallow the errors reported by eslint-disabled code". Currently I get the following error:

Unused eslint-disable directive (no problems were reported from 'relay/unused-fields')

And there's no way around it sans just disabling reportUnusedDisableDirectives, which I don't want to do. My current workaround is to wrap offending template literals in /* eslint-disable relay/unused-fields */.

The only solution I see is to do what graphql-eslint does and utilize a processor (very preferably the same one, so that they don't clash with each other). See #153 for a related problem.

@captbaritone
Copy link
Contributor

Thanks for the report. Can you share an example of code that triggers the issue here? Is it that when you include an eslint-ignore inline in the graphql tagged template literal (# eslint-disable-next-line relay/unused-fields) that this triggers eslint's own reportUnusedDisableDirectives?

@captbaritone
Copy link
Contributor

Additional question: Does this happen when Relay's lint rule is enabled by itself, or is it an interaction with graphql-eslint?

@alecmev
Copy link
Contributor Author

alecmev commented Sep 25, 2024

Is it that when you include an eslint-ignore inline in the graphql tagged template literal (# eslint-disable-next-line relay/unused-fields) that this triggers eslint's own reportUnusedDisableDirectives?

Exactly! Done inside a useLazyLoadQuery(graphql`...`).

Does this happen when Relay's lint rule is enabled by itself, or is it an interaction with graphql-eslint?

Thanks for asking this, I went to double-check and removed graphql-eslint's config outright (instead of using the workaround of including *.graphql in eslint-plugin-relay's files), and the directives aren't reported as unused anymore. So your hunch is correct, this happens only when graphql-eslint's processor is enabled. In retrospect, this is obvious, as without the processor to ESLint the template literal is just an opaque string 😛 Would you like me to close this issue in favor of #153?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants