@graphql-eslint/eslint-plugin 3.14.4-alpha-20230111223410-a558ee8 → 3.14.4-alpha-20230111225020-02d9c28
Sign up to get free protection for your applications and to get access to all the features.
- package/README.md +5 -288
- package/cjs/documents.js +2 -105
- package/cjs/graphql-config.js +1 -1
- package/cjs/parser.js +9 -3
- package/cjs/rules/alphabetize.js +1 -1
- package/cjs/rules/description-style.js +1 -1
- package/cjs/rules/graphql-js-validation.js +1 -1
- package/cjs/rules/input-name.js +4 -4
- package/cjs/rules/lone-executable-definition.js +1 -1
- package/cjs/rules/match-document-filename.js +2 -3
- package/cjs/rules/naming-convention.js +1 -1
- package/cjs/rules/no-anonymous-operations.js +1 -1
- package/cjs/rules/no-case-insensitive-enum-values-duplicates.js +1 -1
- package/cjs/rules/no-deprecated.js +1 -1
- package/cjs/rules/no-duplicate-fields.js +1 -1
- package/cjs/rules/no-hashtag-description.js +1 -1
- package/cjs/rules/no-one-place-fragments.js +1 -1
- package/cjs/rules/no-root-type.js +1 -1
- package/cjs/rules/no-scalar-result-type-on-mutation.js +1 -1
- package/cjs/rules/no-typename-prefix.js +1 -1
- package/cjs/rules/no-unreachable-types.js +1 -1
- package/cjs/rules/no-unused-fields.js +1 -1
- package/cjs/rules/relay-arguments.js +1 -1
- package/cjs/rules/relay-connection-types.js +1 -1
- package/cjs/rules/relay-edge-types.js +1 -1
- package/cjs/rules/relay-page-info.js +1 -1
- package/cjs/rules/require-deprecation-date.js +1 -1
- package/cjs/rules/require-deprecation-reason.js +1 -1
- package/cjs/rules/require-description.js +1 -1
- package/cjs/rules/require-field-of-type-query-in-mutation-result.js +1 -1
- package/cjs/rules/require-id-when-available.js +1 -1
- package/cjs/rules/require-nullable-fields-with-oneof.js +1 -1
- package/cjs/rules/require-type-pattern-with-oneof.js +1 -1
- package/cjs/rules/selection-set-depth.js +1 -1
- package/cjs/rules/strict-id-in-types.js +1 -1
- package/cjs/rules/unique-fragment-name.js +1 -1
- package/cjs/rules/unique-operation-name.js +1 -1
- package/cjs/siblings.js +113 -0
- package/cjs/utils.js +2 -1
- package/docs/README.md +1 -85
- package/docs/custom-rules.md +1 -184
- package/docs/deprecated-rules.md +1 -24
- package/docs/parser-options.md +1 -107
- package/docs/parser.md +1 -67
- package/esm/documents.js +2 -105
- package/esm/graphql-config.js +1 -1
- package/esm/parser.js +10 -4
- package/esm/rules/alphabetize.js +1 -1
- package/esm/rules/description-style.js +1 -1
- package/esm/rules/graphql-js-validation.js +1 -1
- package/esm/rules/input-name.js +4 -4
- package/esm/rules/lone-executable-definition.js +1 -1
- package/esm/rules/match-document-filename.js +3 -4
- package/esm/rules/naming-convention.js +1 -1
- package/esm/rules/no-anonymous-operations.js +1 -1
- package/esm/rules/no-case-insensitive-enum-values-duplicates.js +1 -1
- package/esm/rules/no-deprecated.js +1 -1
- package/esm/rules/no-duplicate-fields.js +1 -1
- package/esm/rules/no-hashtag-description.js +1 -1
- package/esm/rules/no-one-place-fragments.js +1 -1
- package/esm/rules/no-root-type.js +1 -1
- package/esm/rules/no-scalar-result-type-on-mutation.js +1 -1
- package/esm/rules/no-typename-prefix.js +1 -1
- package/esm/rules/no-unreachable-types.js +1 -1
- package/esm/rules/no-unused-fields.js +1 -1
- package/esm/rules/relay-arguments.js +1 -1
- package/esm/rules/relay-connection-types.js +1 -1
- package/esm/rules/relay-edge-types.js +1 -1
- package/esm/rules/relay-page-info.js +1 -1
- package/esm/rules/require-deprecation-date.js +1 -1
- package/esm/rules/require-deprecation-reason.js +1 -1
- package/esm/rules/require-description.js +1 -1
- package/esm/rules/require-field-of-type-query-in-mutation-result.js +1 -1
- package/esm/rules/require-id-when-available.js +1 -1
- package/esm/rules/require-nullable-fields-with-oneof.js +1 -1
- package/esm/rules/require-type-pattern-with-oneof.js +1 -1
- package/esm/rules/selection-set-depth.js +1 -1
- package/esm/rules/strict-id-in-types.js +1 -1
- package/esm/rules/unique-fragment-name.js +1 -1
- package/esm/rules/unique-operation-name.js +1 -1
- package/esm/siblings.js +109 -0
- package/esm/utils.js +1 -0
- package/package.json +1 -1
- package/typings/documents.d.cts +2 -20
- package/typings/documents.d.ts +2 -20
- package/typings/rules/input-name.d.cts +1 -1
- package/typings/rules/input-name.d.ts +1 -1
- package/typings/siblings.d.cts +22 -0
- package/typings/siblings.d.ts +22 -0
- package/typings/types.d.cts +3 -2
- package/typings/types.d.ts +3 -2
- package/typings/utils.d.cts +2 -1
- package/typings/utils.d.ts +2 -1
- package/docs/rules/alphabetize.md +0 -194
- package/docs/rules/description-style.md +0 -57
- package/docs/rules/executable-definitions.md +0 -20
- package/docs/rules/fields-on-correct-type.md +0 -23
- package/docs/rules/fragments-on-composite-type.md +0 -20
- package/docs/rules/input-name.md +0 -80
- package/docs/rules/known-argument-names.md +0 -23
- package/docs/rules/known-directives.md +0 -48
- package/docs/rules/known-fragment-names.md +0 -72
- package/docs/rules/known-type-names.md +0 -24
- package/docs/rules/lone-anonymous-operation.md +0 -20
- package/docs/rules/lone-executable-definition.md +0 -59
- package/docs/rules/lone-schema-definition.md +0 -19
- package/docs/rules/match-document-filename.md +0 -181
- package/docs/rules/naming-convention.md +0 -320
- package/docs/rules/no-anonymous-operations.md +0 -43
- package/docs/rules/no-case-insensitive-enum-values-duplicates.md +0 -46
- package/docs/rules/no-deprecated.md +0 -88
- package/docs/rules/no-duplicate-fields.md +0 -69
- package/docs/rules/no-fragment-cycles.md +0 -19
- package/docs/rules/no-hashtag-description.md +0 -62
- package/docs/rules/no-one-place-fragments.md +0 -51
- package/docs/rules/no-root-type.md +0 -55
- package/docs/rules/no-scalar-result-type-on-mutation.md +0 -39
- package/docs/rules/no-typename-prefix.md +0 -42
- package/docs/rules/no-undefined-variables.md +0 -20
- package/docs/rules/no-unreachable-types.md +0 -52
- package/docs/rules/no-unused-fields.md +0 -64
- package/docs/rules/no-unused-fragments.md +0 -20
- package/docs/rules/no-unused-variables.md +0 -20
- package/docs/rules/one-field-subscriptions.md +0 -19
- package/docs/rules/overlapping-fields-can-be-merged.md +0 -20
- package/docs/rules/possible-fragment-spread.md +0 -21
- package/docs/rules/possible-type-extension.md +0 -19
- package/docs/rules/provided-required-arguments.md +0 -21
- package/docs/rules/relay-arguments.md +0 -59
- package/docs/rules/relay-connection-types.md +0 -43
- package/docs/rules/relay-edge-types.md +0 -60
- package/docs/rules/relay-page-info.md +0 -34
- package/docs/rules/require-deprecation-date.md +0 -59
- package/docs/rules/require-deprecation-reason.md +0 -49
- package/docs/rules/require-description.md +0 -147
- package/docs/rules/require-field-of-type-query-in-mutation-result.md +0 -50
- package/docs/rules/require-id-when-available.md +0 -91
- package/docs/rules/require-nullable-fields-with-oneof.md +0 -38
- package/docs/rules/require-type-pattern-with-oneof.md +0 -39
- package/docs/rules/scalar-leafs.md +0 -23
- package/docs/rules/selection-set-depth.md +0 -86
- package/docs/rules/strict-id-in-types.md +0 -129
- package/docs/rules/unique-argument-names.md +0 -19
- package/docs/rules/unique-directive-names-per-location.md +0 -21
- package/docs/rules/unique-directive-names.md +0 -19
- package/docs/rules/unique-enum-value-names.md +0 -16
- package/docs/rules/unique-field-definition-names.md +0 -19
- package/docs/rules/unique-fragment-name.md +0 -52
- package/docs/rules/unique-input-field-names.md +0 -19
- package/docs/rules/unique-operation-name.md +0 -56
- package/docs/rules/unique-operation-types.md +0 -19
- package/docs/rules/unique-type-names.md +0 -19
- package/docs/rules/unique-variable-names.md +0 -19
- package/docs/rules/value-literals-of-correct-type.md +0 -22
- package/docs/rules/variables-are-input-types.md +0 -20
- package/docs/rules/variables-in-allowed-position.md +0 -19
@@ -1,320 +0,0 @@
|
|
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)
|
@@ -1,43 +0,0 @@
|
|
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)
|
@@ -1,46 +0,0 @@
|
|
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)
|
@@ -1,88 +0,0 @@
|
|
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)
|
@@ -1,69 +0,0 @@
|
|
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)
|
@@ -1,19 +0,0 @@
|
|
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)
|
@@ -1,62 +0,0 @@
|
|
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)
|
@@ -1,51 +0,0 @@
|
|
1
|
-
# `no-one-place-fragments`
|
2
|
-
|
3
|
-
- Category: `Operations`
|
4
|
-
- Rule name: `@graphql-eslint/no-one-place-fragments`
|
5
|
-
- Requires GraphQL Schema: `false` [ℹ️](../../README.md#extended-linting-rules-with-graphql-schema)
|
6
|
-
- Requires GraphQL Operations: `true`
|
7
|
-
[ℹ️](../../README.md#extended-linting-rules-with-siblings-operations)
|
8
|
-
|
9
|
-
Disallow fragments that are used only in one place.
|
10
|
-
|
11
|
-
## Usage Examples
|
12
|
-
|
13
|
-
### Incorrect
|
14
|
-
|
15
|
-
```graphql
|
16
|
-
# eslint @graphql-eslint/no-one-place-fragments: 'error'
|
17
|
-
|
18
|
-
fragment UserFields on User {
|
19
|
-
id
|
20
|
-
}
|
21
|
-
|
22
|
-
{
|
23
|
-
user {
|
24
|
-
...UserFields
|
25
|
-
}
|
26
|
-
}
|
27
|
-
```
|
28
|
-
|
29
|
-
### Correct
|
30
|
-
|
31
|
-
```graphql
|
32
|
-
# eslint @graphql-eslint/no-one-place-fragments: 'error'
|
33
|
-
|
34
|
-
fragment UserFields on User {
|
35
|
-
id
|
36
|
-
}
|
37
|
-
|
38
|
-
{
|
39
|
-
user {
|
40
|
-
...UserFields
|
41
|
-
friends {
|
42
|
-
...UserFields
|
43
|
-
}
|
44
|
-
}
|
45
|
-
}
|
46
|
-
```
|
47
|
-
|
48
|
-
## Resources
|
49
|
-
|
50
|
-
- [Rule source](../../packages/plugin/src/rules/no-one-place-fragments.ts)
|
51
|
-
- [Test source](../../packages/plugin/tests/no-one-place-fragments.spec.ts)
|