Skip to content

A plugin for the code linter ESLint to lint specific details about Relay.

License

Notifications You must be signed in to change notification settings

alecmev/eslint-plugin-relay

This branch is 3 commits behind relayjs/eslint-plugin-relay:main.

Folders and files

NameName
Last commit message
Last commit date
Nov 27, 2023
Sep 9, 2023
Dec 15, 2021
Mar 14, 2019
Jun 3, 2017
Aug 3, 2020
Oct 30, 2018
Sep 11, 2023
Jul 18, 2019
Feb 5, 2021
Nov 20, 2021
Nov 20, 2021
Sep 9, 2023

Repository files navigation

eslint-plugin-relay Build Status npm version

eslint-plugin-relay is a plugin for ESLint to catch common problems in code using Relay early.

Install

npm i --save-dev eslint-plugin-relay

How To Use

  1. Add "relay" to your eslint plugins section.
  2. Add the relay rules such as "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/compat-uses-vars': 'warn',
    'relay/graphql-naming': 'error',
    'relay/generated-flow-types': 'warn',
    '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"
  ]
}

Suppressing rules within graphql tags

The following rules support suppression within graphql tags:

  • relay/unused-fields
  • relay/must-colocate-fragment-spreads

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.

Contribute

We actively welcome pull requests, learn how to contribute.

License

eslint-plugin-relay is MIT licensed.

About

A plugin for the code linter ESLint to lint specific details about Relay.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • JavaScript 100.0%