@graphql-eslint/eslint-plugin 4.0.0-alpha.9 → 4.0.1-alpha-20241127205058-a4fec1a6cf7006ea913f13e6afbf7ed2d82503c3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/cjs/cache.js +1 -2
- package/cjs/configs/index.d.cts +427 -10
- package/cjs/configs/index.js +1 -2
- package/cjs/configs/operations-all.d.cts +8 -8
- package/cjs/configs/operations-all.js +30 -33
- package/cjs/configs/operations-recommended.d.cts +35 -35
- package/cjs/configs/operations-recommended.js +56 -59
- package/cjs/configs/schema-all.d.cts +12 -12
- package/cjs/configs/schema-all.js +26 -29
- package/cjs/configs/schema-recommended.d.cts +23 -23
- package/cjs/configs/schema-recommended.js +70 -73
- package/cjs/configs/schema-relay.d.cts +5 -5
- package/cjs/configs/schema-relay.js +14 -17
- package/cjs/documents.js +1 -2
- package/cjs/estree-converter/converter.js +1 -2
- package/cjs/estree-converter/utils.js +1 -2
- package/cjs/graphql-config.d.cts +6 -1
- package/cjs/graphql-config.js +9 -3
- package/cjs/index.d.cts +436 -16
- package/cjs/index.js +2 -3
- package/cjs/meta.js +1 -2
- package/cjs/parser.js +2 -6
- package/cjs/processor.js +5 -2
- package/cjs/rules/alphabetize/index.js +1 -2
- package/cjs/rules/description-style/index.js +1 -2
- package/cjs/rules/graphql-js-validation.js +4 -5
- package/cjs/rules/index.d.cts +6 -4
- package/cjs/rules/index.js +1 -2
- package/cjs/rules/input-name/index.js +1 -2
- package/cjs/rules/lone-executable-definition/index.js +1 -2
- package/cjs/rules/match-document-filename/index.js +1 -2
- package/cjs/rules/naming-convention/index.js +4 -3
- package/cjs/rules/no-anonymous-operations/index.js +1 -2
- package/cjs/rules/no-deprecated/index.js +20 -8
- package/cjs/rules/no-duplicate-fields/index.js +1 -2
- package/cjs/rules/no-hashtag-description/index.js +1 -2
- package/cjs/rules/no-one-place-fragments/index.js +2 -3
- package/cjs/rules/no-root-type/index.js +2 -3
- package/cjs/rules/no-scalar-result-type-on-mutation/index.js +2 -3
- package/cjs/rules/no-typename-prefix/index.js +1 -2
- package/cjs/rules/no-unreachable-types/index.js +4 -6
- package/cjs/rules/no-unused-fields/index.d.cts +24 -3
- package/cjs/rules/no-unused-fields/index.js +119 -10
- package/cjs/rules/relay-arguments/index.js +2 -3
- package/cjs/rules/relay-connection-types/index.js +1 -2
- package/cjs/rules/relay-edge-types/index.js +2 -3
- package/cjs/rules/relay-page-info/index.js +2 -3
- package/cjs/rules/require-deprecation-date/index.js +1 -2
- package/cjs/rules/require-deprecation-reason/index.js +1 -2
- package/cjs/rules/require-description/index.js +4 -8
- package/cjs/rules/require-field-of-type-query-in-mutation-result/index.js +2 -3
- package/cjs/rules/require-import-fragment/index.js +2 -3
- package/cjs/rules/require-nullable-fields-with-oneof/index.js +1 -2
- package/cjs/rules/require-nullable-result-in-root/index.js +2 -3
- package/cjs/rules/require-selections/index.js +14 -8
- package/cjs/rules/require-type-pattern-with-oneof/index.js +1 -2
- package/cjs/rules/selection-set-depth/index.js +4 -5
- package/cjs/rules/strict-id-in-types/index.js +2 -3
- package/cjs/rules/unique-enum-value-names/index.js +1 -2
- package/cjs/rules/unique-fragment-name/index.js +2 -3
- package/cjs/rules/unique-operation-name/index.js +1 -2
- package/cjs/schema.js +1 -2
- package/cjs/siblings.js +1 -2
- package/cjs/types.d.cts +1 -0
- package/cjs/utils.d.cts +4 -4
- package/cjs/utils.js +7 -8
- package/esm/cache.js +0 -1
- package/esm/configs/index.d.ts +427 -10
- package/esm/configs/index.js +0 -1
- package/esm/configs/operations-all.d.ts +7 -7
- package/esm/configs/operations-all.js +28 -33
- package/esm/configs/operations-recommended.d.ts +34 -34
- package/esm/configs/operations-recommended.js +54 -59
- package/esm/configs/schema-all.d.ts +11 -11
- package/esm/configs/schema-all.js +24 -29
- package/esm/configs/schema-recommended.d.ts +22 -22
- package/esm/configs/schema-recommended.js +68 -73
- package/esm/configs/schema-relay.d.ts +4 -4
- package/esm/configs/schema-relay.js +12 -17
- package/esm/documents.js +0 -1
- package/esm/estree-converter/converter.js +0 -1
- package/esm/estree-converter/utils.js +0 -1
- package/esm/graphql-config.d.ts +6 -1
- package/esm/graphql-config.js +8 -2
- package/esm/index.d.ts +436 -16
- package/esm/index.js +3 -4
- package/esm/meta.js +1 -2
- package/esm/parser.js +3 -7
- package/esm/processor.js +4 -1
- package/esm/rules/alphabetize/index.js +0 -1
- package/esm/rules/description-style/index.js +0 -1
- package/esm/rules/graphql-js-validation.js +5 -6
- package/esm/rules/index.d.ts +6 -4
- package/esm/rules/index.js +0 -1
- package/esm/rules/input-name/index.js +0 -1
- package/esm/rules/lone-executable-definition/index.js +0 -1
- package/esm/rules/match-document-filename/index.js +0 -1
- package/esm/rules/naming-convention/index.js +3 -2
- package/esm/rules/no-anonymous-operations/index.js +0 -1
- package/esm/rules/no-deprecated/index.js +20 -8
- package/esm/rules/no-duplicate-fields/index.js +0 -1
- package/esm/rules/no-hashtag-description/index.js +0 -1
- package/esm/rules/no-one-place-fragments/index.js +2 -3
- package/esm/rules/no-root-type/index.js +2 -3
- package/esm/rules/no-scalar-result-type-on-mutation/index.js +2 -3
- package/esm/rules/no-typename-prefix/index.js +0 -1
- package/esm/rules/no-unreachable-types/index.js +5 -7
- package/esm/rules/no-unused-fields/index.d.ts +24 -3
- package/esm/rules/no-unused-fields/index.js +119 -10
- package/esm/rules/relay-arguments/index.js +2 -3
- package/esm/rules/relay-connection-types/index.js +0 -1
- package/esm/rules/relay-edge-types/index.js +2 -3
- package/esm/rules/relay-page-info/index.js +2 -3
- package/esm/rules/require-deprecation-date/index.js +0 -1
- package/esm/rules/require-deprecation-reason/index.js +0 -1
- package/esm/rules/require-description/index.js +4 -8
- package/esm/rules/require-field-of-type-query-in-mutation-result/index.js +2 -3
- package/esm/rules/require-import-fragment/index.js +2 -3
- package/esm/rules/require-nullable-fields-with-oneof/index.js +0 -1
- package/esm/rules/require-nullable-result-in-root/index.js +2 -3
- package/esm/rules/require-selections/index.js +15 -9
- package/esm/rules/require-type-pattern-with-oneof/index.js +0 -1
- package/esm/rules/selection-set-depth/index.js +4 -5
- package/esm/rules/strict-id-in-types/index.js +2 -3
- package/esm/rules/unique-enum-value-names/index.js +0 -1
- package/esm/rules/unique-fragment-name/index.js +2 -3
- package/esm/rules/unique-operation-name/index.js +0 -1
- package/esm/schema.js +0 -1
- package/esm/siblings.js +0 -1
- package/esm/types.d.ts +1 -0
- package/esm/utils.d.ts +4 -4
- package/esm/utils.js +7 -8
- package/index.browser.js +508 -423
- package/package.json +2 -2
- package/cjs/chunk-UIAXBAMD.js +0 -8
- package/esm/chunk-UIAXBAMD.js +0 -8
package/index.browser.js
CHANGED
@@ -1,241 +1,3 @@
|
|
1
|
-
var __create = Object.create;
|
2
|
-
var __defProp = Object.defineProperty;
|
3
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
4
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
5
|
-
var __getProtoOf = Object.getPrototypeOf, __hasOwnProp = Object.prototype.hasOwnProperty;
|
6
|
-
var __commonJS = (cb, mod) => function() {
|
7
|
-
return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
|
8
|
-
};
|
9
|
-
var __copyProps = (to, from, except, desc) => {
|
10
|
-
if (from && typeof from == "object" || typeof from == "function")
|
11
|
-
for (let key of __getOwnPropNames(from))
|
12
|
-
!__hasOwnProp.call(to, key) && key !== except && __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
13
|
-
return to;
|
14
|
-
};
|
15
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
16
|
-
// If the importer is in node compatibility mode or this is not an ESM
|
17
|
-
// file that has been converted to a CommonJS file using a Babel-
|
18
|
-
// compatible transform (i.e. "__esModule" has not been set), then set
|
19
|
-
// "default" to the CommonJS "module.exports" for node compatibility.
|
20
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: !0 }) : target,
|
21
|
-
mod
|
22
|
-
));
|
23
|
-
|
24
|
-
// src/configs/operations-all.ts
|
25
|
-
var require_operations_all = __commonJS({
|
26
|
-
"src/configs/operations-all.ts"(exports, module) {
|
27
|
-
"use strict";
|
28
|
-
module.exports = {
|
29
|
-
extends: "./configs/operations-recommended",
|
30
|
-
rules: {
|
31
|
-
"@graphql-eslint/alphabetize": [
|
32
|
-
"error",
|
33
|
-
{
|
34
|
-
definitions: !0,
|
35
|
-
selections: ["OperationDefinition", "FragmentDefinition"],
|
36
|
-
variables: !0,
|
37
|
-
arguments: ["Field", "Directive"],
|
38
|
-
groups: ["...", "id", "*", "{"]
|
39
|
-
}
|
40
|
-
],
|
41
|
-
"@graphql-eslint/lone-executable-definition": "error",
|
42
|
-
"@graphql-eslint/match-document-filename": [
|
43
|
-
"error",
|
44
|
-
{
|
45
|
-
query: "kebab-case",
|
46
|
-
mutation: "kebab-case",
|
47
|
-
subscription: "kebab-case",
|
48
|
-
fragment: "kebab-case"
|
49
|
-
}
|
50
|
-
],
|
51
|
-
"@graphql-eslint/no-one-place-fragments": "error",
|
52
|
-
"@graphql-eslint/require-import-fragment": "error"
|
53
|
-
}
|
54
|
-
};
|
55
|
-
}
|
56
|
-
});
|
57
|
-
|
58
|
-
// src/configs/operations-recommended.ts
|
59
|
-
var require_operations_recommended = __commonJS({
|
60
|
-
"src/configs/operations-recommended.ts"(exports, module) {
|
61
|
-
"use strict";
|
62
|
-
module.exports = {
|
63
|
-
parser: "@graphql-eslint/eslint-plugin",
|
64
|
-
plugins: ["@graphql-eslint"],
|
65
|
-
rules: {
|
66
|
-
"@graphql-eslint/executable-definitions": "error",
|
67
|
-
"@graphql-eslint/fields-on-correct-type": "error",
|
68
|
-
"@graphql-eslint/fragments-on-composite-type": "error",
|
69
|
-
"@graphql-eslint/known-argument-names": "error",
|
70
|
-
"@graphql-eslint/known-directives": "error",
|
71
|
-
"@graphql-eslint/known-fragment-names": "error",
|
72
|
-
"@graphql-eslint/known-type-names": "error",
|
73
|
-
"@graphql-eslint/lone-anonymous-operation": "error",
|
74
|
-
"@graphql-eslint/naming-convention": [
|
75
|
-
"error",
|
76
|
-
{
|
77
|
-
VariableDefinition: "camelCase",
|
78
|
-
OperationDefinition: {
|
79
|
-
style: "PascalCase",
|
80
|
-
forbiddenPrefixes: ["Query", "Mutation", "Subscription", "Get"],
|
81
|
-
forbiddenSuffixes: ["Query", "Mutation", "Subscription"]
|
82
|
-
},
|
83
|
-
FragmentDefinition: {
|
84
|
-
style: "PascalCase",
|
85
|
-
forbiddenPrefixes: ["Fragment"],
|
86
|
-
forbiddenSuffixes: ["Fragment"]
|
87
|
-
}
|
88
|
-
}
|
89
|
-
],
|
90
|
-
"@graphql-eslint/no-anonymous-operations": "error",
|
91
|
-
"@graphql-eslint/no-deprecated": "error",
|
92
|
-
"@graphql-eslint/no-duplicate-fields": "error",
|
93
|
-
"@graphql-eslint/no-fragment-cycles": "error",
|
94
|
-
"@graphql-eslint/no-undefined-variables": "error",
|
95
|
-
"@graphql-eslint/no-unused-fragments": "error",
|
96
|
-
"@graphql-eslint/no-unused-variables": "error",
|
97
|
-
"@graphql-eslint/one-field-subscriptions": "error",
|
98
|
-
"@graphql-eslint/overlapping-fields-can-be-merged": "error",
|
99
|
-
"@graphql-eslint/possible-fragment-spread": "error",
|
100
|
-
"@graphql-eslint/provided-required-arguments": "error",
|
101
|
-
"@graphql-eslint/require-selections": "error",
|
102
|
-
"@graphql-eslint/scalar-leafs": "error",
|
103
|
-
"@graphql-eslint/selection-set-depth": ["error", { maxDepth: 7 }],
|
104
|
-
"@graphql-eslint/unique-argument-names": "error",
|
105
|
-
"@graphql-eslint/unique-directive-names-per-location": "error",
|
106
|
-
"@graphql-eslint/unique-fragment-name": "error",
|
107
|
-
"@graphql-eslint/unique-input-field-names": "error",
|
108
|
-
"@graphql-eslint/unique-operation-name": "error",
|
109
|
-
"@graphql-eslint/unique-variable-names": "error",
|
110
|
-
"@graphql-eslint/value-literals-of-correct-type": "error",
|
111
|
-
"@graphql-eslint/variables-are-input-types": "error",
|
112
|
-
"@graphql-eslint/variables-in-allowed-position": "error"
|
113
|
-
}
|
114
|
-
};
|
115
|
-
}
|
116
|
-
});
|
117
|
-
|
118
|
-
// src/configs/schema-all.ts
|
119
|
-
var require_schema_all = __commonJS({
|
120
|
-
"src/configs/schema-all.ts"(exports, module) {
|
121
|
-
"use strict";
|
122
|
-
module.exports = {
|
123
|
-
extends: "./configs/schema-recommended",
|
124
|
-
rules: {
|
125
|
-
"@graphql-eslint/alphabetize": [
|
126
|
-
"error",
|
127
|
-
{
|
128
|
-
definitions: !0,
|
129
|
-
fields: ["ObjectTypeDefinition", "InterfaceTypeDefinition", "InputObjectTypeDefinition"],
|
130
|
-
values: !0,
|
131
|
-
arguments: ["FieldDefinition", "Field", "DirectiveDefinition", "Directive"],
|
132
|
-
groups: ["id", "*", "createdAt", "updatedAt"]
|
133
|
-
}
|
134
|
-
],
|
135
|
-
"@graphql-eslint/input-name": "error",
|
136
|
-
"@graphql-eslint/no-root-type": ["error", { disallow: ["mutation", "subscription"] }],
|
137
|
-
"@graphql-eslint/no-scalar-result-type-on-mutation": "error",
|
138
|
-
"@graphql-eslint/require-deprecation-date": "error",
|
139
|
-
"@graphql-eslint/require-field-of-type-query-in-mutation-result": "error",
|
140
|
-
"@graphql-eslint/require-nullable-fields-with-oneof": "error",
|
141
|
-
"@graphql-eslint/require-nullable-result-in-root": "error",
|
142
|
-
"@graphql-eslint/require-type-pattern-with-oneof": "error"
|
143
|
-
}
|
144
|
-
};
|
145
|
-
}
|
146
|
-
});
|
147
|
-
|
148
|
-
// src/configs/schema-recommended.ts
|
149
|
-
var require_schema_recommended = __commonJS({
|
150
|
-
"src/configs/schema-recommended.ts"(exports, module) {
|
151
|
-
"use strict";
|
152
|
-
module.exports = {
|
153
|
-
parser: "@graphql-eslint/eslint-plugin",
|
154
|
-
plugins: ["@graphql-eslint"],
|
155
|
-
rules: {
|
156
|
-
"@graphql-eslint/description-style": "error",
|
157
|
-
"@graphql-eslint/known-argument-names": "error",
|
158
|
-
"@graphql-eslint/known-directives": "error",
|
159
|
-
"@graphql-eslint/known-type-names": "error",
|
160
|
-
"@graphql-eslint/lone-schema-definition": "error",
|
161
|
-
"@graphql-eslint/naming-convention": [
|
162
|
-
"error",
|
163
|
-
{
|
164
|
-
types: "PascalCase",
|
165
|
-
FieldDefinition: "camelCase",
|
166
|
-
InputValueDefinition: "camelCase",
|
167
|
-
Argument: "camelCase",
|
168
|
-
DirectiveDefinition: "camelCase",
|
169
|
-
EnumValueDefinition: "UPPER_CASE",
|
170
|
-
"FieldDefinition[parent.name.value=Query]": {
|
171
|
-
forbiddenPrefixes: ["query", "get"],
|
172
|
-
forbiddenSuffixes: ["Query"]
|
173
|
-
},
|
174
|
-
"FieldDefinition[parent.name.value=Mutation]": {
|
175
|
-
forbiddenPrefixes: ["mutation"],
|
176
|
-
forbiddenSuffixes: ["Mutation"]
|
177
|
-
},
|
178
|
-
"FieldDefinition[parent.name.value=Subscription]": {
|
179
|
-
forbiddenPrefixes: ["subscription"],
|
180
|
-
forbiddenSuffixes: ["Subscription"]
|
181
|
-
},
|
182
|
-
"EnumTypeDefinition,EnumTypeExtension": {
|
183
|
-
forbiddenPrefixes: ["Enum"],
|
184
|
-
forbiddenSuffixes: ["Enum"]
|
185
|
-
},
|
186
|
-
"InterfaceTypeDefinition,InterfaceTypeExtension": {
|
187
|
-
forbiddenPrefixes: ["Interface"],
|
188
|
-
forbiddenSuffixes: ["Interface"]
|
189
|
-
},
|
190
|
-
"UnionTypeDefinition,UnionTypeExtension": {
|
191
|
-
forbiddenPrefixes: ["Union"],
|
192
|
-
forbiddenSuffixes: ["Union"]
|
193
|
-
},
|
194
|
-
"ObjectTypeDefinition,ObjectTypeExtension": {
|
195
|
-
forbiddenPrefixes: ["Type"],
|
196
|
-
forbiddenSuffixes: ["Type"]
|
197
|
-
}
|
198
|
-
}
|
199
|
-
],
|
200
|
-
"@graphql-eslint/no-hashtag-description": "error",
|
201
|
-
"@graphql-eslint/no-typename-prefix": "error",
|
202
|
-
"@graphql-eslint/no-unreachable-types": "error",
|
203
|
-
"@graphql-eslint/possible-type-extension": "error",
|
204
|
-
"@graphql-eslint/provided-required-arguments": "error",
|
205
|
-
"@graphql-eslint/require-deprecation-reason": "error",
|
206
|
-
"@graphql-eslint/require-description": [
|
207
|
-
"error",
|
208
|
-
{ types: !0, DirectiveDefinition: !0, rootField: !0 }
|
209
|
-
],
|
210
|
-
"@graphql-eslint/strict-id-in-types": "error",
|
211
|
-
"@graphql-eslint/unique-directive-names": "error",
|
212
|
-
"@graphql-eslint/unique-directive-names-per-location": "error",
|
213
|
-
"@graphql-eslint/unique-enum-value-names": "error",
|
214
|
-
"@graphql-eslint/unique-field-definition-names": "error",
|
215
|
-
"@graphql-eslint/unique-operation-types": "error",
|
216
|
-
"@graphql-eslint/unique-type-names": "error"
|
217
|
-
}
|
218
|
-
};
|
219
|
-
}
|
220
|
-
});
|
221
|
-
|
222
|
-
// src/configs/schema-relay.ts
|
223
|
-
var require_schema_relay = __commonJS({
|
224
|
-
"src/configs/schema-relay.ts"(exports, module) {
|
225
|
-
"use strict";
|
226
|
-
module.exports = {
|
227
|
-
parser: "@graphql-eslint/eslint-plugin",
|
228
|
-
plugins: ["@graphql-eslint"],
|
229
|
-
rules: {
|
230
|
-
"@graphql-eslint/relay-arguments": "error",
|
231
|
-
"@graphql-eslint/relay-connection-types": "error",
|
232
|
-
"@graphql-eslint/relay-edge-types": "error",
|
233
|
-
"@graphql-eslint/relay-page-info": "error"
|
234
|
-
}
|
235
|
-
};
|
236
|
-
}
|
237
|
-
});
|
238
|
-
|
239
1
|
// src/parser.ts
|
240
2
|
import debugFactory2 from "debug";
|
241
3
|
import { buildSchema, GraphQLError } from "graphql";
|
@@ -341,8 +103,8 @@ function convertLocation(location) {
|
|
341
103
|
}
|
342
104
|
|
343
105
|
// src/estree-converter/converter.ts
|
344
|
-
function convertToESTree(node,
|
345
|
-
let typeInfo =
|
106
|
+
function convertToESTree(node, schema16) {
|
107
|
+
let typeInfo = schema16 && new TypeInfo(schema16), visitor = {
|
346
108
|
leave(node2, key, parent) {
|
347
109
|
let leadingComments = "description" in node2 && node2.description ? [
|
348
110
|
{
|
@@ -399,21 +161,21 @@ import {
|
|
399
161
|
// src/utils.ts
|
400
162
|
import { Kind as Kind2 } from "graphql";
|
401
163
|
import lowerCase from "lodash.lowercase";
|
402
|
-
function
|
164
|
+
function requireGraphQLOperations(ruleId, context) {
|
403
165
|
let { siblingOperations } = context.sourceCode.parserServices;
|
404
166
|
if (!siblingOperations.available)
|
405
167
|
throw new Error(
|
406
|
-
`Rule \`${ruleId}\` requires graphql-config \`documents\` field to be set and loaded. See https://the-guild.dev/graphql/
|
168
|
+
`Rule \`${ruleId}\` requires graphql-config \`documents\` field to be set and loaded. See https://the-guild.dev/graphql/eslint/docs/usage#providing-operations for more info`
|
407
169
|
);
|
408
170
|
return siblingOperations;
|
409
171
|
}
|
410
|
-
function
|
411
|
-
let { schema:
|
412
|
-
if (!
|
172
|
+
function requireGraphQLSchema(ruleId, context) {
|
173
|
+
let { schema: schema16 } = context.sourceCode.parserServices;
|
174
|
+
if (!schema16)
|
413
175
|
throw new Error(
|
414
|
-
`Rule \`${ruleId}\` requires graphql-config \`schema\` field to be set and loaded. See https://the-guild.dev/graphql/
|
176
|
+
`Rule \`${ruleId}\` requires graphql-config \`schema\` field to be set and loaded. See https://the-guild.dev/graphql/eslint/docs/usage#providing-schema for more info`
|
415
177
|
);
|
416
|
-
return
|
178
|
+
return schema16;
|
417
179
|
}
|
418
180
|
var chalk = {
|
419
181
|
red: (str) => `\x1B[31m${str}\x1B[39m`,
|
@@ -521,7 +283,7 @@ var DisplayNodeNameMap = {
|
|
521
283
|
[Kind2.VARIABLE]: "variable"
|
522
284
|
};
|
523
285
|
function displayNodeName(node) {
|
524
|
-
return `${node.kind === Kind2.OPERATION_DEFINITION ? node.operation : DisplayNodeNameMap[node.kind]} "${"alias" in node && node.alias?.value || "name" in node && node.name?.value}"`;
|
286
|
+
return `${node.kind === Kind2.OPERATION_DEFINITION ? node.operation : DisplayNodeNameMap[node.kind]} "${"alias" in node && node.alias?.value || "name" in node && node.name?.value || node.value}"`;
|
525
287
|
}
|
526
288
|
function getNodeName(node) {
|
527
289
|
switch (node.kind) {
|
@@ -635,7 +397,7 @@ function parseForESLint(code, options) {
|
|
635
397
|
`\`parserOptions.${key}\` was removed in graphql-eslint@4. Use physical graphql-config for setting schema and documents or \`parserOptions.graphQLConfig\` for programmatic usage.`
|
636
398
|
);
|
637
399
|
try {
|
638
|
-
let { filePath } = options, { document } = parseGraphQLSDL(filePath, code, { noLocation: !1 }), project,
|
400
|
+
let { filePath } = options, { document } = parseGraphQLSDL(filePath, code, { noLocation: !1 }), project, schema16, documents;
|
639
401
|
documents = [
|
640
402
|
parseGraphQLSDL(
|
641
403
|
"operation.graphql",
|
@@ -644,14 +406,14 @@ function parseForESLint(code, options) {
|
|
644
406
|
)
|
645
407
|
];
|
646
408
|
try {
|
647
|
-
|
409
|
+
schema16 = buildSchema(options.graphQLConfig.schema);
|
648
410
|
} catch (error) {
|
649
411
|
throw error instanceof Error && (error.message = `Error while loading schema: ${error.message}`), error;
|
650
412
|
}
|
651
|
-
let rootTree = convertToESTree(document,
|
413
|
+
let rootTree = convertToESTree(document, schema16);
|
652
414
|
return {
|
653
415
|
services: {
|
654
|
-
schema:
|
416
|
+
schema: schema16,
|
655
417
|
siblingOperations: getSiblings(documents)
|
656
418
|
},
|
657
419
|
ast: {
|
@@ -1118,14 +880,14 @@ import {
|
|
1118
880
|
import { validateSDL } from "graphql/validation/validate.js";
|
1119
881
|
function validateDocument({
|
1120
882
|
context,
|
1121
|
-
schema:
|
883
|
+
schema: schema16 = null,
|
1122
884
|
documentNode,
|
1123
885
|
rule: rule35,
|
1124
886
|
hasDidYouMeanSuggestions
|
1125
887
|
}) {
|
1126
888
|
if (documentNode.definitions.length !== 0)
|
1127
889
|
try {
|
1128
|
-
let validationErrors =
|
890
|
+
let validationErrors = schema16 ? validate(schema16, documentNode, [rule35]) : validateSDL(documentNode, null, [rule35]);
|
1129
891
|
for (let error of validationErrors) {
|
1130
892
|
let { line, column } = error.locations[0], sourceCode = context.getSourceCode(), { tokens } = sourceCode.ast, token = tokens.find(
|
1131
893
|
(token2) => token2.loc.start.line === line && token2.loc.start.column === column - 1
|
@@ -1171,7 +933,7 @@ var getFragmentDefsAndFragmentSpreads = (node) => {
|
|
1171
933
|
}, handleMissingFragments = ({ ruleId, context, node }) => {
|
1172
934
|
let missingFragments = getMissingFragments(node);
|
1173
935
|
if (missingFragments.length > 0) {
|
1174
|
-
let siblings =
|
936
|
+
let siblings = requireGraphQLOperations(ruleId, context), fragmentsToAdd = [];
|
1175
937
|
for (let fragmentName of missingFragments) {
|
1176
938
|
let [foundFragment] = siblings.getFragment(fragmentName).map((source) => source.document);
|
1177
939
|
foundFragment && fragmentsToAdd.push(foundFragment);
|
@@ -1191,7 +953,7 @@ var getFragmentDefsAndFragmentSpreads = (node) => {
|
|
1191
953
|
ruleId,
|
1192
954
|
rule: rule35,
|
1193
955
|
getDocumentNode,
|
1194
|
-
schema:
|
956
|
+
schema: schema16 = [],
|
1195
957
|
hasDidYouMeanSuggestions
|
1196
958
|
}, docs) => ({
|
1197
959
|
[ruleId]: {
|
@@ -1204,16 +966,16 @@ var getFragmentDefsAndFragmentSpreads = (node) => {
|
|
1204
966
|
description: `${docs.description}
|
1205
967
|
> This rule is a wrapper around a \`graphql-js\` validation function.`
|
1206
968
|
},
|
1207
|
-
schema:
|
969
|
+
schema: schema16,
|
1208
970
|
hasSuggestions: hasDidYouMeanSuggestions
|
1209
971
|
},
|
1210
972
|
create(context) {
|
1211
973
|
return {
|
1212
974
|
Document(node) {
|
1213
|
-
let
|
975
|
+
let schema17 = docs.requiresSchema ? requireGraphQLSchema(ruleId, context) : null, documentNode = getDocumentNode ? getDocumentNode({ ruleId, context, node: node.rawNode() }) : node.rawNode();
|
1214
976
|
validateDocument({
|
1215
977
|
context,
|
1216
|
-
schema:
|
978
|
+
schema: schema17,
|
1217
979
|
documentNode,
|
1218
980
|
rule: rule35,
|
1219
981
|
hasDidYouMeanSuggestions
|
@@ -1454,7 +1216,7 @@ var getFragmentDefsAndFragmentSpreads = (node) => {
|
|
1454
1216
|
ruleId: "no-unused-fragments",
|
1455
1217
|
rule: NoUnusedFragmentsRule,
|
1456
1218
|
getDocumentNode: ({ ruleId, context, node }) => {
|
1457
|
-
let siblings =
|
1219
|
+
let siblings = requireGraphQLOperations(ruleId, context), FilePathToDocumentsMap = [
|
1458
1220
|
...siblings.getOperations(),
|
1459
1221
|
...siblings.getFragments()
|
1460
1222
|
].reduce((map, { filePath, document }) => (map[filePath] ??= [], map[filePath].push(document), map), /* @__PURE__ */ Object.create(null)), getParentNode = (currentFilePath, node2) => {
|
@@ -2509,12 +2271,14 @@ ${TYPES_KINDS.map((kind) => `- \`${kind}\``).join(`
|
|
2509
2271
|
};
|
2510
2272
|
}
|
2511
2273
|
}, checkUnderscore = (isLeading) => (node) => {
|
2274
|
+
if (node.parent.kind === "Field" && node.parent.alias !== node)
|
2275
|
+
return;
|
2512
2276
|
let suggestedName = node.value.replace(isLeading ? /^_+/ : /_+$/, "");
|
2513
2277
|
report(node, `${isLeading ? "Leading" : "Trailing"} underscores are not allowed`, [
|
2514
2278
|
suggestedName
|
2515
2279
|
]);
|
2516
2280
|
}, listeners = {};
|
2517
|
-
allowLeadingUnderscore || (listeners["Name[value=/^_/]
|
2281
|
+
allowLeadingUnderscore || (listeners["Name[value=/^_/]"] = checkUnderscore(!0)), allowTrailingUnderscore || (listeners["Name[value=/_$/]"] = checkUnderscore(!1));
|
2518
2282
|
let selectors = new Set(
|
2519
2283
|
[types && TYPES_KINDS, Object.keys(restOptions)].flat().filter(truthy)
|
2520
2284
|
);
|
@@ -2594,7 +2358,6 @@ var RULE_ID3 = "no-anonymous-operations", rule7 = {
|
|
2594
2358
|
};
|
2595
2359
|
|
2596
2360
|
// src/rules/no-deprecated/index.ts
|
2597
|
-
import { Kind as Kind10 } from "graphql";
|
2598
2361
|
var RULE_ID4 = "no-deprecated", rule8 = {
|
2599
2362
|
meta: {
|
2600
2363
|
type: "suggestion",
|
@@ -2678,24 +2441,24 @@ var RULE_ID4 = "no-deprecated", rule8 = {
|
|
2678
2441
|
recommended: !0
|
2679
2442
|
},
|
2680
2443
|
messages: {
|
2681
|
-
[RULE_ID4]: "
|
2444
|
+
[RULE_ID4]: "{{ type }} is marked as deprecated in your GraphQL schema (reason: {{ reason }})"
|
2682
2445
|
},
|
2683
2446
|
schema: []
|
2684
2447
|
},
|
2685
2448
|
create(context) {
|
2686
|
-
|
2449
|
+
requireGraphQLSchema(RULE_ID4, context);
|
2687
2450
|
function report(node, reason) {
|
2688
|
-
let
|
2451
|
+
let nodeType = displayNodeName(node);
|
2689
2452
|
context.report({
|
2690
2453
|
node,
|
2691
2454
|
messageId: RULE_ID4,
|
2692
2455
|
data: {
|
2693
|
-
type: nodeType,
|
2456
|
+
type: nodeType[0].toUpperCase() + nodeType.slice(1),
|
2694
2457
|
reason
|
2695
2458
|
},
|
2696
2459
|
suggest: [
|
2697
2460
|
{
|
2698
|
-
desc: `Remove
|
2461
|
+
desc: `Remove ${nodeType}`,
|
2699
2462
|
fix: (fixer) => fixer.remove(node)
|
2700
2463
|
}
|
2701
2464
|
]
|
@@ -2709,13 +2472,27 @@ var RULE_ID4 = "no-deprecated", rule8 = {
|
|
2709
2472
|
Field(node) {
|
2710
2473
|
let reason = node.typeInfo().fieldDef?.deprecationReason;
|
2711
2474
|
reason && report(node, reason);
|
2475
|
+
},
|
2476
|
+
Argument(node) {
|
2477
|
+
let reason = node.typeInfo().argument?.deprecationReason;
|
2478
|
+
reason && report(node, reason);
|
2479
|
+
},
|
2480
|
+
ObjectValue(node) {
|
2481
|
+
let { inputType } = node.typeInfo();
|
2482
|
+
if (inputType && "getFields" in inputType) {
|
2483
|
+
let fields = inputType.getFields();
|
2484
|
+
for (let field of node.fields) {
|
2485
|
+
let fieldName = field.name.value, reason = fields[fieldName].deprecationReason;
|
2486
|
+
reason && report(field, reason);
|
2487
|
+
}
|
2488
|
+
}
|
2712
2489
|
}
|
2713
2490
|
};
|
2714
2491
|
}
|
2715
2492
|
};
|
2716
2493
|
|
2717
2494
|
// src/rules/no-duplicate-fields/index.ts
|
2718
|
-
import { Kind as
|
2495
|
+
import { Kind as Kind10 } from "graphql";
|
2719
2496
|
var RULE_ID5 = "no-duplicate-fields", rule9 = {
|
2720
2497
|
meta: {
|
2721
2498
|
type: "suggestion",
|
@@ -2799,7 +2576,7 @@ var RULE_ID5 = "no-duplicate-fields", rule9 = {
|
|
2799
2576
|
desc: `Remove \`${fieldName}\` ${parent.type.toLowerCase()}`,
|
2800
2577
|
fix(fixer) {
|
2801
2578
|
return fixer.remove(
|
2802
|
-
parent.type ===
|
2579
|
+
parent.type === Kind10.VARIABLE ? parent.parent : parent
|
2803
2580
|
);
|
2804
2581
|
}
|
2805
2582
|
}
|
@@ -2822,7 +2599,7 @@ var RULE_ID5 = "no-duplicate-fields", rule9 = {
|
|
2822
2599
|
SelectionSet(node) {
|
2823
2600
|
let set = /* @__PURE__ */ new Set();
|
2824
2601
|
for (let selection of node.selections)
|
2825
|
-
selection.kind ===
|
2602
|
+
selection.kind === Kind10.FIELD && checkNode2(set, selection.alias || selection.name);
|
2826
2603
|
}
|
2827
2604
|
};
|
2828
2605
|
}
|
@@ -2988,7 +2765,7 @@ var RULE_ID7 = "no-one-place-fragments", rule11 = {
|
|
2988
2765
|
schema: []
|
2989
2766
|
},
|
2990
2767
|
create(context) {
|
2991
|
-
let operations =
|
2768
|
+
let operations = requireGraphQLOperations(RULE_ID7, context), allDocuments = [...operations.getOperations(), ...operations.getFragments()], usedFragmentsMap = /* @__PURE__ */ Object.create(null);
|
2992
2769
|
for (let { document, filePath } of allDocuments) {
|
2993
2770
|
let relativeFilePath = relative(CWD, filePath);
|
2994
2771
|
visit4(document, {
|
@@ -3069,9 +2846,9 @@ var schema7 = {
|
|
3069
2846
|
schema: schema7
|
3070
2847
|
},
|
3071
2848
|
create(context) {
|
3072
|
-
let
|
3073
|
-
disallow.has("mutation") &&
|
3074
|
-
disallow.has("subscription") &&
|
2849
|
+
let schema16 = requireGraphQLSchema("no-root-type", context), disallow = new Set(context.options[0].disallow), rootTypeNames = [
|
2850
|
+
disallow.has("mutation") && schema16.getMutationType(),
|
2851
|
+
disallow.has("subscription") && schema16.getSubscriptionType()
|
3075
2852
|
].filter(truthy).map((type) => type.name).join("|");
|
3076
2853
|
return rootTypeNames ? {
|
3077
2854
|
[`:matches(ObjectTypeDefinition, ObjectTypeExtension) > .name[value=/^(${rootTypeNames})$/]`](node) {
|
@@ -3092,7 +2869,7 @@ var schema7 = {
|
|
3092
2869
|
};
|
3093
2870
|
|
3094
2871
|
// src/rules/no-scalar-result-type-on-mutation/index.ts
|
3095
|
-
import { isScalarType, Kind as
|
2872
|
+
import { isScalarType, Kind as Kind11 } from "graphql";
|
3096
2873
|
var RULE_ID8 = "no-scalar-result-type-on-mutation", rule13 = {
|
3097
2874
|
meta: {
|
3098
2875
|
type: "suggestion",
|
@@ -3130,16 +2907,16 @@ var RULE_ID8 = "no-scalar-result-type-on-mutation", rule13 = {
|
|
3130
2907
|
schema: []
|
3131
2908
|
},
|
3132
2909
|
create(context) {
|
3133
|
-
let
|
2910
|
+
let schema16 = requireGraphQLSchema(RULE_ID8, context), mutationType = schema16.getMutationType();
|
3134
2911
|
return mutationType ? {
|
3135
2912
|
[[
|
3136
2913
|
`:matches(ObjectTypeDefinition, ObjectTypeExtension)[name.value=${mutationType.name}]`,
|
3137
2914
|
"> FieldDefinition > .gqlType Name"
|
3138
2915
|
].join(" ")](node) {
|
3139
|
-
let typeName = node.value, graphQLType =
|
2916
|
+
let typeName = node.value, graphQLType = schema16.getType(typeName);
|
3140
2917
|
if (isScalarType(graphQLType)) {
|
3141
2918
|
let fieldDef = node.parent;
|
3142
|
-
for (; fieldDef.kind !==
|
2919
|
+
for (; fieldDef.kind !== Kind11.FIELD_DEFINITION; )
|
3143
2920
|
fieldDef = fieldDef.parent;
|
3144
2921
|
context.report({
|
3145
2922
|
node,
|
@@ -3229,25 +3006,26 @@ var NO_TYPENAME_PREFIX = "NO_TYPENAME_PREFIX", rule14 = {
|
|
3229
3006
|
// src/rules/no-unreachable-types/index.ts
|
3230
3007
|
import {
|
3231
3008
|
DirectiveLocation,
|
3009
|
+
getNamedType,
|
3232
3010
|
isInterfaceType,
|
3233
|
-
Kind as
|
3011
|
+
Kind as Kind12,
|
3234
3012
|
visit as visit5
|
3235
3013
|
} from "graphql";
|
3236
3014
|
import lowerCase3 from "lodash.lowercase";
|
3237
3015
|
var RULE_ID9 = "no-unreachable-types", KINDS = [
|
3238
|
-
|
3239
|
-
|
3240
|
-
|
3241
|
-
|
3242
|
-
|
3243
|
-
|
3244
|
-
|
3245
|
-
|
3246
|
-
|
3247
|
-
|
3248
|
-
|
3249
|
-
|
3250
|
-
|
3016
|
+
Kind12.DIRECTIVE_DEFINITION,
|
3017
|
+
Kind12.OBJECT_TYPE_DEFINITION,
|
3018
|
+
Kind12.OBJECT_TYPE_EXTENSION,
|
3019
|
+
Kind12.INTERFACE_TYPE_DEFINITION,
|
3020
|
+
Kind12.INTERFACE_TYPE_EXTENSION,
|
3021
|
+
Kind12.SCALAR_TYPE_DEFINITION,
|
3022
|
+
Kind12.SCALAR_TYPE_EXTENSION,
|
3023
|
+
Kind12.INPUT_OBJECT_TYPE_DEFINITION,
|
3024
|
+
Kind12.INPUT_OBJECT_TYPE_EXTENSION,
|
3025
|
+
Kind12.UNION_TYPE_DEFINITION,
|
3026
|
+
Kind12.UNION_TYPE_EXTENSION,
|
3027
|
+
Kind12.ENUM_TYPE_DEFINITION,
|
3028
|
+
Kind12.ENUM_TYPE_EXTENSION
|
3251
3029
|
], reachableTypesCache = new ModuleCache(), RequestDirectiveLocations = /* @__PURE__ */ new Set([
|
3252
3030
|
DirectiveLocation.QUERY,
|
3253
3031
|
DirectiveLocation.MUTATION,
|
@@ -3258,8 +3036,8 @@ var RULE_ID9 = "no-unreachable-types", KINDS = [
|
|
3258
3036
|
DirectiveLocation.INLINE_FRAGMENT,
|
3259
3037
|
DirectiveLocation.VARIABLE_DEFINITION
|
3260
3038
|
]);
|
3261
|
-
function getReachableTypes(
|
3262
|
-
let cachedValue = reachableTypesCache.get(
|
3039
|
+
function getReachableTypes(schema16) {
|
3040
|
+
let cachedValue = reachableTypesCache.get(schema16);
|
3263
3041
|
if (cachedValue)
|
3264
3042
|
return cachedValue;
|
3265
3043
|
let reachableTypes = /* @__PURE__ */ new Set(), collect = (node) => {
|
@@ -3267,9 +3045,9 @@ function getReachableTypes(schema15) {
|
|
3267
3045
|
if (reachableTypes.has(typeName))
|
3268
3046
|
return;
|
3269
3047
|
reachableTypes.add(typeName);
|
3270
|
-
let type =
|
3048
|
+
let type = schema16.getType(typeName) || schema16.getDirective(typeName);
|
3271
3049
|
if (isInterfaceType(type)) {
|
3272
|
-
let { objects, interfaces } =
|
3050
|
+
let { objects, interfaces } = schema16.getImplementations(type);
|
3273
3051
|
for (let { astNode } of [...objects, ...interfaces])
|
3274
3052
|
visit5(astNode, visitor);
|
3275
3053
|
} else type?.astNode && visit5(type.astNode, visitor);
|
@@ -3283,22 +3061,20 @@ function getReachableTypes(schema15) {
|
|
3283
3061
|
NamedType: collect
|
3284
3062
|
};
|
3285
3063
|
for (let type of [
|
3286
|
-
|
3064
|
+
schema16,
|
3287
3065
|
// visiting SchemaDefinition node
|
3288
|
-
|
3289
|
-
|
3290
|
-
|
3066
|
+
schema16.getQueryType(),
|
3067
|
+
schema16.getMutationType(),
|
3068
|
+
schema16.getSubscriptionType()
|
3291
3069
|
])
|
3292
3070
|
type?.astNode && visit5(type.astNode, visitor);
|
3293
|
-
for (let node of
|
3071
|
+
for (let node of schema16.getDirectives())
|
3294
3072
|
if (node.locations.some((location) => RequestDirectiveLocations.has(location))) {
|
3295
3073
|
reachableTypes.add(node.name);
|
3296
|
-
for (let arg of node.args)
|
3297
|
-
|
3298
|
-
argTypeName && reachableTypes.add(argTypeName);
|
3299
|
-
}
|
3074
|
+
for (let arg of node.args)
|
3075
|
+
reachableTypes.add(getNamedType(arg.type).name);
|
3300
3076
|
}
|
3301
|
-
return reachableTypesCache.set(
|
3077
|
+
return reachableTypesCache.set(schema16, reachableTypes), reachableTypes;
|
3302
3078
|
}
|
3303
3079
|
var rule15 = {
|
3304
3080
|
meta: {
|
@@ -3351,7 +3127,7 @@ var rule15 = {
|
|
3351
3127
|
hasSuggestions: !0
|
3352
3128
|
},
|
3353
3129
|
create(context) {
|
3354
|
-
let
|
3130
|
+
let schema16 = requireGraphQLSchema(RULE_ID9, context), reachableTypes = getReachableTypes(schema16);
|
3355
3131
|
return {
|
3356
3132
|
[`:matches(${KINDS}) > .name`](node) {
|
3357
3133
|
let typeName = node.value;
|
@@ -3379,12 +3155,105 @@ var rule15 = {
|
|
3379
3155
|
|
3380
3156
|
// src/rules/no-unused-fields/index.ts
|
3381
3157
|
import { TypeInfo as TypeInfo2, visit as visit6, visitWithTypeInfo as visitWithTypeInfo2 } from "graphql";
|
3382
|
-
var RULE_ID10 = "no-unused-fields",
|
3383
|
-
|
3384
|
-
|
3158
|
+
var RULE_ID10 = "no-unused-fields", RELAY_SCHEMA = (
|
3159
|
+
/* GraphQL */
|
3160
|
+
`
|
3161
|
+
# Root Query Type
|
3162
|
+
type Query {
|
3163
|
+
user: User
|
3164
|
+
}
|
3165
|
+
|
3166
|
+
# User Type
|
3167
|
+
type User {
|
3168
|
+
id: ID!
|
3169
|
+
name: String!
|
3170
|
+
friends(first: Int, after: String): FriendConnection!
|
3171
|
+
}
|
3172
|
+
|
3173
|
+
# FriendConnection Type (Relay Connection)
|
3174
|
+
type FriendConnection {
|
3175
|
+
edges: [FriendEdge]
|
3176
|
+
pageInfo: PageInfo!
|
3177
|
+
}
|
3178
|
+
|
3179
|
+
# FriendEdge Type
|
3180
|
+
type FriendEdge {
|
3181
|
+
cursor: String!
|
3182
|
+
node: Friend!
|
3183
|
+
}
|
3184
|
+
|
3185
|
+
# Friend Type
|
3186
|
+
type Friend {
|
3187
|
+
id: ID!
|
3188
|
+
name: String!
|
3189
|
+
}
|
3190
|
+
|
3191
|
+
# PageInfo Type (Relay Pagination)
|
3192
|
+
type PageInfo {
|
3193
|
+
hasPreviousPage: Boolean!
|
3194
|
+
hasNextPage: Boolean!
|
3195
|
+
startCursor: String
|
3196
|
+
endCursor: String
|
3197
|
+
}
|
3198
|
+
`
|
3199
|
+
), RELAY_QUERY = (
|
3200
|
+
/* GraphQL */
|
3201
|
+
`
|
3202
|
+
query {
|
3203
|
+
user {
|
3204
|
+
id
|
3205
|
+
name
|
3206
|
+
friends(first: 10) {
|
3207
|
+
edges {
|
3208
|
+
node {
|
3209
|
+
id
|
3210
|
+
name
|
3211
|
+
}
|
3212
|
+
}
|
3213
|
+
}
|
3214
|
+
}
|
3215
|
+
}
|
3216
|
+
`
|
3217
|
+
), RELAY_DEFAULT_IGNORED_FIELD_SELECTORS = [
|
3218
|
+
"[parent.name.value=PageInfo][name.value=/(endCursor|startCursor|hasNextPage|hasPreviousPage)/]",
|
3219
|
+
"[parent.name.value=/Edge$/][name.value=cursor]",
|
3220
|
+
"[parent.name.value=/Connection$/][name.value=pageInfo]"
|
3221
|
+
], schema8 = {
|
3222
|
+
type: "array",
|
3223
|
+
maxItems: 1,
|
3224
|
+
items: {
|
3225
|
+
type: "object",
|
3226
|
+
additionalProperties: !1,
|
3227
|
+
properties: {
|
3228
|
+
ignoredFieldSelectors: {
|
3229
|
+
type: "array",
|
3230
|
+
uniqueItems: !0,
|
3231
|
+
minItems: 1,
|
3232
|
+
description: [
|
3233
|
+
"Fields that will be ignored and are allowed to be unused.",
|
3234
|
+
"",
|
3235
|
+
"E.g. The following selector will ignore all the relay pagination fields for every connection exposed in the schema:",
|
3236
|
+
"```json",
|
3237
|
+
JSON.stringify(RELAY_DEFAULT_IGNORED_FIELD_SELECTORS, null, 2),
|
3238
|
+
"```",
|
3239
|
+
"",
|
3240
|
+
"> These fields are defined by ESLint [`selectors`](https://eslint.org/docs/developer-guide/selectors).",
|
3241
|
+
"> Paste or drop code into the editor in [ASTExplorer](https://astexplorer.net) and inspect the generated AST to compose your selector."
|
3242
|
+
].join(`
|
3243
|
+
`),
|
3244
|
+
items: {
|
3245
|
+
type: "string",
|
3246
|
+
pattern: "^\\[(.+)]$"
|
3247
|
+
}
|
3248
|
+
}
|
3249
|
+
}
|
3250
|
+
}
|
3251
|
+
}, usedFieldsCache = new ModuleCache();
|
3252
|
+
function getUsedFields(schema16, operations) {
|
3253
|
+
let cachedValue = usedFieldsCache.get(schema16);
|
3385
3254
|
if (cachedValue)
|
3386
3255
|
return cachedValue;
|
3387
|
-
let usedFields = /* @__PURE__ */ Object.create(null), typeInfo = new TypeInfo2(
|
3256
|
+
let usedFields = /* @__PURE__ */ Object.create(null), typeInfo = new TypeInfo2(schema16), visitor = visitWithTypeInfo2(typeInfo, {
|
3388
3257
|
Field(node) {
|
3389
3258
|
if (!typeInfo.getFieldDef())
|
3390
3259
|
return !1;
|
@@ -3394,7 +3263,7 @@ function getUsedFields(schema15, operations) {
|
|
3394
3263
|
}), allDocuments = [...operations.getOperations(), ...operations.getFragments()];
|
3395
3264
|
for (let { document } of allDocuments)
|
3396
3265
|
visit6(document, visitor);
|
3397
|
-
return usedFieldsCache.set(
|
3266
|
+
return usedFieldsCache.set(schema16, usedFields), usedFields;
|
3398
3267
|
}
|
3399
3268
|
var rule16 = {
|
3400
3269
|
meta: {
|
@@ -3456,17 +3325,34 @@ var rule16 = {
|
|
3456
3325
|
}
|
3457
3326
|
`
|
3458
3327
|
)
|
3328
|
+
},
|
3329
|
+
{
|
3330
|
+
title: "Correct (ignoring fields)",
|
3331
|
+
usage: [{ ignoredFieldSelectors: RELAY_DEFAULT_IGNORED_FIELD_SELECTORS }],
|
3332
|
+
code: (
|
3333
|
+
/* GraphQL */
|
3334
|
+
`
|
3335
|
+
### 1\uFE0F\u20E3 YOUR SCHEMA
|
3336
|
+
${RELAY_SCHEMA}
|
3337
|
+
|
3338
|
+
### 2\uFE0F\u20E3 YOUR QUERY
|
3339
|
+
${RELAY_QUERY}
|
3340
|
+
`
|
3341
|
+
)
|
3459
3342
|
}
|
3460
3343
|
]
|
3461
3344
|
},
|
3462
3345
|
type: "suggestion",
|
3463
|
-
schema:
|
3346
|
+
schema: schema8,
|
3464
3347
|
hasSuggestions: !0
|
3465
3348
|
},
|
3466
3349
|
create(context) {
|
3467
|
-
let
|
3350
|
+
let schema16 = requireGraphQLSchema(RULE_ID10, context), siblingsOperations = requireGraphQLOperations(RULE_ID10, context), usedFields = getUsedFields(schema16, siblingsOperations), { ignoredFieldSelectors } = context.options[0] || {};
|
3468
3351
|
return {
|
3469
|
-
|
3352
|
+
[(ignoredFieldSelectors || []).reduce(
|
3353
|
+
(acc, selector2) => `${acc}:not(${selector2})`,
|
3354
|
+
"FieldDefinition"
|
3355
|
+
)](node) {
|
3470
3356
|
let fieldName = node.name.value, parentTypeName = node.parent.name.value;
|
3471
3357
|
usedFields[parentTypeName]?.has(fieldName) || context.report({
|
3472
3358
|
node: node.name,
|
@@ -3488,8 +3374,8 @@ var rule16 = {
|
|
3488
3374
|
};
|
3489
3375
|
|
3490
3376
|
// src/rules/relay-arguments/index.ts
|
3491
|
-
import { isScalarType as isScalarType2, Kind as
|
3492
|
-
var RULE_ID11 = "relay-arguments", MISSING_ARGUMENTS = "MISSING_ARGUMENTS",
|
3377
|
+
import { isScalarType as isScalarType2, Kind as Kind13 } from "graphql";
|
3378
|
+
var RULE_ID11 = "relay-arguments", MISSING_ARGUMENTS = "MISSING_ARGUMENTS", schema9 = {
|
3493
3379
|
type: "array",
|
3494
3380
|
maxItems: 1,
|
3495
3381
|
items: {
|
@@ -3555,14 +3441,14 @@ var RULE_ID11 = "relay-arguments", MISSING_ARGUMENTS = "MISSING_ARGUMENTS", sche
|
|
3555
3441
|
messages: {
|
3556
3442
|
[MISSING_ARGUMENTS]: "A field that returns a Connection type must include forward pagination arguments (`first` and `after`), backward pagination arguments (`last` and `before`), or both."
|
3557
3443
|
},
|
3558
|
-
schema:
|
3444
|
+
schema: schema9
|
3559
3445
|
},
|
3560
3446
|
create(context) {
|
3561
|
-
let
|
3447
|
+
let schema16 = requireGraphQLSchema(RULE_ID11, context), { includeBoth = !0 } = context.options[0] || {};
|
3562
3448
|
return {
|
3563
3449
|
"FieldDefinition > .gqlType Name[value=/Connection$/]"(node) {
|
3564
3450
|
let fieldNode = node.parent;
|
3565
|
-
for (; fieldNode.kind !==
|
3451
|
+
for (; fieldNode.kind !== Kind13.FIELD_DEFINITION; )
|
3566
3452
|
fieldNode = fieldNode.parent;
|
3567
3453
|
let args = Object.fromEntries(
|
3568
3454
|
fieldNode.arguments?.map((argument) => [argument.name.value, argument]) || []
|
@@ -3576,7 +3462,7 @@ var RULE_ID11 = "relay-arguments", MISSING_ARGUMENTS = "MISSING_ARGUMENTS", sche
|
|
3576
3462
|
}
|
3577
3463
|
function checkField(typeName, argumentName) {
|
3578
3464
|
let argument = args[argumentName], hasArgument = !!argument, type = argument;
|
3579
|
-
if (hasArgument && type.gqlType.kind ===
|
3465
|
+
if (hasArgument && type.gqlType.kind === Kind13.NON_NULL_TYPE && (type = type.gqlType), !(hasArgument && type.gqlType.kind === Kind13.NAMED_TYPE && (type.gqlType.name.value === typeName || typeName === "String" && isScalarType2(schema16.getType(type.gqlType.name.value))))) {
|
3580
3466
|
let returnType = typeName === "String" ? "String or Scalar" : typeName;
|
3581
3467
|
context.report({
|
3582
3468
|
node: (argument || fieldNode).name,
|
@@ -3591,17 +3477,17 @@ var RULE_ID11 = "relay-arguments", MISSING_ARGUMENTS = "MISSING_ARGUMENTS", sche
|
|
3591
3477
|
};
|
3592
3478
|
|
3593
3479
|
// src/rules/relay-connection-types/index.ts
|
3594
|
-
import { Kind as
|
3480
|
+
import { Kind as Kind14 } from "graphql";
|
3595
3481
|
var MUST_BE_OBJECT_TYPE = "MUST_BE_OBJECT_TYPE", MUST_CONTAIN_FIELD_EDGES = "MUST_CONTAIN_FIELD_EDGES", MUST_CONTAIN_FIELD_PAGE_INFO = "MUST_CONTAIN_FIELD_PAGE_INFO", MUST_HAVE_CONNECTION_SUFFIX = "MUST_HAVE_CONNECTION_SUFFIX", EDGES_FIELD_MUST_RETURN_LIST_TYPE = "EDGES_FIELD_MUST_RETURN_LIST_TYPE", PAGE_INFO_FIELD_MUST_RETURN_NON_NULL_TYPE = "PAGE_INFO_FIELD_MUST_RETURN_NON_NULL_TYPE", NON_OBJECT_TYPES = [
|
3596
|
-
|
3597
|
-
|
3598
|
-
|
3599
|
-
|
3600
|
-
|
3601
|
-
|
3602
|
-
|
3603
|
-
|
3604
|
-
|
3482
|
+
Kind14.SCALAR_TYPE_DEFINITION,
|
3483
|
+
Kind14.UNION_TYPE_DEFINITION,
|
3484
|
+
Kind14.UNION_TYPE_EXTENSION,
|
3485
|
+
Kind14.INPUT_OBJECT_TYPE_DEFINITION,
|
3486
|
+
Kind14.INPUT_OBJECT_TYPE_EXTENSION,
|
3487
|
+
Kind14.ENUM_TYPE_DEFINITION,
|
3488
|
+
Kind14.ENUM_TYPE_EXTENSION,
|
3489
|
+
Kind14.INTERFACE_TYPE_DEFINITION,
|
3490
|
+
Kind14.INTERFACE_TYPE_EXTENSION
|
3605
3491
|
], notConnectionTypesSelector = `:matches(${NON_OBJECT_TYPES})[name.value=/Connection$/] > .name`, hasEdgesField = (node) => node.fields?.some((field) => field.name.value === "edges"), hasPageInfoField = (node) => node.fields?.some((field) => field.name.value === "pageInfo"), rule18 = {
|
3606
3492
|
meta: {
|
3607
3493
|
type: "problem",
|
@@ -3668,10 +3554,10 @@ var MUST_BE_OBJECT_TYPE = "MUST_BE_OBJECT_TYPE", MUST_CONTAIN_FIELD_EDGES = "MUS
|
|
3668
3554
|
hasEdgesField(node) || context.report({ node: node.name, messageId: MUST_CONTAIN_FIELD_EDGES }), hasPageInfoField(node) || context.report({ node: node.name, messageId: MUST_CONTAIN_FIELD_PAGE_INFO });
|
3669
3555
|
},
|
3670
3556
|
":matches(ObjectTypeDefinition, ObjectTypeExtension)[name.value=/Connection$/] > FieldDefinition[name.value=edges] > .gqlType"(node) {
|
3671
|
-
node.kind ===
|
3557
|
+
node.kind === Kind14.LIST_TYPE || node.kind === Kind14.NON_NULL_TYPE && node.gqlType.kind === Kind14.LIST_TYPE || context.report({ node, messageId: EDGES_FIELD_MUST_RETURN_LIST_TYPE });
|
3672
3558
|
},
|
3673
3559
|
":matches(ObjectTypeDefinition, ObjectTypeExtension)[name.value=/Connection$/] > FieldDefinition[name.value=pageInfo] > .gqlType"(node) {
|
3674
|
-
node.kind ===
|
3560
|
+
node.kind === Kind14.NON_NULL_TYPE && node.gqlType.kind === Kind14.NAMED_TYPE && node.gqlType.name.value === "PageInfo" || context.report({ node, messageId: PAGE_INFO_FIELD_MUST_RETURN_NON_NULL_TYPE });
|
3675
3561
|
}
|
3676
3562
|
};
|
3677
3563
|
}
|
@@ -3681,12 +3567,12 @@ var MUST_BE_OBJECT_TYPE = "MUST_BE_OBJECT_TYPE", MUST_CONTAIN_FIELD_EDGES = "MUS
|
|
3681
3567
|
import {
|
3682
3568
|
isObjectType as isObjectType2,
|
3683
3569
|
isScalarType as isScalarType3,
|
3684
|
-
Kind as
|
3570
|
+
Kind as Kind15,
|
3685
3571
|
visit as visit7
|
3686
3572
|
} from "graphql";
|
3687
3573
|
import { getDocumentNodeFromSchema } from "@graphql-tools/utils";
|
3688
3574
|
var RULE_ID12 = "relay-edge-types", MESSAGE_MUST_BE_OBJECT_TYPE = "MESSAGE_MUST_BE_OBJECT_TYPE", MESSAGE_MISSING_EDGE_SUFFIX = "MESSAGE_MISSING_EDGE_SUFFIX", MESSAGE_LIST_TYPE_ONLY_EDGE_TYPE = "MESSAGE_LIST_TYPE_ONLY_EDGE_TYPE", MESSAGE_SHOULD_IMPLEMENTS_NODE = "MESSAGE_SHOULD_IMPLEMENTS_NODE", edgeTypesCache;
|
3689
|
-
function getEdgeTypes(
|
3575
|
+
function getEdgeTypes(schema16) {
|
3690
3576
|
if (edgeTypesCache)
|
3691
3577
|
return edgeTypesCache;
|
3692
3578
|
let edgeTypes = /* @__PURE__ */ new Set(), visitor = {
|
@@ -3695,14 +3581,14 @@ function getEdgeTypes(schema15) {
|
|
3695
3581
|
return;
|
3696
3582
|
let edges = node.fields?.find((field) => field.name.value === "edges");
|
3697
3583
|
if (edges) {
|
3698
|
-
let edgesTypeName = getTypeName(edges), edgesType =
|
3584
|
+
let edgesTypeName = getTypeName(edges), edgesType = schema16.getType(edgesTypeName);
|
3699
3585
|
isObjectType2(edgesType) && edgeTypes.add(edgesTypeName);
|
3700
3586
|
}
|
3701
3587
|
}
|
3702
|
-
}, astNode = getDocumentNodeFromSchema(
|
3588
|
+
}, astNode = getDocumentNodeFromSchema(schema16);
|
3703
3589
|
return visit7(astNode, visitor), edgeTypesCache = edgeTypes, edgeTypesCache;
|
3704
3590
|
}
|
3705
|
-
var
|
3591
|
+
var schema10 = {
|
3706
3592
|
type: "array",
|
3707
3593
|
maxItems: 1,
|
3708
3594
|
items: {
|
@@ -3768,15 +3654,15 @@ var schema9 = {
|
|
3768
3654
|
[MESSAGE_LIST_TYPE_ONLY_EDGE_TYPE]: "A list type should only wrap an edge type.",
|
3769
3655
|
[MESSAGE_SHOULD_IMPLEMENTS_NODE]: "Edge type's field `node` must implement `Node` interface."
|
3770
3656
|
},
|
3771
|
-
schema:
|
3657
|
+
schema: schema10
|
3772
3658
|
},
|
3773
3659
|
create(context) {
|
3774
|
-
let
|
3660
|
+
let schema16 = requireGraphQLSchema(RULE_ID12, context), edgeTypes = getEdgeTypes(schema16), options = {
|
3775
3661
|
withEdgeSuffix: !0,
|
3776
3662
|
shouldImplementNode: !0,
|
3777
3663
|
listTypeCanWrapOnlyEdgeType: !0,
|
3778
3664
|
...context.options[0]
|
3779
|
-
}, isNamedOrNonNullNamed = (node) => node.kind ===
|
3665
|
+
}, isNamedOrNonNullNamed = (node) => node.kind === Kind15.NAMED_TYPE || node.kind === Kind15.NON_NULL_TYPE && node.gqlType.kind === Kind15.NAMED_TYPE, checkNodeField = (node) => {
|
3780
3666
|
let nodeField = node.fields?.find((field) => field.name.value === "node"), message = "return either a Scalar, Enum, Object, Interface, Union, or a non-null wrapper around one of those types.";
|
3781
3667
|
if (!nodeField)
|
3782
3668
|
context.report({
|
@@ -3786,7 +3672,7 @@ var schema9 = {
|
|
3786
3672
|
else if (!isNamedOrNonNullNamed(nodeField.gqlType))
|
3787
3673
|
context.report({ node: nodeField.name, message: `Field \`node\` must ${message}` });
|
3788
3674
|
else if (options.shouldImplementNode) {
|
3789
|
-
let nodeReturnTypeName = getTypeName(nodeField.gqlType.rawNode()), type =
|
3675
|
+
let nodeReturnTypeName = getTypeName(nodeField.gqlType.rawNode()), type = schema16.getType(nodeReturnTypeName);
|
3790
3676
|
if (!isObjectType2(type))
|
3791
3677
|
return;
|
3792
3678
|
type.astNode.interfaces?.some((n) => n.name.value === "Node") || context.report({ node: node.name, messageId: MESSAGE_SHOULD_IMPLEMENTS_NODE });
|
@@ -3801,10 +3687,10 @@ var schema9 = {
|
|
3801
3687
|
return;
|
3802
3688
|
}
|
3803
3689
|
let typeName = getTypeName(cursorField.rawNode());
|
3804
|
-
(!isNamedOrNonNullNamed(cursorField.gqlType) || typeName !== "String" && !isScalarType3(
|
3690
|
+
(!isNamedOrNonNullNamed(cursorField.gqlType) || typeName !== "String" && !isScalarType3(schema16.getType(typeName))) && context.report({ node: cursorField.name, message: `Field \`cursor\` must ${message}` });
|
3805
3691
|
}, listeners = {
|
3806
3692
|
":matches(ObjectTypeDefinition, ObjectTypeExtension)[name.value=/Connection$/] > FieldDefinition[name.value=edges] > .gqlType Name"(node) {
|
3807
|
-
let type =
|
3693
|
+
let type = schema16.getType(node.value);
|
3808
3694
|
isObjectType2(type) || context.report({ node, messageId: MESSAGE_MUST_BE_OBJECT_TYPE });
|
3809
3695
|
},
|
3810
3696
|
":matches(ObjectTypeDefinition, ObjectTypeExtension)"(node) {
|
@@ -3813,7 +3699,7 @@ var schema9 = {
|
|
3813
3699
|
}
|
3814
3700
|
};
|
3815
3701
|
return options.listTypeCanWrapOnlyEdgeType && (listeners["FieldDefinition > .gqlType"] = (node) => {
|
3816
|
-
if (node.kind ===
|
3702
|
+
if (node.kind === Kind15.LIST_TYPE || node.kind === Kind15.NON_NULL_TYPE && node.gqlType.kind === Kind15.LIST_TYPE) {
|
3817
3703
|
let typeName = getTypeName(node.rawNode());
|
3818
3704
|
edgeTypes.has(typeName) || context.report({ node, messageId: MESSAGE_LIST_TYPE_ONLY_EDGE_TYPE });
|
3819
3705
|
}
|
@@ -3822,7 +3708,7 @@ var schema9 = {
|
|
3822
3708
|
};
|
3823
3709
|
|
3824
3710
|
// src/rules/relay-page-info/index.ts
|
3825
|
-
import { isScalarType as isScalarType4, Kind as
|
3711
|
+
import { isScalarType as isScalarType4, Kind as Kind16 } from "graphql";
|
3826
3712
|
var RULE_ID13 = "relay-page-info", MESSAGE_MUST_EXIST = "MESSAGE_MUST_EXIST", MESSAGE_MUST_BE_OBJECT_TYPE2 = "MESSAGE_MUST_BE_OBJECT_TYPE", notPageInfoTypesSelector = `:matches(${NON_OBJECT_TYPES})[name.value=PageInfo] > .name`, hasPageInfoChecked = !1, rule20 = {
|
3827
3713
|
meta: {
|
3828
3714
|
type: "problem",
|
@@ -3863,8 +3749,8 @@ var RULE_ID13 = "relay-page-info", MESSAGE_MUST_EXIST = "MESSAGE_MUST_EXIST", ME
|
|
3863
3749
|
schema: []
|
3864
3750
|
},
|
3865
3751
|
create(context) {
|
3866
|
-
let
|
3867
|
-
return hasPageInfoChecked || (
|
3752
|
+
let schema16 = requireGraphQLSchema(RULE_ID13, context);
|
3753
|
+
return hasPageInfoChecked || (schema16.getType("PageInfo") || context.report({
|
3868
3754
|
loc: REPORT_ON_FIRST_CHARACTER,
|
3869
3755
|
messageId: MESSAGE_MUST_EXIST
|
3870
3756
|
}), hasPageInfoChecked = !0), {
|
@@ -3878,7 +3764,7 @@ var RULE_ID13 = "relay-page-info", MESSAGE_MUST_EXIST = "MESSAGE_MUST_EXIST", ME
|
|
3878
3764
|
let field = fieldMap[fieldName], isAllowedType = !1;
|
3879
3765
|
if (field) {
|
3880
3766
|
let type = field.gqlType;
|
3881
|
-
typeName === "Boolean" ? isAllowedType = type.kind ===
|
3767
|
+
typeName === "Boolean" ? isAllowedType = type.kind === Kind16.NON_NULL_TYPE && type.gqlType.kind === Kind16.NAMED_TYPE && type.gqlType.name.value === "Boolean" : type.kind === Kind16.NAMED_TYPE && (isAllowedType = type.name.value === "String" || isScalarType4(schema16.getType(type.name.value)));
|
3882
3768
|
}
|
3883
3769
|
if (!isAllowedType) {
|
3884
3770
|
let returnType = typeName === "Boolean" ? "non-null Boolean" : "either String or Scalar, which can be null if there are no results";
|
@@ -3895,7 +3781,7 @@ var RULE_ID13 = "relay-page-info", MESSAGE_MUST_EXIST = "MESSAGE_MUST_EXIST", ME
|
|
3895
3781
|
};
|
3896
3782
|
|
3897
3783
|
// src/rules/require-deprecation-date/index.ts
|
3898
|
-
var DATE_REGEX = /^\d{2}\/\d{2}\/\d{4}$/, MESSAGE_REQUIRE_DATE = "MESSAGE_REQUIRE_DATE", MESSAGE_INVALID_FORMAT = "MESSAGE_INVALID_FORMAT", MESSAGE_INVALID_DATE = "MESSAGE_INVALID_DATE", MESSAGE_CAN_BE_REMOVED = "MESSAGE_CAN_BE_REMOVED",
|
3784
|
+
var DATE_REGEX = /^\d{2}\/\d{2}\/\d{4}$/, MESSAGE_REQUIRE_DATE = "MESSAGE_REQUIRE_DATE", MESSAGE_INVALID_FORMAT = "MESSAGE_INVALID_FORMAT", MESSAGE_INVALID_DATE = "MESSAGE_INVALID_DATE", MESSAGE_CAN_BE_REMOVED = "MESSAGE_CAN_BE_REMOVED", schema11 = {
|
3899
3785
|
type: "array",
|
3900
3786
|
maxItems: 1,
|
3901
3787
|
items: {
|
@@ -3961,7 +3847,7 @@ var DATE_REGEX = /^\d{2}\/\d{2}\/\d{4}$/, MESSAGE_REQUIRE_DATE = "MESSAGE_REQUIR
|
|
3961
3847
|
[MESSAGE_INVALID_DATE]: 'Invalid "{{ deletionDate }}" deletion date for {{ nodeName }}',
|
3962
3848
|
[MESSAGE_CAN_BE_REMOVED]: "{{ nodeName }} \u0441an be removed"
|
3963
3849
|
},
|
3964
|
-
schema:
|
3850
|
+
schema: schema11
|
3965
3851
|
},
|
3966
3852
|
create(context) {
|
3967
3853
|
return {
|
@@ -4082,16 +3968,16 @@ var rule22 = {
|
|
4082
3968
|
};
|
4083
3969
|
|
4084
3970
|
// src/rules/require-description/index.ts
|
4085
|
-
import { Kind as
|
3971
|
+
import { Kind as Kind17, TokenKind as TokenKind3 } from "graphql";
|
4086
3972
|
import { getRootTypeNames } from "@graphql-tools/utils";
|
4087
3973
|
var RULE_ID14 = "require-description", ALLOWED_KINDS2 = [
|
4088
3974
|
...TYPES_KINDS,
|
4089
|
-
|
4090
|
-
|
4091
|
-
|
4092
|
-
|
4093
|
-
|
4094
|
-
],
|
3975
|
+
Kind17.DIRECTIVE_DEFINITION,
|
3976
|
+
Kind17.FIELD_DEFINITION,
|
3977
|
+
Kind17.INPUT_VALUE_DEFINITION,
|
3978
|
+
Kind17.ENUM_VALUE_DEFINITION,
|
3979
|
+
Kind17.OPERATION_DEFINITION
|
3980
|
+
], schema12 = {
|
4095
3981
|
type: "array",
|
4096
3982
|
minItems: 1,
|
4097
3983
|
maxItems: 1,
|
@@ -4113,7 +3999,7 @@ ${TYPES_KINDS.map((kind) => `- \`${kind}\``).join(`
|
|
4113
3999
|
...Object.fromEntries(
|
4114
4000
|
[...ALLOWED_KINDS2].sort().map((kind) => {
|
4115
4001
|
let description = `Read more about this kind on [spec.graphql.org](https://spec.graphql.org/October2021/#${kind}).`;
|
4116
|
-
return kind ===
|
4002
|
+
return kind === Kind17.OPERATION_DEFINITION && (description += '\n> You must use only comment syntax `#` and not description syntax `"""` or `"`.'), [kind, { type: "boolean", description }];
|
4117
4003
|
})
|
4118
4004
|
)
|
4119
4005
|
}
|
@@ -4189,7 +4075,7 @@ ${TYPES_KINDS.map((kind) => `- \`${kind}\``).join(`
|
|
4189
4075
|
configOptions: [
|
4190
4076
|
{
|
4191
4077
|
types: !0,
|
4192
|
-
[
|
4078
|
+
[Kind17.DIRECTIVE_DEFINITION]: !0,
|
4193
4079
|
rootField: !0
|
4194
4080
|
}
|
4195
4081
|
],
|
@@ -4199,23 +4085,25 @@ ${TYPES_KINDS.map((kind) => `- \`${kind}\``).join(`
|
|
4199
4085
|
messages: {
|
4200
4086
|
[RULE_ID14]: "Description is required for {{ nodeName }}"
|
4201
4087
|
},
|
4202
|
-
schema:
|
4088
|
+
schema: schema12
|
4203
4089
|
},
|
4204
4090
|
create(context) {
|
4205
4091
|
let { types, rootField, ...restOptions } = context.options[0] || {}, kinds = new Set(types ? TYPES_KINDS : []);
|
4206
4092
|
for (let [kind, isEnabled] of Object.entries(restOptions))
|
4207
4093
|
isEnabled ? kinds.add(kind) : kinds.delete(kind);
|
4208
4094
|
if (rootField) {
|
4209
|
-
let
|
4095
|
+
let schema16 = requireGraphQLSchema(RULE_ID14, context), rootTypeNames = getRootTypeNames(schema16);
|
4210
4096
|
kinds.add(
|
4211
4097
|
`:matches(ObjectTypeDefinition, ObjectTypeExtension)[name.value=/^(${[
|
4212
4098
|
...rootTypeNames
|
4213
4099
|
].join(",")})$/] > FieldDefinition`
|
4214
4100
|
);
|
4215
4101
|
}
|
4102
|
+
if (!kinds.size)
|
4103
|
+
throw new Error("At least one kind must be enabled");
|
4216
4104
|
return {
|
4217
4105
|
[[...kinds].join(",")](node) {
|
4218
|
-
let description = "", isOperation = node.kind ===
|
4106
|
+
let description = "", isOperation = node.kind === Kind17.OPERATION_DEFINITION;
|
4219
4107
|
if (isOperation) {
|
4220
4108
|
let rawNode = node.rawNode(), { prev, line } = rawNode.loc.startToken;
|
4221
4109
|
if (prev?.kind === TokenKind3.COMMENT) {
|
@@ -4285,10 +4173,10 @@ var RULE_ID15 = "require-field-of-type-query-in-mutation-result", rule24 = {
|
|
4285
4173
|
schema: []
|
4286
4174
|
},
|
4287
4175
|
create(context) {
|
4288
|
-
let
|
4176
|
+
let schema16 = requireGraphQLSchema(RULE_ID15, context), mutationType = schema16.getMutationType(), queryType = schema16.getQueryType();
|
4289
4177
|
return !mutationType || !queryType ? {} : {
|
4290
4178
|
[`:matches(ObjectTypeDefinition, ObjectTypeExtension)[name.value=${mutationType.name}] > FieldDefinition > .gqlType Name`](node) {
|
4291
|
-
let typeName = node.value, graphQLType =
|
4179
|
+
let typeName = node.value, graphQLType = schema16.getType(typeName);
|
4292
4180
|
if (isObjectType3(graphQLType)) {
|
4293
4181
|
let { fields } = graphQLType.astNode;
|
4294
4182
|
fields?.some((field) => getTypeName(field) === queryType.name) || context.report({
|
@@ -4377,7 +4265,7 @@ var RULE_ID16 = "require-import-fragment", SUGGESTION_ID = "add-import-expressio
|
|
4377
4265
|
schema: []
|
4378
4266
|
},
|
4379
4267
|
create(context) {
|
4380
|
-
let comments = context.getSourceCode().getAllComments(), siblings =
|
4268
|
+
let comments = context.getSourceCode().getAllComments(), siblings = requireGraphQLOperations(RULE_ID16, context), filePath = context.filename;
|
4381
4269
|
return {
|
4382
4270
|
"FragmentSpread > .name"(node) {
|
4383
4271
|
let fragmentName = node.value, fragmentsFromSiblings = siblings.getFragment(fragmentName);
|
@@ -4421,7 +4309,7 @@ var RULE_ID16 = "require-import-fragment", SUGGESTION_ID = "add-import-expressio
|
|
4421
4309
|
};
|
4422
4310
|
|
4423
4311
|
// src/rules/require-nullable-fields-with-oneof/index.ts
|
4424
|
-
import { Kind as
|
4312
|
+
import { Kind as Kind18 } from "graphql";
|
4425
4313
|
var RULE_ID17 = "require-nullable-fields-with-oneof", rule26 = {
|
4426
4314
|
meta: {
|
4427
4315
|
type: "suggestion",
|
@@ -4465,11 +4353,11 @@ var RULE_ID17 = "require-nullable-fields-with-oneof", rule26 = {
|
|
4465
4353
|
return {
|
4466
4354
|
"Directive[name.value=oneOf]"({ parent }) {
|
4467
4355
|
if ([
|
4468
|
-
|
4469
|
-
|
4356
|
+
Kind18.OBJECT_TYPE_DEFINITION,
|
4357
|
+
Kind18.INPUT_OBJECT_TYPE_DEFINITION
|
4470
4358
|
].includes(parent.kind))
|
4471
4359
|
for (let field of parent.fields || [])
|
4472
|
-
field.gqlType.kind ===
|
4360
|
+
field.gqlType.kind === Kind18.NON_NULL_TYPE && context.report({
|
4473
4361
|
node: field.name,
|
4474
4362
|
messageId: RULE_ID17,
|
4475
4363
|
data: { nodeName: getNodeName(field) }
|
@@ -4480,7 +4368,7 @@ var RULE_ID17 = "require-nullable-fields-with-oneof", rule26 = {
|
|
4480
4368
|
};
|
4481
4369
|
|
4482
4370
|
// src/rules/require-nullable-result-in-root/index.ts
|
4483
|
-
import { Kind as
|
4371
|
+
import { Kind as Kind19 } from "graphql";
|
4484
4372
|
var RULE_ID18 = "require-nullable-result-in-root", rule27 = {
|
4485
4373
|
meta: {
|
4486
4374
|
type: "suggestion",
|
@@ -4523,16 +4411,16 @@ var RULE_ID18 = "require-nullable-result-in-root", rule27 = {
|
|
4523
4411
|
schema: []
|
4524
4412
|
},
|
4525
4413
|
create(context) {
|
4526
|
-
let
|
4527
|
-
[
|
4414
|
+
let schema16 = requireGraphQLSchema(RULE_ID18, context), rootTypeNames = new Set(
|
4415
|
+
[schema16.getQueryType(), schema16.getMutationType()].filter(truthy).map((type) => type.name)
|
4528
4416
|
), sourceCode = context.getSourceCode();
|
4529
4417
|
return {
|
4530
4418
|
"ObjectTypeDefinition,ObjectTypeExtension"(node) {
|
4531
4419
|
if (rootTypeNames.has(node.name.value))
|
4532
4420
|
for (let field of node.fields || []) {
|
4533
|
-
if (field.gqlType.type !==
|
4421
|
+
if (field.gqlType.type !== Kind19.NON_NULL_TYPE || field.gqlType.gqlType.type !== Kind19.NAMED_TYPE)
|
4534
4422
|
continue;
|
4535
|
-
let name = field.gqlType.gqlType.name.value, type =
|
4423
|
+
let name = field.gqlType.gqlType.name.value, type = schema16.getType(name), resultType = type?.astNode ? getNodeName(type.astNode) : type?.name;
|
4536
4424
|
context.report({
|
4537
4425
|
node: field.gqlType,
|
4538
4426
|
messageId: RULE_ID18,
|
@@ -4561,13 +4449,13 @@ import {
|
|
4561
4449
|
GraphQLInterfaceType,
|
4562
4450
|
GraphQLObjectType,
|
4563
4451
|
GraphQLUnionType,
|
4564
|
-
Kind as
|
4452
|
+
Kind as Kind20,
|
4565
4453
|
TypeInfo as TypeInfo3,
|
4566
4454
|
visit as visit8,
|
4567
4455
|
visitWithTypeInfo as visitWithTypeInfo3
|
4568
4456
|
} from "graphql";
|
4569
4457
|
import { asArray } from "@graphql-tools/utils";
|
4570
|
-
var RULE_ID19 = "require-selections", DEFAULT_ID_FIELD_NAME = "id",
|
4458
|
+
var RULE_ID19 = "require-selections", DEFAULT_ID_FIELD_NAME = "id", schema13 = {
|
4571
4459
|
definitions: {
|
4572
4460
|
asString: {
|
4573
4461
|
type: "string"
|
@@ -4646,19 +4534,20 @@ var RULE_ID19 = "require-selections", DEFAULT_ID_FIELD_NAME = "id", schema12 = {
|
|
4646
4534
|
)
|
4647
4535
|
}
|
4648
4536
|
],
|
4649
|
-
recommended: !0
|
4537
|
+
recommended: !0,
|
4538
|
+
whenNotToUseIt: "Relay Compiler automatically adds an `id` field to any type that has an `id` field, even if it hasn't been explicitly requested. Requesting a field that is not used directly in the code can conflict with another Relay rule: `relay/unused-fields`."
|
4650
4539
|
},
|
4651
4540
|
messages: {
|
4652
4541
|
[RULE_ID19]: `Field{{ pluralSuffix }} {{ fieldName }} must be selected when it's available on a type.
|
4653
4542
|
Include it in your selection set{{ addition }}.`
|
4654
4543
|
},
|
4655
|
-
schema:
|
4544
|
+
schema: schema13
|
4656
4545
|
},
|
4657
4546
|
create(context) {
|
4658
|
-
let
|
4547
|
+
let schema16 = requireGraphQLSchema(RULE_ID19, context), siblings = requireGraphQLOperations(RULE_ID19, context), { fieldName = DEFAULT_ID_FIELD_NAME } = context.options[0] || {}, idNames = asArray(fieldName), selector = "SelectionSet[parent.kind!=/(^OperationDefinition|InlineFragment)$/]", typeInfo = new TypeInfo3(schema16);
|
4659
4548
|
function checkFragments(node) {
|
4660
4549
|
for (let selection of node.selections) {
|
4661
|
-
if (selection.kind !==
|
4550
|
+
if (selection.kind !== Kind20.FRAGMENT_SPREAD)
|
4662
4551
|
continue;
|
4663
4552
|
let [foundSpread] = siblings.getFragment(selection.name.value);
|
4664
4553
|
if (!foundSpread)
|
@@ -4666,7 +4555,7 @@ Include it in your selection set{{ addition }}.`
|
|
4666
4555
|
let checkedFragmentSpreads = /* @__PURE__ */ new Set(), visitor = visitWithTypeInfo3(typeInfo, {
|
4667
4556
|
SelectionSet(node2, key, _parent) {
|
4668
4557
|
let parent = _parent;
|
4669
|
-
parent.kind ===
|
4558
|
+
parent.kind === Kind20.FRAGMENT_DEFINITION ? checkedFragmentSpreads.add(parent.name.value) : parent.kind !== Kind20.INLINE_FRAGMENT && checkSelections(
|
4670
4559
|
node2,
|
4671
4560
|
typeInfo.getType(),
|
4672
4561
|
selection.loc.start,
|
@@ -4682,24 +4571,30 @@ Include it in your selection set{{ addition }}.`
|
|
4682
4571
|
let rawType = getBaseType(type);
|
4683
4572
|
if (rawType instanceof GraphQLObjectType || rawType instanceof GraphQLInterfaceType)
|
4684
4573
|
checkFields(rawType);
|
4685
|
-
else if (rawType instanceof GraphQLUnionType)
|
4686
|
-
for (let selection of node.selections)
|
4687
|
-
|
4688
|
-
|
4574
|
+
else if (rawType instanceof GraphQLUnionType)
|
4575
|
+
for (let selection of node.selections) {
|
4576
|
+
let types = rawType.getTypes();
|
4577
|
+
if (selection.kind === Kind20.INLINE_FRAGMENT) {
|
4578
|
+
let t = types.find((t2) => t2.name === selection.typeCondition.name.value);
|
4689
4579
|
t && checkFields(t);
|
4580
|
+
} else if (selection.kind === Kind20.FRAGMENT_SPREAD) {
|
4581
|
+
let [foundSpread] = siblings.getFragment(selection.name.value);
|
4582
|
+
if (!foundSpread) return;
|
4583
|
+
let fragmentSpread = foundSpread.document, t = fragmentSpread.typeCondition.name.value === rawType.name ? rawType : types.find((t2) => t2.name === fragmentSpread.typeCondition.name.value);
|
4584
|
+
checkedFragmentSpreads.add(fragmentSpread.name.value), checkSelections(fragmentSpread.selectionSet, t, loc, parent, checkedFragmentSpreads);
|
4690
4585
|
}
|
4691
|
-
|
4586
|
+
}
|
4692
4587
|
function checkFields(rawType2) {
|
4693
4588
|
let fields = rawType2.getFields();
|
4694
4589
|
if (!idNames.some((name) => fields[name]))
|
4695
4590
|
return;
|
4696
4591
|
function hasIdField({ selections }) {
|
4697
4592
|
return selections.some((selection) => {
|
4698
|
-
if (selection.kind ===
|
4593
|
+
if (selection.kind === Kind20.FIELD)
|
4699
4594
|
return selection.alias && idNames.includes(selection.alias.value) ? !0 : idNames.includes(selection.name.value);
|
4700
|
-
if (selection.kind ===
|
4595
|
+
if (selection.kind === Kind20.INLINE_FRAGMENT)
|
4701
4596
|
return hasIdField(selection.selectionSet);
|
4702
|
-
if (selection.kind ===
|
4597
|
+
if (selection.kind === Kind20.FRAGMENT_SPREAD) {
|
4703
4598
|
let [foundSpread] = siblings.getFragment(selection.name.value);
|
4704
4599
|
if (foundSpread) {
|
4705
4600
|
let fragmentSpread = foundSpread.document;
|
@@ -4727,7 +4622,7 @@ Include it in your selection set{{ addition }}.`
|
|
4727
4622
|
desc: `Add \`${idName}\` selection`,
|
4728
4623
|
fix: (fixer) => {
|
4729
4624
|
let insertNode = node.selections[0];
|
4730
|
-
return insertNode = insertNode.kind ===
|
4625
|
+
return insertNode = insertNode.kind === Kind20.INLINE_FRAGMENT ? insertNode.selectionSet.selections[0] : insertNode, fixer.insertTextBefore(insertNode, `${idName} `);
|
4731
4626
|
}
|
4732
4627
|
}))), context.report(problem);
|
4733
4628
|
}
|
@@ -4802,9 +4697,9 @@ var RULE_ID20 = "require-type-pattern-with-oneof", rule29 = {
|
|
4802
4697
|
};
|
4803
4698
|
|
4804
4699
|
// src/rules/selection-set-depth/index.ts
|
4805
|
-
import { Kind as
|
4700
|
+
import { Kind as Kind21 } from "graphql";
|
4806
4701
|
import depthLimit from "graphql-depth-limit";
|
4807
|
-
var RULE_ID21 = "selection-set-depth",
|
4702
|
+
var RULE_ID21 = "selection-set-depth", schema14 = {
|
4808
4703
|
type: "array",
|
4809
4704
|
minItems: 1,
|
4810
4705
|
maxItems: 1,
|
@@ -4872,15 +4767,15 @@ var RULE_ID21 = "selection-set-depth", schema13 = {
|
|
4872
4767
|
recommended: !0,
|
4873
4768
|
configOptions: [{ maxDepth: 7 }]
|
4874
4769
|
},
|
4875
|
-
schema:
|
4770
|
+
schema: schema14
|
4876
4771
|
},
|
4877
4772
|
create(context) {
|
4878
4773
|
let siblings = null;
|
4879
4774
|
try {
|
4880
|
-
siblings =
|
4775
|
+
siblings = requireGraphQLOperations(RULE_ID21, context);
|
4881
4776
|
} catch {
|
4882
4777
|
logger.warn(
|
4883
|
-
`Rule "${RULE_ID21}" works best with siblings operations loaded.
|
4778
|
+
`Rule "${RULE_ID21}" works best with siblings operations loaded. See https://the-guild.dev/graphql/eslint/docs/usage#providing-operations for more info`
|
4884
4779
|
);
|
4885
4780
|
}
|
4886
4781
|
let { maxDepth, ignore = [] } = context.options[0], checkFn = depthLimit(maxDepth, { ignore });
|
@@ -4888,7 +4783,7 @@ var RULE_ID21 = "selection-set-depth", schema13 = {
|
|
4888
4783
|
"OperationDefinition, FragmentDefinition"(node) {
|
4889
4784
|
try {
|
4890
4785
|
let rawNode = node.rawNode(), fragmentsInUse = siblings ? siblings.getFragmentsInUse(rawNode) : [], document = {
|
4891
|
-
kind:
|
4786
|
+
kind: Kind21.DOCUMENT,
|
4892
4787
|
definitions: [rawNode, ...fragmentsInUse]
|
4893
4788
|
};
|
4894
4789
|
checkFn({
|
@@ -4922,7 +4817,7 @@ var RULE_ID21 = "selection-set-depth", schema13 = {
|
|
4922
4817
|
});
|
4923
4818
|
} catch (e) {
|
4924
4819
|
logger.warn(
|
4925
|
-
`Rule "${RULE_ID21}" check failed due to a missing siblings operations.
|
4820
|
+
`Rule "${RULE_ID21}" check failed due to a missing siblings operations. See https://the-guild.dev/graphql/eslint/docs/usage#providing-operations for more info`,
|
4926
4821
|
e
|
4927
4822
|
);
|
4928
4823
|
}
|
@@ -4932,8 +4827,8 @@ var RULE_ID21 = "selection-set-depth", schema13 = {
|
|
4932
4827
|
};
|
4933
4828
|
|
4934
4829
|
// src/rules/strict-id-in-types/index.ts
|
4935
|
-
import { Kind as
|
4936
|
-
var RULE_ID22 = "strict-id-in-types",
|
4830
|
+
import { Kind as Kind22 } from "graphql";
|
4831
|
+
var RULE_ID22 = "strict-id-in-types", schema15 = {
|
4937
4832
|
type: "array",
|
4938
4833
|
maxItems: 1,
|
4939
4834
|
items: {
|
@@ -5041,7 +4936,7 @@ var RULE_ID22 = "strict-id-in-types", schema14 = {
|
|
5041
4936
|
}
|
5042
4937
|
]
|
5043
4938
|
},
|
5044
|
-
schema:
|
4939
|
+
schema: schema15
|
5045
4940
|
},
|
5046
4941
|
create(context) {
|
5047
4942
|
let options = {
|
@@ -5049,19 +4944,19 @@ var RULE_ID22 = "strict-id-in-types", schema14 = {
|
|
5049
4944
|
acceptedIdTypes: ["ID"],
|
5050
4945
|
exceptions: {},
|
5051
4946
|
...context.options[0]
|
5052
|
-
},
|
4947
|
+
}, schema16 = requireGraphQLSchema(RULE_ID22, context);
|
5053
4948
|
return {
|
5054
4949
|
[`ObjectTypeDefinition[name.value!=/^(${[
|
5055
|
-
|
5056
|
-
|
5057
|
-
|
4950
|
+
schema16.getQueryType(),
|
4951
|
+
schema16.getMutationType(),
|
4952
|
+
schema16.getSubscriptionType()
|
5058
4953
|
].filter(truthy).map((type) => type.name).join("|")})$/]`](node) {
|
5059
4954
|
let typeName = node.name.value;
|
5060
4955
|
if (options.exceptions.types?.includes(typeName) || options.exceptions.suffixes?.some((suffix) => typeName.endsWith(suffix)))
|
5061
4956
|
return;
|
5062
4957
|
if (node.fields?.filter((field) => {
|
5063
4958
|
let fieldNode = field.rawNode(), isValidIdName = options.acceptedIdNames.includes(fieldNode.name.value), isValidIdType = !1;
|
5064
|
-
return fieldNode.type.kind ===
|
4959
|
+
return fieldNode.type.kind === Kind22.NON_NULL_TYPE && fieldNode.type.type.kind === Kind22.NAMED_TYPE && (isValidIdType = options.acceptedIdTypes.includes(fieldNode.type.type.name.value)), isValidIdName && isValidIdType;
|
5065
4960
|
})?.length !== 1) {
|
5066
4961
|
let pluralNamesSuffix = options.acceptedIdNames.length > 1 ? "s" : "", pluralTypesSuffix = options.acceptedIdTypes.length > 1 ? "s" : "";
|
5067
4962
|
context.report({
|
@@ -5077,7 +4972,7 @@ Accepted type${pluralTypesSuffix}: ${englishJoinWords(options.acceptedIdTypes)}.
|
|
5077
4972
|
};
|
5078
4973
|
|
5079
4974
|
// src/rules/unique-enum-value-names/index.ts
|
5080
|
-
import { Kind as
|
4975
|
+
import { Kind as Kind23 } from "graphql";
|
5081
4976
|
var rule32 = {
|
5082
4977
|
meta: {
|
5083
4978
|
type: "suggestion",
|
@@ -5121,7 +5016,7 @@ var rule32 = {
|
|
5121
5016
|
},
|
5122
5017
|
create(context) {
|
5123
5018
|
return {
|
5124
|
-
[[
|
5019
|
+
[[Kind23.ENUM_TYPE_DEFINITION, Kind23.ENUM_TYPE_EXTENSION].join(",")](node) {
|
5125
5020
|
let duplicates = node.values?.filter(
|
5126
5021
|
(item, index, array) => array.findIndex((v) => v.name.value.toLowerCase() === item.name.value.toLowerCase()) !== index
|
5127
5022
|
);
|
@@ -5147,9 +5042,9 @@ var rule32 = {
|
|
5147
5042
|
|
5148
5043
|
// src/rules/unique-fragment-name/index.ts
|
5149
5044
|
import { relative as relative2 } from "node:path";
|
5150
|
-
import { Kind as
|
5045
|
+
import { Kind as Kind24 } from "graphql";
|
5151
5046
|
var RULE_ID23 = "unique-fragment-name", checkNode = (context, node, ruleId) => {
|
5152
|
-
let documentName = node.name.value, siblings =
|
5047
|
+
let documentName = node.name.value, siblings = requireGraphQLOperations(ruleId, context), siblingDocuments = node.kind === Kind24.FRAGMENT_DEFINITION ? siblings.getFragment(documentName) : siblings.getOperation(documentName), filepath = context.filename, conflictingDocuments = siblingDocuments.filter((f) => {
|
5153
5048
|
let isSameName = f.document.name?.value === documentName, isSamePath = slash(f.filePath) === slash(filepath);
|
5154
5049
|
return isSameName && !isSamePath;
|
5155
5050
|
});
|
@@ -5337,32 +5232,222 @@ var rules = {
|
|
5337
5232
|
"unique-operation-name": rule34
|
5338
5233
|
};
|
5339
5234
|
|
5235
|
+
// src/configs/operations-all.ts
|
5236
|
+
var operations_all_default = {
|
5237
|
+
extends: "./configs/operations-recommended",
|
5238
|
+
rules: {
|
5239
|
+
"@graphql-eslint/alphabetize": [
|
5240
|
+
"error",
|
5241
|
+
{
|
5242
|
+
definitions: !0,
|
5243
|
+
selections: ["OperationDefinition", "FragmentDefinition"],
|
5244
|
+
variables: !0,
|
5245
|
+
arguments: ["Field", "Directive"],
|
5246
|
+
groups: ["...", "id", "*", "{"]
|
5247
|
+
}
|
5248
|
+
],
|
5249
|
+
"@graphql-eslint/lone-executable-definition": "error",
|
5250
|
+
"@graphql-eslint/match-document-filename": [
|
5251
|
+
"error",
|
5252
|
+
{
|
5253
|
+
query: "kebab-case",
|
5254
|
+
mutation: "kebab-case",
|
5255
|
+
subscription: "kebab-case",
|
5256
|
+
fragment: "kebab-case"
|
5257
|
+
}
|
5258
|
+
],
|
5259
|
+
"@graphql-eslint/no-one-place-fragments": "error",
|
5260
|
+
"@graphql-eslint/require-import-fragment": "error"
|
5261
|
+
}
|
5262
|
+
};
|
5263
|
+
|
5264
|
+
// src/configs/operations-recommended.ts
|
5265
|
+
var operations_recommended_default = {
|
5266
|
+
parser: "@graphql-eslint/eslint-plugin",
|
5267
|
+
plugins: ["@graphql-eslint"],
|
5268
|
+
rules: {
|
5269
|
+
"@graphql-eslint/executable-definitions": "error",
|
5270
|
+
"@graphql-eslint/fields-on-correct-type": "error",
|
5271
|
+
"@graphql-eslint/fragments-on-composite-type": "error",
|
5272
|
+
"@graphql-eslint/known-argument-names": "error",
|
5273
|
+
"@graphql-eslint/known-directives": "error",
|
5274
|
+
"@graphql-eslint/known-fragment-names": "error",
|
5275
|
+
"@graphql-eslint/known-type-names": "error",
|
5276
|
+
"@graphql-eslint/lone-anonymous-operation": "error",
|
5277
|
+
"@graphql-eslint/naming-convention": [
|
5278
|
+
"error",
|
5279
|
+
{
|
5280
|
+
VariableDefinition: "camelCase",
|
5281
|
+
OperationDefinition: {
|
5282
|
+
style: "PascalCase",
|
5283
|
+
forbiddenPrefixes: ["Query", "Mutation", "Subscription", "Get"],
|
5284
|
+
forbiddenSuffixes: ["Query", "Mutation", "Subscription"]
|
5285
|
+
},
|
5286
|
+
FragmentDefinition: {
|
5287
|
+
style: "PascalCase",
|
5288
|
+
forbiddenPrefixes: ["Fragment"],
|
5289
|
+
forbiddenSuffixes: ["Fragment"]
|
5290
|
+
}
|
5291
|
+
}
|
5292
|
+
],
|
5293
|
+
"@graphql-eslint/no-anonymous-operations": "error",
|
5294
|
+
"@graphql-eslint/no-deprecated": "error",
|
5295
|
+
"@graphql-eslint/no-duplicate-fields": "error",
|
5296
|
+
"@graphql-eslint/no-fragment-cycles": "error",
|
5297
|
+
"@graphql-eslint/no-undefined-variables": "error",
|
5298
|
+
"@graphql-eslint/no-unused-fragments": "error",
|
5299
|
+
"@graphql-eslint/no-unused-variables": "error",
|
5300
|
+
"@graphql-eslint/one-field-subscriptions": "error",
|
5301
|
+
"@graphql-eslint/overlapping-fields-can-be-merged": "error",
|
5302
|
+
"@graphql-eslint/possible-fragment-spread": "error",
|
5303
|
+
"@graphql-eslint/provided-required-arguments": "error",
|
5304
|
+
"@graphql-eslint/require-selections": "error",
|
5305
|
+
"@graphql-eslint/scalar-leafs": "error",
|
5306
|
+
"@graphql-eslint/selection-set-depth": ["error", { maxDepth: 7 }],
|
5307
|
+
"@graphql-eslint/unique-argument-names": "error",
|
5308
|
+
"@graphql-eslint/unique-directive-names-per-location": "error",
|
5309
|
+
"@graphql-eslint/unique-fragment-name": "error",
|
5310
|
+
"@graphql-eslint/unique-input-field-names": "error",
|
5311
|
+
"@graphql-eslint/unique-operation-name": "error",
|
5312
|
+
"@graphql-eslint/unique-variable-names": "error",
|
5313
|
+
"@graphql-eslint/value-literals-of-correct-type": "error",
|
5314
|
+
"@graphql-eslint/variables-are-input-types": "error",
|
5315
|
+
"@graphql-eslint/variables-in-allowed-position": "error"
|
5316
|
+
}
|
5317
|
+
};
|
5318
|
+
|
5319
|
+
// src/configs/schema-all.ts
|
5320
|
+
var schema_all_default = {
|
5321
|
+
extends: "./configs/schema-recommended",
|
5322
|
+
rules: {
|
5323
|
+
"@graphql-eslint/alphabetize": [
|
5324
|
+
"error",
|
5325
|
+
{
|
5326
|
+
definitions: !0,
|
5327
|
+
fields: ["ObjectTypeDefinition", "InterfaceTypeDefinition", "InputObjectTypeDefinition"],
|
5328
|
+
values: !0,
|
5329
|
+
arguments: ["FieldDefinition", "Field", "DirectiveDefinition", "Directive"],
|
5330
|
+
groups: ["id", "*", "createdAt", "updatedAt"]
|
5331
|
+
}
|
5332
|
+
],
|
5333
|
+
"@graphql-eslint/input-name": "error",
|
5334
|
+
"@graphql-eslint/no-root-type": ["error", { disallow: ["mutation", "subscription"] }],
|
5335
|
+
"@graphql-eslint/no-scalar-result-type-on-mutation": "error",
|
5336
|
+
"@graphql-eslint/require-deprecation-date": "error",
|
5337
|
+
"@graphql-eslint/require-field-of-type-query-in-mutation-result": "error",
|
5338
|
+
"@graphql-eslint/require-nullable-fields-with-oneof": "error",
|
5339
|
+
"@graphql-eslint/require-nullable-result-in-root": "error",
|
5340
|
+
"@graphql-eslint/require-type-pattern-with-oneof": "error"
|
5341
|
+
}
|
5342
|
+
};
|
5343
|
+
|
5344
|
+
// src/configs/schema-recommended.ts
|
5345
|
+
var schema_recommended_default = {
|
5346
|
+
parser: "@graphql-eslint/eslint-plugin",
|
5347
|
+
plugins: ["@graphql-eslint"],
|
5348
|
+
rules: {
|
5349
|
+
"@graphql-eslint/description-style": "error",
|
5350
|
+
"@graphql-eslint/known-argument-names": "error",
|
5351
|
+
"@graphql-eslint/known-directives": "error",
|
5352
|
+
"@graphql-eslint/known-type-names": "error",
|
5353
|
+
"@graphql-eslint/lone-schema-definition": "error",
|
5354
|
+
"@graphql-eslint/naming-convention": [
|
5355
|
+
"error",
|
5356
|
+
{
|
5357
|
+
types: "PascalCase",
|
5358
|
+
FieldDefinition: "camelCase",
|
5359
|
+
InputValueDefinition: "camelCase",
|
5360
|
+
Argument: "camelCase",
|
5361
|
+
DirectiveDefinition: "camelCase",
|
5362
|
+
EnumValueDefinition: "UPPER_CASE",
|
5363
|
+
"FieldDefinition[parent.name.value=Query]": {
|
5364
|
+
forbiddenPrefixes: ["query", "get"],
|
5365
|
+
forbiddenSuffixes: ["Query"]
|
5366
|
+
},
|
5367
|
+
"FieldDefinition[parent.name.value=Mutation]": {
|
5368
|
+
forbiddenPrefixes: ["mutation"],
|
5369
|
+
forbiddenSuffixes: ["Mutation"]
|
5370
|
+
},
|
5371
|
+
"FieldDefinition[parent.name.value=Subscription]": {
|
5372
|
+
forbiddenPrefixes: ["subscription"],
|
5373
|
+
forbiddenSuffixes: ["Subscription"]
|
5374
|
+
},
|
5375
|
+
"EnumTypeDefinition,EnumTypeExtension": {
|
5376
|
+
forbiddenPrefixes: ["Enum"],
|
5377
|
+
forbiddenSuffixes: ["Enum"]
|
5378
|
+
},
|
5379
|
+
"InterfaceTypeDefinition,InterfaceTypeExtension": {
|
5380
|
+
forbiddenPrefixes: ["Interface"],
|
5381
|
+
forbiddenSuffixes: ["Interface"]
|
5382
|
+
},
|
5383
|
+
"UnionTypeDefinition,UnionTypeExtension": {
|
5384
|
+
forbiddenPrefixes: ["Union"],
|
5385
|
+
forbiddenSuffixes: ["Union"]
|
5386
|
+
},
|
5387
|
+
"ObjectTypeDefinition,ObjectTypeExtension": {
|
5388
|
+
forbiddenPrefixes: ["Type"],
|
5389
|
+
forbiddenSuffixes: ["Type"]
|
5390
|
+
}
|
5391
|
+
}
|
5392
|
+
],
|
5393
|
+
"@graphql-eslint/no-hashtag-description": "error",
|
5394
|
+
"@graphql-eslint/no-typename-prefix": "error",
|
5395
|
+
"@graphql-eslint/no-unreachable-types": "error",
|
5396
|
+
"@graphql-eslint/possible-type-extension": "error",
|
5397
|
+
"@graphql-eslint/provided-required-arguments": "error",
|
5398
|
+
"@graphql-eslint/require-deprecation-reason": "error",
|
5399
|
+
"@graphql-eslint/require-description": [
|
5400
|
+
"error",
|
5401
|
+
{ types: !0, DirectiveDefinition: !0, rootField: !0 }
|
5402
|
+
],
|
5403
|
+
"@graphql-eslint/strict-id-in-types": "error",
|
5404
|
+
"@graphql-eslint/unique-directive-names": "error",
|
5405
|
+
"@graphql-eslint/unique-directive-names-per-location": "error",
|
5406
|
+
"@graphql-eslint/unique-enum-value-names": "error",
|
5407
|
+
"@graphql-eslint/unique-field-definition-names": "error",
|
5408
|
+
"@graphql-eslint/unique-operation-types": "error",
|
5409
|
+
"@graphql-eslint/unique-type-names": "error"
|
5410
|
+
}
|
5411
|
+
};
|
5412
|
+
|
5413
|
+
// src/configs/schema-relay.ts
|
5414
|
+
var schema_relay_default = {
|
5415
|
+
parser: "@graphql-eslint/eslint-plugin",
|
5416
|
+
plugins: ["@graphql-eslint"],
|
5417
|
+
rules: {
|
5418
|
+
"@graphql-eslint/relay-arguments": "error",
|
5419
|
+
"@graphql-eslint/relay-connection-types": "error",
|
5420
|
+
"@graphql-eslint/relay-edge-types": "error",
|
5421
|
+
"@graphql-eslint/relay-page-info": "error"
|
5422
|
+
}
|
5423
|
+
};
|
5424
|
+
|
5340
5425
|
// src/configs/index.ts
|
5341
|
-
var
|
5342
|
-
"schema-recommended":
|
5343
|
-
"schema-all":
|
5344
|
-
"schema-relay":
|
5345
|
-
"operations-recommended":
|
5346
|
-
"operations-all":
|
5426
|
+
var configs = {
|
5427
|
+
"schema-recommended": schema_recommended_default,
|
5428
|
+
"schema-all": schema_all_default,
|
5429
|
+
"schema-relay": schema_relay_default,
|
5430
|
+
"operations-recommended": operations_recommended_default,
|
5431
|
+
"operations-all": operations_all_default,
|
5347
5432
|
"flat/schema-recommended": {
|
5348
|
-
rules:
|
5433
|
+
rules: schema_recommended_default.rules
|
5349
5434
|
},
|
5350
5435
|
"flat/schema-all": {
|
5351
5436
|
rules: {
|
5352
|
-
...
|
5353
|
-
...
|
5437
|
+
...schema_recommended_default.rules,
|
5438
|
+
...schema_all_default.rules
|
5354
5439
|
}
|
5355
5440
|
},
|
5356
5441
|
"flat/schema-relay": {
|
5357
|
-
rules:
|
5442
|
+
rules: schema_relay_default.rules
|
5358
5443
|
},
|
5359
5444
|
"flat/operations-recommended": {
|
5360
|
-
rules:
|
5445
|
+
rules: operations_recommended_default.rules
|
5361
5446
|
},
|
5362
5447
|
"flat/operations-all": {
|
5363
5448
|
rules: {
|
5364
|
-
...
|
5365
|
-
...
|
5449
|
+
...operations_recommended_default.rules,
|
5450
|
+
...operations_all_default.rules
|
5366
5451
|
}
|
5367
5452
|
}
|
5368
5453
|
};
|