{"id":13725019,"url":"https://github.com/relayjs/eslint-plugin-relay","last_synced_at":"2025-05-07T19:32:28.471Z","repository":{"id":43333276,"uuid":"93126404","full_name":"relayjs/eslint-plugin-relay","owner":"relayjs","description":"A plugin for the code linter ESLint to lint specific details about Relay.","archived":false,"fork":false,"pushed_at":"2024-08-27T16:31:14.000Z","size":524,"stargazers_count":100,"open_issues_count":26,"forks_count":46,"subscribers_count":20,"default_branch":"main","last_synced_at":"2024-11-08T09:50:23.649Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/relayjs.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2017-06-02T04:16:51.000Z","updated_at":"2024-10-23T15:06:17.000Z","dependencies_parsed_at":"2023-01-20T02:48:11.944Z","dependency_job_id":"bb306095-55ec-41d7-81e5-2211c118eef2","html_url":"https://github.com/relayjs/eslint-plugin-relay","commit_stats":{"total_commits":215,"total_committers":27,"mean_commits":7.962962962962963,"dds":"0.44651162790697674","last_synced_commit":"85b7a9b79f8d779099beff6522df6ad79372ecee"},"previous_names":[],"tags_count":42,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/relayjs%2Feslint-plugin-relay","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/relayjs%2Feslint-plugin-relay/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/relayjs%2Feslint-plugin-relay/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/relayjs%2Feslint-plugin-relay/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/relayjs","download_url":"https://codeload.github.com/relayjs/eslint-plugin-relay/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":224645172,"owners_count":17346090,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-08-03T01:02:09.959Z","updated_at":"2025-05-07T19:32:28.465Z","avatar_url":"https://github.com/relayjs.png","language":"JavaScript","funding_links":[],"categories":["JavaScript"],"sub_categories":[],"readme":"# eslint-plugin-relay [![Build Status](https://travis-ci.org/relayjs/eslint-plugin-relay.svg?branch=master)](https://travis-ci.org/relayjs/eslint-plugin-relay) [![npm version](https://badge.fury.io/js/eslint-plugin-relay.svg)](http://badge.fury.io/js/eslint-plugin-relay)\n\n`eslint-plugin-relay` is a plugin for [ESLint](http://eslint.org/) to catch common problems in code using [Relay](https://facebook.github.io/relay/) early.\n\n## Install\n\n`npm i --save-dev eslint-plugin-relay`\n\n## How To Use\n\n1.  Add `\"relay\"` to your eslint `plugins` section.\n2.  Add the relay rules such as `\"relay/graphql-syntax\": \"error\"` to your eslint `rules` section, see the example for all rules.\n\nExample .eslintrc.js:\n\n```js\nmodule.exports = {\n  // Other eslint properties here\n  rules: {\n    'relay/graphql-syntax': 'error',\n    'relay/graphql-naming': 'error',\n    'relay/must-colocate-fragment-spreads': 'warn',\n    'relay/no-future-added-value': 'warn',\n    'relay/unused-fields': 'warn',\n    'relay/function-required-argument': 'warn',\n    'relay/hook-required-argument': 'warn'\n  },\n  plugins: ['relay']\n};\n```\n\nYou can also enable all the recommended or strict rules at once.\nAdd `plugin:relay/recommended` or `plugin:relay/strict` in `extends`:\n\n```js\n{\n  \"extends\": [\n    \"plugin:relay/recommended\"\n  ]\n}\n```\n\n### Rule Descriptions\n\nBrief descriptions for each rule:\n\n- `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.\n- `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.\n- `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.\n- `relay/unused-fields`: Ensures that every GraphQL field referenced 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/)\n- `relay/function-required-argument`: Ensures that `readInlineData` is always passed an explicit argument even though that argument is allowed to be `undefined` at runtime.\n- `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.\n- `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.\n\n### Suppressing rules within graphql tags\n\nThe following rules support suppression within graphql tags:\n\n- relay/unused-fields\n- relay/must-colocate-fragment-spreads\n\nSupported rules can be suppressed by adding `# eslint-disable-next-line relay/name-of-rule` to the preceding line:\n\n```js\ngraphql`\n  fragment foo on Page {\n    # eslint-disable-next-line relay/must-colocate-fragment-spreads\n    ...unused1\n  }\n`;\n```\n\nNote 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](https://github.com/graphql/graphql-js/issues/2241) in their AST.\n\n## Contribute\n\nWe actively welcome pull requests, learn how to [contribute](./CONTRIBUTING.md).\n\n## License\n\n`eslint-plugin-relay` is [MIT licensed](./LICENSE).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frelayjs%2Feslint-plugin-relay","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frelayjs%2Feslint-plugin-relay","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frelayjs%2Feslint-plugin-relay/lists"}