dimaMachina / graphql-eslint

ESLint parser, plugin and set rules for GraphQL (for schema and operations). Easily customizable with custom rules. Integrates with IDEs and modern GraphQL tools.
https://the-guild.dev/graphql/eslint
MIT License
779 stars 101 forks source link

Eslint 9 compatibility #2311

Open lwasyl opened 1 month ago

lwasyl commented 1 month ago

Issue workflow progress

Progress of the issue based on the Contributor Workflow


Describe the bug

There's an open issue to support eslint 9 flat config files: https://github.com/dimaMachina/graphql-eslint/issues/2178. However, even when opting out from flat config via export ESLINT_USE_FLAT_CONFIG=false, graphql-eslint fails with Eslint 9 due to:

TypeError: Error while loading rule '@graphql-eslint/no-unreachable-types': Cannot destructure property 'schema' of 'context.parserServices' as it is undefined.. Iiuc the problem is that several methods have been deprecated and removed in eslint 9, including context.parserServices which graphql-eslint seems to be calling. Thus it's not only not possible to use flat config, but eslint 9 at all

To Reproduce Steps to reproduce the behavior:

Update eslint to version 9

Expected behavior

graphql-eslint still works

Environment:

Additional context

ldiqual commented 4 weeks ago

Workaround using the compat package from eslint:

import { fixupPluginRules } from '@eslint/compat'
export default [
  {
    plugins: {
      '@graphql-eslint': fixupPluginRules(graphqlPlugin),
    },
    // ...
  }
]