@graphql-eslint/eslint-plugin 3.14.0-alpha-20221220004017-f1f0904 → 3.14.0-alpha-20221220160018-ba4832c
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 +596 -467
- package/index.mjs +597 -468
- 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 +76 -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 +65 -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,
|
@@ -509,7 +509,7 @@ const GRAPHQL_JS_VALIDATIONS = Object.assign({}, validationToRule({
|
|
509
509
|
ruleName: 'LoneAnonymousOperation',
|
510
510
|
}, {
|
511
511
|
category: 'Operations',
|
512
|
-
description: 'A GraphQL document
|
512
|
+
description: 'A GraphQL document that contains an anonymous operation (the `query` short-hand) is only valid if it contains only that one operation definition.',
|
513
513
|
requiresSchema: true,
|
514
514
|
}), validationToRule({
|
515
515
|
ruleId: 'lone-schema-definition',
|
@@ -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,39 @@ 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
|
+
},
|
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: ['.gql', '.graphql'] },
|
1368
|
+
query: schemaOption,
|
1369
|
+
mutation: schemaOption,
|
1370
|
+
subscription: schemaOption,
|
1371
|
+
fragment: schemaOption,
|
1372
|
+
},
|
1373
|
+
},
|
1374
|
+
};
|
1375
|
+
const rule$4 = {
|
1253
1376
|
meta: {
|
1254
1377
|
type: 'suggestion',
|
1255
1378
|
docs: {
|
@@ -1340,38 +1463,7 @@ const rule$3 = {
|
|
1340
1463
|
[MATCH_EXTENSION]: 'File extension "{{ fileExtension }}" don\'t match extension "{{ expectedFileExtension }}"',
|
1341
1464
|
[MATCH_STYLE]: 'Unexpected filename "{{ filename }}". Rename it to "{{ expectedFilename }}"',
|
1342
1465
|
},
|
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
|
-
},
|
1466
|
+
schema: schema$4,
|
1375
1467
|
},
|
1376
1468
|
create(context) {
|
1377
1469
|
const options = context.options[0] || {
|
@@ -1473,7 +1565,67 @@ const ALLOWED_STYLES = Object.keys(StyleToRegex);
|
|
1473
1565
|
const schemaOption$1 = {
|
1474
1566
|
oneOf: [{ $ref: '#/definitions/asString' }, { $ref: '#/definitions/asObject' }],
|
1475
1567
|
};
|
1476
|
-
const
|
1568
|
+
const schema$5 = {
|
1569
|
+
definitions: {
|
1570
|
+
asString: {
|
1571
|
+
enum: ALLOWED_STYLES,
|
1572
|
+
description: `One of: ${ALLOWED_STYLES.map(t => `\`${t}\``).join(', ')}`,
|
1573
|
+
},
|
1574
|
+
asObject: {
|
1575
|
+
type: 'object',
|
1576
|
+
additionalProperties: false,
|
1577
|
+
properties: {
|
1578
|
+
style: { enum: ALLOWED_STYLES },
|
1579
|
+
prefix: { type: 'string' },
|
1580
|
+
suffix: { type: 'string' },
|
1581
|
+
forbiddenPrefixes: ARRAY_DEFAULT_OPTIONS,
|
1582
|
+
forbiddenSuffixes: ARRAY_DEFAULT_OPTIONS,
|
1583
|
+
ignorePattern: {
|
1584
|
+
type: 'string',
|
1585
|
+
description: 'Option to skip validation of some words, e.g. acronyms',
|
1586
|
+
},
|
1587
|
+
},
|
1588
|
+
},
|
1589
|
+
},
|
1590
|
+
type: 'array',
|
1591
|
+
maxItems: 1,
|
1592
|
+
items: {
|
1593
|
+
type: 'object',
|
1594
|
+
additionalProperties: false,
|
1595
|
+
properties: {
|
1596
|
+
types: {
|
1597
|
+
...schemaOption$1,
|
1598
|
+
description: `Includes:\n${TYPES_KINDS.map(kind => `- \`${kind}\``).join('\n')}`,
|
1599
|
+
},
|
1600
|
+
...Object.fromEntries(ALLOWED_KINDS.map(kind => [
|
1601
|
+
kind,
|
1602
|
+
{
|
1603
|
+
...schemaOption$1,
|
1604
|
+
description: `Read more about this kind on [spec.graphql.org](https://spec.graphql.org/October2021/#${kind}).`,
|
1605
|
+
},
|
1606
|
+
])),
|
1607
|
+
allowLeadingUnderscore: {
|
1608
|
+
type: 'boolean',
|
1609
|
+
default: false,
|
1610
|
+
},
|
1611
|
+
allowTrailingUnderscore: {
|
1612
|
+
type: 'boolean',
|
1613
|
+
default: false,
|
1614
|
+
},
|
1615
|
+
},
|
1616
|
+
patternProperties: {
|
1617
|
+
[`^(${ALLOWED_KINDS.join('|')})(.+)?$`]: schemaOption$1,
|
1618
|
+
},
|
1619
|
+
description: [
|
1620
|
+
"> It's possible to use a [`selector`](https://eslint.org/docs/developer-guide/selectors) that starts with allowed `ASTNode` names which are described below.",
|
1621
|
+
'>',
|
1622
|
+
'> Paste or drop code into the editor in [ASTExplorer](https://astexplorer.net) and inspect the generated AST to compose your selector.',
|
1623
|
+
'>',
|
1624
|
+
'> Example: pattern property `FieldDefinition[parent.name.value=Query]` will match only fields for type `Query`.',
|
1625
|
+
].join('\n'),
|
1626
|
+
},
|
1627
|
+
};
|
1628
|
+
const rule$5 = {
|
1477
1629
|
meta: {
|
1478
1630
|
type: 'suggestion',
|
1479
1631
|
docs: {
|
@@ -1589,66 +1741,7 @@ const rule$4 = {
|
|
1589
1741
|
},
|
1590
1742
|
},
|
1591
1743
|
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
|
-
},
|
1744
|
+
schema: schema$5,
|
1652
1745
|
},
|
1653
1746
|
create(context) {
|
1654
1747
|
const options = context.options[0] || {};
|
@@ -1748,8 +1841,8 @@ const rule$4 = {
|
|
1748
1841
|
},
|
1749
1842
|
};
|
1750
1843
|
|
1751
|
-
const RULE_ID$
|
1752
|
-
const rule$
|
1844
|
+
const RULE_ID$2 = 'no-anonymous-operations';
|
1845
|
+
const rule$6 = {
|
1753
1846
|
meta: {
|
1754
1847
|
type: 'suggestion',
|
1755
1848
|
hasSuggestions: true,
|
@@ -1757,7 +1850,7 @@ const rule$5 = {
|
|
1757
1850
|
category: 'Operations',
|
1758
1851
|
description: 'Require name for your GraphQL operations. This is useful since most GraphQL client libraries are using the operation name for caching purposes.',
|
1759
1852
|
recommended: true,
|
1760
|
-
url: `https://github.com/B2o5T/graphql-eslint/blob/master/docs/rules/${RULE_ID$
|
1853
|
+
url: `https://github.com/B2o5T/graphql-eslint/blob/master/docs/rules/${RULE_ID$2}.md`,
|
1761
1854
|
examples: [
|
1762
1855
|
{
|
1763
1856
|
title: 'Incorrect',
|
@@ -1778,7 +1871,7 @@ const rule$5 = {
|
|
1778
1871
|
],
|
1779
1872
|
},
|
1780
1873
|
messages: {
|
1781
|
-
[RULE_ID$
|
1874
|
+
[RULE_ID$2]: 'Anonymous GraphQL operations are forbidden. Make sure to name your {{ operation }}!',
|
1782
1875
|
},
|
1783
1876
|
schema: [],
|
1784
1877
|
},
|
@@ -1791,7 +1884,7 @@ const rule$5 = {
|
|
1791
1884
|
: node.operation;
|
1792
1885
|
context.report({
|
1793
1886
|
loc: getLocation(node.loc.start, node.operation),
|
1794
|
-
messageId: RULE_ID$
|
1887
|
+
messageId: RULE_ID$2,
|
1795
1888
|
data: {
|
1796
1889
|
operation: node.operation,
|
1797
1890
|
},
|
@@ -1811,7 +1904,7 @@ const rule$5 = {
|
|
1811
1904
|
},
|
1812
1905
|
};
|
1813
1906
|
|
1814
|
-
const rule$
|
1907
|
+
const rule$7 = {
|
1815
1908
|
meta: {
|
1816
1909
|
type: 'suggestion',
|
1817
1910
|
hasSuggestions: true,
|
@@ -1869,15 +1962,15 @@ const rule$6 = {
|
|
1869
1962
|
},
|
1870
1963
|
};
|
1871
1964
|
|
1872
|
-
const RULE_ID$
|
1873
|
-
const rule$
|
1965
|
+
const RULE_ID$3 = 'no-deprecated';
|
1966
|
+
const rule$8 = {
|
1874
1967
|
meta: {
|
1875
1968
|
type: 'suggestion',
|
1876
1969
|
hasSuggestions: true,
|
1877
1970
|
docs: {
|
1878
1971
|
category: 'Operations',
|
1879
1972
|
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$
|
1973
|
+
url: `https://github.com/B2o5T/graphql-eslint/blob/master/docs/rules/${RULE_ID$3}.md`,
|
1881
1974
|
requiresSchema: true,
|
1882
1975
|
examples: [
|
1883
1976
|
{
|
@@ -1944,18 +2037,18 @@ const rule$7 = {
|
|
1944
2037
|
recommended: true,
|
1945
2038
|
},
|
1946
2039
|
messages: {
|
1947
|
-
[RULE_ID$
|
2040
|
+
[RULE_ID$3]: 'This {{ type }} is marked as deprecated in your GraphQL schema (reason: {{ reason }})',
|
1948
2041
|
},
|
1949
2042
|
schema: [],
|
1950
2043
|
},
|
1951
2044
|
create(context) {
|
1952
|
-
requireGraphQLSchemaFromContext(RULE_ID$
|
2045
|
+
requireGraphQLSchemaFromContext(RULE_ID$3, context);
|
1953
2046
|
function report(node, reason) {
|
1954
2047
|
const nodeName = node.kind === graphql.Kind.ENUM ? node.value : node.name.value;
|
1955
2048
|
const nodeType = node.kind === graphql.Kind.ENUM ? 'enum value' : 'field';
|
1956
2049
|
context.report({
|
1957
2050
|
node,
|
1958
|
-
messageId: RULE_ID$
|
2051
|
+
messageId: RULE_ID$3,
|
1959
2052
|
data: {
|
1960
2053
|
type: nodeType,
|
1961
2054
|
reason,
|
@@ -1989,15 +2082,15 @@ const rule$7 = {
|
|
1989
2082
|
},
|
1990
2083
|
};
|
1991
2084
|
|
1992
|
-
const RULE_ID$
|
1993
|
-
const rule$
|
2085
|
+
const RULE_ID$4 = 'no-duplicate-fields';
|
2086
|
+
const rule$9 = {
|
1994
2087
|
meta: {
|
1995
2088
|
type: 'suggestion',
|
1996
2089
|
hasSuggestions: true,
|
1997
2090
|
docs: {
|
1998
2091
|
description: 'Checks for duplicate fields in selection set, variables in operation definition, or in arguments set of a field.',
|
1999
2092
|
category: 'Operations',
|
2000
|
-
url: `https://github.com/B2o5T/graphql-eslint/blob/master/docs/rules/${RULE_ID$
|
2093
|
+
url: `https://github.com/B2o5T/graphql-eslint/blob/master/docs/rules/${RULE_ID$4}.md`,
|
2001
2094
|
recommended: true,
|
2002
2095
|
examples: [
|
2003
2096
|
{
|
@@ -2043,7 +2136,7 @@ const rule$8 = {
|
|
2043
2136
|
],
|
2044
2137
|
},
|
2045
2138
|
messages: {
|
2046
|
-
[RULE_ID$
|
2139
|
+
[RULE_ID$4]: '{{ type }} `{{ fieldName }}` defined multiple times.',
|
2047
2140
|
},
|
2048
2141
|
schema: [],
|
2049
2142
|
},
|
@@ -2054,7 +2147,7 @@ const rule$8 = {
|
|
2054
2147
|
const { parent } = node;
|
2055
2148
|
context.report({
|
2056
2149
|
node,
|
2057
|
-
messageId: RULE_ID$
|
2150
|
+
messageId: RULE_ID$4,
|
2058
2151
|
data: {
|
2059
2152
|
type: parent.type,
|
2060
2153
|
fieldName,
|
@@ -2099,7 +2192,7 @@ const rule$8 = {
|
|
2099
2192
|
};
|
2100
2193
|
|
2101
2194
|
const HASHTAG_COMMENT = 'HASHTAG_COMMENT';
|
2102
|
-
const rule$
|
2195
|
+
const rule$a = {
|
2103
2196
|
meta: {
|
2104
2197
|
type: 'suggestion',
|
2105
2198
|
hasSuggestions: true,
|
@@ -2184,8 +2277,25 @@ const rule$9 = {
|
|
2184
2277
|
},
|
2185
2278
|
};
|
2186
2279
|
|
2187
|
-
const
|
2188
|
-
|
2280
|
+
const schema$6 = {
|
2281
|
+
type: 'array',
|
2282
|
+
minItems: 1,
|
2283
|
+
maxItems: 1,
|
2284
|
+
items: {
|
2285
|
+
type: 'object',
|
2286
|
+
additionalProperties: false,
|
2287
|
+
required: ['disallow'],
|
2288
|
+
properties: {
|
2289
|
+
disallow: {
|
2290
|
+
...ARRAY_DEFAULT_OPTIONS,
|
2291
|
+
items: {
|
2292
|
+
enum: ['mutation', 'subscription'],
|
2293
|
+
},
|
2294
|
+
},
|
2295
|
+
},
|
2296
|
+
},
|
2297
|
+
};
|
2298
|
+
const rule$b = {
|
2189
2299
|
meta: {
|
2190
2300
|
type: 'suggestion',
|
2191
2301
|
hasSuggestions: true,
|
@@ -2216,24 +2326,7 @@ const rule$a = {
|
|
2216
2326
|
},
|
2217
2327
|
],
|
2218
2328
|
},
|
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
|
-
},
|
2329
|
+
schema: schema$6,
|
2237
2330
|
},
|
2238
2331
|
create(context) {
|
2239
2332
|
const schema = requireGraphQLSchemaFromContext('no-root-type', context);
|
@@ -2267,15 +2360,15 @@ const rule$a = {
|
|
2267
2360
|
},
|
2268
2361
|
};
|
2269
2362
|
|
2270
|
-
const RULE_ID$
|
2271
|
-
const rule$
|
2363
|
+
const RULE_ID$5 = 'no-scalar-result-type-on-mutation';
|
2364
|
+
const rule$c = {
|
2272
2365
|
meta: {
|
2273
2366
|
type: 'suggestion',
|
2274
2367
|
hasSuggestions: true,
|
2275
2368
|
docs: {
|
2276
2369
|
category: 'Schema',
|
2277
2370
|
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$
|
2371
|
+
url: `https://github.com/B2o5T/graphql-eslint/blob/master/docs/rules/${RULE_ID$5}.md`,
|
2279
2372
|
requiresSchema: true,
|
2280
2373
|
examples: [
|
2281
2374
|
{
|
@@ -2299,7 +2392,7 @@ const rule$b = {
|
|
2299
2392
|
schema: [],
|
2300
2393
|
},
|
2301
2394
|
create(context) {
|
2302
|
-
const schema = requireGraphQLSchemaFromContext(RULE_ID$
|
2395
|
+
const schema = requireGraphQLSchemaFromContext(RULE_ID$5, context);
|
2303
2396
|
const mutationType = schema.getMutationType();
|
2304
2397
|
if (!mutationType) {
|
2305
2398
|
return {};
|
@@ -2330,7 +2423,7 @@ const rule$b = {
|
|
2330
2423
|
};
|
2331
2424
|
|
2332
2425
|
const NO_TYPENAME_PREFIX = 'NO_TYPENAME_PREFIX';
|
2333
|
-
const rule$
|
2426
|
+
const rule$d = {
|
2334
2427
|
meta: {
|
2335
2428
|
type: 'suggestion',
|
2336
2429
|
hasSuggestions: true,
|
@@ -2392,7 +2485,7 @@ const rule$c = {
|
|
2392
2485
|
},
|
2393
2486
|
};
|
2394
2487
|
|
2395
|
-
const RULE_ID$
|
2488
|
+
const RULE_ID$6 = 'no-unreachable-types';
|
2396
2489
|
const KINDS = [
|
2397
2490
|
graphql.Kind.DIRECTIVE_DEFINITION,
|
2398
2491
|
graphql.Kind.OBJECT_TYPE_DEFINITION,
|
@@ -2472,15 +2565,15 @@ function getReachableTypes(schema) {
|
|
2472
2565
|
reachableTypesCache = reachableTypes;
|
2473
2566
|
return reachableTypesCache;
|
2474
2567
|
}
|
2475
|
-
const rule$
|
2568
|
+
const rule$e = {
|
2476
2569
|
meta: {
|
2477
2570
|
messages: {
|
2478
|
-
[RULE_ID$
|
2571
|
+
[RULE_ID$6]: '{{ type }} `{{ typeName }}` is unreachable.',
|
2479
2572
|
},
|
2480
2573
|
docs: {
|
2481
2574
|
description: 'Requires all types to be reachable at some level by root level fields.',
|
2482
2575
|
category: 'Schema',
|
2483
|
-
url: `https://github.com/B2o5T/graphql-eslint/blob/master/docs/rules/${RULE_ID$
|
2576
|
+
url: `https://github.com/B2o5T/graphql-eslint/blob/master/docs/rules/${RULE_ID$6}.md`,
|
2484
2577
|
requiresSchema: true,
|
2485
2578
|
examples: [
|
2486
2579
|
{
|
@@ -2517,7 +2610,7 @@ const rule$d = {
|
|
2517
2610
|
hasSuggestions: true,
|
2518
2611
|
},
|
2519
2612
|
create(context) {
|
2520
|
-
const schema = requireGraphQLSchemaFromContext(RULE_ID$
|
2613
|
+
const schema = requireGraphQLSchemaFromContext(RULE_ID$6, context);
|
2521
2614
|
const reachableTypes = getReachableTypes(schema);
|
2522
2615
|
return {
|
2523
2616
|
[`:matches(${KINDS}) > .name`](node) {
|
@@ -2526,7 +2619,7 @@ const rule$d = {
|
|
2526
2619
|
const type = lowerCase(node.parent.kind.replace(/(Extension|Definition)$/, ''));
|
2527
2620
|
context.report({
|
2528
2621
|
node,
|
2529
|
-
messageId: RULE_ID$
|
2622
|
+
messageId: RULE_ID$6,
|
2530
2623
|
data: {
|
2531
2624
|
type: type[0].toUpperCase() + type.slice(1),
|
2532
2625
|
typeName,
|
@@ -2544,7 +2637,7 @@ const rule$d = {
|
|
2544
2637
|
},
|
2545
2638
|
};
|
2546
2639
|
|
2547
|
-
const RULE_ID$
|
2640
|
+
const RULE_ID$7 = 'no-unused-fields';
|
2548
2641
|
let usedFieldsCache;
|
2549
2642
|
function getUsedFields(schema, operations) {
|
2550
2643
|
// We don't want cache usedFields on test environment
|
@@ -2575,15 +2668,15 @@ function getUsedFields(schema, operations) {
|
|
2575
2668
|
usedFieldsCache = usedFields;
|
2576
2669
|
return usedFieldsCache;
|
2577
2670
|
}
|
2578
|
-
const rule$
|
2671
|
+
const rule$f = {
|
2579
2672
|
meta: {
|
2580
2673
|
messages: {
|
2581
|
-
[RULE_ID$
|
2674
|
+
[RULE_ID$7]: 'Field "{{fieldName}}" is unused',
|
2582
2675
|
},
|
2583
2676
|
docs: {
|
2584
2677
|
description: 'Requires all fields to be used at some level by siblings operations.',
|
2585
2678
|
category: 'Schema',
|
2586
|
-
url: `https://github.com/B2o5T/graphql-eslint/blob/master/docs/rules/${RULE_ID$
|
2679
|
+
url: `https://github.com/B2o5T/graphql-eslint/blob/master/docs/rules/${RULE_ID$7}.md`,
|
2587
2680
|
requiresSiblings: true,
|
2588
2681
|
requiresSchema: true,
|
2589
2682
|
isDisabledForAllConfig: true,
|
@@ -2636,8 +2729,8 @@ const rule$e = {
|
|
2636
2729
|
hasSuggestions: true,
|
2637
2730
|
},
|
2638
2731
|
create(context) {
|
2639
|
-
const schema = requireGraphQLSchemaFromContext(RULE_ID$
|
2640
|
-
const siblingsOperations = requireSiblingsOperations(RULE_ID$
|
2732
|
+
const schema = requireGraphQLSchemaFromContext(RULE_ID$7, context);
|
2733
|
+
const siblingsOperations = requireSiblingsOperations(RULE_ID$7, context);
|
2641
2734
|
const usedFields = getUsedFields(schema, siblingsOperations);
|
2642
2735
|
return {
|
2643
2736
|
FieldDefinition(node) {
|
@@ -2650,7 +2743,7 @@ const rule$e = {
|
|
2650
2743
|
}
|
2651
2744
|
context.report({
|
2652
2745
|
node: node.name,
|
2653
|
-
messageId: RULE_ID$
|
2746
|
+
messageId: RULE_ID$7,
|
2654
2747
|
data: { fieldName },
|
2655
2748
|
suggest: [
|
2656
2749
|
{
|
@@ -2670,9 +2763,25 @@ const rule$e = {
|
|
2670
2763
|
},
|
2671
2764
|
};
|
2672
2765
|
|
2673
|
-
const RULE_ID$
|
2766
|
+
const RULE_ID$8 = 'relay-arguments';
|
2674
2767
|
const MISSING_ARGUMENTS = 'MISSING_ARGUMENTS';
|
2675
|
-
const
|
2768
|
+
const schema$7 = {
|
2769
|
+
type: 'array',
|
2770
|
+
maxItems: 1,
|
2771
|
+
items: {
|
2772
|
+
type: 'object',
|
2773
|
+
additionalProperties: false,
|
2774
|
+
minProperties: 1,
|
2775
|
+
properties: {
|
2776
|
+
includeBoth: {
|
2777
|
+
type: 'boolean',
|
2778
|
+
default: true,
|
2779
|
+
description: 'Enforce including both forward and backward pagination arguments',
|
2780
|
+
},
|
2781
|
+
},
|
2782
|
+
},
|
2783
|
+
};
|
2784
|
+
const rule$g = {
|
2676
2785
|
meta: {
|
2677
2786
|
type: 'problem',
|
2678
2787
|
docs: {
|
@@ -2692,7 +2801,7 @@ const rule$f = {
|
|
2692
2801
|
'- `last` takes a non-negative integer',
|
2693
2802
|
'- `before` takes the Cursor type',
|
2694
2803
|
].join('\n'),
|
2695
|
-
url: `https://github.com/B2o5T/graphql-eslint/blob/master/docs/rules/${RULE_ID$
|
2804
|
+
url: `https://github.com/B2o5T/graphql-eslint/blob/master/docs/rules/${RULE_ID$8}.md`,
|
2696
2805
|
examples: [
|
2697
2806
|
{
|
2698
2807
|
title: 'Incorrect',
|
@@ -2716,25 +2825,10 @@ const rule$f = {
|
|
2716
2825
|
messages: {
|
2717
2826
|
[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
2827
|
},
|
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
|
-
},
|
2828
|
+
schema: schema$7,
|
2735
2829
|
},
|
2736
2830
|
create(context) {
|
2737
|
-
const schema = requireGraphQLSchemaFromContext(RULE_ID$
|
2831
|
+
const schema = requireGraphQLSchemaFromContext(RULE_ID$8, context);
|
2738
2832
|
const { includeBoth = true } = context.options[0] || {};
|
2739
2833
|
return {
|
2740
2834
|
'FieldDefinition > .gqlType Name[value=/Connection$/]'(node) {
|
@@ -2806,7 +2900,7 @@ const NON_OBJECT_TYPES = [
|
|
2806
2900
|
const notConnectionTypesSelector = `:matches(${NON_OBJECT_TYPES})[name.value=/Connection$/] > .name`;
|
2807
2901
|
const hasEdgesField = (node) => node.fields.some(field => field.name.value === 'edges');
|
2808
2902
|
const hasPageInfoField = (node) => node.fields.some(field => field.name.value === 'pageInfo');
|
2809
|
-
const rule$
|
2903
|
+
const rule$h = {
|
2810
2904
|
meta: {
|
2811
2905
|
type: 'problem',
|
2812
2906
|
docs: {
|
@@ -2890,7 +2984,7 @@ const rule$g = {
|
|
2890
2984
|
},
|
2891
2985
|
};
|
2892
2986
|
|
2893
|
-
const RULE_ID$
|
2987
|
+
const RULE_ID$9 = 'relay-edge-types';
|
2894
2988
|
const MESSAGE_MUST_BE_OBJECT_TYPE = 'MESSAGE_MUST_BE_OBJECT_TYPE';
|
2895
2989
|
const MESSAGE_MISSING_EDGE_SUFFIX = 'MESSAGE_MISSING_EDGE_SUFFIX';
|
2896
2990
|
const MESSAGE_LIST_TYPE_ONLY_EDGE_TYPE = 'MESSAGE_LIST_TYPE_ONLY_EDGE_TYPE';
|
@@ -2925,7 +3019,33 @@ function getEdgeTypes(schema) {
|
|
2925
3019
|
edgeTypesCache = edgeTypes;
|
2926
3020
|
return edgeTypesCache;
|
2927
3021
|
}
|
2928
|
-
const
|
3022
|
+
const schema$8 = {
|
3023
|
+
type: 'array',
|
3024
|
+
maxItems: 1,
|
3025
|
+
items: {
|
3026
|
+
type: 'object',
|
3027
|
+
additionalProperties: false,
|
3028
|
+
minProperties: 1,
|
3029
|
+
properties: {
|
3030
|
+
withEdgeSuffix: {
|
3031
|
+
type: 'boolean',
|
3032
|
+
default: true,
|
3033
|
+
description: 'Edge type name must end in "Edge".',
|
3034
|
+
},
|
3035
|
+
shouldImplementNode: {
|
3036
|
+
type: 'boolean',
|
3037
|
+
default: true,
|
3038
|
+
description: "Edge type's field `node` must implement `Node` interface.",
|
3039
|
+
},
|
3040
|
+
listTypeCanWrapOnlyEdgeType: {
|
3041
|
+
type: 'boolean',
|
3042
|
+
default: true,
|
3043
|
+
description: 'A list type should only wrap an edge type.',
|
3044
|
+
},
|
3045
|
+
},
|
3046
|
+
},
|
3047
|
+
};
|
3048
|
+
const rule$i = {
|
2929
3049
|
meta: {
|
2930
3050
|
type: 'problem',
|
2931
3051
|
docs: {
|
@@ -2941,7 +3061,7 @@ const rule$h = {
|
|
2941
3061
|
"- Edge type's field `node` must implement `Node` interface _(optional)_",
|
2942
3062
|
'- A list type should only wrap an edge type _(optional)_',
|
2943
3063
|
].join('\n'),
|
2944
|
-
url: `https://github.com/B2o5T/graphql-eslint/blob/master/docs/rules/${RULE_ID$
|
3064
|
+
url: `https://github.com/B2o5T/graphql-eslint/blob/master/docs/rules/${RULE_ID$9}.md`,
|
2945
3065
|
isDisabledForAllConfig: true,
|
2946
3066
|
requiresSchema: true,
|
2947
3067
|
examples: [
|
@@ -2962,35 +3082,10 @@ const rule$h = {
|
|
2962
3082
|
[MESSAGE_LIST_TYPE_ONLY_EDGE_TYPE]: 'A list type should only wrap an edge type.',
|
2963
3083
|
[MESSAGE_SHOULD_IMPLEMENTS_NODE]: "Edge type's field `node` must implement `Node` interface.",
|
2964
3084
|
},
|
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
|
-
},
|
3085
|
+
schema: schema$8,
|
2991
3086
|
},
|
2992
3087
|
create(context) {
|
2993
|
-
const schema = requireGraphQLSchemaFromContext(RULE_ID$
|
3088
|
+
const schema = requireGraphQLSchemaFromContext(RULE_ID$9, context);
|
2994
3089
|
const edgeTypes = getEdgeTypes(schema);
|
2995
3090
|
const options = {
|
2996
3091
|
withEdgeSuffix: true,
|
@@ -3073,12 +3168,12 @@ const rule$h = {
|
|
3073
3168
|
},
|
3074
3169
|
};
|
3075
3170
|
|
3076
|
-
const RULE_ID$
|
3171
|
+
const RULE_ID$a = 'relay-page-info';
|
3077
3172
|
const MESSAGE_MUST_EXIST = 'MESSAGE_MUST_EXIST';
|
3078
3173
|
const MESSAGE_MUST_BE_OBJECT_TYPE$1 = 'MESSAGE_MUST_BE_OBJECT_TYPE';
|
3079
3174
|
const notPageInfoTypesSelector = `:matches(${NON_OBJECT_TYPES})[name.value=PageInfo] > .name`;
|
3080
3175
|
let hasPageInfoChecked = false;
|
3081
|
-
const rule$
|
3176
|
+
const rule$j = {
|
3082
3177
|
meta: {
|
3083
3178
|
type: 'problem',
|
3084
3179
|
docs: {
|
@@ -3090,7 +3185,7 @@ const rule$i = {
|
|
3090
3185
|
'- `PageInfo` must contain fields `hasPreviousPage` and `hasNextPage`, that return non-null Boolean',
|
3091
3186
|
'- `PageInfo` must contain fields `startCursor` and `endCursor`, that return either String or Scalar, which can be null if there are no results',
|
3092
3187
|
].join('\n'),
|
3093
|
-
url: `https://github.com/B2o5T/graphql-eslint/blob/master/docs/rules/${RULE_ID$
|
3188
|
+
url: `https://github.com/B2o5T/graphql-eslint/blob/master/docs/rules/${RULE_ID$a}.md`,
|
3094
3189
|
examples: [
|
3095
3190
|
{
|
3096
3191
|
title: 'Correct',
|
@@ -3114,7 +3209,7 @@ const rule$i = {
|
|
3114
3209
|
schema: [],
|
3115
3210
|
},
|
3116
3211
|
create(context) {
|
3117
|
-
const schema = requireGraphQLSchemaFromContext(RULE_ID$
|
3212
|
+
const schema = requireGraphQLSchemaFromContext(RULE_ID$a, context);
|
3118
3213
|
if (process.env.NODE_ENV === 'test' || !hasPageInfoChecked) {
|
3119
3214
|
const pageInfoType = schema.getType('PageInfo');
|
3120
3215
|
if (!pageInfoType) {
|
@@ -3330,7 +3425,20 @@ const MESSAGE_REQUIRE_DATE = 'MESSAGE_REQUIRE_DATE';
|
|
3330
3425
|
const MESSAGE_INVALID_FORMAT = 'MESSAGE_INVALID_FORMAT';
|
3331
3426
|
const MESSAGE_INVALID_DATE = 'MESSAGE_INVALID_DATE';
|
3332
3427
|
const MESSAGE_CAN_BE_REMOVED = 'MESSAGE_CAN_BE_REMOVED';
|
3333
|
-
const
|
3428
|
+
const schema$9 = {
|
3429
|
+
type: 'array',
|
3430
|
+
maxItems: 1,
|
3431
|
+
items: {
|
3432
|
+
type: 'object',
|
3433
|
+
additionalProperties: false,
|
3434
|
+
properties: {
|
3435
|
+
argumentName: {
|
3436
|
+
type: 'string',
|
3437
|
+
},
|
3438
|
+
},
|
3439
|
+
},
|
3440
|
+
};
|
3441
|
+
const rule$k = {
|
3334
3442
|
meta: {
|
3335
3443
|
type: 'suggestion',
|
3336
3444
|
hasSuggestions: true,
|
@@ -3375,17 +3483,7 @@ const rule$j = {
|
|
3375
3483
|
[MESSAGE_INVALID_DATE]: 'Invalid "{{ deletionDate }}" deletion date',
|
3376
3484
|
[MESSAGE_CAN_BE_REMOVED]: '"{{ nodeName }}" сan be removed',
|
3377
3485
|
},
|
3378
|
-
schema:
|
3379
|
-
{
|
3380
|
-
type: 'object',
|
3381
|
-
additionalProperties: false,
|
3382
|
-
properties: {
|
3383
|
-
argumentName: {
|
3384
|
-
type: 'string',
|
3385
|
-
},
|
3386
|
-
},
|
3387
|
-
},
|
3388
|
-
],
|
3486
|
+
schema: schema$9,
|
3389
3487
|
},
|
3390
3488
|
create(context) {
|
3391
3489
|
return {
|
@@ -3441,7 +3539,7 @@ const rule$j = {
|
|
3441
3539
|
},
|
3442
3540
|
};
|
3443
3541
|
|
3444
|
-
const rule$
|
3542
|
+
const rule$l = {
|
3445
3543
|
meta: {
|
3446
3544
|
docs: {
|
3447
3545
|
description: 'Require all deprecation directives to specify a reason.',
|
@@ -3494,7 +3592,7 @@ const rule$k = {
|
|
3494
3592
|
},
|
3495
3593
|
};
|
3496
3594
|
|
3497
|
-
const RULE_ID$
|
3595
|
+
const RULE_ID$b = 'require-description';
|
3498
3596
|
const ALLOWED_KINDS$1 = [
|
3499
3597
|
...TYPES_KINDS,
|
3500
3598
|
graphql.Kind.DIRECTIVE_DEFINITION,
|
@@ -3531,12 +3629,40 @@ function getNodeName(node) {
|
|
3531
3629
|
return node.name ? `${node.operation} ${node.name.value}` : node.operation;
|
3532
3630
|
}
|
3533
3631
|
}
|
3534
|
-
const
|
3632
|
+
const schema$a = {
|
3633
|
+
type: 'array',
|
3634
|
+
minItems: 1,
|
3635
|
+
maxItems: 1,
|
3636
|
+
items: {
|
3637
|
+
type: 'object',
|
3638
|
+
additionalProperties: false,
|
3639
|
+
minProperties: 1,
|
3640
|
+
properties: {
|
3641
|
+
types: {
|
3642
|
+
type: 'boolean',
|
3643
|
+
description: `Includes:\n${TYPES_KINDS.map(kind => `- \`${kind}\``).join('\n')}`,
|
3644
|
+
},
|
3645
|
+
rootField: {
|
3646
|
+
type: 'boolean',
|
3647
|
+
description: 'Definitions within `Query`, `Mutation`, and `Subscription` root types.',
|
3648
|
+
},
|
3649
|
+
...Object.fromEntries([...ALLOWED_KINDS$1].sort().map(kind => {
|
3650
|
+
let description = `Read more about this kind on [spec.graphql.org](https://spec.graphql.org/October2021/#${kind}).`;
|
3651
|
+
if (kind === graphql.Kind.OPERATION_DEFINITION) {
|
3652
|
+
description +=
|
3653
|
+
'\n> You must use only comment syntax `#` and not description syntax `"""` or `"`.';
|
3654
|
+
}
|
3655
|
+
return [kind, { type: 'boolean', description }];
|
3656
|
+
})),
|
3657
|
+
},
|
3658
|
+
},
|
3659
|
+
};
|
3660
|
+
const rule$m = {
|
3535
3661
|
meta: {
|
3536
3662
|
docs: {
|
3537
3663
|
category: 'Schema',
|
3538
3664
|
description: 'Enforce descriptions in type definitions and operations.',
|
3539
|
-
url: `https://github.com/B2o5T/graphql-eslint/blob/master/docs/rules/${RULE_ID$
|
3665
|
+
url: `https://github.com/B2o5T/graphql-eslint/blob/master/docs/rules/${RULE_ID$b}.md`,
|
3540
3666
|
examples: [
|
3541
3667
|
{
|
3542
3668
|
title: 'Incorrect',
|
@@ -3570,6 +3696,20 @@ const rule$l = {
|
|
3570
3696
|
mutation createUser {
|
3571
3697
|
# ...
|
3572
3698
|
}
|
3699
|
+
`,
|
3700
|
+
},
|
3701
|
+
{
|
3702
|
+
title: 'Correct',
|
3703
|
+
usage: [{ rootField: true }],
|
3704
|
+
code: /* GraphQL */ `
|
3705
|
+
type Mutation {
|
3706
|
+
"Create a new user"
|
3707
|
+
createUser: User
|
3708
|
+
}
|
3709
|
+
|
3710
|
+
type User {
|
3711
|
+
name: String
|
3712
|
+
}
|
3573
3713
|
`,
|
3574
3714
|
},
|
3575
3715
|
],
|
@@ -3577,41 +3717,19 @@ const rule$l = {
|
|
3577
3717
|
{
|
3578
3718
|
types: true,
|
3579
3719
|
[graphql.Kind.DIRECTIVE_DEFINITION]: true,
|
3720
|
+
// rootField: true TODO enable in graphql-eslint v4
|
3580
3721
|
},
|
3581
3722
|
],
|
3582
3723
|
recommended: true,
|
3583
3724
|
},
|
3584
3725
|
type: 'suggestion',
|
3585
3726
|
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
|
-
},
|
3727
|
+
[RULE_ID$b]: 'Description is required for `{{ nodeName }}`.',
|
3611
3728
|
},
|
3729
|
+
schema: schema$a,
|
3612
3730
|
},
|
3613
3731
|
create(context) {
|
3614
|
-
const { types, ...restOptions } = context.options[0] || {};
|
3732
|
+
const { types, rootField, ...restOptions } = context.options[0] || {};
|
3615
3733
|
const kinds = new Set(types ? TYPES_KINDS : []);
|
3616
3734
|
for (const [kind, isEnabled] of Object.entries(restOptions)) {
|
3617
3735
|
if (isEnabled) {
|
@@ -3621,6 +3739,13 @@ const rule$l = {
|
|
3621
3739
|
kinds.delete(kind);
|
3622
3740
|
}
|
3623
3741
|
}
|
3742
|
+
if (rootField) {
|
3743
|
+
const schema = requireGraphQLSchemaFromContext(RULE_ID$b, context);
|
3744
|
+
const rootTypeNames = utils.getRootTypeNames(schema);
|
3745
|
+
kinds.add(`:matches(ObjectTypeDefinition, ObjectTypeExtension)[name.value=/^(${[
|
3746
|
+
...rootTypeNames,
|
3747
|
+
].join(',')})$/] > FieldDefinition`);
|
3748
|
+
}
|
3624
3749
|
const selector = [...kinds].join(',');
|
3625
3750
|
return {
|
3626
3751
|
[selector](node) {
|
@@ -3644,7 +3769,7 @@ const rule$l = {
|
|
3644
3769
|
if (description.length === 0) {
|
3645
3770
|
context.report({
|
3646
3771
|
loc: isOperation ? getLocation(node.loc.start, node.operation) : node.name.loc,
|
3647
|
-
messageId: RULE_ID$
|
3772
|
+
messageId: RULE_ID$b,
|
3648
3773
|
data: {
|
3649
3774
|
nodeName: getNodeName(node),
|
3650
3775
|
},
|
@@ -3655,14 +3780,14 @@ const rule$l = {
|
|
3655
3780
|
},
|
3656
3781
|
};
|
3657
3782
|
|
3658
|
-
const RULE_ID$
|
3659
|
-
const rule$
|
3783
|
+
const RULE_ID$c = 'require-field-of-type-query-in-mutation-result';
|
3784
|
+
const rule$n = {
|
3660
3785
|
meta: {
|
3661
3786
|
type: 'suggestion',
|
3662
3787
|
docs: {
|
3663
3788
|
category: 'Schema',
|
3664
3789
|
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$
|
3790
|
+
url: `https://github.com/B2o5T/graphql-eslint/blob/master/docs/rules/${RULE_ID$c}.md`,
|
3666
3791
|
requiresSchema: true,
|
3667
3792
|
examples: [
|
3668
3793
|
{
|
@@ -3697,7 +3822,7 @@ const rule$m = {
|
|
3697
3822
|
schema: [],
|
3698
3823
|
},
|
3699
3824
|
create(context) {
|
3700
|
-
const schema = requireGraphQLSchemaFromContext(RULE_ID$
|
3825
|
+
const schema = requireGraphQLSchemaFromContext(RULE_ID$c, context);
|
3701
3826
|
const mutationType = schema.getMutationType();
|
3702
3827
|
const queryType = schema.getQueryType();
|
3703
3828
|
if (!mutationType || !queryType) {
|
@@ -3723,17 +3848,36 @@ const rule$m = {
|
|
3723
3848
|
},
|
3724
3849
|
};
|
3725
3850
|
|
3726
|
-
const RULE_ID$
|
3851
|
+
const RULE_ID$d = 'require-id-when-available';
|
3727
3852
|
const DEFAULT_ID_FIELD_NAME = 'id';
|
3728
|
-
const
|
3853
|
+
const schema$b = {
|
3854
|
+
definitions: {
|
3855
|
+
asString: {
|
3856
|
+
type: 'string',
|
3857
|
+
},
|
3858
|
+
asArray: ARRAY_DEFAULT_OPTIONS,
|
3859
|
+
},
|
3860
|
+
type: 'array',
|
3861
|
+
maxItems: 1,
|
3862
|
+
items: {
|
3863
|
+
type: 'object',
|
3864
|
+
additionalProperties: false,
|
3865
|
+
properties: {
|
3866
|
+
fieldName: {
|
3867
|
+
oneOf: [{ $ref: '#/definitions/asString' }, { $ref: '#/definitions/asArray' }],
|
3868
|
+
default: DEFAULT_ID_FIELD_NAME,
|
3869
|
+
},
|
3870
|
+
},
|
3871
|
+
},
|
3872
|
+
};
|
3873
|
+
const rule$o = {
|
3729
3874
|
meta: {
|
3730
3875
|
type: 'suggestion',
|
3731
|
-
// eslint-disable-next-line eslint-plugin/require-meta-has-suggestions
|
3732
3876
|
hasSuggestions: true,
|
3733
3877
|
docs: {
|
3734
3878
|
category: 'Operations',
|
3735
3879
|
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$
|
3880
|
+
url: `https://github.com/B2o5T/graphql-eslint/blob/master/docs/rules/${RULE_ID$d}.md`,
|
3737
3881
|
requiresSchema: true,
|
3738
3882
|
requiresSiblings: true,
|
3739
3883
|
examples: [
|
@@ -3783,32 +3927,13 @@ const rule$n = {
|
|
3783
3927
|
recommended: true,
|
3784
3928
|
},
|
3785
3929
|
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
|
-
},
|
3930
|
+
[RULE_ID$d]: "Field{{ pluralSuffix }} {{ fieldName }} must be selected when it's available on a type.\nInclude it in your selection set{{ addition }}.",
|
3807
3931
|
},
|
3932
|
+
schema: schema$b,
|
3808
3933
|
},
|
3809
3934
|
create(context) {
|
3810
|
-
const schema = requireGraphQLSchemaFromContext(RULE_ID$
|
3811
|
-
const siblings = requireSiblingsOperations(RULE_ID$
|
3935
|
+
const schema = requireGraphQLSchemaFromContext(RULE_ID$d, context);
|
3936
|
+
const siblings = requireSiblingsOperations(RULE_ID$d, context);
|
3812
3937
|
const { fieldName = DEFAULT_ID_FIELD_NAME } = context.options[0] || {};
|
3813
3938
|
const idNames = utils.asArray(fieldName);
|
3814
3939
|
// Check selections only in OperationDefinition,
|
@@ -3889,7 +4014,7 @@ const rule$n = {
|
|
3889
4014
|
: ` or add to used fragment${checkedFragmentSpreads.size > 1 ? 's' : ''} ${englishJoinWords([...checkedFragmentSpreads].map(name => `\`${name}\``))}`;
|
3890
4015
|
const problem = {
|
3891
4016
|
loc,
|
3892
|
-
messageId: RULE_ID$
|
4017
|
+
messageId: RULE_ID$d,
|
3893
4018
|
data: {
|
3894
4019
|
pluralSuffix,
|
3895
4020
|
fieldName,
|
@@ -3916,15 +4041,31 @@ const rule$n = {
|
|
3916
4041
|
},
|
3917
4042
|
};
|
3918
4043
|
|
3919
|
-
const RULE_ID$
|
3920
|
-
const
|
4044
|
+
const RULE_ID$e = 'selection-set-depth';
|
4045
|
+
const schema$c = {
|
4046
|
+
type: 'array',
|
4047
|
+
minItems: 1,
|
4048
|
+
maxItems: 1,
|
4049
|
+
items: {
|
4050
|
+
type: 'object',
|
4051
|
+
additionalProperties: false,
|
4052
|
+
required: ['maxDepth'],
|
4053
|
+
properties: {
|
4054
|
+
maxDepth: {
|
4055
|
+
type: 'number',
|
4056
|
+
},
|
4057
|
+
ignore: ARRAY_DEFAULT_OPTIONS,
|
4058
|
+
},
|
4059
|
+
},
|
4060
|
+
};
|
4061
|
+
const rule$p = {
|
3921
4062
|
meta: {
|
3922
4063
|
type: 'suggestion',
|
3923
4064
|
hasSuggestions: true,
|
3924
4065
|
docs: {
|
3925
4066
|
category: 'Operations',
|
3926
4067
|
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$
|
4068
|
+
url: `https://github.com/B2o5T/graphql-eslint/blob/master/docs/rules/${RULE_ID$e}.md`,
|
3928
4069
|
requiresSiblings: true,
|
3929
4070
|
examples: [
|
3930
4071
|
{
|
@@ -3970,30 +4111,15 @@ const rule$o = {
|
|
3970
4111
|
recommended: true,
|
3971
4112
|
configOptions: [{ maxDepth: 7 }],
|
3972
4113
|
},
|
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
|
-
},
|
4114
|
+
schema: schema$c,
|
3989
4115
|
},
|
3990
4116
|
create(context) {
|
3991
4117
|
let siblings = null;
|
3992
4118
|
try {
|
3993
|
-
siblings = requireSiblingsOperations(RULE_ID$
|
4119
|
+
siblings = requireSiblingsOperations(RULE_ID$e, context);
|
3994
4120
|
}
|
3995
4121
|
catch (_a) {
|
3996
|
-
logger.warn(`Rule "${RULE_ID$
|
4122
|
+
logger.warn(`Rule "${RULE_ID$e}" works best with siblings operations loaded. For more info: https://bit.ly/graphql-eslint-operations`);
|
3997
4123
|
}
|
3998
4124
|
const { maxDepth, ignore = [] } = context.options[0];
|
3999
4125
|
const checkFn = depthLimit(maxDepth, { ignore });
|
@@ -4037,22 +4163,54 @@ const rule$o = {
|
|
4037
4163
|
});
|
4038
4164
|
}
|
4039
4165
|
catch (e) {
|
4040
|
-
logger.warn(`Rule "${RULE_ID$
|
4166
|
+
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
4167
|
}
|
4042
4168
|
},
|
4043
4169
|
};
|
4044
4170
|
},
|
4045
4171
|
};
|
4046
4172
|
|
4047
|
-
const RULE_ID$
|
4048
|
-
const
|
4173
|
+
const RULE_ID$f = 'strict-id-in-types';
|
4174
|
+
const schema$d = {
|
4175
|
+
type: 'array',
|
4176
|
+
maxItems: 1,
|
4177
|
+
items: {
|
4178
|
+
type: 'object',
|
4179
|
+
additionalProperties: false,
|
4180
|
+
properties: {
|
4181
|
+
acceptedIdNames: {
|
4182
|
+
...ARRAY_DEFAULT_OPTIONS,
|
4183
|
+
default: ['id'],
|
4184
|
+
},
|
4185
|
+
acceptedIdTypes: {
|
4186
|
+
...ARRAY_DEFAULT_OPTIONS,
|
4187
|
+
default: ['ID'],
|
4188
|
+
},
|
4189
|
+
exceptions: {
|
4190
|
+
type: 'object',
|
4191
|
+
additionalProperties: false,
|
4192
|
+
properties: {
|
4193
|
+
types: {
|
4194
|
+
...ARRAY_DEFAULT_OPTIONS,
|
4195
|
+
description: 'This is used to exclude types with names that match one of the specified values.',
|
4196
|
+
},
|
4197
|
+
suffixes: {
|
4198
|
+
...ARRAY_DEFAULT_OPTIONS,
|
4199
|
+
description: 'This is used to exclude types with names with suffixes that match one of the specified values.',
|
4200
|
+
},
|
4201
|
+
},
|
4202
|
+
},
|
4203
|
+
},
|
4204
|
+
},
|
4205
|
+
};
|
4206
|
+
const rule$q = {
|
4049
4207
|
meta: {
|
4050
4208
|
type: 'suggestion',
|
4051
4209
|
docs: {
|
4052
4210
|
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
4211
|
category: 'Schema',
|
4054
4212
|
recommended: true,
|
4055
|
-
url: `https://github.com/B2o5T/graphql-eslint/blob/master/docs/rules/${RULE_ID$
|
4213
|
+
url: `https://github.com/B2o5T/graphql-eslint/blob/master/docs/rules/${RULE_ID$f}.md`,
|
4056
4214
|
requiresSchema: true,
|
4057
4215
|
examples: [
|
4058
4216
|
{
|
@@ -4116,37 +4274,7 @@ const rule$p = {
|
|
4116
4274
|
},
|
4117
4275
|
],
|
4118
4276
|
},
|
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
|
-
},
|
4277
|
+
schema: schema$d,
|
4150
4278
|
},
|
4151
4279
|
create(context) {
|
4152
4280
|
const options = {
|
@@ -4155,7 +4283,7 @@ const rule$p = {
|
|
4155
4283
|
exceptions: {},
|
4156
4284
|
...context.options[0],
|
4157
4285
|
};
|
4158
|
-
const schema = requireGraphQLSchemaFromContext(RULE_ID$
|
4286
|
+
const schema = requireGraphQLSchemaFromContext(RULE_ID$f, context);
|
4159
4287
|
const rootTypeNames = [
|
4160
4288
|
schema.getQueryType(),
|
4161
4289
|
schema.getMutationType(),
|
@@ -4200,7 +4328,7 @@ const rule$p = {
|
|
4200
4328
|
},
|
4201
4329
|
};
|
4202
4330
|
|
4203
|
-
const RULE_ID$
|
4331
|
+
const RULE_ID$g = 'unique-fragment-name';
|
4204
4332
|
const checkNode = (context, node, ruleId) => {
|
4205
4333
|
const documentName = node.name.value;
|
4206
4334
|
const siblings = requireSiblingsOperations(ruleId, context);
|
@@ -4227,13 +4355,13 @@ const checkNode = (context, node, ruleId) => {
|
|
4227
4355
|
});
|
4228
4356
|
}
|
4229
4357
|
};
|
4230
|
-
const rule$
|
4358
|
+
const rule$r = {
|
4231
4359
|
meta: {
|
4232
4360
|
type: 'suggestion',
|
4233
4361
|
docs: {
|
4234
4362
|
category: 'Operations',
|
4235
4363
|
description: 'Enforce unique fragment names across your project.',
|
4236
|
-
url: `https://github.com/B2o5T/graphql-eslint/blob/master/docs/rules/${RULE_ID$
|
4364
|
+
url: `https://github.com/B2o5T/graphql-eslint/blob/master/docs/rules/${RULE_ID$g}.md`,
|
4237
4365
|
requiresSiblings: true,
|
4238
4366
|
examples: [
|
4239
4367
|
{
|
@@ -4271,27 +4399,27 @@ const rule$q = {
|
|
4271
4399
|
],
|
4272
4400
|
},
|
4273
4401
|
messages: {
|
4274
|
-
[RULE_ID$
|
4402
|
+
[RULE_ID$g]: 'Fragment named "{{ documentName }}" already defined in:\n{{ summary }}',
|
4275
4403
|
},
|
4276
4404
|
schema: [],
|
4277
4405
|
},
|
4278
4406
|
create(context) {
|
4279
4407
|
return {
|
4280
4408
|
FragmentDefinition(node) {
|
4281
|
-
checkNode(context, node, RULE_ID$
|
4409
|
+
checkNode(context, node, RULE_ID$g);
|
4282
4410
|
},
|
4283
4411
|
};
|
4284
4412
|
},
|
4285
4413
|
};
|
4286
4414
|
|
4287
|
-
const RULE_ID$
|
4288
|
-
const rule$
|
4415
|
+
const RULE_ID$h = 'unique-operation-name';
|
4416
|
+
const rule$s = {
|
4289
4417
|
meta: {
|
4290
4418
|
type: 'suggestion',
|
4291
4419
|
docs: {
|
4292
4420
|
category: 'Operations',
|
4293
4421
|
description: 'Enforce unique operation names across your project.',
|
4294
|
-
url: `https://github.com/B2o5T/graphql-eslint/blob/master/docs/rules/${RULE_ID$
|
4422
|
+
url: `https://github.com/B2o5T/graphql-eslint/blob/master/docs/rules/${RULE_ID$h}.md`,
|
4295
4423
|
requiresSiblings: true,
|
4296
4424
|
examples: [
|
4297
4425
|
{
|
@@ -4333,14 +4461,14 @@ const rule$r = {
|
|
4333
4461
|
],
|
4334
4462
|
},
|
4335
4463
|
messages: {
|
4336
|
-
[RULE_ID$
|
4464
|
+
[RULE_ID$h]: 'Operation named "{{ documentName }}" already defined in:\n{{ summary }}',
|
4337
4465
|
},
|
4338
4466
|
schema: [],
|
4339
4467
|
},
|
4340
4468
|
create(context) {
|
4341
4469
|
return {
|
4342
4470
|
'OperationDefinition[name!=undefined]'(node) {
|
4343
|
-
checkNode(context, node, RULE_ID$
|
4471
|
+
checkNode(context, node, RULE_ID$h);
|
4344
4472
|
},
|
4345
4473
|
};
|
4346
4474
|
},
|
@@ -4354,31 +4482,32 @@ const rules = {
|
|
4354
4482
|
alphabetize: rule,
|
4355
4483
|
'description-style': rule$1,
|
4356
4484
|
'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-
|
4485
|
+
'lone-executable-definition': rule$3,
|
4486
|
+
'match-document-filename': rule$4,
|
4487
|
+
'naming-convention': rule$5,
|
4488
|
+
'no-anonymous-operations': rule$6,
|
4489
|
+
'no-case-insensitive-enum-values-duplicates': rule$7,
|
4490
|
+
'no-deprecated': rule$8,
|
4491
|
+
'no-duplicate-fields': rule$9,
|
4492
|
+
'no-hashtag-description': rule$a,
|
4493
|
+
'no-root-type': rule$b,
|
4494
|
+
'no-scalar-result-type-on-mutation': rule$c,
|
4495
|
+
'no-typename-prefix': rule$d,
|
4496
|
+
'no-unreachable-types': rule$e,
|
4497
|
+
'no-unused-fields': rule$f,
|
4498
|
+
'relay-arguments': rule$g,
|
4499
|
+
'relay-connection-types': rule$h,
|
4500
|
+
'relay-edge-types': rule$i,
|
4501
|
+
'relay-page-info': rule$j,
|
4502
|
+
'require-deprecation-date': rule$k,
|
4503
|
+
'require-deprecation-reason': rule$l,
|
4504
|
+
'require-description': rule$m,
|
4505
|
+
'require-field-of-type-query-in-mutation-result': rule$n,
|
4506
|
+
'require-id-when-available': rule$o,
|
4507
|
+
'selection-set-depth': rule$p,
|
4508
|
+
'strict-id-in-types': rule$q,
|
4509
|
+
'unique-fragment-name': rule$r,
|
4510
|
+
'unique-operation-name': rule$s,
|
4382
4511
|
};
|
4383
4512
|
|
4384
4513
|
// Based on the `eslint-plugin-import`'s cache
|