@graphql-eslint/eslint-plugin 3.14.0-alpha-20221220004723-85c2e50 → 3.14.0-alpha-20221220171818-aa4bda7
Sign up to get free protection for your applications and to get access to all the features.
- package/configs/operations-all.json +1 -0
- package/index.js +619 -469
- package/index.mjs +620 -470
- package/package.json +1 -1
- package/rules/alphabetize.d.ts +65 -14
- package/rules/description-style.d.ts +18 -4
- package/rules/index.d.ts +80 -18
- package/rules/input-name.d.ts +33 -7
- package/rules/lone-executable-definition.d.ts +26 -0
- package/rules/match-document-filename.d.ts +68 -13
- package/rules/naming-convention.d.ts +80 -34
- package/rules/no-anonymous-operations.d.ts +1 -2
- package/rules/no-case-insensitive-enum-values-duplicates.d.ts +1 -2
- package/rules/no-deprecated.d.ts +1 -2
- package/rules/no-duplicate-fields.d.ts +1 -2
- package/rules/no-hashtag-description.d.ts +1 -2
- package/rules/no-root-type.d.ts +23 -5
- package/rules/no-scalar-result-type-on-mutation.d.ts +1 -2
- package/rules/no-typename-prefix.d.ts +1 -2
- package/rules/no-unreachable-types.d.ts +1 -2
- package/rules/no-unused-fields.d.ts +1 -2
- package/rules/relay-arguments.d.ts +19 -4
- package/rules/relay-connection-types.d.ts +1 -2
- package/rules/relay-edge-types.d.ts +29 -6
- package/rules/relay-page-info.d.ts +1 -2
- package/rules/require-deprecation-date.d.ts +17 -4
- package/rules/require-deprecation-reason.d.ts +1 -2
- package/rules/require-description.d.ts +10 -7
- package/rules/require-field-of-type-query-in-mutation-result.d.ts +1 -2
- package/rules/require-id-when-available.d.ts +34 -4
- package/rules/selection-set-depth.d.ts +26 -5
- package/rules/strict-id-in-types.d.ts +54 -8
- package/rules/unique-fragment-name.d.ts +1 -2
- package/rules/unique-operation-name.d.ts +1 -2
- package/testkit.d.ts +1 -1
- package/types.d.ts +3 -1
- package/utils.d.ts +1 -0
package/index.mjs
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
import { gqlPluckFromCodeStringSync } from '@graphql-tools/graphql-tag-pluck';
|
2
|
-
import { asArray, getDocumentNodeFromSchema, parseGraphQLSDL } from '@graphql-tools/utils';
|
2
|
+
import { asArray, getDocumentNodeFromSchema, getRootTypeNames, parseGraphQLSDL } from '@graphql-tools/utils';
|
3
3
|
import { dirname, extname, basename, relative, resolve } from 'path';
|
4
4
|
import debugFactory from 'debug';
|
5
5
|
import { loadConfigSync, GraphQLConfig } from 'graphql-config';
|
@@ -328,7 +328,7 @@ const validationToRule = ({ ruleId, ruleName, getDocumentNode, schema = [], hasD
|
|
328
328
|
...docs,
|
329
329
|
graphQLJSRuleName: ruleName,
|
330
330
|
url: `https://github.com/B2o5T/graphql-eslint/blob/master/docs/rules/${ruleId}.md`,
|
331
|
-
description: `${docs.description}\n
|
331
|
+
description: `${docs.description}\n> This rule is a wrapper around a \`graphql-js\` validation function.`,
|
332
332
|
},
|
333
333
|
schema,
|
334
334
|
hasSuggestions: hasDidYouMeanSuggestions,
|
@@ -727,6 +727,58 @@ const argumentsEnum = [
|
|
727
727
|
Kind.DIRECTIVE_DEFINITION,
|
728
728
|
Kind.DIRECTIVE,
|
729
729
|
];
|
730
|
+
const schema = {
|
731
|
+
type: 'array',
|
732
|
+
minItems: 1,
|
733
|
+
maxItems: 1,
|
734
|
+
items: {
|
735
|
+
type: 'object',
|
736
|
+
additionalProperties: false,
|
737
|
+
minProperties: 1,
|
738
|
+
properties: {
|
739
|
+
fields: {
|
740
|
+
...ARRAY_DEFAULT_OPTIONS,
|
741
|
+
items: {
|
742
|
+
enum: fieldsEnum,
|
743
|
+
},
|
744
|
+
description: 'Fields of `type`, `interface`, and `input`.',
|
745
|
+
},
|
746
|
+
values: {
|
747
|
+
...ARRAY_DEFAULT_OPTIONS,
|
748
|
+
items: {
|
749
|
+
enum: valuesEnum,
|
750
|
+
},
|
751
|
+
description: 'Values of `enum`.',
|
752
|
+
},
|
753
|
+
selections: {
|
754
|
+
...ARRAY_DEFAULT_OPTIONS,
|
755
|
+
items: {
|
756
|
+
enum: selectionsEnum,
|
757
|
+
},
|
758
|
+
description: 'Selections of `fragment` and operations `query`, `mutation` and `subscription`.',
|
759
|
+
},
|
760
|
+
variables: {
|
761
|
+
...ARRAY_DEFAULT_OPTIONS,
|
762
|
+
items: {
|
763
|
+
enum: variablesEnum,
|
764
|
+
},
|
765
|
+
description: 'Variables of operations `query`, `mutation` and `subscription`.',
|
766
|
+
},
|
767
|
+
arguments: {
|
768
|
+
...ARRAY_DEFAULT_OPTIONS,
|
769
|
+
items: {
|
770
|
+
enum: argumentsEnum,
|
771
|
+
},
|
772
|
+
description: 'Arguments of fields and directives.',
|
773
|
+
},
|
774
|
+
definitions: {
|
775
|
+
type: 'boolean',
|
776
|
+
description: 'Definitions – `type`, `interface`, `enum`, `scalar`, `input`, `union` and `directive`.',
|
777
|
+
default: false,
|
778
|
+
},
|
779
|
+
},
|
780
|
+
},
|
781
|
+
};
|
730
782
|
const rule = {
|
731
783
|
meta: {
|
732
784
|
type: 'suggestion',
|
@@ -833,58 +885,7 @@ const rule = {
|
|
833
885
|
messages: {
|
834
886
|
[RULE_ID]: '`{{ currName }}` should be before {{ prevName }}.',
|
835
887
|
},
|
836
|
-
schema
|
837
|
-
type: 'array',
|
838
|
-
minItems: 1,
|
839
|
-
maxItems: 1,
|
840
|
-
items: {
|
841
|
-
type: 'object',
|
842
|
-
additionalProperties: false,
|
843
|
-
minProperties: 1,
|
844
|
-
properties: {
|
845
|
-
fields: {
|
846
|
-
...ARRAY_DEFAULT_OPTIONS,
|
847
|
-
items: {
|
848
|
-
enum: fieldsEnum,
|
849
|
-
},
|
850
|
-
description: 'Fields of `type`, `interface`, and `input`.',
|
851
|
-
},
|
852
|
-
values: {
|
853
|
-
...ARRAY_DEFAULT_OPTIONS,
|
854
|
-
items: {
|
855
|
-
enum: valuesEnum,
|
856
|
-
},
|
857
|
-
description: 'Values of `enum`.',
|
858
|
-
},
|
859
|
-
selections: {
|
860
|
-
...ARRAY_DEFAULT_OPTIONS,
|
861
|
-
items: {
|
862
|
-
enum: selectionsEnum,
|
863
|
-
},
|
864
|
-
description: 'Selections of `fragment` and operations `query`, `mutation` and `subscription`.',
|
865
|
-
},
|
866
|
-
variables: {
|
867
|
-
...ARRAY_DEFAULT_OPTIONS,
|
868
|
-
items: {
|
869
|
-
enum: variablesEnum,
|
870
|
-
},
|
871
|
-
description: 'Variables of operations `query`, `mutation` and `subscription`.',
|
872
|
-
},
|
873
|
-
arguments: {
|
874
|
-
...ARRAY_DEFAULT_OPTIONS,
|
875
|
-
items: {
|
876
|
-
enum: argumentsEnum,
|
877
|
-
},
|
878
|
-
description: 'Arguments of fields and directives.',
|
879
|
-
},
|
880
|
-
definitions: {
|
881
|
-
type: 'boolean',
|
882
|
-
description: 'Definitions – `type`, `interface`, `enum`, `scalar`, `input`, `union` and `directive`.',
|
883
|
-
default: false,
|
884
|
-
},
|
885
|
-
},
|
886
|
-
},
|
887
|
-
},
|
888
|
+
schema,
|
888
889
|
},
|
889
890
|
create(context) {
|
890
891
|
var _a, _b, _c, _d, _e;
|
@@ -1027,6 +1028,21 @@ const rule = {
|
|
1027
1028
|
},
|
1028
1029
|
};
|
1029
1030
|
|
1031
|
+
const schema$1 = {
|
1032
|
+
type: 'array',
|
1033
|
+
maxItems: 1,
|
1034
|
+
items: {
|
1035
|
+
type: 'object',
|
1036
|
+
additionalProperties: false,
|
1037
|
+
minProperties: 1,
|
1038
|
+
properties: {
|
1039
|
+
style: {
|
1040
|
+
enum: ['block', 'inline'],
|
1041
|
+
default: 'block',
|
1042
|
+
},
|
1043
|
+
},
|
1044
|
+
},
|
1045
|
+
};
|
1030
1046
|
const rule$1 = {
|
1031
1047
|
meta: {
|
1032
1048
|
type: 'suggestion',
|
@@ -1059,18 +1075,7 @@ const rule$1 = {
|
|
1059
1075
|
url: 'https://github.com/B2o5T/graphql-eslint/blob/master/docs/rules/description-style.md',
|
1060
1076
|
recommended: true,
|
1061
1077
|
},
|
1062
|
-
schema:
|
1063
|
-
{
|
1064
|
-
type: 'object',
|
1065
|
-
additionalProperties: false,
|
1066
|
-
properties: {
|
1067
|
-
style: {
|
1068
|
-
enum: ['block', 'inline'],
|
1069
|
-
default: 'block',
|
1070
|
-
},
|
1071
|
-
},
|
1072
|
-
},
|
1073
|
-
],
|
1078
|
+
schema: schema$1,
|
1074
1079
|
},
|
1075
1080
|
create(context) {
|
1076
1081
|
const { style = 'block' } = context.options[0] || {};
|
@@ -1099,6 +1104,36 @@ const rule$1 = {
|
|
1099
1104
|
},
|
1100
1105
|
};
|
1101
1106
|
|
1107
|
+
const schema$2 = {
|
1108
|
+
type: 'array',
|
1109
|
+
maxItems: 1,
|
1110
|
+
items: {
|
1111
|
+
type: 'object',
|
1112
|
+
additionalProperties: false,
|
1113
|
+
properties: {
|
1114
|
+
checkInputType: {
|
1115
|
+
type: 'boolean',
|
1116
|
+
default: false,
|
1117
|
+
description: 'Check that the input type name follows the convention <mutationName>Input',
|
1118
|
+
},
|
1119
|
+
caseSensitiveInputType: {
|
1120
|
+
type: 'boolean',
|
1121
|
+
default: true,
|
1122
|
+
description: 'Allow for case discrepancies in the input type name',
|
1123
|
+
},
|
1124
|
+
checkQueries: {
|
1125
|
+
type: 'boolean',
|
1126
|
+
default: false,
|
1127
|
+
description: 'Apply the rule to Queries',
|
1128
|
+
},
|
1129
|
+
checkMutations: {
|
1130
|
+
type: 'boolean',
|
1131
|
+
default: true,
|
1132
|
+
description: 'Apply the rule to Mutations',
|
1133
|
+
},
|
1134
|
+
},
|
1135
|
+
},
|
1136
|
+
};
|
1102
1137
|
const isObjectType = (node) => [Kind.OBJECT_TYPE_DEFINITION, Kind.OBJECT_TYPE_EXTENSION].includes(node.type);
|
1103
1138
|
const isQueryType = (node) => isObjectType(node) && node.name.value === 'Query';
|
1104
1139
|
const isMutationType = (node) => isObjectType(node) && node.name.value === 'Mutation';
|
@@ -1140,34 +1175,7 @@ const rule$2 = {
|
|
1140
1175
|
},
|
1141
1176
|
],
|
1142
1177
|
},
|
1143
|
-
schema:
|
1144
|
-
{
|
1145
|
-
type: 'object',
|
1146
|
-
additionalProperties: false,
|
1147
|
-
properties: {
|
1148
|
-
checkInputType: {
|
1149
|
-
type: 'boolean',
|
1150
|
-
default: false,
|
1151
|
-
description: 'Check that the input type name follows the convention <mutationName>Input',
|
1152
|
-
},
|
1153
|
-
caseSensitiveInputType: {
|
1154
|
-
type: 'boolean',
|
1155
|
-
default: true,
|
1156
|
-
description: 'Allow for case discrepancies in the input type name',
|
1157
|
-
},
|
1158
|
-
checkQueries: {
|
1159
|
-
type: 'boolean',
|
1160
|
-
default: false,
|
1161
|
-
description: 'Apply the rule to Queries',
|
1162
|
-
},
|
1163
|
-
checkMutations: {
|
1164
|
-
type: 'boolean',
|
1165
|
-
default: true,
|
1166
|
-
description: 'Apply the rule to Mutations',
|
1167
|
-
},
|
1168
|
-
},
|
1169
|
-
},
|
1170
|
-
],
|
1178
|
+
schema: schema$2,
|
1171
1179
|
},
|
1172
1180
|
create(context) {
|
1173
1181
|
const options = {
|
@@ -1229,9 +1237,92 @@ const rule$2 = {
|
|
1229
1237
|
},
|
1230
1238
|
};
|
1231
1239
|
|
1240
|
+
const RULE_ID$1 = 'lone-executable-definition';
|
1241
|
+
const schema$3 = {
|
1242
|
+
type: 'array',
|
1243
|
+
maxItems: 1,
|
1244
|
+
items: {
|
1245
|
+
type: 'object',
|
1246
|
+
minProperties: 1,
|
1247
|
+
additionalProperties: false,
|
1248
|
+
properties: {
|
1249
|
+
ignore: {
|
1250
|
+
...ARRAY_DEFAULT_OPTIONS,
|
1251
|
+
maxItems: 3,
|
1252
|
+
items: {
|
1253
|
+
enum: ['fragment', 'query', 'mutation', 'subscription'],
|
1254
|
+
},
|
1255
|
+
description: 'Allow certain definitions to be placed alongside others.',
|
1256
|
+
},
|
1257
|
+
},
|
1258
|
+
},
|
1259
|
+
};
|
1260
|
+
const rule$3 = {
|
1261
|
+
meta: {
|
1262
|
+
type: 'suggestion',
|
1263
|
+
docs: {
|
1264
|
+
category: 'Operations',
|
1265
|
+
description: 'Require all queries, mutations, subscriptions and fragments to be located in separate files.',
|
1266
|
+
url: `https://github.com/B2o5T/graphql-eslint/blob/master/docs/rules/${RULE_ID$1}.md`,
|
1267
|
+
examples: [
|
1268
|
+
{
|
1269
|
+
title: 'Incorrect',
|
1270
|
+
code: /* GraphQL */ `
|
1271
|
+
query Foo {
|
1272
|
+
id
|
1273
|
+
}
|
1274
|
+
fragment Bar on Baz {
|
1275
|
+
id
|
1276
|
+
}
|
1277
|
+
`,
|
1278
|
+
},
|
1279
|
+
{
|
1280
|
+
title: 'Correct',
|
1281
|
+
code: /* GraphQL */ `
|
1282
|
+
query Foo {
|
1283
|
+
id
|
1284
|
+
}
|
1285
|
+
`,
|
1286
|
+
},
|
1287
|
+
],
|
1288
|
+
},
|
1289
|
+
messages: {
|
1290
|
+
[RULE_ID$1]: '{{name}} should be in a separate file.',
|
1291
|
+
},
|
1292
|
+
schema: schema$3,
|
1293
|
+
},
|
1294
|
+
create(context) {
|
1295
|
+
var _a;
|
1296
|
+
const ignore = new Set(((_a = context.options[0]) === null || _a === void 0 ? void 0 : _a.ignore) || []);
|
1297
|
+
const definitions = [];
|
1298
|
+
return {
|
1299
|
+
':matches(OperationDefinition, FragmentDefinition)'(node) {
|
1300
|
+
const type = 'operation' in node ? node.operation : 'fragment';
|
1301
|
+
if (!ignore.has(type)) {
|
1302
|
+
definitions.push({ type, node });
|
1303
|
+
}
|
1304
|
+
},
|
1305
|
+
'Program:exit'() {
|
1306
|
+
var _a, _b;
|
1307
|
+
for (const { node, type } of definitions.slice(1) /* ignore first definition */) {
|
1308
|
+
let name = pascalCase(type);
|
1309
|
+
const definitionName = (_a = node.name) === null || _a === void 0 ? void 0 : _a.value;
|
1310
|
+
if (definitionName) {
|
1311
|
+
name += ` "${definitionName}"`;
|
1312
|
+
}
|
1313
|
+
context.report({
|
1314
|
+
loc: ((_b = node.name) === null || _b === void 0 ? void 0 : _b.loc) || getLocation(node.loc.start, type),
|
1315
|
+
messageId: RULE_ID$1,
|
1316
|
+
data: { name },
|
1317
|
+
});
|
1318
|
+
}
|
1319
|
+
},
|
1320
|
+
};
|
1321
|
+
},
|
1322
|
+
};
|
1323
|
+
|
1232
1324
|
const MATCH_EXTENSION = 'MATCH_EXTENSION';
|
1233
1325
|
const MATCH_STYLE = 'MATCH_STYLE';
|
1234
|
-
const ACCEPTED_EXTENSIONS = ['.gql', '.graphql'];
|
1235
1326
|
const CASE_STYLES = [
|
1236
1327
|
'camelCase',
|
1237
1328
|
'PascalCase',
|
@@ -1243,7 +1334,40 @@ const CASE_STYLES = [
|
|
1243
1334
|
const schemaOption = {
|
1244
1335
|
oneOf: [{ $ref: '#/definitions/asString' }, { $ref: '#/definitions/asObject' }],
|
1245
1336
|
};
|
1246
|
-
const
|
1337
|
+
const schema$4 = {
|
1338
|
+
definitions: {
|
1339
|
+
asString: {
|
1340
|
+
enum: CASE_STYLES,
|
1341
|
+
description: `One of: ${CASE_STYLES.map(t => `\`${t}\``).join(', ')}`,
|
1342
|
+
},
|
1343
|
+
asObject: {
|
1344
|
+
type: 'object',
|
1345
|
+
additionalProperties: false,
|
1346
|
+
minProperties: 1,
|
1347
|
+
properties: {
|
1348
|
+
style: { enum: CASE_STYLES },
|
1349
|
+
suffix: { type: 'string' },
|
1350
|
+
prefix: { type: 'string' },
|
1351
|
+
},
|
1352
|
+
},
|
1353
|
+
},
|
1354
|
+
type: 'array',
|
1355
|
+
minItems: 1,
|
1356
|
+
maxItems: 1,
|
1357
|
+
items: {
|
1358
|
+
type: 'object',
|
1359
|
+
additionalProperties: false,
|
1360
|
+
minProperties: 1,
|
1361
|
+
properties: {
|
1362
|
+
fileExtension: { enum: ['.gql', '.graphql'] },
|
1363
|
+
query: schemaOption,
|
1364
|
+
mutation: schemaOption,
|
1365
|
+
subscription: schemaOption,
|
1366
|
+
fragment: schemaOption,
|
1367
|
+
},
|
1368
|
+
},
|
1369
|
+
};
|
1370
|
+
const rule$4 = {
|
1247
1371
|
meta: {
|
1248
1372
|
type: 'suggestion',
|
1249
1373
|
docs: {
|
@@ -1318,6 +1442,26 @@ const rule$3 = {
|
|
1318
1442
|
fullName
|
1319
1443
|
}
|
1320
1444
|
}
|
1445
|
+
`,
|
1446
|
+
},
|
1447
|
+
{
|
1448
|
+
title: 'Correct',
|
1449
|
+
usage: [{ fragment: { style: 'kebab-case', prefix: 'mutation.' } }],
|
1450
|
+
code: /* GraphQL */ `
|
1451
|
+
# mutation.add-alert.graphql
|
1452
|
+
mutation addAlert {
|
1453
|
+
foo
|
1454
|
+
}
|
1455
|
+
`,
|
1456
|
+
},
|
1457
|
+
{
|
1458
|
+
title: 'Correct',
|
1459
|
+
usage: [{ fragment: { prefix: 'query.' } }],
|
1460
|
+
code: /* GraphQL */ `
|
1461
|
+
# query.me.graphql
|
1462
|
+
query me {
|
1463
|
+
foo
|
1464
|
+
}
|
1321
1465
|
`,
|
1322
1466
|
},
|
1323
1467
|
],
|
@@ -1334,38 +1478,7 @@ const rule$3 = {
|
|
1334
1478
|
[MATCH_EXTENSION]: 'File extension "{{ fileExtension }}" don\'t match extension "{{ expectedFileExtension }}"',
|
1335
1479
|
[MATCH_STYLE]: 'Unexpected filename "{{ filename }}". Rename it to "{{ expectedFilename }}"',
|
1336
1480
|
},
|
1337
|
-
schema:
|
1338
|
-
definitions: {
|
1339
|
-
asString: {
|
1340
|
-
enum: CASE_STYLES,
|
1341
|
-
description: `One of: ${CASE_STYLES.map(t => `\`${t}\``).join(', ')}`,
|
1342
|
-
},
|
1343
|
-
asObject: {
|
1344
|
-
type: 'object',
|
1345
|
-
additionalProperties: false,
|
1346
|
-
minProperties: 1,
|
1347
|
-
properties: {
|
1348
|
-
style: { enum: CASE_STYLES },
|
1349
|
-
suffix: { type: 'string' },
|
1350
|
-
},
|
1351
|
-
},
|
1352
|
-
},
|
1353
|
-
type: 'array',
|
1354
|
-
minItems: 1,
|
1355
|
-
maxItems: 1,
|
1356
|
-
items: {
|
1357
|
-
type: 'object',
|
1358
|
-
additionalProperties: false,
|
1359
|
-
minProperties: 1,
|
1360
|
-
properties: {
|
1361
|
-
fileExtension: { enum: ACCEPTED_EXTENSIONS },
|
1362
|
-
query: schemaOption,
|
1363
|
-
mutation: schemaOption,
|
1364
|
-
subscription: schemaOption,
|
1365
|
-
fragment: schemaOption,
|
1366
|
-
},
|
1367
|
-
},
|
1368
|
-
},
|
1481
|
+
schema: schema$4,
|
1369
1482
|
},
|
1370
1483
|
create(context) {
|
1371
1484
|
const options = context.options[0] || {
|
@@ -1412,13 +1525,13 @@ const rule$3 = {
|
|
1412
1525
|
option = { style: option };
|
1413
1526
|
}
|
1414
1527
|
const expectedExtension = options.fileExtension || fileExtension;
|
1415
|
-
let expectedFilename;
|
1528
|
+
let expectedFilename = option.prefix || '';
|
1416
1529
|
if (option.style) {
|
1417
|
-
expectedFilename
|
1530
|
+
expectedFilename +=
|
1418
1531
|
option.style === 'matchDocumentStyle' ? docName : convertCase(option.style, docName);
|
1419
1532
|
}
|
1420
1533
|
else {
|
1421
|
-
expectedFilename
|
1534
|
+
expectedFilename += filename;
|
1422
1535
|
}
|
1423
1536
|
expectedFilename += (option.suffix || '') + expectedExtension;
|
1424
1537
|
const filenameWithExtension = filename + expectedExtension;
|
@@ -1467,7 +1580,67 @@ const ALLOWED_STYLES = Object.keys(StyleToRegex);
|
|
1467
1580
|
const schemaOption$1 = {
|
1468
1581
|
oneOf: [{ $ref: '#/definitions/asString' }, { $ref: '#/definitions/asObject' }],
|
1469
1582
|
};
|
1470
|
-
const
|
1583
|
+
const schema$5 = {
|
1584
|
+
definitions: {
|
1585
|
+
asString: {
|
1586
|
+
enum: ALLOWED_STYLES,
|
1587
|
+
description: `One of: ${ALLOWED_STYLES.map(t => `\`${t}\``).join(', ')}`,
|
1588
|
+
},
|
1589
|
+
asObject: {
|
1590
|
+
type: 'object',
|
1591
|
+
additionalProperties: false,
|
1592
|
+
properties: {
|
1593
|
+
style: { enum: ALLOWED_STYLES },
|
1594
|
+
prefix: { type: 'string' },
|
1595
|
+
suffix: { type: 'string' },
|
1596
|
+
forbiddenPrefixes: ARRAY_DEFAULT_OPTIONS,
|
1597
|
+
forbiddenSuffixes: ARRAY_DEFAULT_OPTIONS,
|
1598
|
+
ignorePattern: {
|
1599
|
+
type: 'string',
|
1600
|
+
description: 'Option to skip validation of some words, e.g. acronyms',
|
1601
|
+
},
|
1602
|
+
},
|
1603
|
+
},
|
1604
|
+
},
|
1605
|
+
type: 'array',
|
1606
|
+
maxItems: 1,
|
1607
|
+
items: {
|
1608
|
+
type: 'object',
|
1609
|
+
additionalProperties: false,
|
1610
|
+
properties: {
|
1611
|
+
types: {
|
1612
|
+
...schemaOption$1,
|
1613
|
+
description: `Includes:\n${TYPES_KINDS.map(kind => `- \`${kind}\``).join('\n')}`,
|
1614
|
+
},
|
1615
|
+
...Object.fromEntries(ALLOWED_KINDS.map(kind => [
|
1616
|
+
kind,
|
1617
|
+
{
|
1618
|
+
...schemaOption$1,
|
1619
|
+
description: `Read more about this kind on [spec.graphql.org](https://spec.graphql.org/October2021/#${kind}).`,
|
1620
|
+
},
|
1621
|
+
])),
|
1622
|
+
allowLeadingUnderscore: {
|
1623
|
+
type: 'boolean',
|
1624
|
+
default: false,
|
1625
|
+
},
|
1626
|
+
allowTrailingUnderscore: {
|
1627
|
+
type: 'boolean',
|
1628
|
+
default: false,
|
1629
|
+
},
|
1630
|
+
},
|
1631
|
+
patternProperties: {
|
1632
|
+
[`^(${ALLOWED_KINDS.join('|')})(.+)?$`]: schemaOption$1,
|
1633
|
+
},
|
1634
|
+
description: [
|
1635
|
+
"> It's possible to use a [`selector`](https://eslint.org/docs/developer-guide/selectors) that starts with allowed `ASTNode` names which are described below.",
|
1636
|
+
'>',
|
1637
|
+
'> Paste or drop code into the editor in [ASTExplorer](https://astexplorer.net) and inspect the generated AST to compose your selector.',
|
1638
|
+
'>',
|
1639
|
+
'> Example: pattern property `FieldDefinition[parent.name.value=Query]` will match only fields for type `Query`.',
|
1640
|
+
].join('\n'),
|
1641
|
+
},
|
1642
|
+
};
|
1643
|
+
const rule$5 = {
|
1471
1644
|
meta: {
|
1472
1645
|
type: 'suggestion',
|
1473
1646
|
docs: {
|
@@ -1583,66 +1756,7 @@ const rule$4 = {
|
|
1583
1756
|
},
|
1584
1757
|
},
|
1585
1758
|
hasSuggestions: true,
|
1586
|
-
schema:
|
1587
|
-
definitions: {
|
1588
|
-
asString: {
|
1589
|
-
enum: ALLOWED_STYLES,
|
1590
|
-
description: `One of: ${ALLOWED_STYLES.map(t => `\`${t}\``).join(', ')}`,
|
1591
|
-
},
|
1592
|
-
asObject: {
|
1593
|
-
type: 'object',
|
1594
|
-
additionalProperties: false,
|
1595
|
-
properties: {
|
1596
|
-
style: { enum: ALLOWED_STYLES },
|
1597
|
-
prefix: { type: 'string' },
|
1598
|
-
suffix: { type: 'string' },
|
1599
|
-
forbiddenPrefixes: ARRAY_DEFAULT_OPTIONS,
|
1600
|
-
forbiddenSuffixes: ARRAY_DEFAULT_OPTIONS,
|
1601
|
-
ignorePattern: {
|
1602
|
-
type: 'string',
|
1603
|
-
description: 'Option to skip validation of some words, e.g. acronyms',
|
1604
|
-
},
|
1605
|
-
},
|
1606
|
-
},
|
1607
|
-
},
|
1608
|
-
type: 'array',
|
1609
|
-
maxItems: 1,
|
1610
|
-
items: {
|
1611
|
-
type: 'object',
|
1612
|
-
additionalProperties: false,
|
1613
|
-
properties: {
|
1614
|
-
types: {
|
1615
|
-
...schemaOption$1,
|
1616
|
-
description: `Includes:\n\n${TYPES_KINDS.map(kind => `- \`${kind}\``).join('\n')}`,
|
1617
|
-
},
|
1618
|
-
...Object.fromEntries(ALLOWED_KINDS.map(kind => [
|
1619
|
-
kind,
|
1620
|
-
{
|
1621
|
-
...schemaOption$1,
|
1622
|
-
description: `Read more about this kind on [spec.graphql.org](https://spec.graphql.org/October2021/#${kind}).`,
|
1623
|
-
},
|
1624
|
-
])),
|
1625
|
-
allowLeadingUnderscore: {
|
1626
|
-
type: 'boolean',
|
1627
|
-
default: false,
|
1628
|
-
},
|
1629
|
-
allowTrailingUnderscore: {
|
1630
|
-
type: 'boolean',
|
1631
|
-
default: false,
|
1632
|
-
},
|
1633
|
-
},
|
1634
|
-
patternProperties: {
|
1635
|
-
[`^(${ALLOWED_KINDS.join('|')})(.+)?$`]: schemaOption$1,
|
1636
|
-
},
|
1637
|
-
description: [
|
1638
|
-
"> It's possible to use a [`selector`](https://eslint.org/docs/developer-guide/selectors) that starts with allowed `ASTNode` names which are described below.",
|
1639
|
-
'>',
|
1640
|
-
'> Paste or drop code into the editor in [ASTExplorer](https://astexplorer.net) and inspect the generated AST to compose your selector.',
|
1641
|
-
'>',
|
1642
|
-
'> Example: pattern property `FieldDefinition[parent.name.value=Query]` will match only fields for type `Query`.',
|
1643
|
-
].join('\n'),
|
1644
|
-
},
|
1645
|
-
},
|
1759
|
+
schema: schema$5,
|
1646
1760
|
},
|
1647
1761
|
create(context) {
|
1648
1762
|
const options = context.options[0] || {};
|
@@ -1742,8 +1856,8 @@ const rule$4 = {
|
|
1742
1856
|
},
|
1743
1857
|
};
|
1744
1858
|
|
1745
|
-
const RULE_ID$
|
1746
|
-
const rule$
|
1859
|
+
const RULE_ID$2 = 'no-anonymous-operations';
|
1860
|
+
const rule$6 = {
|
1747
1861
|
meta: {
|
1748
1862
|
type: 'suggestion',
|
1749
1863
|
hasSuggestions: true,
|
@@ -1751,7 +1865,7 @@ const rule$5 = {
|
|
1751
1865
|
category: 'Operations',
|
1752
1866
|
description: 'Require name for your GraphQL operations. This is useful since most GraphQL client libraries are using the operation name for caching purposes.',
|
1753
1867
|
recommended: true,
|
1754
|
-
url: `https://github.com/B2o5T/graphql-eslint/blob/master/docs/rules/${RULE_ID$
|
1868
|
+
url: `https://github.com/B2o5T/graphql-eslint/blob/master/docs/rules/${RULE_ID$2}.md`,
|
1755
1869
|
examples: [
|
1756
1870
|
{
|
1757
1871
|
title: 'Incorrect',
|
@@ -1772,7 +1886,7 @@ const rule$5 = {
|
|
1772
1886
|
],
|
1773
1887
|
},
|
1774
1888
|
messages: {
|
1775
|
-
[RULE_ID$
|
1889
|
+
[RULE_ID$2]: 'Anonymous GraphQL operations are forbidden. Make sure to name your {{ operation }}!',
|
1776
1890
|
},
|
1777
1891
|
schema: [],
|
1778
1892
|
},
|
@@ -1785,7 +1899,7 @@ const rule$5 = {
|
|
1785
1899
|
: node.operation;
|
1786
1900
|
context.report({
|
1787
1901
|
loc: getLocation(node.loc.start, node.operation),
|
1788
|
-
messageId: RULE_ID$
|
1902
|
+
messageId: RULE_ID$2,
|
1789
1903
|
data: {
|
1790
1904
|
operation: node.operation,
|
1791
1905
|
},
|
@@ -1805,7 +1919,7 @@ const rule$5 = {
|
|
1805
1919
|
},
|
1806
1920
|
};
|
1807
1921
|
|
1808
|
-
const rule$
|
1922
|
+
const rule$7 = {
|
1809
1923
|
meta: {
|
1810
1924
|
type: 'suggestion',
|
1811
1925
|
hasSuggestions: true,
|
@@ -1863,15 +1977,15 @@ const rule$6 = {
|
|
1863
1977
|
},
|
1864
1978
|
};
|
1865
1979
|
|
1866
|
-
const RULE_ID$
|
1867
|
-
const rule$
|
1980
|
+
const RULE_ID$3 = 'no-deprecated';
|
1981
|
+
const rule$8 = {
|
1868
1982
|
meta: {
|
1869
1983
|
type: 'suggestion',
|
1870
1984
|
hasSuggestions: true,
|
1871
1985
|
docs: {
|
1872
1986
|
category: 'Operations',
|
1873
1987
|
description: 'Enforce that deprecated fields or enum values are not in use by operations.',
|
1874
|
-
url: `https://github.com/B2o5T/graphql-eslint/blob/master/docs/rules/${RULE_ID$
|
1988
|
+
url: `https://github.com/B2o5T/graphql-eslint/blob/master/docs/rules/${RULE_ID$3}.md`,
|
1875
1989
|
requiresSchema: true,
|
1876
1990
|
examples: [
|
1877
1991
|
{
|
@@ -1938,18 +2052,18 @@ const rule$7 = {
|
|
1938
2052
|
recommended: true,
|
1939
2053
|
},
|
1940
2054
|
messages: {
|
1941
|
-
[RULE_ID$
|
2055
|
+
[RULE_ID$3]: 'This {{ type }} is marked as deprecated in your GraphQL schema (reason: {{ reason }})',
|
1942
2056
|
},
|
1943
2057
|
schema: [],
|
1944
2058
|
},
|
1945
2059
|
create(context) {
|
1946
|
-
requireGraphQLSchemaFromContext(RULE_ID$
|
2060
|
+
requireGraphQLSchemaFromContext(RULE_ID$3, context);
|
1947
2061
|
function report(node, reason) {
|
1948
2062
|
const nodeName = node.kind === Kind.ENUM ? node.value : node.name.value;
|
1949
2063
|
const nodeType = node.kind === Kind.ENUM ? 'enum value' : 'field';
|
1950
2064
|
context.report({
|
1951
2065
|
node,
|
1952
|
-
messageId: RULE_ID$
|
2066
|
+
messageId: RULE_ID$3,
|
1953
2067
|
data: {
|
1954
2068
|
type: nodeType,
|
1955
2069
|
reason,
|
@@ -1983,15 +2097,15 @@ const rule$7 = {
|
|
1983
2097
|
},
|
1984
2098
|
};
|
1985
2099
|
|
1986
|
-
const RULE_ID$
|
1987
|
-
const rule$
|
2100
|
+
const RULE_ID$4 = 'no-duplicate-fields';
|
2101
|
+
const rule$9 = {
|
1988
2102
|
meta: {
|
1989
2103
|
type: 'suggestion',
|
1990
2104
|
hasSuggestions: true,
|
1991
2105
|
docs: {
|
1992
2106
|
description: 'Checks for duplicate fields in selection set, variables in operation definition, or in arguments set of a field.',
|
1993
2107
|
category: 'Operations',
|
1994
|
-
url: `https://github.com/B2o5T/graphql-eslint/blob/master/docs/rules/${RULE_ID$
|
2108
|
+
url: `https://github.com/B2o5T/graphql-eslint/blob/master/docs/rules/${RULE_ID$4}.md`,
|
1995
2109
|
recommended: true,
|
1996
2110
|
examples: [
|
1997
2111
|
{
|
@@ -2037,7 +2151,7 @@ const rule$8 = {
|
|
2037
2151
|
],
|
2038
2152
|
},
|
2039
2153
|
messages: {
|
2040
|
-
[RULE_ID$
|
2154
|
+
[RULE_ID$4]: '{{ type }} `{{ fieldName }}` defined multiple times.',
|
2041
2155
|
},
|
2042
2156
|
schema: [],
|
2043
2157
|
},
|
@@ -2048,7 +2162,7 @@ const rule$8 = {
|
|
2048
2162
|
const { parent } = node;
|
2049
2163
|
context.report({
|
2050
2164
|
node,
|
2051
|
-
messageId: RULE_ID$
|
2165
|
+
messageId: RULE_ID$4,
|
2052
2166
|
data: {
|
2053
2167
|
type: parent.type,
|
2054
2168
|
fieldName,
|
@@ -2093,7 +2207,7 @@ const rule$8 = {
|
|
2093
2207
|
};
|
2094
2208
|
|
2095
2209
|
const HASHTAG_COMMENT = 'HASHTAG_COMMENT';
|
2096
|
-
const rule$
|
2210
|
+
const rule$a = {
|
2097
2211
|
meta: {
|
2098
2212
|
type: 'suggestion',
|
2099
2213
|
hasSuggestions: true,
|
@@ -2178,8 +2292,25 @@ const rule$9 = {
|
|
2178
2292
|
},
|
2179
2293
|
};
|
2180
2294
|
|
2181
|
-
const
|
2182
|
-
|
2295
|
+
const schema$6 = {
|
2296
|
+
type: 'array',
|
2297
|
+
minItems: 1,
|
2298
|
+
maxItems: 1,
|
2299
|
+
items: {
|
2300
|
+
type: 'object',
|
2301
|
+
additionalProperties: false,
|
2302
|
+
required: ['disallow'],
|
2303
|
+
properties: {
|
2304
|
+
disallow: {
|
2305
|
+
...ARRAY_DEFAULT_OPTIONS,
|
2306
|
+
items: {
|
2307
|
+
enum: ['mutation', 'subscription'],
|
2308
|
+
},
|
2309
|
+
},
|
2310
|
+
},
|
2311
|
+
},
|
2312
|
+
};
|
2313
|
+
const rule$b = {
|
2183
2314
|
meta: {
|
2184
2315
|
type: 'suggestion',
|
2185
2316
|
hasSuggestions: true,
|
@@ -2210,24 +2341,7 @@ const rule$a = {
|
|
2210
2341
|
},
|
2211
2342
|
],
|
2212
2343
|
},
|
2213
|
-
schema:
|
2214
|
-
type: 'array',
|
2215
|
-
minItems: 1,
|
2216
|
-
maxItems: 1,
|
2217
|
-
items: {
|
2218
|
-
type: 'object',
|
2219
|
-
additionalProperties: false,
|
2220
|
-
required: ['disallow'],
|
2221
|
-
properties: {
|
2222
|
-
disallow: {
|
2223
|
-
...ARRAY_DEFAULT_OPTIONS,
|
2224
|
-
items: {
|
2225
|
-
enum: ROOT_TYPES,
|
2226
|
-
},
|
2227
|
-
},
|
2228
|
-
},
|
2229
|
-
},
|
2230
|
-
},
|
2344
|
+
schema: schema$6,
|
2231
2345
|
},
|
2232
2346
|
create(context) {
|
2233
2347
|
const schema = requireGraphQLSchemaFromContext('no-root-type', context);
|
@@ -2261,15 +2375,15 @@ const rule$a = {
|
|
2261
2375
|
},
|
2262
2376
|
};
|
2263
2377
|
|
2264
|
-
const RULE_ID$
|
2265
|
-
const rule$
|
2378
|
+
const RULE_ID$5 = 'no-scalar-result-type-on-mutation';
|
2379
|
+
const rule$c = {
|
2266
2380
|
meta: {
|
2267
2381
|
type: 'suggestion',
|
2268
2382
|
hasSuggestions: true,
|
2269
2383
|
docs: {
|
2270
2384
|
category: 'Schema',
|
2271
2385
|
description: 'Avoid scalar result type on mutation type to make sure to return a valid state.',
|
2272
|
-
url: `https://github.com/B2o5T/graphql-eslint/blob/master/docs/rules/${RULE_ID$
|
2386
|
+
url: `https://github.com/B2o5T/graphql-eslint/blob/master/docs/rules/${RULE_ID$5}.md`,
|
2273
2387
|
requiresSchema: true,
|
2274
2388
|
examples: [
|
2275
2389
|
{
|
@@ -2293,7 +2407,7 @@ const rule$b = {
|
|
2293
2407
|
schema: [],
|
2294
2408
|
},
|
2295
2409
|
create(context) {
|
2296
|
-
const schema = requireGraphQLSchemaFromContext(RULE_ID$
|
2410
|
+
const schema = requireGraphQLSchemaFromContext(RULE_ID$5, context);
|
2297
2411
|
const mutationType = schema.getMutationType();
|
2298
2412
|
if (!mutationType) {
|
2299
2413
|
return {};
|
@@ -2324,7 +2438,7 @@ const rule$b = {
|
|
2324
2438
|
};
|
2325
2439
|
|
2326
2440
|
const NO_TYPENAME_PREFIX = 'NO_TYPENAME_PREFIX';
|
2327
|
-
const rule$
|
2441
|
+
const rule$d = {
|
2328
2442
|
meta: {
|
2329
2443
|
type: 'suggestion',
|
2330
2444
|
hasSuggestions: true,
|
@@ -2386,7 +2500,7 @@ const rule$c = {
|
|
2386
2500
|
},
|
2387
2501
|
};
|
2388
2502
|
|
2389
|
-
const RULE_ID$
|
2503
|
+
const RULE_ID$6 = 'no-unreachable-types';
|
2390
2504
|
const KINDS = [
|
2391
2505
|
Kind.DIRECTIVE_DEFINITION,
|
2392
2506
|
Kind.OBJECT_TYPE_DEFINITION,
|
@@ -2466,15 +2580,15 @@ function getReachableTypes(schema) {
|
|
2466
2580
|
reachableTypesCache = reachableTypes;
|
2467
2581
|
return reachableTypesCache;
|
2468
2582
|
}
|
2469
|
-
const rule$
|
2583
|
+
const rule$e = {
|
2470
2584
|
meta: {
|
2471
2585
|
messages: {
|
2472
|
-
[RULE_ID$
|
2586
|
+
[RULE_ID$6]: '{{ type }} `{{ typeName }}` is unreachable.',
|
2473
2587
|
},
|
2474
2588
|
docs: {
|
2475
2589
|
description: 'Requires all types to be reachable at some level by root level fields.',
|
2476
2590
|
category: 'Schema',
|
2477
|
-
url: `https://github.com/B2o5T/graphql-eslint/blob/master/docs/rules/${RULE_ID$
|
2591
|
+
url: `https://github.com/B2o5T/graphql-eslint/blob/master/docs/rules/${RULE_ID$6}.md`,
|
2478
2592
|
requiresSchema: true,
|
2479
2593
|
examples: [
|
2480
2594
|
{
|
@@ -2511,7 +2625,7 @@ const rule$d = {
|
|
2511
2625
|
hasSuggestions: true,
|
2512
2626
|
},
|
2513
2627
|
create(context) {
|
2514
|
-
const schema = requireGraphQLSchemaFromContext(RULE_ID$
|
2628
|
+
const schema = requireGraphQLSchemaFromContext(RULE_ID$6, context);
|
2515
2629
|
const reachableTypes = getReachableTypes(schema);
|
2516
2630
|
return {
|
2517
2631
|
[`:matches(${KINDS}) > .name`](node) {
|
@@ -2520,7 +2634,7 @@ const rule$d = {
|
|
2520
2634
|
const type = lowerCase(node.parent.kind.replace(/(Extension|Definition)$/, ''));
|
2521
2635
|
context.report({
|
2522
2636
|
node,
|
2523
|
-
messageId: RULE_ID$
|
2637
|
+
messageId: RULE_ID$6,
|
2524
2638
|
data: {
|
2525
2639
|
type: type[0].toUpperCase() + type.slice(1),
|
2526
2640
|
typeName,
|
@@ -2538,7 +2652,7 @@ const rule$d = {
|
|
2538
2652
|
},
|
2539
2653
|
};
|
2540
2654
|
|
2541
|
-
const RULE_ID$
|
2655
|
+
const RULE_ID$7 = 'no-unused-fields';
|
2542
2656
|
let usedFieldsCache;
|
2543
2657
|
function getUsedFields(schema, operations) {
|
2544
2658
|
// We don't want cache usedFields on test environment
|
@@ -2569,15 +2683,15 @@ function getUsedFields(schema, operations) {
|
|
2569
2683
|
usedFieldsCache = usedFields;
|
2570
2684
|
return usedFieldsCache;
|
2571
2685
|
}
|
2572
|
-
const rule$
|
2686
|
+
const rule$f = {
|
2573
2687
|
meta: {
|
2574
2688
|
messages: {
|
2575
|
-
[RULE_ID$
|
2689
|
+
[RULE_ID$7]: 'Field "{{fieldName}}" is unused',
|
2576
2690
|
},
|
2577
2691
|
docs: {
|
2578
2692
|
description: 'Requires all fields to be used at some level by siblings operations.',
|
2579
2693
|
category: 'Schema',
|
2580
|
-
url: `https://github.com/B2o5T/graphql-eslint/blob/master/docs/rules/${RULE_ID$
|
2694
|
+
url: `https://github.com/B2o5T/graphql-eslint/blob/master/docs/rules/${RULE_ID$7}.md`,
|
2581
2695
|
requiresSiblings: true,
|
2582
2696
|
requiresSchema: true,
|
2583
2697
|
isDisabledForAllConfig: true,
|
@@ -2630,8 +2744,8 @@ const rule$e = {
|
|
2630
2744
|
hasSuggestions: true,
|
2631
2745
|
},
|
2632
2746
|
create(context) {
|
2633
|
-
const schema = requireGraphQLSchemaFromContext(RULE_ID$
|
2634
|
-
const siblingsOperations = requireSiblingsOperations(RULE_ID$
|
2747
|
+
const schema = requireGraphQLSchemaFromContext(RULE_ID$7, context);
|
2748
|
+
const siblingsOperations = requireSiblingsOperations(RULE_ID$7, context);
|
2635
2749
|
const usedFields = getUsedFields(schema, siblingsOperations);
|
2636
2750
|
return {
|
2637
2751
|
FieldDefinition(node) {
|
@@ -2644,7 +2758,7 @@ const rule$e = {
|
|
2644
2758
|
}
|
2645
2759
|
context.report({
|
2646
2760
|
node: node.name,
|
2647
|
-
messageId: RULE_ID$
|
2761
|
+
messageId: RULE_ID$7,
|
2648
2762
|
data: { fieldName },
|
2649
2763
|
suggest: [
|
2650
2764
|
{
|
@@ -2664,9 +2778,25 @@ const rule$e = {
|
|
2664
2778
|
},
|
2665
2779
|
};
|
2666
2780
|
|
2667
|
-
const RULE_ID$
|
2781
|
+
const RULE_ID$8 = 'relay-arguments';
|
2668
2782
|
const MISSING_ARGUMENTS = 'MISSING_ARGUMENTS';
|
2669
|
-
const
|
2783
|
+
const schema$7 = {
|
2784
|
+
type: 'array',
|
2785
|
+
maxItems: 1,
|
2786
|
+
items: {
|
2787
|
+
type: 'object',
|
2788
|
+
additionalProperties: false,
|
2789
|
+
minProperties: 1,
|
2790
|
+
properties: {
|
2791
|
+
includeBoth: {
|
2792
|
+
type: 'boolean',
|
2793
|
+
default: true,
|
2794
|
+
description: 'Enforce including both forward and backward pagination arguments',
|
2795
|
+
},
|
2796
|
+
},
|
2797
|
+
},
|
2798
|
+
};
|
2799
|
+
const rule$g = {
|
2670
2800
|
meta: {
|
2671
2801
|
type: 'problem',
|
2672
2802
|
docs: {
|
@@ -2686,7 +2816,7 @@ const rule$f = {
|
|
2686
2816
|
'- `last` takes a non-negative integer',
|
2687
2817
|
'- `before` takes the Cursor type',
|
2688
2818
|
].join('\n'),
|
2689
|
-
url: `https://github.com/B2o5T/graphql-eslint/blob/master/docs/rules/${RULE_ID$
|
2819
|
+
url: `https://github.com/B2o5T/graphql-eslint/blob/master/docs/rules/${RULE_ID$8}.md`,
|
2690
2820
|
examples: [
|
2691
2821
|
{
|
2692
2822
|
title: 'Incorrect',
|
@@ -2710,25 +2840,10 @@ const rule$f = {
|
|
2710
2840
|
messages: {
|
2711
2841
|
[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.',
|
2712
2842
|
},
|
2713
|
-
schema:
|
2714
|
-
type: 'array',
|
2715
|
-
maxItems: 1,
|
2716
|
-
items: {
|
2717
|
-
type: 'object',
|
2718
|
-
additionalProperties: false,
|
2719
|
-
minProperties: 1,
|
2720
|
-
properties: {
|
2721
|
-
includeBoth: {
|
2722
|
-
type: 'boolean',
|
2723
|
-
default: true,
|
2724
|
-
description: 'Enforce including both forward and backward pagination arguments',
|
2725
|
-
},
|
2726
|
-
},
|
2727
|
-
},
|
2728
|
-
},
|
2843
|
+
schema: schema$7,
|
2729
2844
|
},
|
2730
2845
|
create(context) {
|
2731
|
-
const schema = requireGraphQLSchemaFromContext(RULE_ID$
|
2846
|
+
const schema = requireGraphQLSchemaFromContext(RULE_ID$8, context);
|
2732
2847
|
const { includeBoth = true } = context.options[0] || {};
|
2733
2848
|
return {
|
2734
2849
|
'FieldDefinition > .gqlType Name[value=/Connection$/]'(node) {
|
@@ -2800,7 +2915,7 @@ const NON_OBJECT_TYPES = [
|
|
2800
2915
|
const notConnectionTypesSelector = `:matches(${NON_OBJECT_TYPES})[name.value=/Connection$/] > .name`;
|
2801
2916
|
const hasEdgesField = (node) => node.fields.some(field => field.name.value === 'edges');
|
2802
2917
|
const hasPageInfoField = (node) => node.fields.some(field => field.name.value === 'pageInfo');
|
2803
|
-
const rule$
|
2918
|
+
const rule$h = {
|
2804
2919
|
meta: {
|
2805
2920
|
type: 'problem',
|
2806
2921
|
docs: {
|
@@ -2884,7 +2999,7 @@ const rule$g = {
|
|
2884
2999
|
},
|
2885
3000
|
};
|
2886
3001
|
|
2887
|
-
const RULE_ID$
|
3002
|
+
const RULE_ID$9 = 'relay-edge-types';
|
2888
3003
|
const MESSAGE_MUST_BE_OBJECT_TYPE = 'MESSAGE_MUST_BE_OBJECT_TYPE';
|
2889
3004
|
const MESSAGE_MISSING_EDGE_SUFFIX = 'MESSAGE_MISSING_EDGE_SUFFIX';
|
2890
3005
|
const MESSAGE_LIST_TYPE_ONLY_EDGE_TYPE = 'MESSAGE_LIST_TYPE_ONLY_EDGE_TYPE';
|
@@ -2919,7 +3034,33 @@ function getEdgeTypes(schema) {
|
|
2919
3034
|
edgeTypesCache = edgeTypes;
|
2920
3035
|
return edgeTypesCache;
|
2921
3036
|
}
|
2922
|
-
const
|
3037
|
+
const schema$8 = {
|
3038
|
+
type: 'array',
|
3039
|
+
maxItems: 1,
|
3040
|
+
items: {
|
3041
|
+
type: 'object',
|
3042
|
+
additionalProperties: false,
|
3043
|
+
minProperties: 1,
|
3044
|
+
properties: {
|
3045
|
+
withEdgeSuffix: {
|
3046
|
+
type: 'boolean',
|
3047
|
+
default: true,
|
3048
|
+
description: 'Edge type name must end in "Edge".',
|
3049
|
+
},
|
3050
|
+
shouldImplementNode: {
|
3051
|
+
type: 'boolean',
|
3052
|
+
default: true,
|
3053
|
+
description: "Edge type's field `node` must implement `Node` interface.",
|
3054
|
+
},
|
3055
|
+
listTypeCanWrapOnlyEdgeType: {
|
3056
|
+
type: 'boolean',
|
3057
|
+
default: true,
|
3058
|
+
description: 'A list type should only wrap an edge type.',
|
3059
|
+
},
|
3060
|
+
},
|
3061
|
+
},
|
3062
|
+
};
|
3063
|
+
const rule$i = {
|
2923
3064
|
meta: {
|
2924
3065
|
type: 'problem',
|
2925
3066
|
docs: {
|
@@ -2935,7 +3076,7 @@ const rule$h = {
|
|
2935
3076
|
"- Edge type's field `node` must implement `Node` interface _(optional)_",
|
2936
3077
|
'- A list type should only wrap an edge type _(optional)_',
|
2937
3078
|
].join('\n'),
|
2938
|
-
url: `https://github.com/B2o5T/graphql-eslint/blob/master/docs/rules/${RULE_ID$
|
3079
|
+
url: `https://github.com/B2o5T/graphql-eslint/blob/master/docs/rules/${RULE_ID$9}.md`,
|
2939
3080
|
isDisabledForAllConfig: true,
|
2940
3081
|
requiresSchema: true,
|
2941
3082
|
examples: [
|
@@ -2956,35 +3097,10 @@ const rule$h = {
|
|
2956
3097
|
[MESSAGE_LIST_TYPE_ONLY_EDGE_TYPE]: 'A list type should only wrap an edge type.',
|
2957
3098
|
[MESSAGE_SHOULD_IMPLEMENTS_NODE]: "Edge type's field `node` must implement `Node` interface.",
|
2958
3099
|
},
|
2959
|
-
schema:
|
2960
|
-
type: 'array',
|
2961
|
-
maxItems: 1,
|
2962
|
-
items: {
|
2963
|
-
type: 'object',
|
2964
|
-
additionalProperties: false,
|
2965
|
-
minProperties: 1,
|
2966
|
-
properties: {
|
2967
|
-
withEdgeSuffix: {
|
2968
|
-
type: 'boolean',
|
2969
|
-
default: true,
|
2970
|
-
description: 'Edge type name must end in "Edge".',
|
2971
|
-
},
|
2972
|
-
shouldImplementNode: {
|
2973
|
-
type: 'boolean',
|
2974
|
-
default: true,
|
2975
|
-
description: "Edge type's field `node` must implement `Node` interface.",
|
2976
|
-
},
|
2977
|
-
listTypeCanWrapOnlyEdgeType: {
|
2978
|
-
type: 'boolean',
|
2979
|
-
default: true,
|
2980
|
-
description: 'A list type should only wrap an edge type.',
|
2981
|
-
},
|
2982
|
-
},
|
2983
|
-
},
|
2984
|
-
},
|
3100
|
+
schema: schema$8,
|
2985
3101
|
},
|
2986
3102
|
create(context) {
|
2987
|
-
const schema = requireGraphQLSchemaFromContext(RULE_ID$
|
3103
|
+
const schema = requireGraphQLSchemaFromContext(RULE_ID$9, context);
|
2988
3104
|
const edgeTypes = getEdgeTypes(schema);
|
2989
3105
|
const options = {
|
2990
3106
|
withEdgeSuffix: true,
|
@@ -3067,12 +3183,12 @@ const rule$h = {
|
|
3067
3183
|
},
|
3068
3184
|
};
|
3069
3185
|
|
3070
|
-
const RULE_ID$
|
3186
|
+
const RULE_ID$a = 'relay-page-info';
|
3071
3187
|
const MESSAGE_MUST_EXIST = 'MESSAGE_MUST_EXIST';
|
3072
3188
|
const MESSAGE_MUST_BE_OBJECT_TYPE$1 = 'MESSAGE_MUST_BE_OBJECT_TYPE';
|
3073
3189
|
const notPageInfoTypesSelector = `:matches(${NON_OBJECT_TYPES})[name.value=PageInfo] > .name`;
|
3074
3190
|
let hasPageInfoChecked = false;
|
3075
|
-
const rule$
|
3191
|
+
const rule$j = {
|
3076
3192
|
meta: {
|
3077
3193
|
type: 'problem',
|
3078
3194
|
docs: {
|
@@ -3084,7 +3200,7 @@ const rule$i = {
|
|
3084
3200
|
'- `PageInfo` must contain fields `hasPreviousPage` and `hasNextPage`, that return non-null Boolean',
|
3085
3201
|
'- `PageInfo` must contain fields `startCursor` and `endCursor`, that return either String or Scalar, which can be null if there are no results',
|
3086
3202
|
].join('\n'),
|
3087
|
-
url: `https://github.com/B2o5T/graphql-eslint/blob/master/docs/rules/${RULE_ID$
|
3203
|
+
url: `https://github.com/B2o5T/graphql-eslint/blob/master/docs/rules/${RULE_ID$a}.md`,
|
3088
3204
|
examples: [
|
3089
3205
|
{
|
3090
3206
|
title: 'Correct',
|
@@ -3108,7 +3224,7 @@ const rule$i = {
|
|
3108
3224
|
schema: [],
|
3109
3225
|
},
|
3110
3226
|
create(context) {
|
3111
|
-
const schema = requireGraphQLSchemaFromContext(RULE_ID$
|
3227
|
+
const schema = requireGraphQLSchemaFromContext(RULE_ID$a, context);
|
3112
3228
|
if (process.env.NODE_ENV === 'test' || !hasPageInfoChecked) {
|
3113
3229
|
const pageInfoType = schema.getType('PageInfo');
|
3114
3230
|
if (!pageInfoType) {
|
@@ -3324,7 +3440,20 @@ const MESSAGE_REQUIRE_DATE = 'MESSAGE_REQUIRE_DATE';
|
|
3324
3440
|
const MESSAGE_INVALID_FORMAT = 'MESSAGE_INVALID_FORMAT';
|
3325
3441
|
const MESSAGE_INVALID_DATE = 'MESSAGE_INVALID_DATE';
|
3326
3442
|
const MESSAGE_CAN_BE_REMOVED = 'MESSAGE_CAN_BE_REMOVED';
|
3327
|
-
const
|
3443
|
+
const schema$9 = {
|
3444
|
+
type: 'array',
|
3445
|
+
maxItems: 1,
|
3446
|
+
items: {
|
3447
|
+
type: 'object',
|
3448
|
+
additionalProperties: false,
|
3449
|
+
properties: {
|
3450
|
+
argumentName: {
|
3451
|
+
type: 'string',
|
3452
|
+
},
|
3453
|
+
},
|
3454
|
+
},
|
3455
|
+
};
|
3456
|
+
const rule$k = {
|
3328
3457
|
meta: {
|
3329
3458
|
type: 'suggestion',
|
3330
3459
|
hasSuggestions: true,
|
@@ -3369,17 +3498,7 @@ const rule$j = {
|
|
3369
3498
|
[MESSAGE_INVALID_DATE]: 'Invalid "{{ deletionDate }}" deletion date',
|
3370
3499
|
[MESSAGE_CAN_BE_REMOVED]: '"{{ nodeName }}" сan be removed',
|
3371
3500
|
},
|
3372
|
-
schema:
|
3373
|
-
{
|
3374
|
-
type: 'object',
|
3375
|
-
additionalProperties: false,
|
3376
|
-
properties: {
|
3377
|
-
argumentName: {
|
3378
|
-
type: 'string',
|
3379
|
-
},
|
3380
|
-
},
|
3381
|
-
},
|
3382
|
-
],
|
3501
|
+
schema: schema$9,
|
3383
3502
|
},
|
3384
3503
|
create(context) {
|
3385
3504
|
return {
|
@@ -3435,7 +3554,7 @@ const rule$j = {
|
|
3435
3554
|
},
|
3436
3555
|
};
|
3437
3556
|
|
3438
|
-
const rule$
|
3557
|
+
const rule$l = {
|
3439
3558
|
meta: {
|
3440
3559
|
docs: {
|
3441
3560
|
description: 'Require all deprecation directives to specify a reason.',
|
@@ -3488,7 +3607,7 @@ const rule$k = {
|
|
3488
3607
|
},
|
3489
3608
|
};
|
3490
3609
|
|
3491
|
-
const RULE_ID$
|
3610
|
+
const RULE_ID$b = 'require-description';
|
3492
3611
|
const ALLOWED_KINDS$1 = [
|
3493
3612
|
...TYPES_KINDS,
|
3494
3613
|
Kind.DIRECTIVE_DEFINITION,
|
@@ -3525,12 +3644,40 @@ function getNodeName(node) {
|
|
3525
3644
|
return node.name ? `${node.operation} ${node.name.value}` : node.operation;
|
3526
3645
|
}
|
3527
3646
|
}
|
3528
|
-
const
|
3647
|
+
const schema$a = {
|
3648
|
+
type: 'array',
|
3649
|
+
minItems: 1,
|
3650
|
+
maxItems: 1,
|
3651
|
+
items: {
|
3652
|
+
type: 'object',
|
3653
|
+
additionalProperties: false,
|
3654
|
+
minProperties: 1,
|
3655
|
+
properties: {
|
3656
|
+
types: {
|
3657
|
+
type: 'boolean',
|
3658
|
+
description: `Includes:\n${TYPES_KINDS.map(kind => `- \`${kind}\``).join('\n')}`,
|
3659
|
+
},
|
3660
|
+
rootField: {
|
3661
|
+
type: 'boolean',
|
3662
|
+
description: 'Definitions within `Query`, `Mutation`, and `Subscription` root types.',
|
3663
|
+
},
|
3664
|
+
...Object.fromEntries([...ALLOWED_KINDS$1].sort().map(kind => {
|
3665
|
+
let description = `Read more about this kind on [spec.graphql.org](https://spec.graphql.org/October2021/#${kind}).`;
|
3666
|
+
if (kind === Kind.OPERATION_DEFINITION) {
|
3667
|
+
description +=
|
3668
|
+
'\n> You must use only comment syntax `#` and not description syntax `"""` or `"`.';
|
3669
|
+
}
|
3670
|
+
return [kind, { type: 'boolean', description }];
|
3671
|
+
})),
|
3672
|
+
},
|
3673
|
+
},
|
3674
|
+
};
|
3675
|
+
const rule$m = {
|
3529
3676
|
meta: {
|
3530
3677
|
docs: {
|
3531
3678
|
category: 'Schema',
|
3532
3679
|
description: 'Enforce descriptions in type definitions and operations.',
|
3533
|
-
url: `https://github.com/B2o5T/graphql-eslint/blob/master/docs/rules/${RULE_ID$
|
3680
|
+
url: `https://github.com/B2o5T/graphql-eslint/blob/master/docs/rules/${RULE_ID$b}.md`,
|
3534
3681
|
examples: [
|
3535
3682
|
{
|
3536
3683
|
title: 'Incorrect',
|
@@ -3564,6 +3711,20 @@ const rule$l = {
|
|
3564
3711
|
mutation createUser {
|
3565
3712
|
# ...
|
3566
3713
|
}
|
3714
|
+
`,
|
3715
|
+
},
|
3716
|
+
{
|
3717
|
+
title: 'Correct',
|
3718
|
+
usage: [{ rootField: true }],
|
3719
|
+
code: /* GraphQL */ `
|
3720
|
+
type Mutation {
|
3721
|
+
"Create a new user"
|
3722
|
+
createUser: User
|
3723
|
+
}
|
3724
|
+
|
3725
|
+
type User {
|
3726
|
+
name: String
|
3727
|
+
}
|
3567
3728
|
`,
|
3568
3729
|
},
|
3569
3730
|
],
|
@@ -3571,41 +3732,19 @@ const rule$l = {
|
|
3571
3732
|
{
|
3572
3733
|
types: true,
|
3573
3734
|
[Kind.DIRECTIVE_DEFINITION]: true,
|
3735
|
+
// rootField: true TODO enable in graphql-eslint v4
|
3574
3736
|
},
|
3575
3737
|
],
|
3576
3738
|
recommended: true,
|
3577
3739
|
},
|
3578
3740
|
type: 'suggestion',
|
3579
3741
|
messages: {
|
3580
|
-
[RULE_ID$
|
3581
|
-
},
|
3582
|
-
schema: {
|
3583
|
-
type: 'array',
|
3584
|
-
minItems: 1,
|
3585
|
-
maxItems: 1,
|
3586
|
-
items: {
|
3587
|
-
type: 'object',
|
3588
|
-
additionalProperties: false,
|
3589
|
-
minProperties: 1,
|
3590
|
-
properties: {
|
3591
|
-
types: {
|
3592
|
-
type: 'boolean',
|
3593
|
-
description: `Includes:\n\n${TYPES_KINDS.map(kind => `- \`${kind}\``).join('\n')}`,
|
3594
|
-
},
|
3595
|
-
...Object.fromEntries([...ALLOWED_KINDS$1].sort().map(kind => {
|
3596
|
-
let description = `Read more about this kind on [spec.graphql.org](https://spec.graphql.org/October2021/#${kind}).`;
|
3597
|
-
if (kind === Kind.OPERATION_DEFINITION) {
|
3598
|
-
description +=
|
3599
|
-
'\n\n> You must use only comment syntax `#` and not description syntax `"""` or `"`.';
|
3600
|
-
}
|
3601
|
-
return [kind, { type: 'boolean', description }];
|
3602
|
-
})),
|
3603
|
-
},
|
3604
|
-
},
|
3742
|
+
[RULE_ID$b]: 'Description is required for `{{ nodeName }}`.',
|
3605
3743
|
},
|
3744
|
+
schema: schema$a,
|
3606
3745
|
},
|
3607
3746
|
create(context) {
|
3608
|
-
const { types, ...restOptions } = context.options[0] || {};
|
3747
|
+
const { types, rootField, ...restOptions } = context.options[0] || {};
|
3609
3748
|
const kinds = new Set(types ? TYPES_KINDS : []);
|
3610
3749
|
for (const [kind, isEnabled] of Object.entries(restOptions)) {
|
3611
3750
|
if (isEnabled) {
|
@@ -3615,6 +3754,13 @@ const rule$l = {
|
|
3615
3754
|
kinds.delete(kind);
|
3616
3755
|
}
|
3617
3756
|
}
|
3757
|
+
if (rootField) {
|
3758
|
+
const schema = requireGraphQLSchemaFromContext(RULE_ID$b, context);
|
3759
|
+
const rootTypeNames = getRootTypeNames(schema);
|
3760
|
+
kinds.add(`:matches(ObjectTypeDefinition, ObjectTypeExtension)[name.value=/^(${[
|
3761
|
+
...rootTypeNames,
|
3762
|
+
].join(',')})$/] > FieldDefinition`);
|
3763
|
+
}
|
3618
3764
|
const selector = [...kinds].join(',');
|
3619
3765
|
return {
|
3620
3766
|
[selector](node) {
|
@@ -3638,7 +3784,7 @@ const rule$l = {
|
|
3638
3784
|
if (description.length === 0) {
|
3639
3785
|
context.report({
|
3640
3786
|
loc: isOperation ? getLocation(node.loc.start, node.operation) : node.name.loc,
|
3641
|
-
messageId: RULE_ID$
|
3787
|
+
messageId: RULE_ID$b,
|
3642
3788
|
data: {
|
3643
3789
|
nodeName: getNodeName(node),
|
3644
3790
|
},
|
@@ -3649,14 +3795,14 @@ const rule$l = {
|
|
3649
3795
|
},
|
3650
3796
|
};
|
3651
3797
|
|
3652
|
-
const RULE_ID$
|
3653
|
-
const rule$
|
3798
|
+
const RULE_ID$c = 'require-field-of-type-query-in-mutation-result';
|
3799
|
+
const rule$n = {
|
3654
3800
|
meta: {
|
3655
3801
|
type: 'suggestion',
|
3656
3802
|
docs: {
|
3657
3803
|
category: 'Schema',
|
3658
3804
|
description: 'Allow the client in one round-trip not only to call mutation but also to get a wagon of data to update their application.\n> Currently, no errors are reported for result type `union`, `interface` and `scalar`.',
|
3659
|
-
url: `https://github.com/B2o5T/graphql-eslint/blob/master/docs/rules/${RULE_ID$
|
3805
|
+
url: `https://github.com/B2o5T/graphql-eslint/blob/master/docs/rules/${RULE_ID$c}.md`,
|
3660
3806
|
requiresSchema: true,
|
3661
3807
|
examples: [
|
3662
3808
|
{
|
@@ -3691,7 +3837,7 @@ const rule$m = {
|
|
3691
3837
|
schema: [],
|
3692
3838
|
},
|
3693
3839
|
create(context) {
|
3694
|
-
const schema = requireGraphQLSchemaFromContext(RULE_ID$
|
3840
|
+
const schema = requireGraphQLSchemaFromContext(RULE_ID$c, context);
|
3695
3841
|
const mutationType = schema.getMutationType();
|
3696
3842
|
const queryType = schema.getQueryType();
|
3697
3843
|
if (!mutationType || !queryType) {
|
@@ -3717,17 +3863,36 @@ const rule$m = {
|
|
3717
3863
|
},
|
3718
3864
|
};
|
3719
3865
|
|
3720
|
-
const RULE_ID$
|
3866
|
+
const RULE_ID$d = 'require-id-when-available';
|
3721
3867
|
const DEFAULT_ID_FIELD_NAME = 'id';
|
3722
|
-
const
|
3868
|
+
const schema$b = {
|
3869
|
+
definitions: {
|
3870
|
+
asString: {
|
3871
|
+
type: 'string',
|
3872
|
+
},
|
3873
|
+
asArray: ARRAY_DEFAULT_OPTIONS,
|
3874
|
+
},
|
3875
|
+
type: 'array',
|
3876
|
+
maxItems: 1,
|
3877
|
+
items: {
|
3878
|
+
type: 'object',
|
3879
|
+
additionalProperties: false,
|
3880
|
+
properties: {
|
3881
|
+
fieldName: {
|
3882
|
+
oneOf: [{ $ref: '#/definitions/asString' }, { $ref: '#/definitions/asArray' }],
|
3883
|
+
default: DEFAULT_ID_FIELD_NAME,
|
3884
|
+
},
|
3885
|
+
},
|
3886
|
+
},
|
3887
|
+
};
|
3888
|
+
const rule$o = {
|
3723
3889
|
meta: {
|
3724
3890
|
type: 'suggestion',
|
3725
|
-
// eslint-disable-next-line eslint-plugin/require-meta-has-suggestions
|
3726
3891
|
hasSuggestions: true,
|
3727
3892
|
docs: {
|
3728
3893
|
category: 'Operations',
|
3729
3894
|
description: 'Enforce selecting specific fields when they are available on the GraphQL type.',
|
3730
|
-
url: `https://github.com/B2o5T/graphql-eslint/blob/master/docs/rules/${RULE_ID$
|
3895
|
+
url: `https://github.com/B2o5T/graphql-eslint/blob/master/docs/rules/${RULE_ID$d}.md`,
|
3731
3896
|
requiresSchema: true,
|
3732
3897
|
requiresSiblings: true,
|
3733
3898
|
examples: [
|
@@ -3777,32 +3942,13 @@ const rule$n = {
|
|
3777
3942
|
recommended: true,
|
3778
3943
|
},
|
3779
3944
|
messages: {
|
3780
|
-
[RULE_ID$
|
3781
|
-
},
|
3782
|
-
schema: {
|
3783
|
-
definitions: {
|
3784
|
-
asString: {
|
3785
|
-
type: 'string',
|
3786
|
-
},
|
3787
|
-
asArray: ARRAY_DEFAULT_OPTIONS,
|
3788
|
-
},
|
3789
|
-
type: 'array',
|
3790
|
-
maxItems: 1,
|
3791
|
-
items: {
|
3792
|
-
type: 'object',
|
3793
|
-
additionalProperties: false,
|
3794
|
-
properties: {
|
3795
|
-
fieldName: {
|
3796
|
-
oneOf: [{ $ref: '#/definitions/asString' }, { $ref: '#/definitions/asArray' }],
|
3797
|
-
default: DEFAULT_ID_FIELD_NAME,
|
3798
|
-
},
|
3799
|
-
},
|
3800
|
-
},
|
3945
|
+
[RULE_ID$d]: "Field{{ pluralSuffix }} {{ fieldName }} must be selected when it's available on a type.\nInclude it in your selection set{{ addition }}.",
|
3801
3946
|
},
|
3947
|
+
schema: schema$b,
|
3802
3948
|
},
|
3803
3949
|
create(context) {
|
3804
|
-
const schema = requireGraphQLSchemaFromContext(RULE_ID$
|
3805
|
-
const siblings = requireSiblingsOperations(RULE_ID$
|
3950
|
+
const schema = requireGraphQLSchemaFromContext(RULE_ID$d, context);
|
3951
|
+
const siblings = requireSiblingsOperations(RULE_ID$d, context);
|
3806
3952
|
const { fieldName = DEFAULT_ID_FIELD_NAME } = context.options[0] || {};
|
3807
3953
|
const idNames = asArray(fieldName);
|
3808
3954
|
// Check selections only in OperationDefinition,
|
@@ -3883,7 +4029,7 @@ const rule$n = {
|
|
3883
4029
|
: ` or add to used fragment${checkedFragmentSpreads.size > 1 ? 's' : ''} ${englishJoinWords([...checkedFragmentSpreads].map(name => `\`${name}\``))}`;
|
3884
4030
|
const problem = {
|
3885
4031
|
loc,
|
3886
|
-
messageId: RULE_ID$
|
4032
|
+
messageId: RULE_ID$d,
|
3887
4033
|
data: {
|
3888
4034
|
pluralSuffix,
|
3889
4035
|
fieldName,
|
@@ -3910,15 +4056,31 @@ const rule$n = {
|
|
3910
4056
|
},
|
3911
4057
|
};
|
3912
4058
|
|
3913
|
-
const RULE_ID$
|
3914
|
-
const
|
4059
|
+
const RULE_ID$e = 'selection-set-depth';
|
4060
|
+
const schema$c = {
|
4061
|
+
type: 'array',
|
4062
|
+
minItems: 1,
|
4063
|
+
maxItems: 1,
|
4064
|
+
items: {
|
4065
|
+
type: 'object',
|
4066
|
+
additionalProperties: false,
|
4067
|
+
required: ['maxDepth'],
|
4068
|
+
properties: {
|
4069
|
+
maxDepth: {
|
4070
|
+
type: 'number',
|
4071
|
+
},
|
4072
|
+
ignore: ARRAY_DEFAULT_OPTIONS,
|
4073
|
+
},
|
4074
|
+
},
|
4075
|
+
};
|
4076
|
+
const rule$p = {
|
3915
4077
|
meta: {
|
3916
4078
|
type: 'suggestion',
|
3917
4079
|
hasSuggestions: true,
|
3918
4080
|
docs: {
|
3919
4081
|
category: 'Operations',
|
3920
4082
|
description: 'Limit the complexity of the GraphQL operations solely by their depth. Based on [graphql-depth-limit](https://npmjs.com/package/graphql-depth-limit).',
|
3921
|
-
url: `https://github.com/B2o5T/graphql-eslint/blob/master/docs/rules/${RULE_ID$
|
4083
|
+
url: `https://github.com/B2o5T/graphql-eslint/blob/master/docs/rules/${RULE_ID$e}.md`,
|
3922
4084
|
requiresSiblings: true,
|
3923
4085
|
examples: [
|
3924
4086
|
{
|
@@ -3964,30 +4126,15 @@ const rule$o = {
|
|
3964
4126
|
recommended: true,
|
3965
4127
|
configOptions: [{ maxDepth: 7 }],
|
3966
4128
|
},
|
3967
|
-
schema:
|
3968
|
-
type: 'array',
|
3969
|
-
minItems: 1,
|
3970
|
-
maxItems: 1,
|
3971
|
-
items: {
|
3972
|
-
type: 'object',
|
3973
|
-
additionalProperties: false,
|
3974
|
-
required: ['maxDepth'],
|
3975
|
-
properties: {
|
3976
|
-
maxDepth: {
|
3977
|
-
type: 'number',
|
3978
|
-
},
|
3979
|
-
ignore: ARRAY_DEFAULT_OPTIONS,
|
3980
|
-
},
|
3981
|
-
},
|
3982
|
-
},
|
4129
|
+
schema: schema$c,
|
3983
4130
|
},
|
3984
4131
|
create(context) {
|
3985
4132
|
let siblings = null;
|
3986
4133
|
try {
|
3987
|
-
siblings = requireSiblingsOperations(RULE_ID$
|
4134
|
+
siblings = requireSiblingsOperations(RULE_ID$e, context);
|
3988
4135
|
}
|
3989
4136
|
catch (_a) {
|
3990
|
-
logger.warn(`Rule "${RULE_ID$
|
4137
|
+
logger.warn(`Rule "${RULE_ID$e}" works best with siblings operations loaded. For more info: https://bit.ly/graphql-eslint-operations`);
|
3991
4138
|
}
|
3992
4139
|
const { maxDepth, ignore = [] } = context.options[0];
|
3993
4140
|
const checkFn = depthLimit(maxDepth, { ignore });
|
@@ -4031,22 +4178,54 @@ const rule$o = {
|
|
4031
4178
|
});
|
4032
4179
|
}
|
4033
4180
|
catch (e) {
|
4034
|
-
logger.warn(`Rule "${RULE_ID$
|
4181
|
+
logger.warn(`Rule "${RULE_ID$e}" check failed due to a missing siblings operations. For more info: https://bit.ly/graphql-eslint-operations`, e);
|
4035
4182
|
}
|
4036
4183
|
},
|
4037
4184
|
};
|
4038
4185
|
},
|
4039
4186
|
};
|
4040
4187
|
|
4041
|
-
const RULE_ID$
|
4042
|
-
const
|
4188
|
+
const RULE_ID$f = 'strict-id-in-types';
|
4189
|
+
const schema$d = {
|
4190
|
+
type: 'array',
|
4191
|
+
maxItems: 1,
|
4192
|
+
items: {
|
4193
|
+
type: 'object',
|
4194
|
+
additionalProperties: false,
|
4195
|
+
properties: {
|
4196
|
+
acceptedIdNames: {
|
4197
|
+
...ARRAY_DEFAULT_OPTIONS,
|
4198
|
+
default: ['id'],
|
4199
|
+
},
|
4200
|
+
acceptedIdTypes: {
|
4201
|
+
...ARRAY_DEFAULT_OPTIONS,
|
4202
|
+
default: ['ID'],
|
4203
|
+
},
|
4204
|
+
exceptions: {
|
4205
|
+
type: 'object',
|
4206
|
+
additionalProperties: false,
|
4207
|
+
properties: {
|
4208
|
+
types: {
|
4209
|
+
...ARRAY_DEFAULT_OPTIONS,
|
4210
|
+
description: 'This is used to exclude types with names that match one of the specified values.',
|
4211
|
+
},
|
4212
|
+
suffixes: {
|
4213
|
+
...ARRAY_DEFAULT_OPTIONS,
|
4214
|
+
description: 'This is used to exclude types with names with suffixes that match one of the specified values.',
|
4215
|
+
},
|
4216
|
+
},
|
4217
|
+
},
|
4218
|
+
},
|
4219
|
+
},
|
4220
|
+
};
|
4221
|
+
const rule$q = {
|
4043
4222
|
meta: {
|
4044
4223
|
type: 'suggestion',
|
4045
4224
|
docs: {
|
4046
4225
|
description: 'Requires output types to have one unique identifier unless they do not have a logical one. Exceptions can be used to ignore output types that do not have unique identifiers.',
|
4047
4226
|
category: 'Schema',
|
4048
4227
|
recommended: true,
|
4049
|
-
url: `https://github.com/B2o5T/graphql-eslint/blob/master/docs/rules/${RULE_ID$
|
4228
|
+
url: `https://github.com/B2o5T/graphql-eslint/blob/master/docs/rules/${RULE_ID$f}.md`,
|
4050
4229
|
requiresSchema: true,
|
4051
4230
|
examples: [
|
4052
4231
|
{
|
@@ -4110,37 +4289,7 @@ const rule$p = {
|
|
4110
4289
|
},
|
4111
4290
|
],
|
4112
4291
|
},
|
4113
|
-
schema:
|
4114
|
-
type: 'array',
|
4115
|
-
maxItems: 1,
|
4116
|
-
items: {
|
4117
|
-
type: 'object',
|
4118
|
-
additionalProperties: false,
|
4119
|
-
properties: {
|
4120
|
-
acceptedIdNames: {
|
4121
|
-
...ARRAY_DEFAULT_OPTIONS,
|
4122
|
-
default: ['id'],
|
4123
|
-
},
|
4124
|
-
acceptedIdTypes: {
|
4125
|
-
...ARRAY_DEFAULT_OPTIONS,
|
4126
|
-
default: ['ID'],
|
4127
|
-
},
|
4128
|
-
exceptions: {
|
4129
|
-
type: 'object',
|
4130
|
-
properties: {
|
4131
|
-
types: {
|
4132
|
-
...ARRAY_DEFAULT_OPTIONS,
|
4133
|
-
description: 'This is used to exclude types with names that match one of the specified values.',
|
4134
|
-
},
|
4135
|
-
suffixes: {
|
4136
|
-
...ARRAY_DEFAULT_OPTIONS,
|
4137
|
-
description: 'This is used to exclude types with names with suffixes that match one of the specified values.',
|
4138
|
-
},
|
4139
|
-
},
|
4140
|
-
},
|
4141
|
-
},
|
4142
|
-
},
|
4143
|
-
},
|
4292
|
+
schema: schema$d,
|
4144
4293
|
},
|
4145
4294
|
create(context) {
|
4146
4295
|
const options = {
|
@@ -4149,7 +4298,7 @@ const rule$p = {
|
|
4149
4298
|
exceptions: {},
|
4150
4299
|
...context.options[0],
|
4151
4300
|
};
|
4152
|
-
const schema = requireGraphQLSchemaFromContext(RULE_ID$
|
4301
|
+
const schema = requireGraphQLSchemaFromContext(RULE_ID$f, context);
|
4153
4302
|
const rootTypeNames = [
|
4154
4303
|
schema.getQueryType(),
|
4155
4304
|
schema.getMutationType(),
|
@@ -4194,7 +4343,7 @@ const rule$p = {
|
|
4194
4343
|
},
|
4195
4344
|
};
|
4196
4345
|
|
4197
|
-
const RULE_ID$
|
4346
|
+
const RULE_ID$g = 'unique-fragment-name';
|
4198
4347
|
const checkNode = (context, node, ruleId) => {
|
4199
4348
|
const documentName = node.name.value;
|
4200
4349
|
const siblings = requireSiblingsOperations(ruleId, context);
|
@@ -4221,13 +4370,13 @@ const checkNode = (context, node, ruleId) => {
|
|
4221
4370
|
});
|
4222
4371
|
}
|
4223
4372
|
};
|
4224
|
-
const rule$
|
4373
|
+
const rule$r = {
|
4225
4374
|
meta: {
|
4226
4375
|
type: 'suggestion',
|
4227
4376
|
docs: {
|
4228
4377
|
category: 'Operations',
|
4229
4378
|
description: 'Enforce unique fragment names across your project.',
|
4230
|
-
url: `https://github.com/B2o5T/graphql-eslint/blob/master/docs/rules/${RULE_ID$
|
4379
|
+
url: `https://github.com/B2o5T/graphql-eslint/blob/master/docs/rules/${RULE_ID$g}.md`,
|
4231
4380
|
requiresSiblings: true,
|
4232
4381
|
examples: [
|
4233
4382
|
{
|
@@ -4265,27 +4414,27 @@ const rule$q = {
|
|
4265
4414
|
],
|
4266
4415
|
},
|
4267
4416
|
messages: {
|
4268
|
-
[RULE_ID$
|
4417
|
+
[RULE_ID$g]: 'Fragment named "{{ documentName }}" already defined in:\n{{ summary }}',
|
4269
4418
|
},
|
4270
4419
|
schema: [],
|
4271
4420
|
},
|
4272
4421
|
create(context) {
|
4273
4422
|
return {
|
4274
4423
|
FragmentDefinition(node) {
|
4275
|
-
checkNode(context, node, RULE_ID$
|
4424
|
+
checkNode(context, node, RULE_ID$g);
|
4276
4425
|
},
|
4277
4426
|
};
|
4278
4427
|
},
|
4279
4428
|
};
|
4280
4429
|
|
4281
|
-
const RULE_ID$
|
4282
|
-
const rule$
|
4430
|
+
const RULE_ID$h = 'unique-operation-name';
|
4431
|
+
const rule$s = {
|
4283
4432
|
meta: {
|
4284
4433
|
type: 'suggestion',
|
4285
4434
|
docs: {
|
4286
4435
|
category: 'Operations',
|
4287
4436
|
description: 'Enforce unique operation names across your project.',
|
4288
|
-
url: `https://github.com/B2o5T/graphql-eslint/blob/master/docs/rules/${RULE_ID$
|
4437
|
+
url: `https://github.com/B2o5T/graphql-eslint/blob/master/docs/rules/${RULE_ID$h}.md`,
|
4289
4438
|
requiresSiblings: true,
|
4290
4439
|
examples: [
|
4291
4440
|
{
|
@@ -4327,14 +4476,14 @@ const rule$r = {
|
|
4327
4476
|
],
|
4328
4477
|
},
|
4329
4478
|
messages: {
|
4330
|
-
[RULE_ID$
|
4479
|
+
[RULE_ID$h]: 'Operation named "{{ documentName }}" already defined in:\n{{ summary }}',
|
4331
4480
|
},
|
4332
4481
|
schema: [],
|
4333
4482
|
},
|
4334
4483
|
create(context) {
|
4335
4484
|
return {
|
4336
4485
|
'OperationDefinition[name!=undefined]'(node) {
|
4337
|
-
checkNode(context, node, RULE_ID$
|
4486
|
+
checkNode(context, node, RULE_ID$h);
|
4338
4487
|
},
|
4339
4488
|
};
|
4340
4489
|
},
|
@@ -4348,31 +4497,32 @@ const rules = {
|
|
4348
4497
|
alphabetize: rule,
|
4349
4498
|
'description-style': rule$1,
|
4350
4499
|
'input-name': rule$2,
|
4351
|
-
'
|
4352
|
-
'
|
4353
|
-
'
|
4354
|
-
'no-
|
4355
|
-
'no-
|
4356
|
-
'no-
|
4357
|
-
'no-
|
4358
|
-
'no-
|
4359
|
-
'no-
|
4360
|
-
'no-
|
4361
|
-
'no-
|
4362
|
-
'no-
|
4363
|
-
'
|
4364
|
-
'relay-
|
4365
|
-
'relay-
|
4366
|
-
'relay-
|
4367
|
-
'
|
4368
|
-
'require-deprecation-
|
4369
|
-
'require-
|
4370
|
-
'require-
|
4371
|
-
'require-
|
4372
|
-
'
|
4373
|
-
'
|
4374
|
-
'
|
4375
|
-
'unique-
|
4500
|
+
'lone-executable-definition': rule$3,
|
4501
|
+
'match-document-filename': rule$4,
|
4502
|
+
'naming-convention': rule$5,
|
4503
|
+
'no-anonymous-operations': rule$6,
|
4504
|
+
'no-case-insensitive-enum-values-duplicates': rule$7,
|
4505
|
+
'no-deprecated': rule$8,
|
4506
|
+
'no-duplicate-fields': rule$9,
|
4507
|
+
'no-hashtag-description': rule$a,
|
4508
|
+
'no-root-type': rule$b,
|
4509
|
+
'no-scalar-result-type-on-mutation': rule$c,
|
4510
|
+
'no-typename-prefix': rule$d,
|
4511
|
+
'no-unreachable-types': rule$e,
|
4512
|
+
'no-unused-fields': rule$f,
|
4513
|
+
'relay-arguments': rule$g,
|
4514
|
+
'relay-connection-types': rule$h,
|
4515
|
+
'relay-edge-types': rule$i,
|
4516
|
+
'relay-page-info': rule$j,
|
4517
|
+
'require-deprecation-date': rule$k,
|
4518
|
+
'require-deprecation-reason': rule$l,
|
4519
|
+
'require-description': rule$m,
|
4520
|
+
'require-field-of-type-query-in-mutation-result': rule$n,
|
4521
|
+
'require-id-when-available': rule$o,
|
4522
|
+
'selection-set-depth': rule$p,
|
4523
|
+
'strict-id-in-types': rule$q,
|
4524
|
+
'unique-fragment-name': rule$r,
|
4525
|
+
'unique-operation-name': rule$s,
|
4376
4526
|
};
|
4377
4527
|
|
4378
4528
|
// Based on the `eslint-plugin-import`'s cache
|