Linter rulesGraphQLno-type-suffix

no-type-suffix

Since 0.9.0

This rule checks that type names don’t end with a redundant suffix such as Type or Enum.

Rule Details

The kind of a type is already part of its definition and of introspection; UserType or KindEnum only make names longer. By default the suffixes are Type, Object, Interface, Union, Enum, Scalar and Input; Input is allowed on input object types (see input-type-suffix).

Configuration

The configuration block is an object with the suffixes property, the list of suffixes that are reported.

version: "1.0"
commands:
  lint:
    graphql:
      rules:
        no-type-suffix: [error, { suffixes: [Type, Model] }]

The rule can be disabled for a node and everything nested in it with an # apigenie-lint-disable no-type-suffix comment on the node, or for a whole file with the comment at the top of the file, separated from the first definition by a blank line. It applies to definitions.

Examples

Good.

type User { id: ID! }
enum Kind { CAT }

Bad. The linter reports Object type 'UserType' should not end with 'Type'.

type UserType { id: ID! }

Related rules