Open alecmev opened 4 weeks ago
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
?
Additional question: Does this happen when Relay's lint rule is enabled by itself, or is it an interaction with graphql-eslint
?
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 ownreportUnusedDisableDirectives
?
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?
The problem is pretty simple, this plugin has its own handling of eslint-disable directives in GraphQL strings:
https://github.com/relayjs/eslint-plugin-relay/blob/24fd162eee099e3f8145f26b3e7d82fa60952466/src/rule-unused-fields.js#L23-L25
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:
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 https://github.com/relayjs/eslint-plugin-relay/issues/153 for a related problem.