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

Improve linting for graphql #83

Closed
tobiasdiez opened this issue May 1, 2021 · 2 comments · Fixed by #166 or #1428
Closed

Improve linting for graphql #83

tobiasdiez opened this issue May 1, 2021 · 2 comments · Fixed by #166 or #1428
Labels
p2: nice to have Nice to have feature/enhancement but not very important type: developer experience

Comments

@tobiasdiez
Copy link
Member

tobiasdiez commented May 1, 2021

https://github.com/apollographql/eslint-plugin-graphql
https://github.com/cjoudrey/graphql-schema-linter

Require all operations to be named.

@tobiasdiez tobiasdiez added the p2: nice to have Nice to have feature/enhancement but not very important label May 17, 2021
@tobiasdiez
Copy link
Member Author

@tobiasdiez
Copy link
Member Author

ToDos:

  • Also lint vue files: Support extracting GraphQL documents from vue/svelte files dimaMachina/graphql-eslint#480
  • Todos in the code
    // Make sure to not prefix id names with typename, i.e. 'id' instead of 'userId'.
    '@graphql-eslint/avoid-typename-prefix': 'error',
    // Requires all types to be reachable at some level by root level fields.
    '@graphql-eslint/no-unreachable-types': 'error',
    // Enforces that deprecated fields or enum values are not in use by operations.
    // TODO: Set this to error once we follow this convention
    '@graphql-eslint/no-deprecated': 'warn',
    // Enforces unique fragment name.
    '@graphql-eslint/unique-fragment-name': 'error',
    // Enforces unique operation names.
    // TODO: Does not work yet
    // '@graphql-eslint/unique-operation-name': 'error',
    // Requires to use """ or " for adding a GraphQL description instead of #.
    // TODO: Does not work yet, so set to warn
    '@graphql-eslint/no-hashtag-description': 'warn',
    // Requires sname for your GraphQL operations.
    '@graphql-eslint/no-anonymous-operations': 'error',
    // Make sure to not add the operation type to the name of the operation, e.g. 'user' instead of 'userQuery'.
    '@graphql-eslint/no-operation-name-suffix': 'error',
    // Requires all deprecation directives to specify a reason
    '@graphql-eslint/require-deprecation-reason': ['error'],
    // Enforces descriptions in your type definitions
    '@graphql-eslint/require-description': [
    'warn',
    { on: ['ObjectTypeDefinition', 'FieldDefinition'] },
    ],
    // Checks for duplicate fields in selection set, variables in operation definition, or in arguments set of a field.
    '@graphql-eslint/avoid-duplicate-fields': ['error'],
    // Requires mutation argument to be always called "input" and input type to be called Mutation name + "Input".
    // TODO: Set this to error once we follow this convention
    '@graphql-eslint/input-name': ['warn', { checkInputType: true }],

@tobiasdiez tobiasdiez reopened this Jul 1, 2021
@tobiasdiez tobiasdiez changed the title Add linting for graphql Improve linting for graphql Jul 1, 2021
tobiasdiez added a commit that referenced this issue Sep 18, 2022
Fixes #83 by activating all recommended graphql eslint rules.
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
p2: nice to have Nice to have feature/enhancement but not very important type: developer experience
Projects
None yet
1 participant