@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.js
CHANGED
@@ -334,7 +334,7 @@ const validationToRule = ({ ruleId, ruleName, getDocumentNode, schema = [], hasD
|
|
334
334
|
...docs,
|
335
335
|
graphQLJSRuleName: ruleName,
|
336
336
|
url: `https://github.com/B2o5T/graphql-eslint/blob/master/docs/rules/${ruleId}.md`,
|
337
|
-
description: `${docs.description}\n
|
337
|
+
description: `${docs.description}\n> This rule is a wrapper around a \`graphql-js\` validation function.`,
|
338
338
|
},
|
339
339
|
schema,
|
340
340
|
hasSuggestions: hasDidYouMeanSuggestions,
|
@@ -733,6 +733,58 @@ const argumentsEnum = [
|
|
733
733
|
graphql.Kind.DIRECTIVE_DEFINITION,
|
734
734
|
graphql.Kind.DIRECTIVE,
|
735
735
|
];
|
736
|
+
const schema = {
|
737
|
+
type: 'array',
|
738
|
+
minItems: 1,
|
739
|
+
maxItems: 1,
|
740
|
+
items: {
|
741
|
+
type: 'object',
|
742
|
+
additionalProperties: false,
|
743
|
+
minProperties: 1,
|
744
|
+
properties: {
|
745
|
+
fields: {
|
746
|
+
...ARRAY_DEFAULT_OPTIONS,
|
747
|
+
items: {
|
748
|
+
enum: fieldsEnum,
|
749
|
+
},
|
750
|
+
description: 'Fields of `type`, `interface`, and `input`.',
|
751
|
+
},
|
752
|
+
values: {
|
753
|
+
...ARRAY_DEFAULT_OPTIONS,
|
754
|
+
items: {
|
755
|
+
enum: valuesEnum,
|
756
|
+
},
|
757
|
+
description: 'Values of `enum`.',
|
758
|
+
},
|
759
|
+
selections: {
|
760
|
+
...ARRAY_DEFAULT_OPTIONS,
|
761
|
+
items: {
|
762
|
+
enum: selectionsEnum,
|
763
|
+
},
|
764
|
+
description: 'Selections of `fragment` and operations `query`, `mutation` and `subscription`.',
|
765
|
+
},
|
766
|
+
variables: {
|
767
|
+
...ARRAY_DEFAULT_OPTIONS,
|
768
|
+
items: {
|
769
|
+
enum: variablesEnum,
|
770
|
+
},
|
771
|
+
description: 'Variables of operations `query`, `mutation` and `subscription`.',
|
772
|
+
},
|
773
|
+
arguments: {
|
774
|
+
...ARRAY_DEFAULT_OPTIONS,
|
775
|
+
items: {
|
776
|
+
enum: argumentsEnum,
|
777
|
+
},
|
778
|
+
description: 'Arguments of fields and directives.',
|
779
|
+
},
|
780
|
+
definitions: {
|
781
|
+
type: 'boolean',
|
782
|
+
description: 'Definitions – `type`, `interface`, `enum`, `scalar`, `input`, `union` and `directive`.',
|
783
|
+
default: false,
|
784
|
+
},
|
785
|
+
},
|
786
|
+
},
|
787
|
+
};
|
736
788
|
const rule = {
|
737
789
|
meta: {
|
738
790
|
type: 'suggestion',
|
@@ -839,58 +891,7 @@ const rule = {
|
|
839
891
|
messages: {
|
840
892
|
[RULE_ID]: '`{{ currName }}` should be before {{ prevName }}.',
|
841
893
|
},
|
842
|
-
schema
|
843
|
-
type: 'array',
|
844
|
-
minItems: 1,
|
845
|
-
maxItems: 1,
|
846
|
-
items: {
|
847
|
-
type: 'object',
|
848
|
-
additionalProperties: false,
|
849
|
-
minProperties: 1,
|
850
|
-
properties: {
|
851
|
-
fields: {
|
852
|
-
...ARRAY_DEFAULT_OPTIONS,
|
853
|
-
items: {
|
854
|
-
enum: fieldsEnum,
|
855
|
-
},
|
856
|
-
description: 'Fields of `type`, `interface`, and `input`.',
|
857
|
-
},
|
858
|
-
values: {
|
859
|
-
...ARRAY_DEFAULT_OPTIONS,
|
860
|
-
items: {
|
861
|
-
enum: valuesEnum,
|
862
|
-
},
|
863
|
-
description: 'Values of `enum`.',
|
864
|
-
},
|
865
|
-
selections: {
|
866
|
-
...ARRAY_DEFAULT_OPTIONS,
|
867
|
-
items: {
|
868
|
-
enum: selectionsEnum,
|
869
|
-
},
|
870
|
-
description: 'Selections of `fragment` and operations `query`, `mutation` and `subscription`.',
|
871
|
-
},
|
872
|
-
variables: {
|
873
|
-
...ARRAY_DEFAULT_OPTIONS,
|
874
|
-
items: {
|
875
|
-
enum: variablesEnum,
|
876
|
-
},
|
877
|
-
description: 'Variables of operations `query`, `mutation` and `subscription`.',
|
878
|
-
},
|
879
|
-
arguments: {
|
880
|
-
...ARRAY_DEFAULT_OPTIONS,
|
881
|
-
items: {
|
882
|
-
enum: argumentsEnum,
|
883
|
-
},
|
884
|
-
description: 'Arguments of fields and directives.',
|
885
|
-
},
|
886
|
-
definitions: {
|
887
|
-
type: 'boolean',
|
888
|
-
description: 'Definitions – `type`, `interface`, `enum`, `scalar`, `input`, `union` and `directive`.',
|
889
|
-
default: false,
|
890
|
-
},
|
891
|
-
},
|
892
|
-
},
|
893
|
-
},
|
894
|
+
schema,
|
894
895
|
},
|
895
896
|
create(context) {
|
896
897
|
var _a, _b, _c, _d, _e;
|
@@ -1033,6 +1034,21 @@ const rule = {
|
|
1033
1034
|
},
|
1034
1035
|
};
|
1035
1036
|
|
1037
|
+
const schema$1 = {
|
1038
|
+
type: 'array',
|
1039
|
+
maxItems: 1,
|
1040
|
+
items: {
|
1041
|
+
type: 'object',
|
1042
|
+
additionalProperties: false,
|
1043
|
+
minProperties: 1,
|
1044
|
+
properties: {
|
1045
|
+
style: {
|
1046
|
+
enum: ['block', 'inline'],
|
1047
|
+
default: 'block',
|
1048
|
+
},
|
1049
|
+
},
|
1050
|
+
},
|
1051
|
+
};
|
1036
1052
|
const rule$1 = {
|
1037
1053
|
meta: {
|
1038
1054
|
type: 'suggestion',
|
@@ -1065,18 +1081,7 @@ const rule$1 = {
|
|
1065
1081
|
url: 'https://github.com/B2o5T/graphql-eslint/blob/master/docs/rules/description-style.md',
|
1066
1082
|
recommended: true,
|
1067
1083
|
},
|
1068
|
-
schema:
|
1069
|
-
{
|
1070
|
-
type: 'object',
|
1071
|
-
additionalProperties: false,
|
1072
|
-
properties: {
|
1073
|
-
style: {
|
1074
|
-
enum: ['block', 'inline'],
|
1075
|
-
default: 'block',
|
1076
|
-
},
|
1077
|
-
},
|
1078
|
-
},
|
1079
|
-
],
|
1084
|
+
schema: schema$1,
|
1080
1085
|
},
|
1081
1086
|
create(context) {
|
1082
1087
|
const { style = 'block' } = context.options[0] || {};
|
@@ -1105,6 +1110,36 @@ const rule$1 = {
|
|
1105
1110
|
},
|
1106
1111
|
};
|
1107
1112
|
|
1113
|
+
const schema$2 = {
|
1114
|
+
type: 'array',
|
1115
|
+
maxItems: 1,
|
1116
|
+
items: {
|
1117
|
+
type: 'object',
|
1118
|
+
additionalProperties: false,
|
1119
|
+
properties: {
|
1120
|
+
checkInputType: {
|
1121
|
+
type: 'boolean',
|
1122
|
+
default: false,
|
1123
|
+
description: 'Check that the input type name follows the convention <mutationName>Input',
|
1124
|
+
},
|
1125
|
+
caseSensitiveInputType: {
|
1126
|
+
type: 'boolean',
|
1127
|
+
default: true,
|
1128
|
+
description: 'Allow for case discrepancies in the input type name',
|
1129
|
+
},
|
1130
|
+
checkQueries: {
|
1131
|
+
type: 'boolean',
|
1132
|
+
default: false,
|
1133
|
+
description: 'Apply the rule to Queries',
|
1134
|
+
},
|
1135
|
+
checkMutations: {
|
1136
|
+
type: 'boolean',
|
1137
|
+
default: true,
|
1138
|
+
description: 'Apply the rule to Mutations',
|
1139
|
+
},
|
1140
|
+
},
|
1141
|
+
},
|
1142
|
+
};
|
1108
1143
|
const isObjectType = (node) => [graphql.Kind.OBJECT_TYPE_DEFINITION, graphql.Kind.OBJECT_TYPE_EXTENSION].includes(node.type);
|
1109
1144
|
const isQueryType = (node) => isObjectType(node) && node.name.value === 'Query';
|
1110
1145
|
const isMutationType = (node) => isObjectType(node) && node.name.value === 'Mutation';
|
@@ -1146,34 +1181,7 @@ const rule$2 = {
|
|
1146
1181
|
},
|
1147
1182
|
],
|
1148
1183
|
},
|
1149
|
-
schema:
|
1150
|
-
{
|
1151
|
-
type: 'object',
|
1152
|
-
additionalProperties: false,
|
1153
|
-
properties: {
|
1154
|
-
checkInputType: {
|
1155
|
-
type: 'boolean',
|
1156
|
-
default: false,
|
1157
|
-
description: 'Check that the input type name follows the convention <mutationName>Input',
|
1158
|
-
},
|
1159
|
-
caseSensitiveInputType: {
|
1160
|
-
type: 'boolean',
|
1161
|
-
default: true,
|
1162
|
-
description: 'Allow for case discrepancies in the input type name',
|
1163
|
-
},
|
1164
|
-
checkQueries: {
|
1165
|
-
type: 'boolean',
|
1166
|
-
default: false,
|
1167
|
-
description: 'Apply the rule to Queries',
|
1168
|
-
},
|
1169
|
-
checkMutations: {
|
1170
|
-
type: 'boolean',
|
1171
|
-
default: true,
|
1172
|
-
description: 'Apply the rule to Mutations',
|
1173
|
-
},
|
1174
|
-
},
|
1175
|
-
},
|
1176
|
-
],
|
1184
|
+
schema: schema$2,
|
1177
1185
|
},
|
1178
1186
|
create(context) {
|
1179
1187
|
const options = {
|
@@ -1235,9 +1243,92 @@ const rule$2 = {
|
|
1235
1243
|
},
|
1236
1244
|
};
|
1237
1245
|
|
1246
|
+
const RULE_ID$1 = 'lone-executable-definition';
|
1247
|
+
const schema$3 = {
|
1248
|
+
type: 'array',
|
1249
|
+
maxItems: 1,
|
1250
|
+
items: {
|
1251
|
+
type: 'object',
|
1252
|
+
minProperties: 1,
|
1253
|
+
additionalProperties: false,
|
1254
|
+
properties: {
|
1255
|
+
ignore: {
|
1256
|
+
...ARRAY_DEFAULT_OPTIONS,
|
1257
|
+
maxItems: 3,
|
1258
|
+
items: {
|
1259
|
+
enum: ['fragment', 'query', 'mutation', 'subscription'],
|
1260
|
+
},
|
1261
|
+
description: 'Allow certain definitions to be placed alongside others.',
|
1262
|
+
},
|
1263
|
+
},
|
1264
|
+
},
|
1265
|
+
};
|
1266
|
+
const rule$3 = {
|
1267
|
+
meta: {
|
1268
|
+
type: 'suggestion',
|
1269
|
+
docs: {
|
1270
|
+
category: 'Operations',
|
1271
|
+
description: 'Require all queries, mutations, subscriptions and fragments to be located in separate files.',
|
1272
|
+
url: `https://github.com/B2o5T/graphql-eslint/blob/master/docs/rules/${RULE_ID$1}.md`,
|
1273
|
+
examples: [
|
1274
|
+
{
|
1275
|
+
title: 'Incorrect',
|
1276
|
+
code: /* GraphQL */ `
|
1277
|
+
query Foo {
|
1278
|
+
id
|
1279
|
+
}
|
1280
|
+
fragment Bar on Baz {
|
1281
|
+
id
|
1282
|
+
}
|
1283
|
+
`,
|
1284
|
+
},
|
1285
|
+
{
|
1286
|
+
title: 'Correct',
|
1287
|
+
code: /* GraphQL */ `
|
1288
|
+
query Foo {
|
1289
|
+
id
|
1290
|
+
}
|
1291
|
+
`,
|
1292
|
+
},
|
1293
|
+
],
|
1294
|
+
},
|
1295
|
+
messages: {
|
1296
|
+
[RULE_ID$1]: '{{name}} should be in a separate file.',
|
1297
|
+
},
|
1298
|
+
schema: schema$3,
|
1299
|
+
},
|
1300
|
+
create(context) {
|
1301
|
+
var _a;
|
1302
|
+
const ignore = new Set(((_a = context.options[0]) === null || _a === void 0 ? void 0 : _a.ignore) || []);
|
1303
|
+
const definitions = [];
|
1304
|
+
return {
|
1305
|
+
':matches(OperationDefinition, FragmentDefinition)'(node) {
|
1306
|
+
const type = 'operation' in node ? node.operation : 'fragment';
|
1307
|
+
if (!ignore.has(type)) {
|
1308
|
+
definitions.push({ type, node });
|
1309
|
+
}
|
1310
|
+
},
|
1311
|
+
'Program:exit'() {
|
1312
|
+
var _a, _b;
|
1313
|
+
for (const { node, type } of definitions.slice(1) /* ignore first definition */) {
|
1314
|
+
let name = pascalCase(type);
|
1315
|
+
const definitionName = (_a = node.name) === null || _a === void 0 ? void 0 : _a.value;
|
1316
|
+
if (definitionName) {
|
1317
|
+
name += ` "${definitionName}"`;
|
1318
|
+
}
|
1319
|
+
context.report({
|
1320
|
+
loc: ((_b = node.name) === null || _b === void 0 ? void 0 : _b.loc) || getLocation(node.loc.start, type),
|
1321
|
+
messageId: RULE_ID$1,
|
1322
|
+
data: { name },
|
1323
|
+
});
|
1324
|
+
}
|
1325
|
+
},
|
1326
|
+
};
|
1327
|
+
},
|
1328
|
+
};
|
1329
|
+
|
1238
1330
|
const MATCH_EXTENSION = 'MATCH_EXTENSION';
|
1239
1331
|
const MATCH_STYLE = 'MATCH_STYLE';
|
1240
|
-
const ACCEPTED_EXTENSIONS = ['.gql', '.graphql'];
|
1241
1332
|
const CASE_STYLES = [
|
1242
1333
|
'camelCase',
|
1243
1334
|
'PascalCase',
|
@@ -1249,7 +1340,40 @@ const CASE_STYLES = [
|
|
1249
1340
|
const schemaOption = {
|
1250
1341
|
oneOf: [{ $ref: '#/definitions/asString' }, { $ref: '#/definitions/asObject' }],
|
1251
1342
|
};
|
1252
|
-
const
|
1343
|
+
const schema$4 = {
|
1344
|
+
definitions: {
|
1345
|
+
asString: {
|
1346
|
+
enum: CASE_STYLES,
|
1347
|
+
description: `One of: ${CASE_STYLES.map(t => `\`${t}\``).join(', ')}`,
|
1348
|
+
},
|
1349
|
+
asObject: {
|
1350
|
+
type: 'object',
|
1351
|
+
additionalProperties: false,
|
1352
|
+
minProperties: 1,
|
1353
|
+
properties: {
|
1354
|
+
style: { enum: CASE_STYLES },
|
1355
|
+
suffix: { type: 'string' },
|
1356
|
+
prefix: { type: 'string' },
|
1357
|
+
},
|
1358
|
+
},
|
1359
|
+
},
|
1360
|
+
type: 'array',
|
1361
|
+
minItems: 1,
|
1362
|
+
maxItems: 1,
|
1363
|
+
items: {
|
1364
|
+
type: 'object',
|
1365
|
+
additionalProperties: false,
|
1366
|
+
minProperties: 1,
|
1367
|
+
properties: {
|
1368
|
+
fileExtension: { enum: ['.gql', '.graphql'] },
|
1369
|
+
query: schemaOption,
|
1370
|
+
mutation: schemaOption,
|
1371
|
+
subscription: schemaOption,
|
1372
|
+
fragment: schemaOption,
|
1373
|
+
},
|
1374
|
+
},
|
1375
|
+
};
|
1376
|
+
const rule$4 = {
|
1253
1377
|
meta: {
|
1254
1378
|
type: 'suggestion',
|
1255
1379
|
docs: {
|
@@ -1324,6 +1448,26 @@ const rule$3 = {
|
|
1324
1448
|
fullName
|
1325
1449
|
}
|
1326
1450
|
}
|
1451
|
+
`,
|
1452
|
+
},
|
1453
|
+
{
|
1454
|
+
title: 'Correct',
|
1455
|
+
usage: [{ fragment: { style: 'kebab-case', prefix: 'mutation.' } }],
|
1456
|
+
code: /* GraphQL */ `
|
1457
|
+
# mutation.add-alert.graphql
|
1458
|
+
mutation addAlert {
|
1459
|
+
foo
|
1460
|
+
}
|
1461
|
+
`,
|
1462
|
+
},
|
1463
|
+
{
|
1464
|
+
title: 'Correct',
|
1465
|
+
usage: [{ fragment: { prefix: 'query.' } }],
|
1466
|
+
code: /* GraphQL */ `
|
1467
|
+
# query.me.graphql
|
1468
|
+
query me {
|
1469
|
+
foo
|
1470
|
+
}
|
1327
1471
|
`,
|
1328
1472
|
},
|
1329
1473
|
],
|
@@ -1340,38 +1484,7 @@ const rule$3 = {
|
|
1340
1484
|
[MATCH_EXTENSION]: 'File extension "{{ fileExtension }}" don\'t match extension "{{ expectedFileExtension }}"',
|
1341
1485
|
[MATCH_STYLE]: 'Unexpected filename "{{ filename }}". Rename it to "{{ expectedFilename }}"',
|
1342
1486
|
},
|
1343
|
-
schema:
|
1344
|
-
definitions: {
|
1345
|
-
asString: {
|
1346
|
-
enum: CASE_STYLES,
|
1347
|
-
description: `One of: ${CASE_STYLES.map(t => `\`${t}\``).join(', ')}`,
|
1348
|
-
},
|
1349
|
-
asObject: {
|
1350
|
-
type: 'object',
|
1351
|
-
additionalProperties: false,
|
1352
|
-
minProperties: 1,
|
1353
|
-
properties: {
|
1354
|
-
style: { enum: CASE_STYLES },
|
1355
|
-
suffix: { type: 'string' },
|
1356
|
-
},
|
1357
|
-
},
|
1358
|
-
},
|
1359
|
-
type: 'array',
|
1360
|
-
minItems: 1,
|
1361
|
-
maxItems: 1,
|
1362
|
-
items: {
|
1363
|
-
type: 'object',
|
1364
|
-
additionalProperties: false,
|
1365
|
-
minProperties: 1,
|
1366
|
-
properties: {
|
1367
|
-
fileExtension: { enum: ACCEPTED_EXTENSIONS },
|
1368
|
-
query: schemaOption,
|
1369
|
-
mutation: schemaOption,
|
1370
|
-
subscription: schemaOption,
|
1371
|
-
fragment: schemaOption,
|
1372
|
-
},
|
1373
|
-
},
|
1374
|
-
},
|
1487
|
+
schema: schema$4,
|
1375
1488
|
},
|
1376
1489
|
create(context) {
|
1377
1490
|
const options = context.options[0] || {
|
@@ -1418,13 +1531,13 @@ const rule$3 = {
|
|
1418
1531
|
option = { style: option };
|
1419
1532
|
}
|
1420
1533
|
const expectedExtension = options.fileExtension || fileExtension;
|
1421
|
-
let expectedFilename;
|
1534
|
+
let expectedFilename = option.prefix || '';
|
1422
1535
|
if (option.style) {
|
1423
|
-
expectedFilename
|
1536
|
+
expectedFilename +=
|
1424
1537
|
option.style === 'matchDocumentStyle' ? docName : convertCase(option.style, docName);
|
1425
1538
|
}
|
1426
1539
|
else {
|
1427
|
-
expectedFilename
|
1540
|
+
expectedFilename += filename;
|
1428
1541
|
}
|
1429
1542
|
expectedFilename += (option.suffix || '') + expectedExtension;
|
1430
1543
|
const filenameWithExtension = filename + expectedExtension;
|
@@ -1473,7 +1586,67 @@ const ALLOWED_STYLES = Object.keys(StyleToRegex);
|
|
1473
1586
|
const schemaOption$1 = {
|
1474
1587
|
oneOf: [{ $ref: '#/definitions/asString' }, { $ref: '#/definitions/asObject' }],
|
1475
1588
|
};
|
1476
|
-
const
|
1589
|
+
const schema$5 = {
|
1590
|
+
definitions: {
|
1591
|
+
asString: {
|
1592
|
+
enum: ALLOWED_STYLES,
|
1593
|
+
description: `One of: ${ALLOWED_STYLES.map(t => `\`${t}\``).join(', ')}`,
|
1594
|
+
},
|
1595
|
+
asObject: {
|
1596
|
+
type: 'object',
|
1597
|
+
additionalProperties: false,
|
1598
|
+
properties: {
|
1599
|
+
style: { enum: ALLOWED_STYLES },
|
1600
|
+
prefix: { type: 'string' },
|
1601
|
+
suffix: { type: 'string' },
|
1602
|
+
forbiddenPrefixes: ARRAY_DEFAULT_OPTIONS,
|
1603
|
+
forbiddenSuffixes: ARRAY_DEFAULT_OPTIONS,
|
1604
|
+
ignorePattern: {
|
1605
|
+
type: 'string',
|
1606
|
+
description: 'Option to skip validation of some words, e.g. acronyms',
|
1607
|
+
},
|
1608
|
+
},
|
1609
|
+
},
|
1610
|
+
},
|
1611
|
+
type: 'array',
|
1612
|
+
maxItems: 1,
|
1613
|
+
items: {
|
1614
|
+
type: 'object',
|
1615
|
+
additionalProperties: false,
|
1616
|
+
properties: {
|
1617
|
+
types: {
|
1618
|
+
...schemaOption$1,
|
1619
|
+
description: `Includes:\n${TYPES_KINDS.map(kind => `- \`${kind}\``).join('\n')}`,
|
1620
|
+
},
|
1621
|
+
...Object.fromEntries(ALLOWED_KINDS.map(kind => [
|
1622
|
+
kind,
|
1623
|
+
{
|
1624
|
+
...schemaOption$1,
|
1625
|
+
description: `Read more about this kind on [spec.graphql.org](https://spec.graphql.org/October2021/#${kind}).`,
|
1626
|
+
},
|
1627
|
+
])),
|
1628
|
+
allowLeadingUnderscore: {
|
1629
|
+
type: 'boolean',
|
1630
|
+
default: false,
|
1631
|
+
},
|
1632
|
+
allowTrailingUnderscore: {
|
1633
|
+
type: 'boolean',
|
1634
|
+
default: false,
|
1635
|
+
},
|
1636
|
+
},
|
1637
|
+
patternProperties: {
|
1638
|
+
[`^(${ALLOWED_KINDS.join('|')})(.+)?$`]: schemaOption$1,
|
1639
|
+
},
|
1640
|
+
description: [
|
1641
|
+
"> It's possible to use a [`selector`](https://eslint.org/docs/developer-guide/selectors) that starts with allowed `ASTNode` names which are described below.",
|
1642
|
+
'>',
|
1643
|
+
'> Paste or drop code into the editor in [ASTExplorer](https://astexplorer.net) and inspect the generated AST to compose your selector.',
|
1644
|
+
'>',
|
1645
|
+
'> Example: pattern property `FieldDefinition[parent.name.value=Query]` will match only fields for type `Query`.',
|
1646
|
+
].join('\n'),
|
1647
|
+
},
|
1648
|
+
};
|
1649
|
+
const rule$5 = {
|
1477
1650
|
meta: {
|
1478
1651
|
type: 'suggestion',
|
1479
1652
|
docs: {
|
@@ -1589,66 +1762,7 @@ const rule$4 = {
|
|
1589
1762
|
},
|
1590
1763
|
},
|
1591
1764
|
hasSuggestions: true,
|
1592
|
-
schema:
|
1593
|
-
definitions: {
|
1594
|
-
asString: {
|
1595
|
-
enum: ALLOWED_STYLES,
|
1596
|
-
description: `One of: ${ALLOWED_STYLES.map(t => `\`${t}\``).join(', ')}`,
|
1597
|
-
},
|
1598
|
-
asObject: {
|
1599
|
-
type: 'object',
|
1600
|
-
additionalProperties: false,
|
1601
|
-
properties: {
|
1602
|
-
style: { enum: ALLOWED_STYLES },
|
1603
|
-
prefix: { type: 'string' },
|
1604
|
-
suffix: { type: 'string' },
|
1605
|
-
forbiddenPrefixes: ARRAY_DEFAULT_OPTIONS,
|
1606
|
-
forbiddenSuffixes: ARRAY_DEFAULT_OPTIONS,
|
1607
|
-
ignorePattern: {
|
1608
|
-
type: 'string',
|
1609
|
-
description: 'Option to skip validation of some words, e.g. acronyms',
|
1610
|
-
},
|
1611
|
-
},
|
1612
|
-
},
|
1613
|
-
},
|
1614
|
-
type: 'array',
|
1615
|
-
maxItems: 1,
|
1616
|
-
items: {
|
1617
|
-
type: 'object',
|
1618
|
-
additionalProperties: false,
|
1619
|
-
properties: {
|
1620
|
-
types: {
|
1621
|
-
...schemaOption$1,
|
1622
|
-
description: `Includes:\n\n${TYPES_KINDS.map(kind => `- \`${kind}\``).join('\n')}`,
|
1623
|
-
},
|
1624
|
-
...Object.fromEntries(ALLOWED_KINDS.map(kind => [
|
1625
|
-
kind,
|
1626
|
-
{
|
1627
|
-
...schemaOption$1,
|
1628
|
-
description: `Read more about this kind on [spec.graphql.org](https://spec.graphql.org/October2021/#${kind}).`,
|
1629
|
-
},
|
1630
|
-
])),
|
1631
|
-
allowLeadingUnderscore: {
|
1632
|
-
type: 'boolean',
|
1633
|
-
default: false,
|
1634
|
-
},
|
1635
|
-
allowTrailingUnderscore: {
|
1636
|
-
type: 'boolean',
|
1637
|
-
default: false,
|
1638
|
-
},
|
1639
|
-
},
|
1640
|
-
patternProperties: {
|
1641
|
-
[`^(${ALLOWED_KINDS.join('|')})(.+)?$`]: schemaOption$1,
|
1642
|
-
},
|
1643
|
-
description: [
|
1644
|
-
"> It's possible to use a [`selector`](https://eslint.org/docs/developer-guide/selectors) that starts with allowed `ASTNode` names which are described below.",
|
1645
|
-
'>',
|
1646
|
-
'> Paste or drop code into the editor in [ASTExplorer](https://astexplorer.net) and inspect the generated AST to compose your selector.',
|
1647
|
-
'>',
|
1648
|
-
'> Example: pattern property `FieldDefinition[parent.name.value=Query]` will match only fields for type `Query`.',
|
1649
|
-
].join('\n'),
|
1650
|
-
},
|
1651
|
-
},
|
1765
|
+
schema: schema$5,
|
1652
1766
|
},
|
1653
1767
|
create(context) {
|
1654
1768
|
const options = context.options[0] || {};
|
@@ -1748,8 +1862,8 @@ const rule$4 = {
|
|
1748
1862
|
},
|
1749
1863
|
};
|
1750
1864
|
|
1751
|
-
const RULE_ID$
|
1752
|
-
const rule$
|
1865
|
+
const RULE_ID$2 = 'no-anonymous-operations';
|
1866
|
+
const rule$6 = {
|
1753
1867
|
meta: {
|
1754
1868
|
type: 'suggestion',
|
1755
1869
|
hasSuggestions: true,
|
@@ -1757,7 +1871,7 @@ const rule$5 = {
|
|
1757
1871
|
category: 'Operations',
|
1758
1872
|
description: 'Require name for your GraphQL operations. This is useful since most GraphQL client libraries are using the operation name for caching purposes.',
|
1759
1873
|
recommended: true,
|
1760
|
-
url: `https://github.com/B2o5T/graphql-eslint/blob/master/docs/rules/${RULE_ID$
|
1874
|
+
url: `https://github.com/B2o5T/graphql-eslint/blob/master/docs/rules/${RULE_ID$2}.md`,
|
1761
1875
|
examples: [
|
1762
1876
|
{
|
1763
1877
|
title: 'Incorrect',
|
@@ -1778,7 +1892,7 @@ const rule$5 = {
|
|
1778
1892
|
],
|
1779
1893
|
},
|
1780
1894
|
messages: {
|
1781
|
-
[RULE_ID$
|
1895
|
+
[RULE_ID$2]: 'Anonymous GraphQL operations are forbidden. Make sure to name your {{ operation }}!',
|
1782
1896
|
},
|
1783
1897
|
schema: [],
|
1784
1898
|
},
|
@@ -1791,7 +1905,7 @@ const rule$5 = {
|
|
1791
1905
|
: node.operation;
|
1792
1906
|
context.report({
|
1793
1907
|
loc: getLocation(node.loc.start, node.operation),
|
1794
|
-
messageId: RULE_ID$
|
1908
|
+
messageId: RULE_ID$2,
|
1795
1909
|
data: {
|
1796
1910
|
operation: node.operation,
|
1797
1911
|
},
|
@@ -1811,7 +1925,7 @@ const rule$5 = {
|
|
1811
1925
|
},
|
1812
1926
|
};
|
1813
1927
|
|
1814
|
-
const rule$
|
1928
|
+
const rule$7 = {
|
1815
1929
|
meta: {
|
1816
1930
|
type: 'suggestion',
|
1817
1931
|
hasSuggestions: true,
|
@@ -1869,15 +1983,15 @@ const rule$6 = {
|
|
1869
1983
|
},
|
1870
1984
|
};
|
1871
1985
|
|
1872
|
-
const RULE_ID$
|
1873
|
-
const rule$
|
1986
|
+
const RULE_ID$3 = 'no-deprecated';
|
1987
|
+
const rule$8 = {
|
1874
1988
|
meta: {
|
1875
1989
|
type: 'suggestion',
|
1876
1990
|
hasSuggestions: true,
|
1877
1991
|
docs: {
|
1878
1992
|
category: 'Operations',
|
1879
1993
|
description: 'Enforce that deprecated fields or enum values are not in use by operations.',
|
1880
|
-
url: `https://github.com/B2o5T/graphql-eslint/blob/master/docs/rules/${RULE_ID$
|
1994
|
+
url: `https://github.com/B2o5T/graphql-eslint/blob/master/docs/rules/${RULE_ID$3}.md`,
|
1881
1995
|
requiresSchema: true,
|
1882
1996
|
examples: [
|
1883
1997
|
{
|
@@ -1944,18 +2058,18 @@ const rule$7 = {
|
|
1944
2058
|
recommended: true,
|
1945
2059
|
},
|
1946
2060
|
messages: {
|
1947
|
-
[RULE_ID$
|
2061
|
+
[RULE_ID$3]: 'This {{ type }} is marked as deprecated in your GraphQL schema (reason: {{ reason }})',
|
1948
2062
|
},
|
1949
2063
|
schema: [],
|
1950
2064
|
},
|
1951
2065
|
create(context) {
|
1952
|
-
requireGraphQLSchemaFromContext(RULE_ID$
|
2066
|
+
requireGraphQLSchemaFromContext(RULE_ID$3, context);
|
1953
2067
|
function report(node, reason) {
|
1954
2068
|
const nodeName = node.kind === graphql.Kind.ENUM ? node.value : node.name.value;
|
1955
2069
|
const nodeType = node.kind === graphql.Kind.ENUM ? 'enum value' : 'field';
|
1956
2070
|
context.report({
|
1957
2071
|
node,
|
1958
|
-
messageId: RULE_ID$
|
2072
|
+
messageId: RULE_ID$3,
|
1959
2073
|
data: {
|
1960
2074
|
type: nodeType,
|
1961
2075
|
reason,
|
@@ -1989,15 +2103,15 @@ const rule$7 = {
|
|
1989
2103
|
},
|
1990
2104
|
};
|
1991
2105
|
|
1992
|
-
const RULE_ID$
|
1993
|
-
const rule$
|
2106
|
+
const RULE_ID$4 = 'no-duplicate-fields';
|
2107
|
+
const rule$9 = {
|
1994
2108
|
meta: {
|
1995
2109
|
type: 'suggestion',
|
1996
2110
|
hasSuggestions: true,
|
1997
2111
|
docs: {
|
1998
2112
|
description: 'Checks for duplicate fields in selection set, variables in operation definition, or in arguments set of a field.',
|
1999
2113
|
category: 'Operations',
|
2000
|
-
url: `https://github.com/B2o5T/graphql-eslint/blob/master/docs/rules/${RULE_ID$
|
2114
|
+
url: `https://github.com/B2o5T/graphql-eslint/blob/master/docs/rules/${RULE_ID$4}.md`,
|
2001
2115
|
recommended: true,
|
2002
2116
|
examples: [
|
2003
2117
|
{
|
@@ -2043,7 +2157,7 @@ const rule$8 = {
|
|
2043
2157
|
],
|
2044
2158
|
},
|
2045
2159
|
messages: {
|
2046
|
-
[RULE_ID$
|
2160
|
+
[RULE_ID$4]: '{{ type }} `{{ fieldName }}` defined multiple times.',
|
2047
2161
|
},
|
2048
2162
|
schema: [],
|
2049
2163
|
},
|
@@ -2054,7 +2168,7 @@ const rule$8 = {
|
|
2054
2168
|
const { parent } = node;
|
2055
2169
|
context.report({
|
2056
2170
|
node,
|
2057
|
-
messageId: RULE_ID$
|
2171
|
+
messageId: RULE_ID$4,
|
2058
2172
|
data: {
|
2059
2173
|
type: parent.type,
|
2060
2174
|
fieldName,
|
@@ -2099,7 +2213,7 @@ const rule$8 = {
|
|
2099
2213
|
};
|
2100
2214
|
|
2101
2215
|
const HASHTAG_COMMENT = 'HASHTAG_COMMENT';
|
2102
|
-
const rule$
|
2216
|
+
const rule$a = {
|
2103
2217
|
meta: {
|
2104
2218
|
type: 'suggestion',
|
2105
2219
|
hasSuggestions: true,
|
@@ -2184,8 +2298,25 @@ const rule$9 = {
|
|
2184
2298
|
},
|
2185
2299
|
};
|
2186
2300
|
|
2187
|
-
const
|
2188
|
-
|
2301
|
+
const schema$6 = {
|
2302
|
+
type: 'array',
|
2303
|
+
minItems: 1,
|
2304
|
+
maxItems: 1,
|
2305
|
+
items: {
|
2306
|
+
type: 'object',
|
2307
|
+
additionalProperties: false,
|
2308
|
+
required: ['disallow'],
|
2309
|
+
properties: {
|
2310
|
+
disallow: {
|
2311
|
+
...ARRAY_DEFAULT_OPTIONS,
|
2312
|
+
items: {
|
2313
|
+
enum: ['mutation', 'subscription'],
|
2314
|
+
},
|
2315
|
+
},
|
2316
|
+
},
|
2317
|
+
},
|
2318
|
+
};
|
2319
|
+
const rule$b = {
|
2189
2320
|
meta: {
|
2190
2321
|
type: 'suggestion',
|
2191
2322
|
hasSuggestions: true,
|
@@ -2216,24 +2347,7 @@ const rule$a = {
|
|
2216
2347
|
},
|
2217
2348
|
],
|
2218
2349
|
},
|
2219
|
-
schema:
|
2220
|
-
type: 'array',
|
2221
|
-
minItems: 1,
|
2222
|
-
maxItems: 1,
|
2223
|
-
items: {
|
2224
|
-
type: 'object',
|
2225
|
-
additionalProperties: false,
|
2226
|
-
required: ['disallow'],
|
2227
|
-
properties: {
|
2228
|
-
disallow: {
|
2229
|
-
...ARRAY_DEFAULT_OPTIONS,
|
2230
|
-
items: {
|
2231
|
-
enum: ROOT_TYPES,
|
2232
|
-
},
|
2233
|
-
},
|
2234
|
-
},
|
2235
|
-
},
|
2236
|
-
},
|
2350
|
+
schema: schema$6,
|
2237
2351
|
},
|
2238
2352
|
create(context) {
|
2239
2353
|
const schema = requireGraphQLSchemaFromContext('no-root-type', context);
|
@@ -2267,15 +2381,15 @@ const rule$a = {
|
|
2267
2381
|
},
|
2268
2382
|
};
|
2269
2383
|
|
2270
|
-
const RULE_ID$
|
2271
|
-
const rule$
|
2384
|
+
const RULE_ID$5 = 'no-scalar-result-type-on-mutation';
|
2385
|
+
const rule$c = {
|
2272
2386
|
meta: {
|
2273
2387
|
type: 'suggestion',
|
2274
2388
|
hasSuggestions: true,
|
2275
2389
|
docs: {
|
2276
2390
|
category: 'Schema',
|
2277
2391
|
description: 'Avoid scalar result type on mutation type to make sure to return a valid state.',
|
2278
|
-
url: `https://github.com/B2o5T/graphql-eslint/blob/master/docs/rules/${RULE_ID$
|
2392
|
+
url: `https://github.com/B2o5T/graphql-eslint/blob/master/docs/rules/${RULE_ID$5}.md`,
|
2279
2393
|
requiresSchema: true,
|
2280
2394
|
examples: [
|
2281
2395
|
{
|
@@ -2299,7 +2413,7 @@ const rule$b = {
|
|
2299
2413
|
schema: [],
|
2300
2414
|
},
|
2301
2415
|
create(context) {
|
2302
|
-
const schema = requireGraphQLSchemaFromContext(RULE_ID$
|
2416
|
+
const schema = requireGraphQLSchemaFromContext(RULE_ID$5, context);
|
2303
2417
|
const mutationType = schema.getMutationType();
|
2304
2418
|
if (!mutationType) {
|
2305
2419
|
return {};
|
@@ -2330,7 +2444,7 @@ const rule$b = {
|
|
2330
2444
|
};
|
2331
2445
|
|
2332
2446
|
const NO_TYPENAME_PREFIX = 'NO_TYPENAME_PREFIX';
|
2333
|
-
const rule$
|
2447
|
+
const rule$d = {
|
2334
2448
|
meta: {
|
2335
2449
|
type: 'suggestion',
|
2336
2450
|
hasSuggestions: true,
|
@@ -2392,7 +2506,7 @@ const rule$c = {
|
|
2392
2506
|
},
|
2393
2507
|
};
|
2394
2508
|
|
2395
|
-
const RULE_ID$
|
2509
|
+
const RULE_ID$6 = 'no-unreachable-types';
|
2396
2510
|
const KINDS = [
|
2397
2511
|
graphql.Kind.DIRECTIVE_DEFINITION,
|
2398
2512
|
graphql.Kind.OBJECT_TYPE_DEFINITION,
|
@@ -2472,15 +2586,15 @@ function getReachableTypes(schema) {
|
|
2472
2586
|
reachableTypesCache = reachableTypes;
|
2473
2587
|
return reachableTypesCache;
|
2474
2588
|
}
|
2475
|
-
const rule$
|
2589
|
+
const rule$e = {
|
2476
2590
|
meta: {
|
2477
2591
|
messages: {
|
2478
|
-
[RULE_ID$
|
2592
|
+
[RULE_ID$6]: '{{ type }} `{{ typeName }}` is unreachable.',
|
2479
2593
|
},
|
2480
2594
|
docs: {
|
2481
2595
|
description: 'Requires all types to be reachable at some level by root level fields.',
|
2482
2596
|
category: 'Schema',
|
2483
|
-
url: `https://github.com/B2o5T/graphql-eslint/blob/master/docs/rules/${RULE_ID$
|
2597
|
+
url: `https://github.com/B2o5T/graphql-eslint/blob/master/docs/rules/${RULE_ID$6}.md`,
|
2484
2598
|
requiresSchema: true,
|
2485
2599
|
examples: [
|
2486
2600
|
{
|
@@ -2517,7 +2631,7 @@ const rule$d = {
|
|
2517
2631
|
hasSuggestions: true,
|
2518
2632
|
},
|
2519
2633
|
create(context) {
|
2520
|
-
const schema = requireGraphQLSchemaFromContext(RULE_ID$
|
2634
|
+
const schema = requireGraphQLSchemaFromContext(RULE_ID$6, context);
|
2521
2635
|
const reachableTypes = getReachableTypes(schema);
|
2522
2636
|
return {
|
2523
2637
|
[`:matches(${KINDS}) > .name`](node) {
|
@@ -2526,7 +2640,7 @@ const rule$d = {
|
|
2526
2640
|
const type = lowerCase(node.parent.kind.replace(/(Extension|Definition)$/, ''));
|
2527
2641
|
context.report({
|
2528
2642
|
node,
|
2529
|
-
messageId: RULE_ID$
|
2643
|
+
messageId: RULE_ID$6,
|
2530
2644
|
data: {
|
2531
2645
|
type: type[0].toUpperCase() + type.slice(1),
|
2532
2646
|
typeName,
|
@@ -2544,7 +2658,7 @@ const rule$d = {
|
|
2544
2658
|
},
|
2545
2659
|
};
|
2546
2660
|
|
2547
|
-
const RULE_ID$
|
2661
|
+
const RULE_ID$7 = 'no-unused-fields';
|
2548
2662
|
let usedFieldsCache;
|
2549
2663
|
function getUsedFields(schema, operations) {
|
2550
2664
|
// We don't want cache usedFields on test environment
|
@@ -2575,15 +2689,15 @@ function getUsedFields(schema, operations) {
|
|
2575
2689
|
usedFieldsCache = usedFields;
|
2576
2690
|
return usedFieldsCache;
|
2577
2691
|
}
|
2578
|
-
const rule$
|
2692
|
+
const rule$f = {
|
2579
2693
|
meta: {
|
2580
2694
|
messages: {
|
2581
|
-
[RULE_ID$
|
2695
|
+
[RULE_ID$7]: 'Field "{{fieldName}}" is unused',
|
2582
2696
|
},
|
2583
2697
|
docs: {
|
2584
2698
|
description: 'Requires all fields to be used at some level by siblings operations.',
|
2585
2699
|
category: 'Schema',
|
2586
|
-
url: `https://github.com/B2o5T/graphql-eslint/blob/master/docs/rules/${RULE_ID$
|
2700
|
+
url: `https://github.com/B2o5T/graphql-eslint/blob/master/docs/rules/${RULE_ID$7}.md`,
|
2587
2701
|
requiresSiblings: true,
|
2588
2702
|
requiresSchema: true,
|
2589
2703
|
isDisabledForAllConfig: true,
|
@@ -2636,8 +2750,8 @@ const rule$e = {
|
|
2636
2750
|
hasSuggestions: true,
|
2637
2751
|
},
|
2638
2752
|
create(context) {
|
2639
|
-
const schema = requireGraphQLSchemaFromContext(RULE_ID$
|
2640
|
-
const siblingsOperations = requireSiblingsOperations(RULE_ID$
|
2753
|
+
const schema = requireGraphQLSchemaFromContext(RULE_ID$7, context);
|
2754
|
+
const siblingsOperations = requireSiblingsOperations(RULE_ID$7, context);
|
2641
2755
|
const usedFields = getUsedFields(schema, siblingsOperations);
|
2642
2756
|
return {
|
2643
2757
|
FieldDefinition(node) {
|
@@ -2650,7 +2764,7 @@ const rule$e = {
|
|
2650
2764
|
}
|
2651
2765
|
context.report({
|
2652
2766
|
node: node.name,
|
2653
|
-
messageId: RULE_ID$
|
2767
|
+
messageId: RULE_ID$7,
|
2654
2768
|
data: { fieldName },
|
2655
2769
|
suggest: [
|
2656
2770
|
{
|
@@ -2670,9 +2784,25 @@ const rule$e = {
|
|
2670
2784
|
},
|
2671
2785
|
};
|
2672
2786
|
|
2673
|
-
const RULE_ID$
|
2787
|
+
const RULE_ID$8 = 'relay-arguments';
|
2674
2788
|
const MISSING_ARGUMENTS = 'MISSING_ARGUMENTS';
|
2675
|
-
const
|
2789
|
+
const schema$7 = {
|
2790
|
+
type: 'array',
|
2791
|
+
maxItems: 1,
|
2792
|
+
items: {
|
2793
|
+
type: 'object',
|
2794
|
+
additionalProperties: false,
|
2795
|
+
minProperties: 1,
|
2796
|
+
properties: {
|
2797
|
+
includeBoth: {
|
2798
|
+
type: 'boolean',
|
2799
|
+
default: true,
|
2800
|
+
description: 'Enforce including both forward and backward pagination arguments',
|
2801
|
+
},
|
2802
|
+
},
|
2803
|
+
},
|
2804
|
+
};
|
2805
|
+
const rule$g = {
|
2676
2806
|
meta: {
|
2677
2807
|
type: 'problem',
|
2678
2808
|
docs: {
|
@@ -2692,7 +2822,7 @@ const rule$f = {
|
|
2692
2822
|
'- `last` takes a non-negative integer',
|
2693
2823
|
'- `before` takes the Cursor type',
|
2694
2824
|
].join('\n'),
|
2695
|
-
url: `https://github.com/B2o5T/graphql-eslint/blob/master/docs/rules/${RULE_ID$
|
2825
|
+
url: `https://github.com/B2o5T/graphql-eslint/blob/master/docs/rules/${RULE_ID$8}.md`,
|
2696
2826
|
examples: [
|
2697
2827
|
{
|
2698
2828
|
title: 'Incorrect',
|
@@ -2716,25 +2846,10 @@ const rule$f = {
|
|
2716
2846
|
messages: {
|
2717
2847
|
[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.',
|
2718
2848
|
},
|
2719
|
-
schema:
|
2720
|
-
type: 'array',
|
2721
|
-
maxItems: 1,
|
2722
|
-
items: {
|
2723
|
-
type: 'object',
|
2724
|
-
additionalProperties: false,
|
2725
|
-
minProperties: 1,
|
2726
|
-
properties: {
|
2727
|
-
includeBoth: {
|
2728
|
-
type: 'boolean',
|
2729
|
-
default: true,
|
2730
|
-
description: 'Enforce including both forward and backward pagination arguments',
|
2731
|
-
},
|
2732
|
-
},
|
2733
|
-
},
|
2734
|
-
},
|
2849
|
+
schema: schema$7,
|
2735
2850
|
},
|
2736
2851
|
create(context) {
|
2737
|
-
const schema = requireGraphQLSchemaFromContext(RULE_ID$
|
2852
|
+
const schema = requireGraphQLSchemaFromContext(RULE_ID$8, context);
|
2738
2853
|
const { includeBoth = true } = context.options[0] || {};
|
2739
2854
|
return {
|
2740
2855
|
'FieldDefinition > .gqlType Name[value=/Connection$/]'(node) {
|
@@ -2806,7 +2921,7 @@ const NON_OBJECT_TYPES = [
|
|
2806
2921
|
const notConnectionTypesSelector = `:matches(${NON_OBJECT_TYPES})[name.value=/Connection$/] > .name`;
|
2807
2922
|
const hasEdgesField = (node) => node.fields.some(field => field.name.value === 'edges');
|
2808
2923
|
const hasPageInfoField = (node) => node.fields.some(field => field.name.value === 'pageInfo');
|
2809
|
-
const rule$
|
2924
|
+
const rule$h = {
|
2810
2925
|
meta: {
|
2811
2926
|
type: 'problem',
|
2812
2927
|
docs: {
|
@@ -2890,7 +3005,7 @@ const rule$g = {
|
|
2890
3005
|
},
|
2891
3006
|
};
|
2892
3007
|
|
2893
|
-
const RULE_ID$
|
3008
|
+
const RULE_ID$9 = 'relay-edge-types';
|
2894
3009
|
const MESSAGE_MUST_BE_OBJECT_TYPE = 'MESSAGE_MUST_BE_OBJECT_TYPE';
|
2895
3010
|
const MESSAGE_MISSING_EDGE_SUFFIX = 'MESSAGE_MISSING_EDGE_SUFFIX';
|
2896
3011
|
const MESSAGE_LIST_TYPE_ONLY_EDGE_TYPE = 'MESSAGE_LIST_TYPE_ONLY_EDGE_TYPE';
|
@@ -2925,7 +3040,33 @@ function getEdgeTypes(schema) {
|
|
2925
3040
|
edgeTypesCache = edgeTypes;
|
2926
3041
|
return edgeTypesCache;
|
2927
3042
|
}
|
2928
|
-
const
|
3043
|
+
const schema$8 = {
|
3044
|
+
type: 'array',
|
3045
|
+
maxItems: 1,
|
3046
|
+
items: {
|
3047
|
+
type: 'object',
|
3048
|
+
additionalProperties: false,
|
3049
|
+
minProperties: 1,
|
3050
|
+
properties: {
|
3051
|
+
withEdgeSuffix: {
|
3052
|
+
type: 'boolean',
|
3053
|
+
default: true,
|
3054
|
+
description: 'Edge type name must end in "Edge".',
|
3055
|
+
},
|
3056
|
+
shouldImplementNode: {
|
3057
|
+
type: 'boolean',
|
3058
|
+
default: true,
|
3059
|
+
description: "Edge type's field `node` must implement `Node` interface.",
|
3060
|
+
},
|
3061
|
+
listTypeCanWrapOnlyEdgeType: {
|
3062
|
+
type: 'boolean',
|
3063
|
+
default: true,
|
3064
|
+
description: 'A list type should only wrap an edge type.',
|
3065
|
+
},
|
3066
|
+
},
|
3067
|
+
},
|
3068
|
+
};
|
3069
|
+
const rule$i = {
|
2929
3070
|
meta: {
|
2930
3071
|
type: 'problem',
|
2931
3072
|
docs: {
|
@@ -2941,7 +3082,7 @@ const rule$h = {
|
|
2941
3082
|
"- Edge type's field `node` must implement `Node` interface _(optional)_",
|
2942
3083
|
'- A list type should only wrap an edge type _(optional)_',
|
2943
3084
|
].join('\n'),
|
2944
|
-
url: `https://github.com/B2o5T/graphql-eslint/blob/master/docs/rules/${RULE_ID$
|
3085
|
+
url: `https://github.com/B2o5T/graphql-eslint/blob/master/docs/rules/${RULE_ID$9}.md`,
|
2945
3086
|
isDisabledForAllConfig: true,
|
2946
3087
|
requiresSchema: true,
|
2947
3088
|
examples: [
|
@@ -2962,35 +3103,10 @@ const rule$h = {
|
|
2962
3103
|
[MESSAGE_LIST_TYPE_ONLY_EDGE_TYPE]: 'A list type should only wrap an edge type.',
|
2963
3104
|
[MESSAGE_SHOULD_IMPLEMENTS_NODE]: "Edge type's field `node` must implement `Node` interface.",
|
2964
3105
|
},
|
2965
|
-
schema:
|
2966
|
-
type: 'array',
|
2967
|
-
maxItems: 1,
|
2968
|
-
items: {
|
2969
|
-
type: 'object',
|
2970
|
-
additionalProperties: false,
|
2971
|
-
minProperties: 1,
|
2972
|
-
properties: {
|
2973
|
-
withEdgeSuffix: {
|
2974
|
-
type: 'boolean',
|
2975
|
-
default: true,
|
2976
|
-
description: 'Edge type name must end in "Edge".',
|
2977
|
-
},
|
2978
|
-
shouldImplementNode: {
|
2979
|
-
type: 'boolean',
|
2980
|
-
default: true,
|
2981
|
-
description: "Edge type's field `node` must implement `Node` interface.",
|
2982
|
-
},
|
2983
|
-
listTypeCanWrapOnlyEdgeType: {
|
2984
|
-
type: 'boolean',
|
2985
|
-
default: true,
|
2986
|
-
description: 'A list type should only wrap an edge type.',
|
2987
|
-
},
|
2988
|
-
},
|
2989
|
-
},
|
2990
|
-
},
|
3106
|
+
schema: schema$8,
|
2991
3107
|
},
|
2992
3108
|
create(context) {
|
2993
|
-
const schema = requireGraphQLSchemaFromContext(RULE_ID$
|
3109
|
+
const schema = requireGraphQLSchemaFromContext(RULE_ID$9, context);
|
2994
3110
|
const edgeTypes = getEdgeTypes(schema);
|
2995
3111
|
const options = {
|
2996
3112
|
withEdgeSuffix: true,
|
@@ -3073,12 +3189,12 @@ const rule$h = {
|
|
3073
3189
|
},
|
3074
3190
|
};
|
3075
3191
|
|
3076
|
-
const RULE_ID$
|
3192
|
+
const RULE_ID$a = 'relay-page-info';
|
3077
3193
|
const MESSAGE_MUST_EXIST = 'MESSAGE_MUST_EXIST';
|
3078
3194
|
const MESSAGE_MUST_BE_OBJECT_TYPE$1 = 'MESSAGE_MUST_BE_OBJECT_TYPE';
|
3079
3195
|
const notPageInfoTypesSelector = `:matches(${NON_OBJECT_TYPES})[name.value=PageInfo] > .name`;
|
3080
3196
|
let hasPageInfoChecked = false;
|
3081
|
-
const rule$
|
3197
|
+
const rule$j = {
|
3082
3198
|
meta: {
|
3083
3199
|
type: 'problem',
|
3084
3200
|
docs: {
|
@@ -3090,7 +3206,7 @@ const rule$i = {
|
|
3090
3206
|
'- `PageInfo` must contain fields `hasPreviousPage` and `hasNextPage`, that return non-null Boolean',
|
3091
3207
|
'- `PageInfo` must contain fields `startCursor` and `endCursor`, that return either String or Scalar, which can be null if there are no results',
|
3092
3208
|
].join('\n'),
|
3093
|
-
url: `https://github.com/B2o5T/graphql-eslint/blob/master/docs/rules/${RULE_ID$
|
3209
|
+
url: `https://github.com/B2o5T/graphql-eslint/blob/master/docs/rules/${RULE_ID$a}.md`,
|
3094
3210
|
examples: [
|
3095
3211
|
{
|
3096
3212
|
title: 'Correct',
|
@@ -3114,7 +3230,7 @@ const rule$i = {
|
|
3114
3230
|
schema: [],
|
3115
3231
|
},
|
3116
3232
|
create(context) {
|
3117
|
-
const schema = requireGraphQLSchemaFromContext(RULE_ID$
|
3233
|
+
const schema = requireGraphQLSchemaFromContext(RULE_ID$a, context);
|
3118
3234
|
if (process.env.NODE_ENV === 'test' || !hasPageInfoChecked) {
|
3119
3235
|
const pageInfoType = schema.getType('PageInfo');
|
3120
3236
|
if (!pageInfoType) {
|
@@ -3330,7 +3446,20 @@ const MESSAGE_REQUIRE_DATE = 'MESSAGE_REQUIRE_DATE';
|
|
3330
3446
|
const MESSAGE_INVALID_FORMAT = 'MESSAGE_INVALID_FORMAT';
|
3331
3447
|
const MESSAGE_INVALID_DATE = 'MESSAGE_INVALID_DATE';
|
3332
3448
|
const MESSAGE_CAN_BE_REMOVED = 'MESSAGE_CAN_BE_REMOVED';
|
3333
|
-
const
|
3449
|
+
const schema$9 = {
|
3450
|
+
type: 'array',
|
3451
|
+
maxItems: 1,
|
3452
|
+
items: {
|
3453
|
+
type: 'object',
|
3454
|
+
additionalProperties: false,
|
3455
|
+
properties: {
|
3456
|
+
argumentName: {
|
3457
|
+
type: 'string',
|
3458
|
+
},
|
3459
|
+
},
|
3460
|
+
},
|
3461
|
+
};
|
3462
|
+
const rule$k = {
|
3334
3463
|
meta: {
|
3335
3464
|
type: 'suggestion',
|
3336
3465
|
hasSuggestions: true,
|
@@ -3375,17 +3504,7 @@ const rule$j = {
|
|
3375
3504
|
[MESSAGE_INVALID_DATE]: 'Invalid "{{ deletionDate }}" deletion date',
|
3376
3505
|
[MESSAGE_CAN_BE_REMOVED]: '"{{ nodeName }}" сan be removed',
|
3377
3506
|
},
|
3378
|
-
schema:
|
3379
|
-
{
|
3380
|
-
type: 'object',
|
3381
|
-
additionalProperties: false,
|
3382
|
-
properties: {
|
3383
|
-
argumentName: {
|
3384
|
-
type: 'string',
|
3385
|
-
},
|
3386
|
-
},
|
3387
|
-
},
|
3388
|
-
],
|
3507
|
+
schema: schema$9,
|
3389
3508
|
},
|
3390
3509
|
create(context) {
|
3391
3510
|
return {
|
@@ -3441,7 +3560,7 @@ const rule$j = {
|
|
3441
3560
|
},
|
3442
3561
|
};
|
3443
3562
|
|
3444
|
-
const rule$
|
3563
|
+
const rule$l = {
|
3445
3564
|
meta: {
|
3446
3565
|
docs: {
|
3447
3566
|
description: 'Require all deprecation directives to specify a reason.',
|
@@ -3494,7 +3613,7 @@ const rule$k = {
|
|
3494
3613
|
},
|
3495
3614
|
};
|
3496
3615
|
|
3497
|
-
const RULE_ID$
|
3616
|
+
const RULE_ID$b = 'require-description';
|
3498
3617
|
const ALLOWED_KINDS$1 = [
|
3499
3618
|
...TYPES_KINDS,
|
3500
3619
|
graphql.Kind.DIRECTIVE_DEFINITION,
|
@@ -3531,12 +3650,40 @@ function getNodeName(node) {
|
|
3531
3650
|
return node.name ? `${node.operation} ${node.name.value}` : node.operation;
|
3532
3651
|
}
|
3533
3652
|
}
|
3534
|
-
const
|
3653
|
+
const schema$a = {
|
3654
|
+
type: 'array',
|
3655
|
+
minItems: 1,
|
3656
|
+
maxItems: 1,
|
3657
|
+
items: {
|
3658
|
+
type: 'object',
|
3659
|
+
additionalProperties: false,
|
3660
|
+
minProperties: 1,
|
3661
|
+
properties: {
|
3662
|
+
types: {
|
3663
|
+
type: 'boolean',
|
3664
|
+
description: `Includes:\n${TYPES_KINDS.map(kind => `- \`${kind}\``).join('\n')}`,
|
3665
|
+
},
|
3666
|
+
rootField: {
|
3667
|
+
type: 'boolean',
|
3668
|
+
description: 'Definitions within `Query`, `Mutation`, and `Subscription` root types.',
|
3669
|
+
},
|
3670
|
+
...Object.fromEntries([...ALLOWED_KINDS$1].sort().map(kind => {
|
3671
|
+
let description = `Read more about this kind on [spec.graphql.org](https://spec.graphql.org/October2021/#${kind}).`;
|
3672
|
+
if (kind === graphql.Kind.OPERATION_DEFINITION) {
|
3673
|
+
description +=
|
3674
|
+
'\n> You must use only comment syntax `#` and not description syntax `"""` or `"`.';
|
3675
|
+
}
|
3676
|
+
return [kind, { type: 'boolean', description }];
|
3677
|
+
})),
|
3678
|
+
},
|
3679
|
+
},
|
3680
|
+
};
|
3681
|
+
const rule$m = {
|
3535
3682
|
meta: {
|
3536
3683
|
docs: {
|
3537
3684
|
category: 'Schema',
|
3538
3685
|
description: 'Enforce descriptions in type definitions and operations.',
|
3539
|
-
url: `https://github.com/B2o5T/graphql-eslint/blob/master/docs/rules/${RULE_ID$
|
3686
|
+
url: `https://github.com/B2o5T/graphql-eslint/blob/master/docs/rules/${RULE_ID$b}.md`,
|
3540
3687
|
examples: [
|
3541
3688
|
{
|
3542
3689
|
title: 'Incorrect',
|
@@ -3570,6 +3717,20 @@ const rule$l = {
|
|
3570
3717
|
mutation createUser {
|
3571
3718
|
# ...
|
3572
3719
|
}
|
3720
|
+
`,
|
3721
|
+
},
|
3722
|
+
{
|
3723
|
+
title: 'Correct',
|
3724
|
+
usage: [{ rootField: true }],
|
3725
|
+
code: /* GraphQL */ `
|
3726
|
+
type Mutation {
|
3727
|
+
"Create a new user"
|
3728
|
+
createUser: User
|
3729
|
+
}
|
3730
|
+
|
3731
|
+
type User {
|
3732
|
+
name: String
|
3733
|
+
}
|
3573
3734
|
`,
|
3574
3735
|
},
|
3575
3736
|
],
|
@@ -3577,41 +3738,19 @@ const rule$l = {
|
|
3577
3738
|
{
|
3578
3739
|
types: true,
|
3579
3740
|
[graphql.Kind.DIRECTIVE_DEFINITION]: true,
|
3741
|
+
// rootField: true TODO enable in graphql-eslint v4
|
3580
3742
|
},
|
3581
3743
|
],
|
3582
3744
|
recommended: true,
|
3583
3745
|
},
|
3584
3746
|
type: 'suggestion',
|
3585
3747
|
messages: {
|
3586
|
-
[RULE_ID$
|
3587
|
-
},
|
3588
|
-
schema: {
|
3589
|
-
type: 'array',
|
3590
|
-
minItems: 1,
|
3591
|
-
maxItems: 1,
|
3592
|
-
items: {
|
3593
|
-
type: 'object',
|
3594
|
-
additionalProperties: false,
|
3595
|
-
minProperties: 1,
|
3596
|
-
properties: {
|
3597
|
-
types: {
|
3598
|
-
type: 'boolean',
|
3599
|
-
description: `Includes:\n\n${TYPES_KINDS.map(kind => `- \`${kind}\``).join('\n')}`,
|
3600
|
-
},
|
3601
|
-
...Object.fromEntries([...ALLOWED_KINDS$1].sort().map(kind => {
|
3602
|
-
let description = `Read more about this kind on [spec.graphql.org](https://spec.graphql.org/October2021/#${kind}).`;
|
3603
|
-
if (kind === graphql.Kind.OPERATION_DEFINITION) {
|
3604
|
-
description +=
|
3605
|
-
'\n\n> You must use only comment syntax `#` and not description syntax `"""` or `"`.';
|
3606
|
-
}
|
3607
|
-
return [kind, { type: 'boolean', description }];
|
3608
|
-
})),
|
3609
|
-
},
|
3610
|
-
},
|
3748
|
+
[RULE_ID$b]: 'Description is required for `{{ nodeName }}`.',
|
3611
3749
|
},
|
3750
|
+
schema: schema$a,
|
3612
3751
|
},
|
3613
3752
|
create(context) {
|
3614
|
-
const { types, ...restOptions } = context.options[0] || {};
|
3753
|
+
const { types, rootField, ...restOptions } = context.options[0] || {};
|
3615
3754
|
const kinds = new Set(types ? TYPES_KINDS : []);
|
3616
3755
|
for (const [kind, isEnabled] of Object.entries(restOptions)) {
|
3617
3756
|
if (isEnabled) {
|
@@ -3621,6 +3760,13 @@ const rule$l = {
|
|
3621
3760
|
kinds.delete(kind);
|
3622
3761
|
}
|
3623
3762
|
}
|
3763
|
+
if (rootField) {
|
3764
|
+
const schema = requireGraphQLSchemaFromContext(RULE_ID$b, context);
|
3765
|
+
const rootTypeNames = utils.getRootTypeNames(schema);
|
3766
|
+
kinds.add(`:matches(ObjectTypeDefinition, ObjectTypeExtension)[name.value=/^(${[
|
3767
|
+
...rootTypeNames,
|
3768
|
+
].join(',')})$/] > FieldDefinition`);
|
3769
|
+
}
|
3624
3770
|
const selector = [...kinds].join(',');
|
3625
3771
|
return {
|
3626
3772
|
[selector](node) {
|
@@ -3644,7 +3790,7 @@ const rule$l = {
|
|
3644
3790
|
if (description.length === 0) {
|
3645
3791
|
context.report({
|
3646
3792
|
loc: isOperation ? getLocation(node.loc.start, node.operation) : node.name.loc,
|
3647
|
-
messageId: RULE_ID$
|
3793
|
+
messageId: RULE_ID$b,
|
3648
3794
|
data: {
|
3649
3795
|
nodeName: getNodeName(node),
|
3650
3796
|
},
|
@@ -3655,14 +3801,14 @@ const rule$l = {
|
|
3655
3801
|
},
|
3656
3802
|
};
|
3657
3803
|
|
3658
|
-
const RULE_ID$
|
3659
|
-
const rule$
|
3804
|
+
const RULE_ID$c = 'require-field-of-type-query-in-mutation-result';
|
3805
|
+
const rule$n = {
|
3660
3806
|
meta: {
|
3661
3807
|
type: 'suggestion',
|
3662
3808
|
docs: {
|
3663
3809
|
category: 'Schema',
|
3664
3810
|
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`.',
|
3665
|
-
url: `https://github.com/B2o5T/graphql-eslint/blob/master/docs/rules/${RULE_ID$
|
3811
|
+
url: `https://github.com/B2o5T/graphql-eslint/blob/master/docs/rules/${RULE_ID$c}.md`,
|
3666
3812
|
requiresSchema: true,
|
3667
3813
|
examples: [
|
3668
3814
|
{
|
@@ -3697,7 +3843,7 @@ const rule$m = {
|
|
3697
3843
|
schema: [],
|
3698
3844
|
},
|
3699
3845
|
create(context) {
|
3700
|
-
const schema = requireGraphQLSchemaFromContext(RULE_ID$
|
3846
|
+
const schema = requireGraphQLSchemaFromContext(RULE_ID$c, context);
|
3701
3847
|
const mutationType = schema.getMutationType();
|
3702
3848
|
const queryType = schema.getQueryType();
|
3703
3849
|
if (!mutationType || !queryType) {
|
@@ -3723,17 +3869,36 @@ const rule$m = {
|
|
3723
3869
|
},
|
3724
3870
|
};
|
3725
3871
|
|
3726
|
-
const RULE_ID$
|
3872
|
+
const RULE_ID$d = 'require-id-when-available';
|
3727
3873
|
const DEFAULT_ID_FIELD_NAME = 'id';
|
3728
|
-
const
|
3874
|
+
const schema$b = {
|
3875
|
+
definitions: {
|
3876
|
+
asString: {
|
3877
|
+
type: 'string',
|
3878
|
+
},
|
3879
|
+
asArray: ARRAY_DEFAULT_OPTIONS,
|
3880
|
+
},
|
3881
|
+
type: 'array',
|
3882
|
+
maxItems: 1,
|
3883
|
+
items: {
|
3884
|
+
type: 'object',
|
3885
|
+
additionalProperties: false,
|
3886
|
+
properties: {
|
3887
|
+
fieldName: {
|
3888
|
+
oneOf: [{ $ref: '#/definitions/asString' }, { $ref: '#/definitions/asArray' }],
|
3889
|
+
default: DEFAULT_ID_FIELD_NAME,
|
3890
|
+
},
|
3891
|
+
},
|
3892
|
+
},
|
3893
|
+
};
|
3894
|
+
const rule$o = {
|
3729
3895
|
meta: {
|
3730
3896
|
type: 'suggestion',
|
3731
|
-
// eslint-disable-next-line eslint-plugin/require-meta-has-suggestions
|
3732
3897
|
hasSuggestions: true,
|
3733
3898
|
docs: {
|
3734
3899
|
category: 'Operations',
|
3735
3900
|
description: 'Enforce selecting specific fields when they are available on the GraphQL type.',
|
3736
|
-
url: `https://github.com/B2o5T/graphql-eslint/blob/master/docs/rules/${RULE_ID$
|
3901
|
+
url: `https://github.com/B2o5T/graphql-eslint/blob/master/docs/rules/${RULE_ID$d}.md`,
|
3737
3902
|
requiresSchema: true,
|
3738
3903
|
requiresSiblings: true,
|
3739
3904
|
examples: [
|
@@ -3783,32 +3948,13 @@ const rule$n = {
|
|
3783
3948
|
recommended: true,
|
3784
3949
|
},
|
3785
3950
|
messages: {
|
3786
|
-
[RULE_ID$
|
3787
|
-
},
|
3788
|
-
schema: {
|
3789
|
-
definitions: {
|
3790
|
-
asString: {
|
3791
|
-
type: 'string',
|
3792
|
-
},
|
3793
|
-
asArray: ARRAY_DEFAULT_OPTIONS,
|
3794
|
-
},
|
3795
|
-
type: 'array',
|
3796
|
-
maxItems: 1,
|
3797
|
-
items: {
|
3798
|
-
type: 'object',
|
3799
|
-
additionalProperties: false,
|
3800
|
-
properties: {
|
3801
|
-
fieldName: {
|
3802
|
-
oneOf: [{ $ref: '#/definitions/asString' }, { $ref: '#/definitions/asArray' }],
|
3803
|
-
default: DEFAULT_ID_FIELD_NAME,
|
3804
|
-
},
|
3805
|
-
},
|
3806
|
-
},
|
3951
|
+
[RULE_ID$d]: "Field{{ pluralSuffix }} {{ fieldName }} must be selected when it's available on a type.\nInclude it in your selection set{{ addition }}.",
|
3807
3952
|
},
|
3953
|
+
schema: schema$b,
|
3808
3954
|
},
|
3809
3955
|
create(context) {
|
3810
|
-
const schema = requireGraphQLSchemaFromContext(RULE_ID$
|
3811
|
-
const siblings = requireSiblingsOperations(RULE_ID$
|
3956
|
+
const schema = requireGraphQLSchemaFromContext(RULE_ID$d, context);
|
3957
|
+
const siblings = requireSiblingsOperations(RULE_ID$d, context);
|
3812
3958
|
const { fieldName = DEFAULT_ID_FIELD_NAME } = context.options[0] || {};
|
3813
3959
|
const idNames = utils.asArray(fieldName);
|
3814
3960
|
// Check selections only in OperationDefinition,
|
@@ -3889,7 +4035,7 @@ const rule$n = {
|
|
3889
4035
|
: ` or add to used fragment${checkedFragmentSpreads.size > 1 ? 's' : ''} ${englishJoinWords([...checkedFragmentSpreads].map(name => `\`${name}\``))}`;
|
3890
4036
|
const problem = {
|
3891
4037
|
loc,
|
3892
|
-
messageId: RULE_ID$
|
4038
|
+
messageId: RULE_ID$d,
|
3893
4039
|
data: {
|
3894
4040
|
pluralSuffix,
|
3895
4041
|
fieldName,
|
@@ -3916,15 +4062,31 @@ const rule$n = {
|
|
3916
4062
|
},
|
3917
4063
|
};
|
3918
4064
|
|
3919
|
-
const RULE_ID$
|
3920
|
-
const
|
4065
|
+
const RULE_ID$e = 'selection-set-depth';
|
4066
|
+
const schema$c = {
|
4067
|
+
type: 'array',
|
4068
|
+
minItems: 1,
|
4069
|
+
maxItems: 1,
|
4070
|
+
items: {
|
4071
|
+
type: 'object',
|
4072
|
+
additionalProperties: false,
|
4073
|
+
required: ['maxDepth'],
|
4074
|
+
properties: {
|
4075
|
+
maxDepth: {
|
4076
|
+
type: 'number',
|
4077
|
+
},
|
4078
|
+
ignore: ARRAY_DEFAULT_OPTIONS,
|
4079
|
+
},
|
4080
|
+
},
|
4081
|
+
};
|
4082
|
+
const rule$p = {
|
3921
4083
|
meta: {
|
3922
4084
|
type: 'suggestion',
|
3923
4085
|
hasSuggestions: true,
|
3924
4086
|
docs: {
|
3925
4087
|
category: 'Operations',
|
3926
4088
|
description: 'Limit the complexity of the GraphQL operations solely by their depth. Based on [graphql-depth-limit](https://npmjs.com/package/graphql-depth-limit).',
|
3927
|
-
url: `https://github.com/B2o5T/graphql-eslint/blob/master/docs/rules/${RULE_ID$
|
4089
|
+
url: `https://github.com/B2o5T/graphql-eslint/blob/master/docs/rules/${RULE_ID$e}.md`,
|
3928
4090
|
requiresSiblings: true,
|
3929
4091
|
examples: [
|
3930
4092
|
{
|
@@ -3970,30 +4132,15 @@ const rule$o = {
|
|
3970
4132
|
recommended: true,
|
3971
4133
|
configOptions: [{ maxDepth: 7 }],
|
3972
4134
|
},
|
3973
|
-
schema:
|
3974
|
-
type: 'array',
|
3975
|
-
minItems: 1,
|
3976
|
-
maxItems: 1,
|
3977
|
-
items: {
|
3978
|
-
type: 'object',
|
3979
|
-
additionalProperties: false,
|
3980
|
-
required: ['maxDepth'],
|
3981
|
-
properties: {
|
3982
|
-
maxDepth: {
|
3983
|
-
type: 'number',
|
3984
|
-
},
|
3985
|
-
ignore: ARRAY_DEFAULT_OPTIONS,
|
3986
|
-
},
|
3987
|
-
},
|
3988
|
-
},
|
4135
|
+
schema: schema$c,
|
3989
4136
|
},
|
3990
4137
|
create(context) {
|
3991
4138
|
let siblings = null;
|
3992
4139
|
try {
|
3993
|
-
siblings = requireSiblingsOperations(RULE_ID$
|
4140
|
+
siblings = requireSiblingsOperations(RULE_ID$e, context);
|
3994
4141
|
}
|
3995
4142
|
catch (_a) {
|
3996
|
-
logger.warn(`Rule "${RULE_ID$
|
4143
|
+
logger.warn(`Rule "${RULE_ID$e}" works best with siblings operations loaded. For more info: https://bit.ly/graphql-eslint-operations`);
|
3997
4144
|
}
|
3998
4145
|
const { maxDepth, ignore = [] } = context.options[0];
|
3999
4146
|
const checkFn = depthLimit(maxDepth, { ignore });
|
@@ -4037,22 +4184,54 @@ const rule$o = {
|
|
4037
4184
|
});
|
4038
4185
|
}
|
4039
4186
|
catch (e) {
|
4040
|
-
logger.warn(`Rule "${RULE_ID$
|
4187
|
+
logger.warn(`Rule "${RULE_ID$e}" check failed due to a missing siblings operations. For more info: https://bit.ly/graphql-eslint-operations`, e);
|
4041
4188
|
}
|
4042
4189
|
},
|
4043
4190
|
};
|
4044
4191
|
},
|
4045
4192
|
};
|
4046
4193
|
|
4047
|
-
const RULE_ID$
|
4048
|
-
const
|
4194
|
+
const RULE_ID$f = 'strict-id-in-types';
|
4195
|
+
const schema$d = {
|
4196
|
+
type: 'array',
|
4197
|
+
maxItems: 1,
|
4198
|
+
items: {
|
4199
|
+
type: 'object',
|
4200
|
+
additionalProperties: false,
|
4201
|
+
properties: {
|
4202
|
+
acceptedIdNames: {
|
4203
|
+
...ARRAY_DEFAULT_OPTIONS,
|
4204
|
+
default: ['id'],
|
4205
|
+
},
|
4206
|
+
acceptedIdTypes: {
|
4207
|
+
...ARRAY_DEFAULT_OPTIONS,
|
4208
|
+
default: ['ID'],
|
4209
|
+
},
|
4210
|
+
exceptions: {
|
4211
|
+
type: 'object',
|
4212
|
+
additionalProperties: false,
|
4213
|
+
properties: {
|
4214
|
+
types: {
|
4215
|
+
...ARRAY_DEFAULT_OPTIONS,
|
4216
|
+
description: 'This is used to exclude types with names that match one of the specified values.',
|
4217
|
+
},
|
4218
|
+
suffixes: {
|
4219
|
+
...ARRAY_DEFAULT_OPTIONS,
|
4220
|
+
description: 'This is used to exclude types with names with suffixes that match one of the specified values.',
|
4221
|
+
},
|
4222
|
+
},
|
4223
|
+
},
|
4224
|
+
},
|
4225
|
+
},
|
4226
|
+
};
|
4227
|
+
const rule$q = {
|
4049
4228
|
meta: {
|
4050
4229
|
type: 'suggestion',
|
4051
4230
|
docs: {
|
4052
4231
|
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.',
|
4053
4232
|
category: 'Schema',
|
4054
4233
|
recommended: true,
|
4055
|
-
url: `https://github.com/B2o5T/graphql-eslint/blob/master/docs/rules/${RULE_ID$
|
4234
|
+
url: `https://github.com/B2o5T/graphql-eslint/blob/master/docs/rules/${RULE_ID$f}.md`,
|
4056
4235
|
requiresSchema: true,
|
4057
4236
|
examples: [
|
4058
4237
|
{
|
@@ -4116,37 +4295,7 @@ const rule$p = {
|
|
4116
4295
|
},
|
4117
4296
|
],
|
4118
4297
|
},
|
4119
|
-
schema:
|
4120
|
-
type: 'array',
|
4121
|
-
maxItems: 1,
|
4122
|
-
items: {
|
4123
|
-
type: 'object',
|
4124
|
-
additionalProperties: false,
|
4125
|
-
properties: {
|
4126
|
-
acceptedIdNames: {
|
4127
|
-
...ARRAY_DEFAULT_OPTIONS,
|
4128
|
-
default: ['id'],
|
4129
|
-
},
|
4130
|
-
acceptedIdTypes: {
|
4131
|
-
...ARRAY_DEFAULT_OPTIONS,
|
4132
|
-
default: ['ID'],
|
4133
|
-
},
|
4134
|
-
exceptions: {
|
4135
|
-
type: 'object',
|
4136
|
-
properties: {
|
4137
|
-
types: {
|
4138
|
-
...ARRAY_DEFAULT_OPTIONS,
|
4139
|
-
description: 'This is used to exclude types with names that match one of the specified values.',
|
4140
|
-
},
|
4141
|
-
suffixes: {
|
4142
|
-
...ARRAY_DEFAULT_OPTIONS,
|
4143
|
-
description: 'This is used to exclude types with names with suffixes that match one of the specified values.',
|
4144
|
-
},
|
4145
|
-
},
|
4146
|
-
},
|
4147
|
-
},
|
4148
|
-
},
|
4149
|
-
},
|
4298
|
+
schema: schema$d,
|
4150
4299
|
},
|
4151
4300
|
create(context) {
|
4152
4301
|
const options = {
|
@@ -4155,7 +4304,7 @@ const rule$p = {
|
|
4155
4304
|
exceptions: {},
|
4156
4305
|
...context.options[0],
|
4157
4306
|
};
|
4158
|
-
const schema = requireGraphQLSchemaFromContext(RULE_ID$
|
4307
|
+
const schema = requireGraphQLSchemaFromContext(RULE_ID$f, context);
|
4159
4308
|
const rootTypeNames = [
|
4160
4309
|
schema.getQueryType(),
|
4161
4310
|
schema.getMutationType(),
|
@@ -4200,7 +4349,7 @@ const rule$p = {
|
|
4200
4349
|
},
|
4201
4350
|
};
|
4202
4351
|
|
4203
|
-
const RULE_ID$
|
4352
|
+
const RULE_ID$g = 'unique-fragment-name';
|
4204
4353
|
const checkNode = (context, node, ruleId) => {
|
4205
4354
|
const documentName = node.name.value;
|
4206
4355
|
const siblings = requireSiblingsOperations(ruleId, context);
|
@@ -4227,13 +4376,13 @@ const checkNode = (context, node, ruleId) => {
|
|
4227
4376
|
});
|
4228
4377
|
}
|
4229
4378
|
};
|
4230
|
-
const rule$
|
4379
|
+
const rule$r = {
|
4231
4380
|
meta: {
|
4232
4381
|
type: 'suggestion',
|
4233
4382
|
docs: {
|
4234
4383
|
category: 'Operations',
|
4235
4384
|
description: 'Enforce unique fragment names across your project.',
|
4236
|
-
url: `https://github.com/B2o5T/graphql-eslint/blob/master/docs/rules/${RULE_ID$
|
4385
|
+
url: `https://github.com/B2o5T/graphql-eslint/blob/master/docs/rules/${RULE_ID$g}.md`,
|
4237
4386
|
requiresSiblings: true,
|
4238
4387
|
examples: [
|
4239
4388
|
{
|
@@ -4271,27 +4420,27 @@ const rule$q = {
|
|
4271
4420
|
],
|
4272
4421
|
},
|
4273
4422
|
messages: {
|
4274
|
-
[RULE_ID$
|
4423
|
+
[RULE_ID$g]: 'Fragment named "{{ documentName }}" already defined in:\n{{ summary }}',
|
4275
4424
|
},
|
4276
4425
|
schema: [],
|
4277
4426
|
},
|
4278
4427
|
create(context) {
|
4279
4428
|
return {
|
4280
4429
|
FragmentDefinition(node) {
|
4281
|
-
checkNode(context, node, RULE_ID$
|
4430
|
+
checkNode(context, node, RULE_ID$g);
|
4282
4431
|
},
|
4283
4432
|
};
|
4284
4433
|
},
|
4285
4434
|
};
|
4286
4435
|
|
4287
|
-
const RULE_ID$
|
4288
|
-
const rule$
|
4436
|
+
const RULE_ID$h = 'unique-operation-name';
|
4437
|
+
const rule$s = {
|
4289
4438
|
meta: {
|
4290
4439
|
type: 'suggestion',
|
4291
4440
|
docs: {
|
4292
4441
|
category: 'Operations',
|
4293
4442
|
description: 'Enforce unique operation names across your project.',
|
4294
|
-
url: `https://github.com/B2o5T/graphql-eslint/blob/master/docs/rules/${RULE_ID$
|
4443
|
+
url: `https://github.com/B2o5T/graphql-eslint/blob/master/docs/rules/${RULE_ID$h}.md`,
|
4295
4444
|
requiresSiblings: true,
|
4296
4445
|
examples: [
|
4297
4446
|
{
|
@@ -4333,14 +4482,14 @@ const rule$r = {
|
|
4333
4482
|
],
|
4334
4483
|
},
|
4335
4484
|
messages: {
|
4336
|
-
[RULE_ID$
|
4485
|
+
[RULE_ID$h]: 'Operation named "{{ documentName }}" already defined in:\n{{ summary }}',
|
4337
4486
|
},
|
4338
4487
|
schema: [],
|
4339
4488
|
},
|
4340
4489
|
create(context) {
|
4341
4490
|
return {
|
4342
4491
|
'OperationDefinition[name!=undefined]'(node) {
|
4343
|
-
checkNode(context, node, RULE_ID$
|
4492
|
+
checkNode(context, node, RULE_ID$h);
|
4344
4493
|
},
|
4345
4494
|
};
|
4346
4495
|
},
|
@@ -4354,31 +4503,32 @@ const rules = {
|
|
4354
4503
|
alphabetize: rule,
|
4355
4504
|
'description-style': rule$1,
|
4356
4505
|
'input-name': rule$2,
|
4357
|
-
'
|
4358
|
-
'
|
4359
|
-
'
|
4360
|
-
'no-
|
4361
|
-
'no-
|
4362
|
-
'no-
|
4363
|
-
'no-
|
4364
|
-
'no-
|
4365
|
-
'no-
|
4366
|
-
'no-
|
4367
|
-
'no-
|
4368
|
-
'no-
|
4369
|
-
'
|
4370
|
-
'relay-
|
4371
|
-
'relay-
|
4372
|
-
'relay-
|
4373
|
-
'
|
4374
|
-
'require-deprecation-
|
4375
|
-
'require-
|
4376
|
-
'require-
|
4377
|
-
'require-
|
4378
|
-
'
|
4379
|
-
'
|
4380
|
-
'
|
4381
|
-
'unique-
|
4506
|
+
'lone-executable-definition': rule$3,
|
4507
|
+
'match-document-filename': rule$4,
|
4508
|
+
'naming-convention': rule$5,
|
4509
|
+
'no-anonymous-operations': rule$6,
|
4510
|
+
'no-case-insensitive-enum-values-duplicates': rule$7,
|
4511
|
+
'no-deprecated': rule$8,
|
4512
|
+
'no-duplicate-fields': rule$9,
|
4513
|
+
'no-hashtag-description': rule$a,
|
4514
|
+
'no-root-type': rule$b,
|
4515
|
+
'no-scalar-result-type-on-mutation': rule$c,
|
4516
|
+
'no-typename-prefix': rule$d,
|
4517
|
+
'no-unreachable-types': rule$e,
|
4518
|
+
'no-unused-fields': rule$f,
|
4519
|
+
'relay-arguments': rule$g,
|
4520
|
+
'relay-connection-types': rule$h,
|
4521
|
+
'relay-edge-types': rule$i,
|
4522
|
+
'relay-page-info': rule$j,
|
4523
|
+
'require-deprecation-date': rule$k,
|
4524
|
+
'require-deprecation-reason': rule$l,
|
4525
|
+
'require-description': rule$m,
|
4526
|
+
'require-field-of-type-query-in-mutation-result': rule$n,
|
4527
|
+
'require-id-when-available': rule$o,
|
4528
|
+
'selection-set-depth': rule$p,
|
4529
|
+
'strict-id-in-types': rule$q,
|
4530
|
+
'unique-fragment-name': rule$r,
|
4531
|
+
'unique-operation-name': rule$s,
|
4382
4532
|
};
|
4383
4533
|
|
4384
4534
|
// Based on the `eslint-plugin-import`'s cache
|