Registry / testing / eslint-plugin-relay

eslint-plugin-relay

JSON →
library2.0.0jsnpmunverified

ESLint plugin for Relay, version 2.0.0, released under MIT license. It provides lint rules to catch common problems in Relay code, such as invalid GraphQL syntax, naming convention violations, missing colocated fragment spreads, and unused fields. The plugin ships with recommended and strict configurations, and supports suppression of certain rules within graphql tagged templates. Key differentiators: it provides faster feedback than the Relay Compiler for syntax and naming issues, and includes rules like `must-colocate-fragment-spreads` that enforce best practices for data fetching. It is actively maintained by the Relay team.

npm install eslint-plugin-relay
INSTALL
IMPORT
SIG · ESLINT-PLUGIN-RELA
E
eslint-plugin-relay
testingjavascriptv2.0.0
Install
Import
Disk
Pass rate
0/ 6
Env Coverage0 / 6
glibc
1822
musl
1822
Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
node 18226 runs
build_error
glibc
node 18226 runs
build_error
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

plugin
plugins: ['relay']
plugins: ['eslint-plugin-relay']
ESLint plugin names should omit the 'eslint-plugin-' prefix when listed in 'plugins'.
recommended config
extends: ['plugin:relay/recommended']
extends: ['relay/recommended']
Use the full 'plugin:' prefix syntax when extending a plugin's config.
strict config
extends: ['plugin:relay/strict']
extends: ['relay/strict']
Similar to recommended, use 'plugin:' prefix.

Installs and configures eslint-plugin-relay with all core rules enabled to catch common Relay code issues.

npm i --save-dev eslint-plugin-relay // .eslintrc.js module.exports = { plugins: ['relay'], 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', }, // Alternatively, use recommended config: // extends: ['plugin:relay/recommended'] };
Debug
Known issues
gotchaThe `must-colocate-fragment-spreads` rule relies on globally unique module names and may not work well outside of Meta's environment.
fix
Consider disabling this rule if your project uses non-unique module names or relative imports.
affects: >=1.0.0
deprecatedThe rule `relay/graphql-syntax` is deprecated? Actually it is still valid but may be superseded by compiler validation.
fix
No fix needed; rule still works, but you can rely on Relay Compiler for syntax validation.
affects: >=2.0.0
gotchaSuppression within graphql tags only supports `eslint-disable-next-line`, not `eslint-disable-line`, due to graphql-js AST limitations.
fix
Use `eslint-disable-next-line` comment before the line you want to suppress, not inline.
affects: >=1.0.0
Errors
Common errors & fixes
ESLint couldn't find the plugin "eslint-plugin-relay".
The plugin is not installed or is missing from package.json devDependencies.
fix
Run `npm i --save-dev eslint-plugin-relay` and ensure it is listed in your package.json.
Configuration for rule "relay/graphql-syntax" is invalid: Value "error" is not a valid severity.
Rule severity must be 0, 1, 2 or 'off', 'warn', 'error'. Using a string like 'error' is fine, but sometimes typos occur.
fix
Use 'error' correctly: `'relay/graphql-syntax': 'error'`.
Upgrade
Version history
2.0.0latest on npm
Audit
Dependencies
eslintrequiredpeer dependency; the plugin requires ESLint as a linter framework
graphqlrequiredused internally for parsing and validating GraphQL strings
Agent activity
4 hits · last 30 days
node
4
Resources
eslint-plugin-relay — npm install eslint-plugin-relay · libregistry