
Product
Introducing Socket MCP for Claude Desktop
Add secure dependency scanning to Claude Desktop with Socket MCP, a one-click extension that keeps your coding conversations safe from malicious packages.
eslint-plugin-relay
Advanced tools
eslint-plugin-relay
is a plugin for ESLint to catch common problems in code using Relay early.
npm i --save-dev eslint-plugin-relay
"relay"
to your eslint plugins
section."relay/graphql-syntax": "error"
to your eslint rules
section, see the example for all rules.Example .eslintrc.js:
module.exports = {
// Other eslint properties here
rules: {
'relay/graphql-syntax': 'error',
'relay/graphql-naming': 'error',
'relay/must-colocate-fragment-spreads': 'warn',
'relay/no-future-added-value': 'warn',
'relay/unused-fields': 'warn',
'relay/function-required-argument': 'warn',
'relay/hook-required-argument': 'warn'
},
plugins: ['relay']
};
You can also enable all the recommended or strict rules at once.
Add plugin:relay/recommended
or plugin:relay/strict
in extends
:
{
"extends": [
"plugin:relay/recommended"
]
}
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 queries follow Relay's naming conventions. This is also validated by the Relay Compiler, but the ESLint plugin can often provide faster feedback.relay/no-future-added-value
: Ensures code does not try to explicitly handle the "%future added value"
enum variant which Relay inserts as a placeholder to ensure you handle the possibility that new enum variants may be added by the server after your application has been deployed.relay/unused-fields
: Ensures that every GraphQL field referenced is used within the module that includes it. This helps enable Relay's optimal data fetchingrelay/function-required-argument
: Ensures that readInlineData
is always passed an explicit argument even though that argument is allowed to be undefined
at runtime.relay/hook-required-argument
: Ensures that Relay hooks are always passed an explicit argument even though that argument is allowed to be undefined
at runtime.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 anti-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.The following rules support suppression within graphql tags:
Supported rules can be suppressed by adding # eslint-disable-next-line relay/name-of-rule
to the preceding line:
graphql`
fragment foo on Page {
# eslint-disable-next-line relay/must-colocate-fragment-spreads
...unused1
}
`;
Note that only the eslint-disable-next-line
form of suppression works. eslint-disable-line
doesn't currently work until graphql-js provides support for parsing Comment nodes in their AST.
We actively welcome pull requests, learn how to contribute.
eslint-plugin-relay
is MIT licensed.
2.0.0
relay/compat-uses-vars
and relay/generated-flow-types
rules 493346f, 5c313c6generated-typescript-types
rule 31bfd44, f29444d, 0c91b68, ead1352, 105cf7fFAQs
ESLint plugin for Relay.
The npm package eslint-plugin-relay receives a total of 116,424 weekly downloads. As such, eslint-plugin-relay popularity was classified as popular.
We found that eslint-plugin-relay demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 6 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Product
Add secure dependency scanning to Claude Desktop with Socket MCP, a one-click extension that keeps your coding conversations safe from malicious packages.
Product
Socket now supports Scala and Kotlin, bringing AI-powered threat detection to JVM projects with easy manifest generation and fast, accurate scans.
Application Security
/Security News
Socket CEO Feross Aboukhadijeh and a16z partner Joel de la Garza discuss vibe coding, AI-driven software development, and how the rise of LLMs, despite their risks, still points toward a more secure and innovative future.