Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Expose valid types for eslint rules #2881

Open
dr3 opened this issue Feb 4, 2025 · 0 comments
Open

Expose valid types for eslint rules #2881

dr3 opened this issue Feb 4, 2025 · 0 comments

Comments

@dr3
Copy link

dr3 commented Feb 4, 2025

Is your feature request related to a problem? Please describe.

Now that Eslint 9 allows JS configs, you can use type safety around rules

You can currently access types via

import type graphqlPlugin from '@graphql-eslint/eslint-plugin';

type Groups = Partial<typeof graphqlPlugin['configs']>
type GraphQLRules = Partial<NonNullable<Groups[keyof Groups]>['rules']>;

const graphqlRules = {
  '@graphql-eslint/alphabetize': [
    'error',
    {
        selections: ['OperationDefinition']
    },
  ],
} satisfies GraphQLRules;

export default graphqlRules;

However this produces error

Type '{ selections: string[]; }' is missing the following properties from type '{ definitions: boolean; selections: string[]; variables: boolean; arguments: string[]; groups: string[]; }': definitions, variables, arguments, groupsts(2739)

Despite the docs implying that you don't need to set all arguments to the rule

Image

Describe the solution you'd like

Expose GraphQLRules as a export (to avoid the consumer having to dig for it), and correctly type optional fields

Describe alternatives you've considered

Additional context

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

1 participant