Linter rules
Naming Convention
These rules enforce naming conventions.
FIELD_NAMES_SHOULD_BE_CAMEL_CASE
Field names should always use camelCase.
type User {
First_Name: String
}
Correct:
type User {
firstName: String
}
TYPE_NAMES_SHOULD_BE_PASCAL_CASE
Type names should always use PascalCase.
type userProject {
id: ID!
}
type UserProject {
id: ID!
}
SHOULD_NOT_HAVE_TYPE_PREFIX
A type's name should never be prefixed with 'Type'.
type TypeUser {
id: ID!
}
type User {
id: ID!
}
SHOULD_NOT_HAVE_TYPE_SUFFIX
A type's name should never be suffixed with 'Type'.
type UserType {
id: ID!
}
type User {
id: ID!
}
SHOULD_NOT_HAVE_INPUT_PREFIX
An input's name should never be prefixed with 'Input'.
input InputUser {
id: ID!
}
input UserInput {
id: ID!
}
SHOULD_HAVE_INPUT_SUFFIX
An input's name should always be suffixed with 'Input'.
input User {
id: ID!
}
input UserInput {
id: ID!
}
SHOULD_NOT_HAVE_ENUM_PREFIX
An enum's name should never be prefixed with 'Enum'.
enum EnumUserStatus {
ADMIN
USER
}
enum UserStatus {
ADMIN
USER
}
SHOULD_NOT_HAVE_ENUM_SUFFIX
An enum's name should never be suffixed with 'Enum'.
enum UserStatusEnum {
ADMIN
USER
}
enum UserStatus {
ADMIN
USER
}
SHOULD_NOT_HAVE_INTERFACE_PREFIX
An interface type's name should never be prefixed with 'Interface'.
interface InterfaceUser {
id: ID!
}
interface User {
id: ID!
}
SHOULD_NOT_HAVE_INTERFACE_SUFFIX
An interface type's name should never be suffixed with 'Interface'.
interface UserInterface {
id: ID!
}
interface User {
id: ID!
}
ENUM_VALUES_SHOULD_BE_UPPER_CASE
Enum values should always use UPPER_CASE.
enum UserRole {
admin
user
}
enum UserRole {
ADMIN
USER
}
Alphabetical Sort
These rules enforce the arrangement of types, fields and so on in the schema.
ORDER_FIELDS
Ensures all fields are sorted in alphabetical order.
type User {
lastName: String
firstName: String
}
type User {
firstName: String
lastName: String
}
ORDER_ENUM_VALUES
Ensures all enum values are sorted in alphabetical order.
enum UserRole {
USER
ADMIN
}
enum UserRole {
ADMIN
USER
}
ORDER_DEFINITIONS
Ensures all definitions are sorted in alphabetical order.
Violation:
type User{
id: ID;
name: String;
}
type Member {
id: ID;
name: String;
}
Correct:
type Member {
id: ID;
name: String;
}
type User{
id: ID;
name: String;
}
Others
ALL_TYPES_REQUIRE_DESCRIPTION
Ensures all type definitions are accompanied by a description.
The types include:-
ObjectTypeDefinition
InterfaceTypeDefinition
EnumTypeDefinition
ScalarTypeDefinition
InputObjectTypeDefinition
UnionTypeDefinition
type User {
id: ID!
}
interface Member {
id: ID!
}
# Represents a user in the system
type User {
id: ID!
}
# Represents a member in the system
interface Member {
id: ID!
}
DISALLOW_CASE_INSENSITIVE_ENUM_VALUES
Ensures enum values eliminate duplicates by disallowing case insensitivity.
enum UserRole {
ADMIN
admin
}
enum UserRole {
ADMIN
}
NO_TYPENAME_PREFIX_IN_TYPE_FIELDS
Ensures field names do not include their type's name as a prefix.
type User {
userId: ID!
}
type User {
id: ID!
}
Last updated