Skip to content

graphqlPlugin type incompatible with plugins in eslint defineConfig type #2936

@tomocrafter

Description

@tomocrafter

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

https://github.com/graphql-hive/graphql-eslint/blob/master/examples/graphql-config/eslint.config.js shows type error on

plugins: {
'@graphql-eslint': graphqlPlugin,
},

if you enable typescript for this file, or rename it to .ts

Type '{ parser: { parseForESLint: (code: string, options: ParserOptions) => GraphQLESLintParseResult; meta: { name: string; version: string | undefined; }; }; processor: { ...; }; rules: { ...; }; configs: { ...; }; }' is not assignable to type 'Plugin'.
  Types of property 'rules' are incompatible.
    Type '{ alphabetize: GraphQLESLintRule<{ definitions?: boolean | undefined; selections?: ("OperationDefinition" | "FragmentDefinition")[] | undefined; arguments?: ("Field" | "Directive" | "FieldDefinition" | "DirectiveDefinition")[] | undefined; values?: boolean | undefined; fields?: ("ObjectTypeDefinition" | ... 1 more ....' is not assignable to type 'Record<string, RuleDefinition<RuleDefinitionTypeOptions>>'.
      Property 'alphabetize' is incompatible with index signature.
        Type 'GraphQLESLintRule<{ definitions?: boolean | undefined; selections?: ("OperationDefinition" | "FragmentDefinition")[] | undefined; arguments?: ("Field" | "Directive" | "FieldDefinition" | "DirectiveDefinition")[] | undefined; values?: boolean | undefined; fields?: ("ObjectTypeDefinition" | ... 1 more ... | "InputObje...' is not assignable to type 'RuleDefinition<RuleDefinitionTypeOptions>'.
          Types of property 'meta' are incompatible.
            Type 'Omit<RuleMetaData, "docs" | "schema"> & { docs?: RuleDocsInfo<{ definitions?: boolean | undefined; selections?: ("OperationDefinition" | "FragmentDefinition")[] | undefined; ... 4 more ...; groups?: string[] | undefined; }[]> | undefined; schema: any; }' is not assignable to type 'RulesMeta<string, unknown> | undefined'.
              Type 'Omit<RuleMetaData, "docs" | "schema"> & { docs?: RuleDocsInfo<{ definitions?: boolean | undefined; selections?: ("OperationDefinition" | "FragmentDefinition")[] | undefined; ... 4 more ...; groups?: string[] | undefined; }[]> | undefined; schema: any; }' is not assignable to type 'RulesMeta<string, unknown>'.
                Types of property 'docs' are incompatible.
                  Type 'RuleDocsInfo<{ definitions?: boolean | undefined; selections?: ("OperationDefinition" | "FragmentDefinition")[] | undefined; arguments?: ("Field" | "Directive" | "FieldDefinition" | "DirectiveDefinition")[] | undefined; values?: boolean | undefined; fields?: ("ObjectTypeDefinition" | ... 1 more ... | "InputObjectTyp...' is not assignable to type 'RulesMetaDocs | undefined'.
                    Type 'RuleDocsInfo<{ definitions?: boolean | undefined; selections?: ("OperationDefinition" | "FragmentDefinition")[] | undefined; arguments?: ("Field" | "Directive" | "FieldDefinition" | "DirectiveDefinition")[] | undefined; values?: boolean | undefined; fields?: ("ObjectTypeDefinition" | ... 1 more ... | "InputObjectTyp...' is not assignable to type 'RulesMetaDocs | undefined'.
                      Type 'RuleDocsInfo<{ definitions?: boolean | undefined; selections?: ("OperationDefinition" | "FragmentDefinition")[] | undefined; arguments?: ("Field" | "Directive" | "FieldDefinition" | "DirectiveDefinition")[] | undefined; values?: boolean | undefined; fields?: ("ObjectTypeDefinition" | ... 1 more ... | "InputObjectTyp...' is not assignable to type 'RulesMetaDocs'.
                        Types of property 'category' are incompatible.
                          Type 'CategoryType | CategoryType[]' is not assignable to type 'string | undefined'.
                            Type 'CategoryType[]' is not assignable to type 'string'.ts(2322)

To Reproduce Steps to reproduce the behavior:

Expected behavior

No type error

Environment:

  • OS: Ubuntu 24.04
  • @graphql-eslint/eslint-plugin: 4.4.0
  • Node.js: 22.14.0

Additional context

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