@graphql-eslint/eslint-plugin 3.14.0-alpha-20221221142641-4e1a924 → 3.14.0-alpha-20221222012949-5caade4
Sign up to get free protection for your applications and to get access to all the features.
- package/README.md +309 -0
- package/cjs/cache.js +30 -0
- package/cjs/configs/base.js +7 -0
- package/cjs/configs/index.js +16 -0
- package/cjs/configs/operations-all.js +31 -0
- package/cjs/configs/operations-recommended.js +56 -0
- package/cjs/configs/relay.js +12 -0
- package/cjs/configs/schema-all.js +23 -0
- package/cjs/configs/schema-recommended.js +52 -0
- package/cjs/documents.js +149 -0
- package/cjs/estree-converter/converter.js +62 -0
- package/cjs/estree-converter/index.js +6 -0
- package/cjs/estree-converter/types.js +2 -0
- package/cjs/estree-converter/utils.js +109 -0
- package/cjs/graphql-config.js +55 -0
- package/cjs/index.js +17 -0
- package/cjs/parser.js +61 -0
- package/cjs/processor.js +78 -0
- package/cjs/rules/alphabetize.js +348 -0
- package/cjs/rules/description-style.js +78 -0
- package/cjs/rules/graphql-js-validation.js +499 -0
- package/cjs/rules/index.js +68 -0
- package/cjs/rules/input-name.js +136 -0
- package/cjs/rules/lone-executable-definition.js +88 -0
- package/cjs/rules/match-document-filename.js +235 -0
- package/cjs/rules/naming-convention.js +310 -0
- package/cjs/rules/no-anonymous-operations.js +67 -0
- package/cjs/rules/no-case-insensitive-enum-values-duplicates.js +61 -0
- package/cjs/rules/no-deprecated.js +124 -0
- package/cjs/rules/no-duplicate-fields.js +112 -0
- package/cjs/rules/no-hashtag-description.js +89 -0
- package/cjs/rules/no-root-type.js +86 -0
- package/cjs/rules/no-scalar-result-type-on-mutation.js +66 -0
- package/cjs/rules/no-typename-prefix.js +65 -0
- package/cjs/rules/no-unreachable-types.js +158 -0
- package/cjs/rules/no-unused-fields.js +130 -0
- package/cjs/rules/relay-arguments.js +121 -0
- package/cjs/rules/relay-connection-types.js +107 -0
- package/cjs/rules/relay-edge-types.js +189 -0
- package/cjs/rules/relay-page-info.js +100 -0
- package/cjs/rules/require-deprecation-date.js +123 -0
- package/cjs/rules/require-deprecation-reason.js +56 -0
- package/cjs/rules/require-description.js +193 -0
- package/cjs/rules/require-field-of-type-query-in-mutation-result.js +72 -0
- package/cjs/rules/require-id-when-available.js +199 -0
- package/cjs/rules/selection-set-depth.js +135 -0
- package/cjs/rules/strict-id-in-types.js +162 -0
- package/cjs/rules/unique-fragment-name.js +90 -0
- package/cjs/rules/unique-operation-name.js +65 -0
- package/cjs/schema.js +42 -0
- package/cjs/testkit.js +183 -0
- package/cjs/types.js +2 -0
- package/cjs/utils.js +96 -0
- package/docs/README.md +82 -0
- package/docs/custom-rules.md +184 -0
- package/docs/deprecated-rules.md +24 -0
- package/docs/parser-options.md +95 -0
- package/docs/parser.md +67 -0
- package/docs/rules/alphabetize.md +194 -0
- package/docs/rules/description-style.md +57 -0
- package/docs/rules/executable-definitions.md +20 -0
- package/docs/rules/fields-on-correct-type.md +23 -0
- package/docs/rules/fragments-on-composite-type.md +20 -0
- package/docs/rules/input-name.md +80 -0
- package/docs/rules/known-argument-names.md +23 -0
- package/docs/rules/known-directives.md +48 -0
- package/docs/rules/known-fragment-names.md +72 -0
- package/docs/rules/known-type-names.md +24 -0
- package/docs/rules/lone-anonymous-operation.md +20 -0
- package/docs/rules/lone-executable-definition.md +59 -0
- package/docs/rules/lone-schema-definition.md +19 -0
- package/docs/rules/match-document-filename.md +181 -0
- package/docs/rules/naming-convention.md +320 -0
- package/docs/rules/no-anonymous-operations.md +43 -0
- package/docs/rules/no-case-insensitive-enum-values-duplicates.md +46 -0
- package/docs/rules/no-deprecated.md +88 -0
- package/docs/rules/no-duplicate-fields.md +69 -0
- package/docs/rules/no-fragment-cycles.md +19 -0
- package/docs/rules/no-hashtag-description.md +62 -0
- package/docs/rules/no-root-type.md +55 -0
- package/docs/rules/no-scalar-result-type-on-mutation.md +39 -0
- package/docs/rules/no-typename-prefix.md +42 -0
- package/docs/rules/no-undefined-variables.md +20 -0
- package/docs/rules/no-unreachable-types.md +52 -0
- package/docs/rules/no-unused-fields.md +64 -0
- package/docs/rules/no-unused-fragments.md +20 -0
- package/docs/rules/no-unused-variables.md +20 -0
- package/docs/rules/one-field-subscriptions.md +19 -0
- package/docs/rules/overlapping-fields-can-be-merged.md +20 -0
- package/docs/rules/possible-fragment-spread.md +21 -0
- package/docs/rules/possible-type-extension.md +19 -0
- package/docs/rules/provided-required-arguments.md +21 -0
- package/docs/rules/relay-arguments.md +59 -0
- package/docs/rules/relay-connection-types.md +43 -0
- package/docs/rules/relay-edge-types.md +60 -0
- package/docs/rules/relay-page-info.md +34 -0
- package/docs/rules/require-deprecation-date.md +59 -0
- package/docs/rules/require-deprecation-reason.md +49 -0
- package/docs/rules/require-description.md +147 -0
- package/docs/rules/require-field-of-type-query-in-mutation-result.md +50 -0
- package/docs/rules/require-id-when-available.md +91 -0
- package/docs/rules/scalar-leafs.md +23 -0
- package/docs/rules/selection-set-depth.md +86 -0
- package/docs/rules/strict-id-in-types.md +129 -0
- package/docs/rules/unique-argument-names.md +19 -0
- package/docs/rules/unique-directive-names-per-location.md +21 -0
- package/docs/rules/unique-directive-names.md +19 -0
- package/docs/rules/unique-enum-value-names.md +16 -0
- package/docs/rules/unique-field-definition-names.md +19 -0
- package/docs/rules/unique-fragment-name.md +52 -0
- package/docs/rules/unique-input-field-names.md +19 -0
- package/docs/rules/unique-operation-name.md +56 -0
- package/docs/rules/unique-operation-types.md +19 -0
- package/docs/rules/unique-type-names.md +19 -0
- package/docs/rules/unique-variable-names.md +19 -0
- package/docs/rules/value-literals-of-correct-type.md +22 -0
- package/docs/rules/variables-are-input-types.md +20 -0
- package/docs/rules/variables-in-allowed-position.md +19 -0
- package/package.json +8 -11
- package/{cache.d.ts → typings/cache.d.cts} +0 -0
- package/typings/cache.d.ts +10 -0
- package/typings/configs/base.d.cts +5 -0
- package/typings/configs/base.d.ts +5 -0
- package/typings/configs/index.d.cts +139 -0
- package/typings/configs/index.d.ts +139 -0
- package/typings/configs/operations-all.d.cts +20 -0
- package/typings/configs/operations-all.d.ts +20 -0
- package/typings/configs/operations-recommended.d.cts +50 -0
- package/typings/configs/operations-recommended.d.ts +50 -0
- package/typings/configs/relay.d.cts +10 -0
- package/typings/configs/relay.d.ts +10 -0
- package/typings/configs/schema-all.d.cts +15 -0
- package/typings/configs/schema-all.d.ts +15 -0
- package/typings/configs/schema-recommended.d.cts +47 -0
- package/typings/configs/schema-recommended.d.ts +47 -0
- package/{documents.d.ts → typings/documents.d.cts} +0 -0
- package/typings/documents.d.ts +21 -0
- package/{estree-converter/converter.d.ts → typings/estree-converter/converter.d.cts} +0 -0
- package/typings/estree-converter/converter.d.ts +3 -0
- package/{estree-converter/index.d.ts → typings/estree-converter/index.d.cts} +0 -0
- package/typings/estree-converter/index.d.ts +3 -0
- package/{estree-converter/types.d.ts → typings/estree-converter/types.d.cts} +0 -0
- package/typings/estree-converter/types.d.ts +40 -0
- package/{estree-converter/utils.d.ts → typings/estree-converter/utils.d.cts} +0 -0
- package/typings/estree-converter/utils.d.ts +13 -0
- package/{graphql-config.d.ts → typings/graphql-config.d.cts} +0 -0
- package/typings/graphql-config.d.ts +4 -0
- package/typings/index.d.cts +9 -0
- package/{index.d.ts → typings/index.d.ts} +1 -5
- package/{parser.d.ts → typings/parser.d.cts} +0 -0
- package/typings/parser.d.ts +2 -0
- package/{processor.d.ts → typings/processor.d.cts} +0 -0
- package/typings/processor.d.ts +6 -0
- package/{rules/alphabetize.d.ts → typings/rules/alphabetize.d.cts} +0 -0
- package/typings/rules/alphabetize.d.ts +76 -0
- package/{rules/description-style.d.ts → typings/rules/description-style.d.cts} +0 -0
- package/typings/rules/description-style.d.ts +20 -0
- package/{rules/graphql-js-validation.d.ts → typings/rules/graphql-js-validation.d.cts} +0 -0
- package/typings/rules/graphql-js-validation.d.ts +2 -0
- package/{rules/index.d.ts → typings/rules/index.d.cts} +0 -0
- package/typings/rules/index.d.ts +104 -0
- package/{rules/input-name.d.ts → typings/rules/input-name.d.cts} +0 -0
- package/typings/rules/input-name.d.ts +35 -0
- package/{rules/lone-executable-definition.d.ts → typings/rules/lone-executable-definition.d.cts} +0 -0
- package/typings/rules/lone-executable-definition.d.ts +26 -0
- package/{rules/match-document-filename.d.ts → typings/rules/match-document-filename.d.cts} +0 -0
- package/typings/rules/match-document-filename.d.ts +72 -0
- package/{rules/naming-convention.d.ts → typings/rules/naming-convention.d.cts} +0 -0
- package/typings/rules/naming-convention.d.ts +83 -0
- package/{rules/no-anonymous-operations.d.ts → typings/rules/no-anonymous-operations.d.cts} +0 -0
- package/{rules/no-case-insensitive-enum-values-duplicates.d.ts → typings/rules/no-anonymous-operations.d.ts} +0 -0
- package/{rules/no-hashtag-description.d.ts → typings/rules/no-case-insensitive-enum-values-duplicates.d.cts} +0 -0
- package/{rules/no-scalar-result-type-on-mutation.d.ts → typings/rules/no-case-insensitive-enum-values-duplicates.d.ts} +0 -0
- package/{rules/no-deprecated.d.ts → typings/rules/no-deprecated.d.cts} +0 -0
- package/typings/rules/no-deprecated.d.ts +2 -0
- package/{rules/no-duplicate-fields.d.ts → typings/rules/no-duplicate-fields.d.cts} +0 -0
- package/{rules/relay-page-info.d.ts → typings/rules/no-duplicate-fields.d.ts} +0 -0
- package/{rules/no-typename-prefix.d.ts → typings/rules/no-hashtag-description.d.cts} +0 -0
- package/{rules/no-unreachable-types.d.ts → typings/rules/no-hashtag-description.d.ts} +0 -0
- package/{rules/no-root-type.d.ts → typings/rules/no-root-type.d.cts} +0 -0
- package/typings/rules/no-root-type.d.ts +25 -0
- package/{rules/no-unused-fields.d.ts → typings/rules/no-scalar-result-type-on-mutation.d.cts} +0 -0
- package/{rules/unique-operation-name.d.ts → typings/rules/no-scalar-result-type-on-mutation.d.ts} +0 -0
- package/typings/rules/no-typename-prefix.d.cts +2 -0
- package/typings/rules/no-typename-prefix.d.ts +2 -0
- package/typings/rules/no-unreachable-types.d.cts +2 -0
- package/typings/rules/no-unreachable-types.d.ts +2 -0
- package/typings/rules/no-unused-fields.d.cts +2 -0
- package/typings/rules/no-unused-fields.d.ts +2 -0
- package/{rules/relay-arguments.d.ts → typings/rules/relay-arguments.d.cts} +0 -0
- package/typings/rules/relay-arguments.d.ts +21 -0
- package/{rules/relay-connection-types.d.ts → typings/rules/relay-connection-types.d.cts} +0 -0
- package/typings/rules/relay-connection-types.d.ts +4 -0
- package/{rules/relay-edge-types.d.ts → typings/rules/relay-edge-types.d.cts} +0 -0
- package/typings/rules/relay-edge-types.d.ts +31 -0
- package/{rules/require-deprecation-reason.d.ts → typings/rules/relay-page-info.d.cts} +0 -0
- package/{rules/require-field-of-type-query-in-mutation-result.d.ts → typings/rules/relay-page-info.d.ts} +0 -0
- package/{rules/require-deprecation-date.d.ts → typings/rules/require-deprecation-date.d.cts} +0 -0
- package/typings/rules/require-deprecation-date.d.ts +18 -0
- package/typings/rules/require-deprecation-reason.d.cts +2 -0
- package/typings/rules/require-deprecation-reason.d.ts +2 -0
- package/{rules/require-description.d.ts → typings/rules/require-description.d.cts} +0 -0
- package/typings/rules/require-description.d.ts +14 -0
- package/typings/rules/require-field-of-type-query-in-mutation-result.d.cts +2 -0
- package/typings/rules/require-field-of-type-query-in-mutation-result.d.ts +2 -0
- package/{rules/require-id-when-available.d.ts → typings/rules/require-id-when-available.d.cts} +0 -0
- package/typings/rules/require-id-when-available.d.ts +36 -0
- package/{rules/selection-set-depth.d.ts → typings/rules/selection-set-depth.d.cts} +0 -0
- package/typings/rules/selection-set-depth.d.ts +28 -0
- package/{rules/strict-id-in-types.d.ts → typings/rules/strict-id-in-types.d.cts} +0 -0
- package/typings/rules/strict-id-in-types.d.ts +57 -0
- package/{rules/unique-fragment-name.d.ts → typings/rules/unique-fragment-name.d.cts} +0 -0
- package/typings/rules/unique-fragment-name.d.ts +5 -0
- package/typings/rules/unique-operation-name.d.cts +2 -0
- package/typings/rules/unique-operation-name.d.ts +2 -0
- package/{schema.d.ts → typings/schema.d.cts} +0 -0
- package/typings/schema.d.ts +3 -0
- package/{testkit.d.ts → typings/testkit.d.cts} +0 -0
- package/typings/testkit.d.ts +27 -0
- package/{types.d.ts → typings/types.d.cts} +0 -0
- package/typings/types.d.ts +81 -0
- package/{utils.d.ts → typings/utils.d.cts} +0 -0
- package/typings/utils.d.ts +34 -0
- package/configs/base.json +0 -4
- package/configs/operations-all.json +0 -25
- package/configs/operations-recommended.json +0 -50
- package/configs/relay.json +0 -9
- package/configs/schema-all.json +0 -17
- package/configs/schema-recommended.json +0 -49
- package/index.js +0 -4995
- package/index.mjs +0 -4983
@@ -0,0 +1,320 @@
|
|
1
|
+
# `naming-convention`
|
2
|
+
|
3
|
+
✅ The `"extends": "plugin:@graphql-eslint/schema-recommended"` and
|
4
|
+
`"plugin:@graphql-eslint/operations-recommended"` property in a configuration file enables this
|
5
|
+
rule.
|
6
|
+
|
7
|
+
💡 This rule provides
|
8
|
+
[suggestions](https://eslint.org/docs/developer-guide/working-with-rules#providing-suggestions)
|
9
|
+
|
10
|
+
- Category: `Schema & Operations`
|
11
|
+
- Rule name: `@graphql-eslint/naming-convention`
|
12
|
+
- Requires GraphQL Schema: `false` [ℹ️](../../README.md#extended-linting-rules-with-graphql-schema)
|
13
|
+
- Requires GraphQL Operations: `false`
|
14
|
+
[ℹ️](../../README.md#extended-linting-rules-with-siblings-operations)
|
15
|
+
|
16
|
+
Require names to follow specified conventions.
|
17
|
+
|
18
|
+
## Usage Examples
|
19
|
+
|
20
|
+
### Incorrect
|
21
|
+
|
22
|
+
```graphql
|
23
|
+
# eslint @graphql-eslint/naming-convention: ['error', { types: 'PascalCase', FieldDefinition: 'camelCase' }]
|
24
|
+
|
25
|
+
type user {
|
26
|
+
first_name: String!
|
27
|
+
}
|
28
|
+
```
|
29
|
+
|
30
|
+
### Incorrect
|
31
|
+
|
32
|
+
```graphql
|
33
|
+
# eslint @graphql-eslint/naming-convention: ['error', { FragmentDefinition: { style: 'PascalCase', forbiddenSuffixes: ['Fragment'] } }]
|
34
|
+
|
35
|
+
fragment UserFragment on User {
|
36
|
+
# ...
|
37
|
+
}
|
38
|
+
```
|
39
|
+
|
40
|
+
### Incorrect
|
41
|
+
|
42
|
+
```graphql
|
43
|
+
# eslint @graphql-eslint/naming-convention: ['error', { 'FieldDefinition[parent.name.value=Query]': { forbiddenPrefixes: ['get'] } }]
|
44
|
+
|
45
|
+
type Query {
|
46
|
+
getUsers: [User!]!
|
47
|
+
}
|
48
|
+
```
|
49
|
+
|
50
|
+
### Correct
|
51
|
+
|
52
|
+
```graphql
|
53
|
+
# eslint @graphql-eslint/naming-convention: ['error', { types: 'PascalCase', FieldDefinition: 'camelCase' }]
|
54
|
+
|
55
|
+
type User {
|
56
|
+
firstName: String
|
57
|
+
}
|
58
|
+
```
|
59
|
+
|
60
|
+
### Correct
|
61
|
+
|
62
|
+
```graphql
|
63
|
+
# eslint @graphql-eslint/naming-convention: ['error', { FragmentDefinition: { style: 'PascalCase', forbiddenSuffixes: ['Fragment'] } }]
|
64
|
+
|
65
|
+
fragment UserFields on User {
|
66
|
+
# ...
|
67
|
+
}
|
68
|
+
```
|
69
|
+
|
70
|
+
### Correct
|
71
|
+
|
72
|
+
```graphql
|
73
|
+
# eslint @graphql-eslint/naming-convention: ['error', { 'FieldDefinition[parent.name.value=Query]': { forbiddenPrefixes: ['get'] } }]
|
74
|
+
|
75
|
+
type Query {
|
76
|
+
users: [User!]!
|
77
|
+
}
|
78
|
+
```
|
79
|
+
|
80
|
+
### Correct
|
81
|
+
|
82
|
+
```graphql
|
83
|
+
# eslint @graphql-eslint/naming-convention: ['error', { FieldDefinition: { style: 'camelCase', ignorePattern: '^(EAN13|UPC|UK)' } }]
|
84
|
+
|
85
|
+
type Product {
|
86
|
+
EAN13: String
|
87
|
+
UPC: String
|
88
|
+
UKFlag: String
|
89
|
+
}
|
90
|
+
```
|
91
|
+
|
92
|
+
## Config Schema
|
93
|
+
|
94
|
+
> It's possible to use a [`selector`](https://eslint.org/docs/developer-guide/selectors) that starts
|
95
|
+
> with allowed `ASTNode` names which are described below.
|
96
|
+
>
|
97
|
+
> Paste or drop code into the editor in [ASTExplorer](https://astexplorer.net) and inspect the
|
98
|
+
> generated AST to compose your selector.
|
99
|
+
>
|
100
|
+
> Example: pattern property `FieldDefinition[parent.name.value=Query]` will match only fields for
|
101
|
+
> type `Query`.
|
102
|
+
|
103
|
+
The schema defines the following properties:
|
104
|
+
|
105
|
+
### `types`
|
106
|
+
|
107
|
+
Includes:
|
108
|
+
|
109
|
+
- `ObjectTypeDefinition`
|
110
|
+
- `InterfaceTypeDefinition`
|
111
|
+
- `EnumTypeDefinition`
|
112
|
+
- `ScalarTypeDefinition`
|
113
|
+
- `InputObjectTypeDefinition`
|
114
|
+
- `UnionTypeDefinition`
|
115
|
+
|
116
|
+
The object must be one of the following types:
|
117
|
+
|
118
|
+
- `asString`
|
119
|
+
- `asObject`
|
120
|
+
|
121
|
+
### `Argument`
|
122
|
+
|
123
|
+
Read more about this kind on [spec.graphql.org](https://spec.graphql.org/October2021/#Argument).
|
124
|
+
|
125
|
+
The object must be one of the following types:
|
126
|
+
|
127
|
+
- `asString`
|
128
|
+
- `asObject`
|
129
|
+
|
130
|
+
### `DirectiveDefinition`
|
131
|
+
|
132
|
+
Read more about this kind on
|
133
|
+
[spec.graphql.org](https://spec.graphql.org/October2021/#DirectiveDefinition).
|
134
|
+
|
135
|
+
The object must be one of the following types:
|
136
|
+
|
137
|
+
- `asString`
|
138
|
+
- `asObject`
|
139
|
+
|
140
|
+
### `EnumTypeDefinition`
|
141
|
+
|
142
|
+
Read more about this kind on
|
143
|
+
[spec.graphql.org](https://spec.graphql.org/October2021/#EnumTypeDefinition).
|
144
|
+
|
145
|
+
The object must be one of the following types:
|
146
|
+
|
147
|
+
- `asString`
|
148
|
+
- `asObject`
|
149
|
+
|
150
|
+
### `EnumValueDefinition`
|
151
|
+
|
152
|
+
Read more about this kind on
|
153
|
+
[spec.graphql.org](https://spec.graphql.org/October2021/#EnumValueDefinition).
|
154
|
+
|
155
|
+
The object must be one of the following types:
|
156
|
+
|
157
|
+
- `asString`
|
158
|
+
- `asObject`
|
159
|
+
|
160
|
+
### `FieldDefinition`
|
161
|
+
|
162
|
+
Read more about this kind on
|
163
|
+
[spec.graphql.org](https://spec.graphql.org/October2021/#FieldDefinition).
|
164
|
+
|
165
|
+
The object must be one of the following types:
|
166
|
+
|
167
|
+
- `asString`
|
168
|
+
- `asObject`
|
169
|
+
|
170
|
+
### `FragmentDefinition`
|
171
|
+
|
172
|
+
Read more about this kind on
|
173
|
+
[spec.graphql.org](https://spec.graphql.org/October2021/#FragmentDefinition).
|
174
|
+
|
175
|
+
The object must be one of the following types:
|
176
|
+
|
177
|
+
- `asString`
|
178
|
+
- `asObject`
|
179
|
+
|
180
|
+
### `InputObjectTypeDefinition`
|
181
|
+
|
182
|
+
Read more about this kind on
|
183
|
+
[spec.graphql.org](https://spec.graphql.org/October2021/#InputObjectTypeDefinition).
|
184
|
+
|
185
|
+
The object must be one of the following types:
|
186
|
+
|
187
|
+
- `asString`
|
188
|
+
- `asObject`
|
189
|
+
|
190
|
+
### `InputValueDefinition`
|
191
|
+
|
192
|
+
Read more about this kind on
|
193
|
+
[spec.graphql.org](https://spec.graphql.org/October2021/#InputValueDefinition).
|
194
|
+
|
195
|
+
The object must be one of the following types:
|
196
|
+
|
197
|
+
- `asString`
|
198
|
+
- `asObject`
|
199
|
+
|
200
|
+
### `InterfaceTypeDefinition`
|
201
|
+
|
202
|
+
Read more about this kind on
|
203
|
+
[spec.graphql.org](https://spec.graphql.org/October2021/#InterfaceTypeDefinition).
|
204
|
+
|
205
|
+
The object must be one of the following types:
|
206
|
+
|
207
|
+
- `asString`
|
208
|
+
- `asObject`
|
209
|
+
|
210
|
+
### `ObjectTypeDefinition`
|
211
|
+
|
212
|
+
Read more about this kind on
|
213
|
+
[spec.graphql.org](https://spec.graphql.org/October2021/#ObjectTypeDefinition).
|
214
|
+
|
215
|
+
The object must be one of the following types:
|
216
|
+
|
217
|
+
- `asString`
|
218
|
+
- `asObject`
|
219
|
+
|
220
|
+
### `OperationDefinition`
|
221
|
+
|
222
|
+
Read more about this kind on
|
223
|
+
[spec.graphql.org](https://spec.graphql.org/October2021/#OperationDefinition).
|
224
|
+
|
225
|
+
The object must be one of the following types:
|
226
|
+
|
227
|
+
- `asString`
|
228
|
+
- `asObject`
|
229
|
+
|
230
|
+
### `ScalarTypeDefinition`
|
231
|
+
|
232
|
+
Read more about this kind on
|
233
|
+
[spec.graphql.org](https://spec.graphql.org/October2021/#ScalarTypeDefinition).
|
234
|
+
|
235
|
+
The object must be one of the following types:
|
236
|
+
|
237
|
+
- `asString`
|
238
|
+
- `asObject`
|
239
|
+
|
240
|
+
### `UnionTypeDefinition`
|
241
|
+
|
242
|
+
Read more about this kind on
|
243
|
+
[spec.graphql.org](https://spec.graphql.org/October2021/#UnionTypeDefinition).
|
244
|
+
|
245
|
+
The object must be one of the following types:
|
246
|
+
|
247
|
+
- `asString`
|
248
|
+
- `asObject`
|
249
|
+
|
250
|
+
### `VariableDefinition`
|
251
|
+
|
252
|
+
Read more about this kind on
|
253
|
+
[spec.graphql.org](https://spec.graphql.org/October2021/#VariableDefinition).
|
254
|
+
|
255
|
+
The object must be one of the following types:
|
256
|
+
|
257
|
+
- `asString`
|
258
|
+
- `asObject`
|
259
|
+
|
260
|
+
### `allowLeadingUnderscore` (boolean)
|
261
|
+
|
262
|
+
Default: `false`
|
263
|
+
|
264
|
+
### `allowTrailingUnderscore` (boolean)
|
265
|
+
|
266
|
+
Default: `false`
|
267
|
+
|
268
|
+
---
|
269
|
+
|
270
|
+
# Sub Schemas
|
271
|
+
|
272
|
+
The schema defines the following additional types:
|
273
|
+
|
274
|
+
## `asString` (enum)
|
275
|
+
|
276
|
+
One of: `camelCase`, `PascalCase`, `snake_case`, `UPPER_CASE`
|
277
|
+
|
278
|
+
## `asObject` (object)
|
279
|
+
|
280
|
+
Properties of the `asObject` object:
|
281
|
+
|
282
|
+
### `style` (enum)
|
283
|
+
|
284
|
+
This element must be one of the following enum values:
|
285
|
+
|
286
|
+
- `camelCase`
|
287
|
+
- `PascalCase`
|
288
|
+
- `snake_case`
|
289
|
+
- `UPPER_CASE`
|
290
|
+
|
291
|
+
### `prefix` (string)
|
292
|
+
|
293
|
+
### `suffix` (string)
|
294
|
+
|
295
|
+
### `forbiddenPrefixes` (array)
|
296
|
+
|
297
|
+
The object is an array with all elements of the type `string`.
|
298
|
+
|
299
|
+
Additional restrictions:
|
300
|
+
|
301
|
+
- Minimum items: `1`
|
302
|
+
- Unique items: `true`
|
303
|
+
|
304
|
+
### `forbiddenSuffixes` (array)
|
305
|
+
|
306
|
+
The object is an array with all elements of the type `string`.
|
307
|
+
|
308
|
+
Additional restrictions:
|
309
|
+
|
310
|
+
- Minimum items: `1`
|
311
|
+
- Unique items: `true`
|
312
|
+
|
313
|
+
### `ignorePattern` (string)
|
314
|
+
|
315
|
+
Option to skip validation of some words, e.g. acronyms
|
316
|
+
|
317
|
+
## Resources
|
318
|
+
|
319
|
+
- [Rule source](../../packages/plugin/src/rules/naming-convention.ts)
|
320
|
+
- [Test source](../../packages/plugin/tests/naming-convention.spec.ts)
|
@@ -0,0 +1,43 @@
|
|
1
|
+
# `no-anonymous-operations`
|
2
|
+
|
3
|
+
✅ The `"extends": "plugin:@graphql-eslint/operations-recommended"` property in a configuration file
|
4
|
+
enables this rule.
|
5
|
+
|
6
|
+
💡 This rule provides
|
7
|
+
[suggestions](https://eslint.org/docs/developer-guide/working-with-rules#providing-suggestions)
|
8
|
+
|
9
|
+
- Category: `Operations`
|
10
|
+
- Rule name: `@graphql-eslint/no-anonymous-operations`
|
11
|
+
- Requires GraphQL Schema: `false` [ℹ️](../../README.md#extended-linting-rules-with-graphql-schema)
|
12
|
+
- Requires GraphQL Operations: `false`
|
13
|
+
[ℹ️](../../README.md#extended-linting-rules-with-siblings-operations)
|
14
|
+
|
15
|
+
Require name for your GraphQL operations. This is useful since most GraphQL client libraries are
|
16
|
+
using the operation name for caching purposes.
|
17
|
+
|
18
|
+
## Usage Examples
|
19
|
+
|
20
|
+
### Incorrect
|
21
|
+
|
22
|
+
```graphql
|
23
|
+
# eslint @graphql-eslint/no-anonymous-operations: 'error'
|
24
|
+
|
25
|
+
query {
|
26
|
+
# ...
|
27
|
+
}
|
28
|
+
```
|
29
|
+
|
30
|
+
### Correct
|
31
|
+
|
32
|
+
```graphql
|
33
|
+
# eslint @graphql-eslint/no-anonymous-operations: 'error'
|
34
|
+
|
35
|
+
query user {
|
36
|
+
# ...
|
37
|
+
}
|
38
|
+
```
|
39
|
+
|
40
|
+
## Resources
|
41
|
+
|
42
|
+
- [Rule source](../../packages/plugin/src/rules/no-anonymous-operations.ts)
|
43
|
+
- [Test source](../../packages/plugin/tests/no-anonymous-operations.spec.ts)
|
@@ -0,0 +1,46 @@
|
|
1
|
+
# `no-case-insensitive-enum-values-duplicates`
|
2
|
+
|
3
|
+
✅ The `"extends": "plugin:@graphql-eslint/schema-recommended"` property in a configuration file
|
4
|
+
enables this rule.
|
5
|
+
|
6
|
+
💡 This rule provides
|
7
|
+
[suggestions](https://eslint.org/docs/developer-guide/working-with-rules#providing-suggestions)
|
8
|
+
|
9
|
+
- Category: `Schema`
|
10
|
+
- Rule name: `@graphql-eslint/no-case-insensitive-enum-values-duplicates`
|
11
|
+
- Requires GraphQL Schema: `false` [ℹ️](../../README.md#extended-linting-rules-with-graphql-schema)
|
12
|
+
- Requires GraphQL Operations: `false`
|
13
|
+
[ℹ️](../../README.md#extended-linting-rules-with-siblings-operations)
|
14
|
+
|
15
|
+
Disallow case-insensitive enum values duplicates.
|
16
|
+
|
17
|
+
## Usage Examples
|
18
|
+
|
19
|
+
### Incorrect
|
20
|
+
|
21
|
+
```graphql
|
22
|
+
# eslint @graphql-eslint/no-case-insensitive-enum-values-duplicates: 'error'
|
23
|
+
|
24
|
+
enum MyEnum {
|
25
|
+
Value
|
26
|
+
VALUE
|
27
|
+
ValuE
|
28
|
+
}
|
29
|
+
```
|
30
|
+
|
31
|
+
### Correct
|
32
|
+
|
33
|
+
```graphql
|
34
|
+
# eslint @graphql-eslint/no-case-insensitive-enum-values-duplicates: 'error'
|
35
|
+
|
36
|
+
enum MyEnum {
|
37
|
+
Value1
|
38
|
+
Value2
|
39
|
+
Value3
|
40
|
+
}
|
41
|
+
```
|
42
|
+
|
43
|
+
## Resources
|
44
|
+
|
45
|
+
- [Rule source](../../packages/plugin/src/rules/no-case-insensitive-enum-values-duplicates.ts)
|
46
|
+
- [Test source](../../packages/plugin/tests/no-case-insensitive-enum-values-duplicates.spec.ts)
|
@@ -0,0 +1,88 @@
|
|
1
|
+
# `no-deprecated`
|
2
|
+
|
3
|
+
✅ The `"extends": "plugin:@graphql-eslint/operations-recommended"` property in a configuration file
|
4
|
+
enables this rule.
|
5
|
+
|
6
|
+
💡 This rule provides
|
7
|
+
[suggestions](https://eslint.org/docs/developer-guide/working-with-rules#providing-suggestions)
|
8
|
+
|
9
|
+
- Category: `Operations`
|
10
|
+
- Rule name: `@graphql-eslint/no-deprecated`
|
11
|
+
- Requires GraphQL Schema: `true` [ℹ️](../../README.md#extended-linting-rules-with-graphql-schema)
|
12
|
+
- Requires GraphQL Operations: `false`
|
13
|
+
[ℹ️](../../README.md#extended-linting-rules-with-siblings-operations)
|
14
|
+
|
15
|
+
Enforce that deprecated fields or enum values are not in use by operations.
|
16
|
+
|
17
|
+
## Usage Examples
|
18
|
+
|
19
|
+
### Incorrect (field)
|
20
|
+
|
21
|
+
```graphql
|
22
|
+
# eslint @graphql-eslint/no-deprecated: 'error'
|
23
|
+
|
24
|
+
# In your schema
|
25
|
+
type User {
|
26
|
+
id: ID!
|
27
|
+
name: String! @deprecated(reason: "old field, please use fullName instead")
|
28
|
+
fullName: String!
|
29
|
+
}
|
30
|
+
|
31
|
+
# Query
|
32
|
+
query user {
|
33
|
+
user {
|
34
|
+
name # This is deprecated, so you'll get an error
|
35
|
+
}
|
36
|
+
}
|
37
|
+
```
|
38
|
+
|
39
|
+
### Incorrect (enum value)
|
40
|
+
|
41
|
+
```graphql
|
42
|
+
# eslint @graphql-eslint/no-deprecated: 'error'
|
43
|
+
|
44
|
+
# In your schema
|
45
|
+
type Mutation {
|
46
|
+
changeSomething(type: SomeType): Boolean!
|
47
|
+
}
|
48
|
+
|
49
|
+
enum SomeType {
|
50
|
+
NEW
|
51
|
+
OLD @deprecated(reason: "old field, please use NEW instead")
|
52
|
+
}
|
53
|
+
|
54
|
+
# Mutation
|
55
|
+
mutation {
|
56
|
+
changeSomething(
|
57
|
+
type: OLD # This is deprecated, so you'll get an error
|
58
|
+
) {
|
59
|
+
...
|
60
|
+
}
|
61
|
+
}
|
62
|
+
```
|
63
|
+
|
64
|
+
### Correct
|
65
|
+
|
66
|
+
```graphql
|
67
|
+
# eslint @graphql-eslint/no-deprecated: 'error'
|
68
|
+
|
69
|
+
# In your schema
|
70
|
+
type User {
|
71
|
+
id: ID!
|
72
|
+
name: String! @deprecated(reason: "old field, please use fullName instead")
|
73
|
+
fullName: String!
|
74
|
+
}
|
75
|
+
|
76
|
+
# Query
|
77
|
+
query user {
|
78
|
+
user {
|
79
|
+
id
|
80
|
+
fullName
|
81
|
+
}
|
82
|
+
}
|
83
|
+
```
|
84
|
+
|
85
|
+
## Resources
|
86
|
+
|
87
|
+
- [Rule source](../../packages/plugin/src/rules/no-deprecated.ts)
|
88
|
+
- [Test source](../../packages/plugin/tests/no-deprecated.spec.ts)
|
@@ -0,0 +1,69 @@
|
|
1
|
+
# `no-duplicate-fields`
|
2
|
+
|
3
|
+
✅ The `"extends": "plugin:@graphql-eslint/operations-recommended"` property in a configuration file
|
4
|
+
enables this rule.
|
5
|
+
|
6
|
+
💡 This rule provides
|
7
|
+
[suggestions](https://eslint.org/docs/developer-guide/working-with-rules#providing-suggestions)
|
8
|
+
|
9
|
+
- Category: `Operations`
|
10
|
+
- Rule name: `@graphql-eslint/no-duplicate-fields`
|
11
|
+
- Requires GraphQL Schema: `false` [ℹ️](../../README.md#extended-linting-rules-with-graphql-schema)
|
12
|
+
- Requires GraphQL Operations: `false`
|
13
|
+
[ℹ️](../../README.md#extended-linting-rules-with-siblings-operations)
|
14
|
+
|
15
|
+
Checks for duplicate fields in selection set, variables in operation definition, or in arguments set
|
16
|
+
of a field.
|
17
|
+
|
18
|
+
## Usage Examples
|
19
|
+
|
20
|
+
### Incorrect
|
21
|
+
|
22
|
+
```graphql
|
23
|
+
# eslint @graphql-eslint/no-duplicate-fields: 'error'
|
24
|
+
|
25
|
+
query {
|
26
|
+
user {
|
27
|
+
name
|
28
|
+
email
|
29
|
+
name # duplicate field
|
30
|
+
}
|
31
|
+
}
|
32
|
+
```
|
33
|
+
|
34
|
+
### Incorrect
|
35
|
+
|
36
|
+
```graphql
|
37
|
+
# eslint @graphql-eslint/no-duplicate-fields: 'error'
|
38
|
+
|
39
|
+
query {
|
40
|
+
users(
|
41
|
+
first: 100
|
42
|
+
skip: 50
|
43
|
+
after: "cji629tngfgou0b73kt7vi5jo"
|
44
|
+
first: 100 # duplicate argument
|
45
|
+
) {
|
46
|
+
id
|
47
|
+
}
|
48
|
+
}
|
49
|
+
```
|
50
|
+
|
51
|
+
### Incorrect
|
52
|
+
|
53
|
+
```graphql
|
54
|
+
# eslint @graphql-eslint/no-duplicate-fields: 'error'
|
55
|
+
|
56
|
+
query (
|
57
|
+
$first: Int!
|
58
|
+
$first: Int! # duplicate variable
|
59
|
+
) {
|
60
|
+
users(first: $first, skip: 50) {
|
61
|
+
id
|
62
|
+
}
|
63
|
+
}
|
64
|
+
```
|
65
|
+
|
66
|
+
## Resources
|
67
|
+
|
68
|
+
- [Rule source](../../packages/plugin/src/rules/no-duplicate-fields.ts)
|
69
|
+
- [Test source](../../packages/plugin/tests/no-duplicate-fields.spec.ts)
|
@@ -0,0 +1,19 @@
|
|
1
|
+
# `no-fragment-cycles`
|
2
|
+
|
3
|
+
✅ The `"extends": "plugin:@graphql-eslint/operations-recommended"` property in a configuration file
|
4
|
+
enables this rule.
|
5
|
+
|
6
|
+
- Category: `Operations`
|
7
|
+
- Rule name: `@graphql-eslint/no-fragment-cycles`
|
8
|
+
- Requires GraphQL Schema: `true` [ℹ️](../../README.md#extended-linting-rules-with-graphql-schema)
|
9
|
+
- Requires GraphQL Operations: `false`
|
10
|
+
[ℹ️](../../README.md#extended-linting-rules-with-siblings-operations)
|
11
|
+
|
12
|
+
A GraphQL fragment is only valid when it does not have cycles in fragments usage.
|
13
|
+
|
14
|
+
> This rule is a wrapper around a `graphql-js` validation function.
|
15
|
+
|
16
|
+
## Resources
|
17
|
+
|
18
|
+
- [Rule source](https://github.com/graphql/graphql-js/blob/main/src/validation/rules/NoFragmentCyclesRule.ts)
|
19
|
+
- [Test source](https://github.com/graphql/graphql-js/tree/main/src/validation/__tests__/NoFragmentCyclesRule-test.ts)
|
@@ -0,0 +1,62 @@
|
|
1
|
+
# `no-hashtag-description`
|
2
|
+
|
3
|
+
✅ The `"extends": "plugin:@graphql-eslint/schema-recommended"` property in a configuration file
|
4
|
+
enables this rule.
|
5
|
+
|
6
|
+
💡 This rule provides
|
7
|
+
[suggestions](https://eslint.org/docs/developer-guide/working-with-rules#providing-suggestions)
|
8
|
+
|
9
|
+
- Category: `Schema`
|
10
|
+
- Rule name: `@graphql-eslint/no-hashtag-description`
|
11
|
+
- Requires GraphQL Schema: `false` [ℹ️](../../README.md#extended-linting-rules-with-graphql-schema)
|
12
|
+
- Requires GraphQL Operations: `false`
|
13
|
+
[ℹ️](../../README.md#extended-linting-rules-with-siblings-operations)
|
14
|
+
|
15
|
+
Requires to use `"""` or `"` for adding a GraphQL description instead of `#`. Allows to use hashtag
|
16
|
+
for comments, as long as it's not attached to an AST definition.
|
17
|
+
|
18
|
+
## Usage Examples
|
19
|
+
|
20
|
+
### Incorrect
|
21
|
+
|
22
|
+
```graphql
|
23
|
+
# eslint @graphql-eslint/no-hashtag-description: 'error'
|
24
|
+
|
25
|
+
# Represents a user
|
26
|
+
type User {
|
27
|
+
id: ID!
|
28
|
+
name: String
|
29
|
+
}
|
30
|
+
```
|
31
|
+
|
32
|
+
### Correct
|
33
|
+
|
34
|
+
```graphql
|
35
|
+
# eslint @graphql-eslint/no-hashtag-description: 'error'
|
36
|
+
|
37
|
+
" Represents a user "
|
38
|
+
type User {
|
39
|
+
id: ID!
|
40
|
+
name: String
|
41
|
+
}
|
42
|
+
```
|
43
|
+
|
44
|
+
### Correct
|
45
|
+
|
46
|
+
```graphql
|
47
|
+
# eslint @graphql-eslint/no-hashtag-description: 'error'
|
48
|
+
|
49
|
+
# This file defines the basic User type.
|
50
|
+
# This comment is valid because it's not attached specifically to an AST object.
|
51
|
+
|
52
|
+
" Represents a user "
|
53
|
+
type User {
|
54
|
+
id: ID! # This one is also valid, since it comes after the AST object
|
55
|
+
name: String
|
56
|
+
}
|
57
|
+
```
|
58
|
+
|
59
|
+
## Resources
|
60
|
+
|
61
|
+
- [Rule source](../../packages/plugin/src/rules/no-hashtag-description.ts)
|
62
|
+
- [Test source](../../packages/plugin/tests/no-hashtag-description.spec.ts)
|
@@ -0,0 +1,55 @@
|
|
1
|
+
# `no-root-type`
|
2
|
+
|
3
|
+
💡 This rule provides
|
4
|
+
[suggestions](https://eslint.org/docs/developer-guide/working-with-rules#providing-suggestions)
|
5
|
+
|
6
|
+
- Category: `Schema`
|
7
|
+
- Rule name: `@graphql-eslint/no-root-type`
|
8
|
+
- Requires GraphQL Schema: `true` [ℹ️](../../README.md#extended-linting-rules-with-graphql-schema)
|
9
|
+
- Requires GraphQL Operations: `false`
|
10
|
+
[ℹ️](../../README.md#extended-linting-rules-with-siblings-operations)
|
11
|
+
|
12
|
+
Disallow using root types `mutation` and/or `subscription`.
|
13
|
+
|
14
|
+
## Usage Examples
|
15
|
+
|
16
|
+
### Incorrect
|
17
|
+
|
18
|
+
```graphql
|
19
|
+
# eslint @graphql-eslint/no-root-type: ['error', { disallow: ['mutation', 'subscription'] }]
|
20
|
+
|
21
|
+
type Mutation {
|
22
|
+
createUser(input: CreateUserInput!): User!
|
23
|
+
}
|
24
|
+
```
|
25
|
+
|
26
|
+
### Correct
|
27
|
+
|
28
|
+
```graphql
|
29
|
+
# eslint @graphql-eslint/no-root-type: ['error', { disallow: ['mutation', 'subscription'] }]
|
30
|
+
|
31
|
+
type Query {
|
32
|
+
users: [User!]!
|
33
|
+
}
|
34
|
+
```
|
35
|
+
|
36
|
+
## Config Schema
|
37
|
+
|
38
|
+
The schema defines the following properties:
|
39
|
+
|
40
|
+
### `disallow` (array, required)
|
41
|
+
|
42
|
+
The elements of the array can contain the following enum values:
|
43
|
+
|
44
|
+
- `mutation`
|
45
|
+
- `subscription`
|
46
|
+
|
47
|
+
Additional restrictions:
|
48
|
+
|
49
|
+
- Minimum items: `1`
|
50
|
+
- Unique items: `true`
|
51
|
+
|
52
|
+
## Resources
|
53
|
+
|
54
|
+
- [Rule source](../../packages/plugin/src/rules/no-root-type.ts)
|
55
|
+
- [Test source](../../packages/plugin/tests/no-root-type.spec.ts)
|