Skip to content

The alphabetize rule is broken with ESLint v10 #2945

@strmer15

Description

@strmer15

Issue workflow progress

Progress of the issue based on the
Contributor Workflow

  • 1. The issue provides a reproduction available on GitHub, Stackblitz or CodeSandbox

    For example, you can start off by editing the
    'basic' example on Stackblitz.

    Please make sure the graphql-eslint version under package.json matches yours.

  • 2. A failing test has been provided

  • 3. A local solution has been provided

  • 4. A pull request is pending review


Describe the bug

When using this plugin with ESLint v10, I immediately get an error for the alphabetize rule:

Oops! Something went wrong! :(

ESLint: 10.0.2

TypeError: Error while loading rule '@graphql-eslint/alphabetize': context.getSourceCode is not a function

To Reproduce Steps to reproduce the behavior:

Upgrade to ESLint v10

Run eslint against your code.

Expected behavior

There are no errors.

Environment:

  • OS: Linux fedora 6.18.10-402.asahi.fc42.aarch64+16k
  • @graphql-eslint/eslint-plugin: 4.4.0
  • Node.js: 24.13.0

Additional context

My flat config (only relevant portion shown):

import { defineConfig } from 'eslint/config';
import graphqlPlugin from '@graphql-eslint/eslint-plugin';

const baseConfig = defineConfig(
  {
    files: ['**/*.js', '**/*.ts', '**/*.jsx', '**/*.tsx'],
    processor: graphqlPlugin.processor,
    plugins: {
      '@graphql-eslint': graphqlPlugin,
    },
    rules: {
      '@graphql-eslint/no-anonymous-operations': 'error',
    },
  },
  {
    files: ['**/*.graphql'],
    languageOptions: {
      parser: graphqlPlugin.parser,
    },
    plugins: {
      '@graphql-eslint': graphqlPlugin,
    },
    rules: {
      '@graphql-eslint/alphabetize': [
        'error',
        {
          definitions: true,
          fields: [
            'ObjectTypeDefinition',
            'InterfaceTypeDefinition',
            'InputObjectTypeDefinition',
          ],
          groups: ['id', '*', 'createdAt', 'updatedAt'],
          selections: ['FragmentDefinition', 'OperationDefinition'],
          values: true,
        },
      ],
      '@graphql-eslint/no-anonymous-operations': 'error',
    },
  },
);

export default baseConfig;

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions