naming-convention
Require names to follow specified conventions.
✅ The "extends": "plugin:@graphql-eslint/schema-recommended" and
"plugin:@graphql-eslint/operations-recommended" property in a configuration file enables this
rule.
💡 This rule provides suggestions
- Category:
Schema & Operations - Rule name:
@graphql-eslint/naming-convention - Requires GraphQL Schema:
falseℹ️ - Requires GraphQL Operations:
falseℹ️
Require names to follow specified conventions.
Usage Examples
Incorrect
Incorrect
Incorrect
Correct
Correct
Correct
Correct
Correct
Correct
Correct (Relay fragment convention <module_name>_<property_name>)
Config Schema
It’s possible to use a
selectorthat starts with allowedASTNodenames which are described below.Paste or drop code into the editor in ASTExplorer and inspect the generated AST to compose your selector.
Example: pattern property
FieldDefinition[parent.name.value=Query]will match only fields for typeQuery.
The schema defines the following properties:
types
Includes:
ObjectTypeDefinitionInterfaceTypeDefinitionEnumTypeDefinitionScalarTypeDefinitionInputObjectTypeDefinitionUnionTypeDefinition
The object must be one of the following types:
asStringasObject
Argument
[!NOTE]
Read more about this kind on spec.graphql.org.
The object must be one of the following types:
asStringasObject
DirectiveDefinition
[!NOTE]
Read more about this kind on spec.graphql.org.
The object must be one of the following types:
asStringasObject
EnumTypeDefinition
[!NOTE]
Read more about this kind on spec.graphql.org.
The object must be one of the following types:
asStringasObject
EnumValueDefinition
[!NOTE]
Read more about this kind on spec.graphql.org.
The object must be one of the following types:
asStringasObject
FieldDefinition
[!NOTE]
Read more about this kind on spec.graphql.org.
The object must be one of the following types:
asStringasObject
FragmentDefinition
[!NOTE]
Read more about this kind on spec.graphql.org.
The object must be one of the following types:
asStringasObject
InputObjectTypeDefinition
[!NOTE]
Read more about this kind on spec.graphql.org.
The object must be one of the following types:
asStringasObject
InputValueDefinition
[!NOTE]
Read more about this kind on spec.graphql.org.
The object must be one of the following types:
asStringasObject
InterfaceTypeDefinition
[!NOTE]
Read more about this kind on spec.graphql.org.
The object must be one of the following types:
asStringasObject
ObjectTypeDefinition
[!NOTE]
Read more about this kind on spec.graphql.org.
The object must be one of the following types:
asStringasObject
OperationDefinition
[!NOTE]
Read more about this kind on spec.graphql.org.
The object must be one of the following types:
asStringasObject
ScalarTypeDefinition
[!NOTE]
Read more about this kind on spec.graphql.org.
The object must be one of the following types:
asStringasObject
UnionTypeDefinition
[!NOTE]
Read more about this kind on spec.graphql.org.
The object must be one of the following types:
asStringasObject
VariableDefinition
[!NOTE]
Read more about this kind on spec.graphql.org.
The object must be one of the following types:
asStringasObject
allowLeadingUnderscore (boolean)
Default: false
allowTrailingUnderscore (boolean)
Default: false
Sub Schemas
The schema defines the following additional types:
asString (enum)
One of: camelCase, PascalCase, snake_case, UPPER_CASE
asObject (object)
Properties of the asObject object:
style (enum)
One of: camelCase, PascalCase, snake_case, UPPER_CASE
This element must be one of the following enum values:
camelCasePascalCasesnake_caseUPPER_CASE
prefix (string)
suffix (string)
forbiddenPatterns (array)
Should be of instance of RegEx
The object is an array with all elements of the type object.
The array object has the following properties:
Additional restrictions:
- Minimum items:
1 - Unique items:
true
requiredPattern (object)
Should be of instance of RegEx
forbiddenPrefixes (array)
[!WARNING]
This option is deprecated and will be removed in the next major release. Use
forbiddenPatternsinstead.
The object is an array with all elements of the type string.
Additional restrictions:
- Minimum items:
1 - Unique items:
true
forbiddenSuffixes (array)
[!WARNING]
This option is deprecated and will be removed in the next major release. Use
forbiddenPatternsinstead.
The object is an array with all elements of the type string.
Additional restrictions:
- Minimum items:
1 - Unique items:
true
requiredPrefixes (array)
[!WARNING]
This option is deprecated and will be removed in the next major release. Use
requiredPatterninstead.
The object is an array with all elements of the type string.
Additional restrictions:
- Minimum items:
1 - Unique items:
true
requiredSuffixes (array)
[!WARNING]
This option is deprecated and will be removed in the next major release. Use
requiredPatterninstead.
The object is an array with all elements of the type string.
Additional restrictions:
- Minimum items:
1 - Unique items:
true
ignorePattern (string)
Option to skip validation of some words, e.g. acronyms