no-type-suffix

Since 0.9.0 · In the rulesets: Strict at error, All at error

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).

The rule applies to definitions. An # apigenie-lint-disable no-type-suffix comment on a node turns it off for the node and everything nested in it; at the top of the file, separated from the first definition by a blank line, the comment turns it off for the whole file.

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] }]

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! }

Turn it off or change its severity

In apigenie.yaml, off turns the rule off and warning or error sets its severity; a rule with options takes the severity and the options as a pair, [warning, options]. lint.graphql has the details.

commands:
  lint:
    graphql:
      rules:
        no-type-suffix: off

Related rules

Last updated on View as Markdown
Was this helpful?