@graphql-eslint/eslint-plugin 4.3.0 → 4.4.0-alpha-20241207210859-41eb4549764dc0314b5bd4f257ea6667b178540e
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 +6 -2
- package/cjs/configs/operations-all.js +2 -2
- package/cjs/configs/schema-all.js +2 -2
- package/cjs/configs/schema-recommended.js +1 -1
- package/cjs/documents.js +13 -7
- package/cjs/estree-converter/converter.js +17 -8
- package/cjs/estree-converter/utils.js +22 -9
- package/cjs/graphql-config.js +13 -6
- package/cjs/index.d.cts +18 -4
- package/cjs/meta.js +1 -1
- package/cjs/parser.js +36 -9
- package/cjs/processor.js +48 -20
- package/cjs/rules/alphabetize/index.js +99 -47
- package/cjs/rules/description-style/index.js +10 -6
- package/cjs/rules/graphql-js-validation.js +142 -108
- package/cjs/rules/index.d.cts +18 -4
- package/cjs/rules/input-name/index.js +51 -38
- package/cjs/rules/lone-executable-definition/index.js +15 -6
- package/cjs/rules/match-document-filename/index.d.cts +4 -3
- package/cjs/rules/match-document-filename/index.js +63 -37
- package/cjs/rules/naming-convention/index.d.cts +6 -10
- package/cjs/rules/naming-convention/index.js +179 -82
- package/cjs/rules/no-anonymous-operations/index.js +8 -5
- package/cjs/rules/no-deprecated/index.js +27 -13
- package/cjs/rules/no-duplicate-fields/index.js +15 -8
- package/cjs/rules/no-hashtag-description/index.js +18 -10
- package/cjs/rules/no-one-place-fragments/index.js +17 -10
- package/cjs/rules/no-root-type/index.js +15 -8
- package/cjs/rules/no-scalar-result-type-on-mutation/index.js +20 -12
- package/cjs/rules/no-typename-prefix/index.js +25 -21
- package/cjs/rules/no-unreachable-types/index.js +34 -17
- package/cjs/rules/no-unused-fields/index.js +56 -30
- package/cjs/rules/relay-arguments/index.js +31 -13
- package/cjs/rules/relay-connection-types/index.js +31 -9
- package/cjs/rules/relay-edge-types/index.js +84 -41
- package/cjs/rules/relay-page-info/index.js +31 -14
- package/cjs/rules/require-deprecation-date/index.js +20 -9
- package/cjs/rules/require-deprecation-reason/index.js +8 -5
- package/cjs/rules/require-description/index.d.cts +79 -13
- package/cjs/rules/require-description/index.js +67 -49
- package/cjs/rules/require-field-of-type-query-in-mutation-result/index.js +21 -10
- package/cjs/rules/require-import-fragment/index.js +20 -11
- package/cjs/rules/require-nullable-fields-with-oneof/index.js +12 -5
- package/cjs/rules/require-nullable-result-in-root/index.js +32 -27
- package/cjs/rules/require-selections/index.js +88 -46
- package/cjs/rules/require-type-pattern-with-oneof/index.js +14 -10
- package/cjs/rules/selection-set-depth/index.js +19 -10
- package/cjs/rules/strict-id-in-types/index.js +32 -19
- package/cjs/rules/unique-enum-value-names/index.js +4 -3
- package/cjs/rules/unique-fragment-name/index.js +25 -18
- package/cjs/rules/unique-operation-name/index.js +5 -5
- package/cjs/schema.js +14 -8
- package/cjs/siblings.js +60 -32
- package/cjs/utils.js +23 -9
- package/esm/cache.js +6 -2
- package/esm/configs/operations-all.js +2 -2
- package/esm/configs/schema-all.js +2 -2
- package/esm/configs/schema-recommended.js +1 -1
- package/esm/documents.js +13 -7
- package/esm/estree-converter/converter.js +17 -8
- package/esm/estree-converter/utils.js +22 -9
- package/esm/graphql-config.js +13 -6
- package/esm/index.d.ts +18 -4
- package/esm/meta.js +1 -1
- package/esm/parser.js +36 -9
- package/esm/processor.js +48 -20
- package/esm/rules/alphabetize/index.js +99 -47
- package/esm/rules/description-style/index.js +10 -6
- package/esm/rules/graphql-js-validation.js +142 -108
- package/esm/rules/index.d.ts +18 -4
- package/esm/rules/input-name/index.js +51 -38
- package/esm/rules/lone-executable-definition/index.js +15 -6
- package/esm/rules/match-document-filename/index.d.ts +4 -3
- package/esm/rules/match-document-filename/index.js +63 -37
- package/esm/rules/naming-convention/index.d.ts +6 -10
- package/esm/rules/naming-convention/index.js +179 -82
- package/esm/rules/no-anonymous-operations/index.js +8 -5
- package/esm/rules/no-deprecated/index.js +27 -13
- package/esm/rules/no-duplicate-fields/index.js +15 -8
- package/esm/rules/no-hashtag-description/index.js +18 -10
- package/esm/rules/no-one-place-fragments/index.js +17 -10
- package/esm/rules/no-root-type/index.js +15 -8
- package/esm/rules/no-scalar-result-type-on-mutation/index.js +20 -12
- package/esm/rules/no-typename-prefix/index.js +25 -21
- package/esm/rules/no-unreachable-types/index.js +34 -17
- package/esm/rules/no-unused-fields/index.js +56 -30
- package/esm/rules/relay-arguments/index.js +31 -13
- package/esm/rules/relay-connection-types/index.js +31 -9
- package/esm/rules/relay-edge-types/index.js +84 -41
- package/esm/rules/relay-page-info/index.js +31 -14
- package/esm/rules/require-deprecation-date/index.js +20 -9
- package/esm/rules/require-deprecation-reason/index.js +8 -5
- package/esm/rules/require-description/index.d.ts +79 -13
- package/esm/rules/require-description/index.js +67 -49
- package/esm/rules/require-field-of-type-query-in-mutation-result/index.js +21 -10
- package/esm/rules/require-import-fragment/index.js +20 -11
- package/esm/rules/require-nullable-fields-with-oneof/index.js +12 -5
- package/esm/rules/require-nullable-result-in-root/index.js +32 -27
- package/esm/rules/require-selections/index.js +88 -46
- package/esm/rules/require-type-pattern-with-oneof/index.js +14 -10
- package/esm/rules/selection-set-depth/index.js +19 -10
- package/esm/rules/strict-id-in-types/index.js +32 -19
- package/esm/rules/unique-enum-value-names/index.js +4 -3
- package/esm/rules/unique-fragment-name/index.js +25 -18
- package/esm/rules/unique-operation-name/index.js +5 -5
- package/esm/schema.js +15 -8
- package/esm/siblings.js +60 -32
- package/esm/utils.js +23 -9
- package/index.browser.js +1871 -1160
- package/package.json +1 -1
@@ -49,61 +49,77 @@ function validateDocument({
|
|
49
49
|
rule,
|
50
50
|
hasDidYouMeanSuggestions
|
51
51
|
}) {
|
52
|
-
if (documentNode.definitions.length
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
return {
|
72
|
-
desc: `Rename to \`${name}\``,
|
73
|
-
fix: (fixer) => fixer.replaceText(token, name)
|
74
|
-
};
|
75
|
-
}) : []
|
76
|
-
});
|
52
|
+
if (documentNode.definitions.length === 0) {
|
53
|
+
return;
|
54
|
+
}
|
55
|
+
try {
|
56
|
+
const validationErrors = schema ? _graphql.validate.call(void 0, schema, documentNode, [rule]) : _validatejs.validateSDL.call(void 0, documentNode, null, [rule]);
|
57
|
+
for (const error of validationErrors) {
|
58
|
+
const { line, column } = error.locations[0];
|
59
|
+
const sourceCode = context.getSourceCode();
|
60
|
+
const { tokens } = sourceCode.ast;
|
61
|
+
const token = tokens.find(
|
62
|
+
(token2) => token2.loc.start.line === line && token2.loc.start.column === column - 1
|
63
|
+
);
|
64
|
+
let loc = {
|
65
|
+
line,
|
66
|
+
column: column - 1
|
67
|
+
};
|
68
|
+
if (token) {
|
69
|
+
loc = // if cursor on `@` symbol than use next node
|
70
|
+
token.type === "@" ? sourceCode.getNodeByRangeIndex(token.range[1] + 1).loc : token.loc;
|
77
71
|
}
|
78
|
-
|
72
|
+
const didYouMeanContent = _optionalChain([error, 'access', _ => _.message, 'access', _2 => _2.match, 'call', _3 => _3(/Did you mean (?<content>.*)\?$/), 'optionalAccess', _4 => _4.groups, 'access', _5 => _5.content]);
|
73
|
+
const matches = didYouMeanContent ? [...didYouMeanContent.matchAll(/"(?<name>[^"]*)"/g)] : [];
|
79
74
|
context.report({
|
80
|
-
loc
|
81
|
-
message: error.message
|
75
|
+
loc,
|
76
|
+
message: error.message,
|
77
|
+
suggest: hasDidYouMeanSuggestions ? matches.map((match) => {
|
78
|
+
const { name } = match.groups;
|
79
|
+
return {
|
80
|
+
desc: `Rename to \`${name}\``,
|
81
|
+
fix: (fixer) => fixer.replaceText(token, name)
|
82
|
+
};
|
83
|
+
}) : []
|
82
84
|
});
|
83
85
|
}
|
86
|
+
} catch (error) {
|
87
|
+
context.report({
|
88
|
+
loc: _utilsjs.REPORT_ON_FIRST_CHARACTER,
|
89
|
+
message: error.message
|
90
|
+
});
|
91
|
+
}
|
84
92
|
}
|
85
93
|
const getFragmentDefsAndFragmentSpreads = (node) => {
|
86
|
-
const fragmentDefs = /* @__PURE__ */ new Set()
|
87
|
-
|
94
|
+
const fragmentDefs = /* @__PURE__ */ new Set();
|
95
|
+
const fragmentSpreads = /* @__PURE__ */ new Set();
|
96
|
+
const visitor = {
|
88
97
|
FragmentDefinition(node2) {
|
89
98
|
fragmentDefs.add(node2.name.value);
|
90
99
|
},
|
91
100
|
FragmentSpread(node2) {
|
92
101
|
fragmentSpreads.add(node2.name.value);
|
93
102
|
}
|
94
|
-
}
|
95
|
-
|
103
|
+
};
|
104
|
+
_graphql.visit.call(void 0, node, visitor);
|
105
|
+
return { fragmentDefs, fragmentSpreads };
|
106
|
+
};
|
107
|
+
const getMissingFragments = (node) => {
|
96
108
|
const { fragmentDefs, fragmentSpreads } = getFragmentDefsAndFragmentSpreads(node);
|
97
109
|
return [...fragmentSpreads].filter((name) => !fragmentDefs.has(name));
|
98
|
-
}
|
110
|
+
};
|
111
|
+
const handleMissingFragments = ({ ruleId, context, node }) => {
|
99
112
|
const missingFragments = getMissingFragments(node);
|
100
113
|
if (missingFragments.length > 0) {
|
101
|
-
const siblings = _utilsjs.requireGraphQLOperations.call(void 0, ruleId, context)
|
114
|
+
const siblings = _utilsjs.requireGraphQLOperations.call(void 0, ruleId, context);
|
115
|
+
const fragmentsToAdd = [];
|
102
116
|
for (const fragmentName of missingFragments) {
|
103
117
|
const [foundFragment] = siblings.getFragment(fragmentName).map((source) => source.document);
|
104
|
-
|
118
|
+
if (foundFragment) {
|
119
|
+
fragmentsToAdd.push(foundFragment);
|
120
|
+
}
|
105
121
|
}
|
106
|
-
if (fragmentsToAdd.length > 0)
|
122
|
+
if (fragmentsToAdd.length > 0) {
|
107
123
|
return handleMissingFragments({
|
108
124
|
ruleId,
|
109
125
|
context,
|
@@ -112,44 +128,50 @@ const getFragmentDefsAndFragmentSpreads = (node) => {
|
|
112
128
|
definitions: [...node.definitions, ...fragmentsToAdd]
|
113
129
|
}
|
114
130
|
});
|
131
|
+
}
|
115
132
|
}
|
116
133
|
return node;
|
117
|
-
}
|
134
|
+
};
|
135
|
+
const validationToRule = ({
|
118
136
|
ruleId,
|
119
137
|
rule,
|
120
138
|
getDocumentNode,
|
121
139
|
schema = [],
|
122
140
|
hasDidYouMeanSuggestions
|
123
|
-
}, docs) =>
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
141
|
+
}, docs) => {
|
142
|
+
return {
|
143
|
+
[ruleId]: {
|
144
|
+
meta: {
|
145
|
+
docs: {
|
146
|
+
recommended: true,
|
147
|
+
...docs,
|
148
|
+
graphQLJSRuleName: rule.name,
|
149
|
+
url: `https://the-guild.dev/graphql/eslint/rules/${ruleId}`,
|
150
|
+
description: `${docs.description}
|
132
151
|
> This rule is a wrapper around a \`graphql-js\` validation function.`
|
152
|
+
},
|
153
|
+
schema,
|
154
|
+
hasSuggestions: hasDidYouMeanSuggestions
|
133
155
|
},
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
};
|
156
|
+
create(context) {
|
157
|
+
return {
|
158
|
+
Document(node) {
|
159
|
+
const schema2 = docs.requiresSchema ? _utilsjs.requireGraphQLSchema.call(void 0, ruleId, context) : null;
|
160
|
+
const documentNode = getDocumentNode ? getDocumentNode({ ruleId, context, node: node.rawNode() }) : node.rawNode();
|
161
|
+
validateDocument({
|
162
|
+
context,
|
163
|
+
schema: schema2,
|
164
|
+
documentNode,
|
165
|
+
rule,
|
166
|
+
hasDidYouMeanSuggestions
|
167
|
+
});
|
168
|
+
}
|
169
|
+
};
|
170
|
+
}
|
150
171
|
}
|
151
|
-
}
|
152
|
-
}
|
172
|
+
};
|
173
|
+
};
|
174
|
+
const GRAPHQL_JS_VALIDATIONS = Object.assign(
|
153
175
|
{},
|
154
176
|
validationToRule(
|
155
177
|
{
|
@@ -159,19 +181,19 @@ const getFragmentDefsAndFragmentSpreads = (node) => {
|
|
159
181
|
{
|
160
182
|
category: "Operations",
|
161
183
|
description: "A GraphQL document is only valid for execution if all definitions are either operation or fragment definitions.",
|
162
|
-
requiresSchema:
|
184
|
+
requiresSchema: true
|
163
185
|
}
|
164
186
|
),
|
165
187
|
validationToRule(
|
166
188
|
{
|
167
189
|
ruleId: "fields-on-correct-type",
|
168
190
|
rule: _indexjs.FieldsOnCorrectTypeRule,
|
169
|
-
hasDidYouMeanSuggestions:
|
191
|
+
hasDidYouMeanSuggestions: true
|
170
192
|
},
|
171
193
|
{
|
172
194
|
category: "Operations",
|
173
195
|
description: "A GraphQL document is only valid if all fields selected are defined by the parent type, or are an allowed meta field such as `__typename`.",
|
174
|
-
requiresSchema:
|
196
|
+
requiresSchema: true
|
175
197
|
}
|
176
198
|
),
|
177
199
|
validationToRule(
|
@@ -182,19 +204,19 @@ const getFragmentDefsAndFragmentSpreads = (node) => {
|
|
182
204
|
{
|
183
205
|
category: "Operations",
|
184
206
|
description: "Fragments use a type condition to determine if they apply, since fragments can only be spread into a composite type (object, interface, or union), the type condition must also be a composite type.",
|
185
|
-
requiresSchema:
|
207
|
+
requiresSchema: true
|
186
208
|
}
|
187
209
|
),
|
188
210
|
validationToRule(
|
189
211
|
{
|
190
212
|
ruleId: "known-argument-names",
|
191
213
|
rule: _indexjs.KnownArgumentNamesRule,
|
192
|
-
hasDidYouMeanSuggestions:
|
214
|
+
hasDidYouMeanSuggestions: true
|
193
215
|
},
|
194
216
|
{
|
195
217
|
category: ["Schema", "Operations"],
|
196
218
|
description: "A GraphQL field is only valid if all supplied arguments are defined by that field.",
|
197
|
-
requiresSchema:
|
219
|
+
requiresSchema: true
|
198
220
|
}
|
199
221
|
),
|
200
222
|
validationToRule(
|
@@ -203,8 +225,9 @@ const getFragmentDefsAndFragmentSpreads = (node) => {
|
|
203
225
|
rule: _indexjs.KnownDirectivesRule,
|
204
226
|
getDocumentNode({ context, node: documentNode }) {
|
205
227
|
const { ignoreClientDirectives = [] } = context.options[0] || {};
|
206
|
-
if (ignoreClientDirectives.length === 0)
|
228
|
+
if (ignoreClientDirectives.length === 0) {
|
207
229
|
return documentNode;
|
230
|
+
}
|
208
231
|
const filterDirectives = (node) => ({
|
209
232
|
...node,
|
210
233
|
directives: _optionalChain([node, 'access', _6 => _6.directives, 'optionalAccess', _7 => _7.filter, 'call', _8 => _8(
|
@@ -221,7 +244,7 @@ const getFragmentDefsAndFragmentSpreads = (node) => {
|
|
221
244
|
maxItems: 1,
|
222
245
|
items: {
|
223
246
|
type: "object",
|
224
|
-
additionalProperties:
|
247
|
+
additionalProperties: false,
|
225
248
|
required: ["ignoreClientDirectives"],
|
226
249
|
properties: {
|
227
250
|
ignoreClientDirectives: _utilsjs.ARRAY_DEFAULT_OPTIONS
|
@@ -232,7 +255,7 @@ const getFragmentDefsAndFragmentSpreads = (node) => {
|
|
232
255
|
{
|
233
256
|
category: ["Schema", "Operations"],
|
234
257
|
description: "A GraphQL document is only valid if all `@directive`s are known by the schema and legally positioned.",
|
235
|
-
requiresSchema:
|
258
|
+
requiresSchema: true,
|
236
259
|
examples: [
|
237
260
|
{
|
238
261
|
title: "Valid",
|
@@ -260,8 +283,8 @@ const getFragmentDefsAndFragmentSpreads = (node) => {
|
|
260
283
|
{
|
261
284
|
category: "Operations",
|
262
285
|
description: "A GraphQL document is only valid if all `...Fragment` fragment spreads refer to fragments defined in the same document.",
|
263
|
-
requiresSchema:
|
264
|
-
requiresSiblings:
|
286
|
+
requiresSchema: true,
|
287
|
+
requiresSiblings: true,
|
265
288
|
examples: [
|
266
289
|
{
|
267
290
|
title: "Incorrect",
|
@@ -323,12 +346,12 @@ const getFragmentDefsAndFragmentSpreads = (node) => {
|
|
323
346
|
{
|
324
347
|
ruleId: "known-type-names",
|
325
348
|
rule: _indexjs.KnownTypeNamesRule,
|
326
|
-
hasDidYouMeanSuggestions:
|
349
|
+
hasDidYouMeanSuggestions: true
|
327
350
|
},
|
328
351
|
{
|
329
352
|
category: ["Schema", "Operations"],
|
330
353
|
description: "A GraphQL document is only valid if referenced types (specifically variable definitions and fragment conditions) are defined by the type schema.",
|
331
|
-
requiresSchema:
|
354
|
+
requiresSchema: true
|
332
355
|
}
|
333
356
|
),
|
334
357
|
validationToRule(
|
@@ -339,7 +362,7 @@ const getFragmentDefsAndFragmentSpreads = (node) => {
|
|
339
362
|
{
|
340
363
|
category: "Operations",
|
341
364
|
description: "A GraphQL document that contains an anonymous operation (the `query` short-hand) is only valid if it contains only that one operation definition.",
|
342
|
-
requiresSchema:
|
365
|
+
requiresSchema: true
|
343
366
|
}
|
344
367
|
),
|
345
368
|
validationToRule(
|
@@ -360,7 +383,7 @@ const getFragmentDefsAndFragmentSpreads = (node) => {
|
|
360
383
|
{
|
361
384
|
category: "Operations",
|
362
385
|
description: "A GraphQL fragment is only valid when it does not have cycles in fragments usage.",
|
363
|
-
requiresSchema:
|
386
|
+
requiresSchema: true
|
364
387
|
}
|
365
388
|
),
|
366
389
|
validationToRule(
|
@@ -372,8 +395,8 @@ const getFragmentDefsAndFragmentSpreads = (node) => {
|
|
372
395
|
{
|
373
396
|
category: "Operations",
|
374
397
|
description: "A GraphQL operation is only valid if all variables encountered, both directly and via fragment spreads, are defined by that operation.",
|
375
|
-
requiresSchema:
|
376
|
-
requiresSiblings:
|
398
|
+
requiresSchema: true,
|
399
|
+
requiresSiblings: true
|
377
400
|
}
|
378
401
|
),
|
379
402
|
validationToRule(
|
@@ -381,25 +404,36 @@ const getFragmentDefsAndFragmentSpreads = (node) => {
|
|
381
404
|
ruleId: "no-unused-fragments",
|
382
405
|
rule: _indexjs.NoUnusedFragmentsRule,
|
383
406
|
getDocumentNode: ({ ruleId, context, node }) => {
|
384
|
-
const siblings = _utilsjs.requireGraphQLOperations.call(void 0, ruleId, context)
|
407
|
+
const siblings = _utilsjs.requireGraphQLOperations.call(void 0, ruleId, context);
|
408
|
+
const FilePathToDocumentsMap = [
|
385
409
|
...siblings.getOperations(),
|
386
410
|
...siblings.getFragments()
|
387
|
-
].reduce((map, { filePath, document }) =>
|
411
|
+
].reduce((map, { filePath, document }) => {
|
412
|
+
map[filePath] ??= [];
|
413
|
+
map[filePath].push(document);
|
414
|
+
return map;
|
415
|
+
}, /* @__PURE__ */ Object.create(null));
|
416
|
+
const getParentNode = (currentFilePath, node2) => {
|
388
417
|
const { fragmentDefs } = getFragmentDefsAndFragmentSpreads(node2);
|
389
|
-
if (fragmentDefs.size === 0)
|
418
|
+
if (fragmentDefs.size === 0) {
|
390
419
|
return node2;
|
420
|
+
}
|
391
421
|
delete FilePathToDocumentsMap[currentFilePath];
|
392
|
-
for (const [filePath, documents] of Object.entries(FilePathToDocumentsMap))
|
393
|
-
|
422
|
+
for (const [filePath, documents] of Object.entries(FilePathToDocumentsMap)) {
|
423
|
+
const missingFragments = getMissingFragments({
|
394
424
|
kind: _graphql.Kind.DOCUMENT,
|
395
425
|
definitions: documents
|
396
|
-
})
|
426
|
+
});
|
427
|
+
const isCurrentFileImportFragment = missingFragments.some(
|
397
428
|
(fragment) => fragmentDefs.has(fragment)
|
398
|
-
)
|
429
|
+
);
|
430
|
+
if (isCurrentFileImportFragment) {
|
399
431
|
return getParentNode(filePath, {
|
400
432
|
kind: _graphql.Kind.DOCUMENT,
|
401
433
|
definitions: [...node2.definitions, ...documents]
|
402
434
|
});
|
435
|
+
}
|
436
|
+
}
|
403
437
|
return node2;
|
404
438
|
};
|
405
439
|
return getParentNode(context.filename, node);
|
@@ -408,8 +442,8 @@ const getFragmentDefsAndFragmentSpreads = (node) => {
|
|
408
442
|
{
|
409
443
|
category: "Operations",
|
410
444
|
description: "A GraphQL document is only valid if all fragment definitions are spread within operations, or spread within other fragments spread within operations.",
|
411
|
-
requiresSchema:
|
412
|
-
requiresSiblings:
|
445
|
+
requiresSchema: true,
|
446
|
+
requiresSiblings: true
|
413
447
|
}
|
414
448
|
),
|
415
449
|
validationToRule(
|
@@ -421,8 +455,8 @@ const getFragmentDefsAndFragmentSpreads = (node) => {
|
|
421
455
|
{
|
422
456
|
category: "Operations",
|
423
457
|
description: "A GraphQL operation is only valid if all variables defined by an operation are used, either directly or within a spread fragment.",
|
424
|
-
requiresSchema:
|
425
|
-
requiresSiblings:
|
458
|
+
requiresSchema: true,
|
459
|
+
requiresSiblings: true
|
426
460
|
}
|
427
461
|
),
|
428
462
|
validationToRule(
|
@@ -433,7 +467,7 @@ const getFragmentDefsAndFragmentSpreads = (node) => {
|
|
433
467
|
{
|
434
468
|
category: "Operations",
|
435
469
|
description: "A selection set is only valid if all fields (including spreading any fragments) either correspond to distinct response names or can be merged without ambiguity.",
|
436
|
-
requiresSchema:
|
470
|
+
requiresSchema: true
|
437
471
|
}
|
438
472
|
),
|
439
473
|
validationToRule(
|
@@ -444,20 +478,20 @@ const getFragmentDefsAndFragmentSpreads = (node) => {
|
|
444
478
|
{
|
445
479
|
category: "Operations",
|
446
480
|
description: "A fragment spread is only valid if the type condition could ever possibly be true: if there is a non-empty intersection of the possible parent types, and possible types which pass the type condition.",
|
447
|
-
requiresSchema:
|
481
|
+
requiresSchema: true
|
448
482
|
}
|
449
483
|
),
|
450
484
|
validationToRule(
|
451
485
|
{
|
452
486
|
ruleId: "possible-type-extension",
|
453
487
|
rule: _indexjs.PossibleTypeExtensionsRule,
|
454
|
-
hasDidYouMeanSuggestions:
|
488
|
+
hasDidYouMeanSuggestions: true
|
455
489
|
},
|
456
490
|
{
|
457
491
|
category: "Schema",
|
458
492
|
description: "A type extension is only valid if the type is defined and has the same kind.",
|
459
|
-
recommended:
|
460
|
-
requiresSchema:
|
493
|
+
recommended: true,
|
494
|
+
requiresSchema: true
|
461
495
|
}
|
462
496
|
),
|
463
497
|
validationToRule(
|
@@ -468,19 +502,19 @@ const getFragmentDefsAndFragmentSpreads = (node) => {
|
|
468
502
|
{
|
469
503
|
category: ["Schema", "Operations"],
|
470
504
|
description: "A field or directive is only valid if all required (non-null without a default value) field arguments have been provided.",
|
471
|
-
requiresSchema:
|
505
|
+
requiresSchema: true
|
472
506
|
}
|
473
507
|
),
|
474
508
|
validationToRule(
|
475
509
|
{
|
476
510
|
ruleId: "scalar-leafs",
|
477
511
|
rule: _indexjs.ScalarLeafsRule,
|
478
|
-
hasDidYouMeanSuggestions:
|
512
|
+
hasDidYouMeanSuggestions: true
|
479
513
|
},
|
480
514
|
{
|
481
515
|
category: "Operations",
|
482
516
|
description: "A GraphQL document is valid only if all leaf fields (fields without sub selections) are of scalar or enum types.",
|
483
|
-
requiresSchema:
|
517
|
+
requiresSchema: true
|
484
518
|
}
|
485
519
|
),
|
486
520
|
validationToRule(
|
@@ -491,7 +525,7 @@ const getFragmentDefsAndFragmentSpreads = (node) => {
|
|
491
525
|
{
|
492
526
|
category: "Operations",
|
493
527
|
description: "A GraphQL subscription is valid only if it contains a single root field.",
|
494
|
-
requiresSchema:
|
528
|
+
requiresSchema: true
|
495
529
|
}
|
496
530
|
),
|
497
531
|
validationToRule(
|
@@ -502,7 +536,7 @@ const getFragmentDefsAndFragmentSpreads = (node) => {
|
|
502
536
|
{
|
503
537
|
category: "Operations",
|
504
538
|
description: "A GraphQL field or directive is only valid if all supplied arguments are uniquely named.",
|
505
|
-
requiresSchema:
|
539
|
+
requiresSchema: true
|
506
540
|
}
|
507
541
|
),
|
508
542
|
validationToRule(
|
@@ -523,7 +557,7 @@ const getFragmentDefsAndFragmentSpreads = (node) => {
|
|
523
557
|
{
|
524
558
|
category: ["Schema", "Operations"],
|
525
559
|
description: "A GraphQL document is only valid if all non-repeatable directives at a given location are uniquely named.",
|
526
|
-
requiresSchema:
|
560
|
+
requiresSchema: true
|
527
561
|
}
|
528
562
|
),
|
529
563
|
validationToRule(
|
@@ -574,19 +608,19 @@ const getFragmentDefsAndFragmentSpreads = (node) => {
|
|
574
608
|
{
|
575
609
|
category: "Operations",
|
576
610
|
description: "A GraphQL operation is only valid if all its variables are uniquely named.",
|
577
|
-
requiresSchema:
|
611
|
+
requiresSchema: true
|
578
612
|
}
|
579
613
|
),
|
580
614
|
validationToRule(
|
581
615
|
{
|
582
616
|
ruleId: "value-literals-of-correct-type",
|
583
617
|
rule: _indexjs.ValuesOfCorrectTypeRule,
|
584
|
-
hasDidYouMeanSuggestions:
|
618
|
+
hasDidYouMeanSuggestions: true
|
585
619
|
},
|
586
620
|
{
|
587
621
|
category: "Operations",
|
588
622
|
description: "A GraphQL document is only valid if all value literals are of the type expected at their position.",
|
589
|
-
requiresSchema:
|
623
|
+
requiresSchema: true
|
590
624
|
}
|
591
625
|
),
|
592
626
|
validationToRule(
|
@@ -597,7 +631,7 @@ const getFragmentDefsAndFragmentSpreads = (node) => {
|
|
597
631
|
{
|
598
632
|
category: "Operations",
|
599
633
|
description: "A GraphQL operation is only valid if all the variables it defines are of input types (scalar, enum, or input object).",
|
600
|
-
requiresSchema:
|
634
|
+
requiresSchema: true
|
601
635
|
}
|
602
636
|
),
|
603
637
|
validationToRule(
|
@@ -608,7 +642,7 @@ const getFragmentDefsAndFragmentSpreads = (node) => {
|
|
608
642
|
{
|
609
643
|
category: "Operations",
|
610
644
|
description: "Variables passed to field arguments conform to type.",
|
611
|
-
requiresSchema:
|
645
|
+
requiresSchema: true
|
612
646
|
}
|
613
647
|
)
|
614
648
|
);
|
package/cjs/rules/index.d.cts
CHANGED
@@ -1,4 +1,3 @@
|
|
1
|
-
import { RuleOptions } from './require-description/index.cjs';
|
2
1
|
import { CaseStyle } from '../utils.cjs';
|
3
2
|
import * as graphql from 'graphql';
|
4
3
|
import { GraphQLESLintRule } from '../types.cjs';
|
@@ -64,9 +63,9 @@ declare const rules: {
|
|
64
63
|
forbiddenPatterns?: {
|
65
64
|
[x: string]: unknown;
|
66
65
|
}[] | undefined;
|
67
|
-
|
66
|
+
requiredPattern?: {
|
68
67
|
[x: string]: unknown;
|
69
|
-
}
|
68
|
+
} | undefined;
|
70
69
|
forbiddenPrefixes?: string[] | undefined;
|
71
70
|
forbiddenSuffixes?: string[] | undefined;
|
72
71
|
requiredPrefixes?: string[] | undefined;
|
@@ -104,7 +103,22 @@ declare const rules: {
|
|
104
103
|
argumentName?: string | undefined;
|
105
104
|
}[]>;
|
106
105
|
'require-deprecation-reason': GraphQLESLintRule;
|
107
|
-
'require-description': GraphQLESLintRule<
|
106
|
+
'require-description': GraphQLESLintRule<{
|
107
|
+
types?: true | undefined;
|
108
|
+
OperationDefinition?: boolean | undefined;
|
109
|
+
ScalarTypeDefinition?: boolean | undefined;
|
110
|
+
ObjectTypeDefinition?: boolean | undefined;
|
111
|
+
FieldDefinition?: boolean | undefined;
|
112
|
+
InputValueDefinition?: boolean | undefined;
|
113
|
+
InterfaceTypeDefinition?: boolean | undefined;
|
114
|
+
UnionTypeDefinition?: boolean | undefined;
|
115
|
+
EnumTypeDefinition?: boolean | undefined;
|
116
|
+
EnumValueDefinition?: boolean | undefined;
|
117
|
+
InputObjectTypeDefinition?: boolean | undefined;
|
118
|
+
DirectiveDefinition?: boolean | undefined;
|
119
|
+
rootField?: true | undefined;
|
120
|
+
ignoredSelectors?: string[] | undefined;
|
121
|
+
}[]>;
|
108
122
|
'require-field-of-type-query-in-mutation-result': GraphQLESLintRule;
|
109
123
|
'require-import-fragment': GraphQLESLintRule;
|
110
124
|
'require-nullable-fields-with-oneof': GraphQLESLintRule;
|