New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More

@graphql-eslint/eslint-plugin

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@graphql-eslint/eslint-plugin


Version published
Weekly downloads
616K
increased by10.18%
Maintainers
2
Weekly downloads
 
Created

What is @graphql-eslint/eslint-plugin?

@graphql-eslint/eslint-plugin is an ESLint plugin that provides linting rules for GraphQL schema and operations. It helps developers enforce best practices, catch errors early, and maintain consistency in their GraphQL code.

What are @graphql-eslint/eslint-plugin's main functionalities?

Linting GraphQL Schema

This feature allows you to lint your GraphQL schema files. The example configuration enforces rules to ensure that all type names are known and warns about deprecated fields.

module.exports = {
  'plugins': ['@graphql-eslint'],
  'overrides': [
    {
      'files': ['*.graphql'],
      'parser': '@graphql-eslint/eslint-plugin',
      'rules': {
        '@graphql-eslint/known-type-names': 'error',
        '@graphql-eslint/no-deprecated': 'warn'
      }
    }
  ]
};

Linting GraphQL Operations

This feature allows you to lint GraphQL operations within your JavaScript files. The example configuration enforces rules to ensure that there are no unused fields and that the 'id' field is used when available.

module.exports = {
  'plugins': ['@graphql-eslint'],
  'overrides': [
    {
      'files': ['*.js'],
      'processor': '@graphql-eslint/graphql',
      'rules': {
        '@graphql-eslint/no-unused-fields': 'error',
        '@graphql-eslint/require-id-when-available': 'warn'
      }
    }
  ]
};

Custom Rules

This feature allows you to define custom linting rules for your GraphQL code. The example configuration shows how to set up a custom rule with specific options.

module.exports = {
  'plugins': ['@graphql-eslint'],
  'rules': {
    '@graphql-eslint/custom-rule': [
      'error',
      {
        'ruleOption': 'value'
      }
    ]
  }
};

Other packages similar to @graphql-eslint/eslint-plugin

FAQs

Package last updated on 05 Oct 2020

Did you know?

Socket

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.

Install

Related posts