@graphql-eslint/eslint-plugin 2.3.0-alpha-4c161e5.0 → 2.3.0-alpha-6ba4002.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/configs/all.d.ts +0 -7
- package/configs/index.d.ts +0 -7
- package/docs/README.md +0 -1
- package/docs/rules/avoid-operation-name-prefix.md +7 -3
- package/docs/rules/description-style.md +8 -4
- package/docs/rules/input-name.md +9 -5
- package/docs/rules/match-document-filename.md +10 -6
- package/docs/rules/naming-convention.md +19 -15
- package/docs/rules/require-deprecation-date.md +6 -2
- package/docs/rules/require-description.md +10 -2
- package/docs/rules/require-id-when-available.md +6 -2
- package/docs/rules/selection-set-depth.md +12 -4
- package/docs/rules/strict-id-in-types.md +10 -6
- package/index.js +68 -312
- package/index.mjs +68 -312
- package/package.json +1 -1
- package/rules/index.d.ts +0 -7
- package/testkit.d.ts +1 -1
- package/types.d.ts +0 -1
- package/docs/rules/alphabetize.md +0 -140
- package/rules/alphabetize.d.ts +0 -17
package/index.mjs
CHANGED
@@ -65,16 +65,6 @@ const allConfig = {
|
|
65
65
|
...recommendedConfig,
|
66
66
|
rules: {
|
67
67
|
...recommendedConfig.rules,
|
68
|
-
'@graphql-eslint/alphabetize': [
|
69
|
-
'error',
|
70
|
-
{
|
71
|
-
fields: ['ObjectTypeDefinition', 'InterfaceTypeDefinition', 'InputObjectTypeDefinition'],
|
72
|
-
values: ['EnumTypeDefinition'],
|
73
|
-
selections: ['OperationDefinition', 'FragmentDefinition'],
|
74
|
-
variables: ['OperationDefinition'],
|
75
|
-
arguments: ['FieldDefinition', 'Field', 'DirectiveDefinition', 'Directive'],
|
76
|
-
},
|
77
|
-
],
|
78
68
|
'@graphql-eslint/avoid-duplicate-fields': 'error',
|
79
69
|
'@graphql-eslint/avoid-operation-name-prefix': 'error',
|
80
70
|
'@graphql-eslint/avoid-scalar-result-type-on-mutation': 'error',
|
@@ -314,6 +304,14 @@ const validationToRule = (name, ruleName, docs, getDocumentNode) => {
|
|
314
304
|
},
|
315
305
|
};
|
316
306
|
};
|
307
|
+
const importFiles = (context) => {
|
308
|
+
const code = context.getSourceCode().text;
|
309
|
+
if (!isGraphQLImportFile(code)) {
|
310
|
+
return null;
|
311
|
+
}
|
312
|
+
// Import documents because file contains '#import' comments
|
313
|
+
return processImport(context.getFilename());
|
314
|
+
};
|
317
315
|
const GRAPHQL_JS_VALIDATIONS = Object.assign({}, validationToRule('executable-definitions', 'ExecutableDefinitions', {
|
318
316
|
description: `A GraphQL document is only valid for execution if all definitions are either operation or fragment definitions.`,
|
319
317
|
}), validationToRule('fields-on-correct-type', 'FieldsOnCorrectType', {
|
@@ -390,14 +388,7 @@ const GRAPHQL_JS_VALIDATIONS = Object.assign({}, validationToRule('executable-de
|
|
390
388
|
\``,
|
391
389
|
},
|
392
390
|
],
|
393
|
-
},
|
394
|
-
const code = context.getSourceCode().text;
|
395
|
-
if (!isGraphQLImportFile(code)) {
|
396
|
-
return null;
|
397
|
-
}
|
398
|
-
// Import documents because file contains '#import' comments
|
399
|
-
return processImport(context.getFilename());
|
400
|
-
}), validationToRule('known-type-names', 'KnownTypeNames', {
|
391
|
+
}, importFiles), validationToRule('known-type-names', 'KnownTypeNames', {
|
401
392
|
description: `A GraphQL document is only valid if referenced types (specifically variable definitions and fragment conditions) are defined by the type schema.`,
|
402
393
|
}), validationToRule('lone-anonymous-operation', 'LoneAnonymousOperation', {
|
403
394
|
description: `A GraphQL document is only valid if when it contains an anonymous operation (the query short-hand) that it contains only that one operation definition.`,
|
@@ -439,7 +430,7 @@ const GRAPHQL_JS_VALIDATIONS = Object.assign({}, validationToRule('executable-de
|
|
439
430
|
return getParentNode(context.getFilename());
|
440
431
|
}), validationToRule('no-unused-variables', 'NoUnusedVariables', {
|
441
432
|
description: `A GraphQL operation is only valid if all variables defined by an operation are used, either directly or within a spread fragment.`,
|
442
|
-
}), validationToRule('overlapping-fields-can-be-merged', 'OverlappingFieldsCanBeMerged', {
|
433
|
+
}, importFiles), validationToRule('overlapping-fields-can-be-merged', 'OverlappingFieldsCanBeMerged', {
|
443
434
|
description: `A selection set is only valid if all fields (including spreading any fragments) either correspond to distinct response names or can be merged without ambiguity.`,
|
444
435
|
}), validationToRule('possible-fragment-spread', 'PossibleFragmentSpreads', {
|
445
436
|
description: `A fragment spread is only valid if the type condition could ever possibly be true: if there is a non-empty intersection of the possible parent types, and possible types which pass the type condition.`,
|
@@ -484,240 +475,6 @@ const GRAPHQL_JS_VALIDATIONS = Object.assign({}, validationToRule('executable-de
|
|
484
475
|
description: `Variables passed to field arguments conform to type.`,
|
485
476
|
}));
|
486
477
|
|
487
|
-
const ALPHABETIZE = 'ALPHABETIZE';
|
488
|
-
const fieldsEnum = [Kind.OBJECT_TYPE_DEFINITION, Kind.INTERFACE_TYPE_DEFINITION, Kind.INPUT_OBJECT_TYPE_DEFINITION];
|
489
|
-
const valuesEnum = [Kind.ENUM_TYPE_DEFINITION];
|
490
|
-
const selectionsEnum = [Kind.OPERATION_DEFINITION, Kind.FRAGMENT_DEFINITION];
|
491
|
-
const variablesEnum = [Kind.OPERATION_DEFINITION];
|
492
|
-
const argumentsEnum = [Kind.FIELD_DEFINITION, Kind.FIELD, Kind.DIRECTIVE_DEFINITION, Kind.DIRECTIVE];
|
493
|
-
const rule = {
|
494
|
-
meta: {
|
495
|
-
type: 'suggestion',
|
496
|
-
docs: {
|
497
|
-
category: 'Best Practices',
|
498
|
-
description: 'Enforce arrange in alphabetical order for type fields, enum values, input object fields, operation selections and more.',
|
499
|
-
url: 'https://github.com/dotansimha/graphql-eslint/blob/master/docs/rules/alphabetize.md',
|
500
|
-
examples: [
|
501
|
-
{
|
502
|
-
title: 'Incorrect',
|
503
|
-
usage: [{ fields: [Kind.OBJECT_TYPE_DEFINITION] }],
|
504
|
-
code: /* GraphQL */ `
|
505
|
-
type User {
|
506
|
-
password: String
|
507
|
-
firstName: String! # should be before "password"
|
508
|
-
age: Int # should be before "firstName"
|
509
|
-
lastName: String!
|
510
|
-
}
|
511
|
-
`,
|
512
|
-
},
|
513
|
-
{
|
514
|
-
title: 'Correct',
|
515
|
-
usage: [{ fields: [Kind.OBJECT_TYPE_DEFINITION] }],
|
516
|
-
code: /* GraphQL */ `
|
517
|
-
type User {
|
518
|
-
age: Int
|
519
|
-
firstName: String!
|
520
|
-
lastName: String!
|
521
|
-
password: String
|
522
|
-
}
|
523
|
-
`,
|
524
|
-
},
|
525
|
-
{
|
526
|
-
title: 'Incorrect',
|
527
|
-
usage: [{ values: [Kind.ENUM_TYPE_DEFINITION] }],
|
528
|
-
code: /* GraphQL */ `
|
529
|
-
enum Role {
|
530
|
-
SUPER_ADMIN
|
531
|
-
ADMIN # should be before "SUPER_ADMIN"
|
532
|
-
USER
|
533
|
-
GOD # should be before "USER"
|
534
|
-
}
|
535
|
-
`,
|
536
|
-
},
|
537
|
-
{
|
538
|
-
title: 'Correct',
|
539
|
-
usage: [{ values: [Kind.ENUM_TYPE_DEFINITION] }],
|
540
|
-
code: /* GraphQL */ `
|
541
|
-
enum Role {
|
542
|
-
ADMIN
|
543
|
-
GOD
|
544
|
-
SUPER_ADMIN
|
545
|
-
USER
|
546
|
-
}
|
547
|
-
`,
|
548
|
-
},
|
549
|
-
{
|
550
|
-
title: 'Incorrect',
|
551
|
-
usage: [{ selections: [Kind.OPERATION_DEFINITION] }],
|
552
|
-
code: /* GraphQL */ `
|
553
|
-
query {
|
554
|
-
me {
|
555
|
-
firstName
|
556
|
-
lastName
|
557
|
-
email # should be before "lastName"
|
558
|
-
}
|
559
|
-
}
|
560
|
-
`,
|
561
|
-
},
|
562
|
-
{
|
563
|
-
title: 'Correct',
|
564
|
-
usage: [{ selections: [Kind.OPERATION_DEFINITION] }],
|
565
|
-
code: /* GraphQL */ `
|
566
|
-
query {
|
567
|
-
me {
|
568
|
-
email
|
569
|
-
firstName
|
570
|
-
lastName
|
571
|
-
}
|
572
|
-
}
|
573
|
-
`,
|
574
|
-
},
|
575
|
-
],
|
576
|
-
optionsForConfig: [
|
577
|
-
{
|
578
|
-
fields: fieldsEnum,
|
579
|
-
values: valuesEnum,
|
580
|
-
selections: selectionsEnum,
|
581
|
-
variables: variablesEnum,
|
582
|
-
arguments: argumentsEnum,
|
583
|
-
},
|
584
|
-
],
|
585
|
-
},
|
586
|
-
messages: {
|
587
|
-
[ALPHABETIZE]: '"{{ currName }}" should be before "{{ prevName }}".',
|
588
|
-
},
|
589
|
-
schema: {
|
590
|
-
type: 'array',
|
591
|
-
minItems: 1,
|
592
|
-
maxItems: 1,
|
593
|
-
items: {
|
594
|
-
type: 'object',
|
595
|
-
additionalProperties: false,
|
596
|
-
minProperties: 1,
|
597
|
-
properties: {
|
598
|
-
fields: {
|
599
|
-
type: 'array',
|
600
|
-
contains: {
|
601
|
-
enum: fieldsEnum,
|
602
|
-
},
|
603
|
-
description: 'Fields of `type`, `interface`, and `input`.',
|
604
|
-
},
|
605
|
-
values: {
|
606
|
-
type: 'array',
|
607
|
-
contains: {
|
608
|
-
enum: valuesEnum,
|
609
|
-
},
|
610
|
-
description: 'Values of `enum`.',
|
611
|
-
},
|
612
|
-
selections: {
|
613
|
-
type: 'array',
|
614
|
-
contains: {
|
615
|
-
enum: selectionsEnum,
|
616
|
-
},
|
617
|
-
description: 'Selections of operations (`query`, `mutation` and `subscription`) and `fragment`.',
|
618
|
-
},
|
619
|
-
variables: {
|
620
|
-
type: 'array',
|
621
|
-
contains: {
|
622
|
-
enum: variablesEnum,
|
623
|
-
},
|
624
|
-
description: 'Variables of operations (`query`, `mutation` and `subscription`).',
|
625
|
-
},
|
626
|
-
arguments: {
|
627
|
-
type: 'array',
|
628
|
-
contains: {
|
629
|
-
enum: argumentsEnum,
|
630
|
-
},
|
631
|
-
description: 'Arguments of fields and directives.',
|
632
|
-
},
|
633
|
-
},
|
634
|
-
},
|
635
|
-
},
|
636
|
-
},
|
637
|
-
create(context) {
|
638
|
-
var _a, _b, _c, _d, _e;
|
639
|
-
function checkNodes(nodes) {
|
640
|
-
let prevName = null;
|
641
|
-
for (const node of nodes) {
|
642
|
-
const currName = node.name.value;
|
643
|
-
if (prevName && prevName > currName) {
|
644
|
-
const { start, end } = node.name.loc;
|
645
|
-
const isVariableNode = node.kind === Kind.VARIABLE;
|
646
|
-
context.report({
|
647
|
-
loc: {
|
648
|
-
start: {
|
649
|
-
line: start.line,
|
650
|
-
column: start.column - (isVariableNode ? 2 : 1),
|
651
|
-
},
|
652
|
-
end: {
|
653
|
-
line: end.line,
|
654
|
-
column: end.column,
|
655
|
-
},
|
656
|
-
},
|
657
|
-
messageId: ALPHABETIZE,
|
658
|
-
data: isVariableNode
|
659
|
-
? {
|
660
|
-
currName: `$${currName}`,
|
661
|
-
prevName: `$${prevName}`,
|
662
|
-
}
|
663
|
-
: { currName, prevName },
|
664
|
-
});
|
665
|
-
}
|
666
|
-
prevName = currName;
|
667
|
-
}
|
668
|
-
}
|
669
|
-
const opts = context.options[0];
|
670
|
-
const fields = new Set((_a = opts.fields) !== null && _a !== void 0 ? _a : []);
|
671
|
-
const listeners = {};
|
672
|
-
const fieldsSelector = [
|
673
|
-
fields.has(Kind.OBJECT_TYPE_DEFINITION) && [Kind.OBJECT_TYPE_DEFINITION, Kind.OBJECT_TYPE_EXTENSION],
|
674
|
-
fields.has(Kind.INTERFACE_TYPE_DEFINITION) && [Kind.INTERFACE_TYPE_DEFINITION, Kind.INTERFACE_TYPE_EXTENSION],
|
675
|
-
fields.has(Kind.INPUT_OBJECT_TYPE_DEFINITION) && [
|
676
|
-
Kind.INPUT_OBJECT_TYPE_DEFINITION,
|
677
|
-
Kind.INPUT_OBJECT_TYPE_EXTENSION,
|
678
|
-
],
|
679
|
-
]
|
680
|
-
.flat()
|
681
|
-
.join(',');
|
682
|
-
const hasEnumValues = ((_b = opts.values) === null || _b === void 0 ? void 0 : _b[0]) === Kind.ENUM_TYPE_DEFINITION;
|
683
|
-
const selectionsSelector = (_c = opts.selections) === null || _c === void 0 ? void 0 : _c.join(',');
|
684
|
-
const hasVariables = ((_d = opts.variables) === null || _d === void 0 ? void 0 : _d[0]) === Kind.OPERATION_DEFINITION;
|
685
|
-
const argumentsSelector = (_e = opts.arguments) === null || _e === void 0 ? void 0 : _e.join(',');
|
686
|
-
if (fieldsSelector) {
|
687
|
-
listeners[fieldsSelector] = (node) => {
|
688
|
-
checkNodes(node.fields);
|
689
|
-
};
|
690
|
-
}
|
691
|
-
if (hasEnumValues) {
|
692
|
-
const enumValuesSelector = [Kind.ENUM_TYPE_DEFINITION, Kind.ENUM_TYPE_EXTENSION].join(',');
|
693
|
-
listeners[enumValuesSelector] = (node) => {
|
694
|
-
checkNodes(node.values);
|
695
|
-
};
|
696
|
-
}
|
697
|
-
if (selectionsSelector) {
|
698
|
-
listeners[`:matches(${selectionsSelector}) SelectionSet`] = (node) => {
|
699
|
-
checkNodes(node.selections
|
700
|
-
// inline fragment don't have name, so we skip them
|
701
|
-
.filter(selection => selection.kind !== Kind.INLINE_FRAGMENT)
|
702
|
-
.map(selection =>
|
703
|
-
// sort by alias is field is renamed
|
704
|
-
'alias' in selection && selection.alias ? { name: selection.alias } : selection));
|
705
|
-
};
|
706
|
-
}
|
707
|
-
if (hasVariables) {
|
708
|
-
listeners.OperationDefinition = (node) => {
|
709
|
-
checkNodes(node.variableDefinitions.map(varDef => varDef.variable));
|
710
|
-
};
|
711
|
-
}
|
712
|
-
if (argumentsSelector) {
|
713
|
-
listeners[argumentsSelector] = (node) => {
|
714
|
-
checkNodes(node.arguments);
|
715
|
-
};
|
716
|
-
}
|
717
|
-
return listeners;
|
718
|
-
},
|
719
|
-
};
|
720
|
-
|
721
478
|
const AVOID_DUPLICATE_FIELDS = 'AVOID_DUPLICATE_FIELDS';
|
722
479
|
const ensureUnique = () => {
|
723
480
|
const set = new Set();
|
@@ -732,7 +489,7 @@ const ensureUnique = () => {
|
|
732
489
|
},
|
733
490
|
};
|
734
491
|
};
|
735
|
-
const rule
|
492
|
+
const rule = {
|
736
493
|
meta: {
|
737
494
|
type: 'suggestion',
|
738
495
|
docs: {
|
@@ -840,7 +597,7 @@ const rule$1 = {
|
|
840
597
|
};
|
841
598
|
|
842
599
|
const AVOID_OPERATION_NAME_PREFIX = 'AVOID_OPERATION_NAME_PREFIX';
|
843
|
-
const rule$
|
600
|
+
const rule$1 = {
|
844
601
|
meta: {
|
845
602
|
type: 'suggestion',
|
846
603
|
docs: {
|
@@ -926,7 +683,7 @@ const rule$2 = {
|
|
926
683
|
},
|
927
684
|
};
|
928
685
|
|
929
|
-
const rule$
|
686
|
+
const rule$2 = {
|
930
687
|
meta: {
|
931
688
|
type: 'suggestion',
|
932
689
|
docs: {
|
@@ -978,7 +735,7 @@ const rule$3 = {
|
|
978
735
|
};
|
979
736
|
|
980
737
|
const AVOID_TYPENAME_PREFIX = 'AVOID_TYPENAME_PREFIX';
|
981
|
-
const rule$
|
738
|
+
const rule$3 = {
|
982
739
|
meta: {
|
983
740
|
type: 'suggestion',
|
984
741
|
docs: {
|
@@ -1032,7 +789,7 @@ const rule$4 = {
|
|
1032
789
|
},
|
1033
790
|
};
|
1034
791
|
|
1035
|
-
const rule$
|
792
|
+
const rule$4 = {
|
1036
793
|
meta: {
|
1037
794
|
type: 'suggestion',
|
1038
795
|
docs: {
|
@@ -1043,9 +800,9 @@ const rule$5 = {
|
|
1043
800
|
code: /* GraphQL */ `
|
1044
801
|
""" Description """
|
1045
802
|
type someTypeName {
|
1046
|
-
|
803
|
+
...
|
1047
804
|
}
|
1048
|
-
|
805
|
+
`,
|
1049
806
|
},
|
1050
807
|
{
|
1051
808
|
title: 'Correct',
|
@@ -1053,9 +810,9 @@ const rule$5 = {
|
|
1053
810
|
code: /* GraphQL */ `
|
1054
811
|
" Description "
|
1055
812
|
type someTypeName {
|
1056
|
-
|
813
|
+
...
|
1057
814
|
}
|
1058
|
-
|
815
|
+
`,
|
1059
816
|
},
|
1060
817
|
],
|
1061
818
|
description: 'Require all comments to follow the same style (either block or inline).',
|
@@ -1092,7 +849,7 @@ const rule$5 = {
|
|
1092
849
|
},
|
1093
850
|
};
|
1094
851
|
|
1095
|
-
const rule$
|
852
|
+
const rule$5 = {
|
1096
853
|
meta: {
|
1097
854
|
type: 'suggestion',
|
1098
855
|
docs: {
|
@@ -1217,7 +974,7 @@ const CASE_STYLES = [
|
|
1217
974
|
const schemaOption = {
|
1218
975
|
oneOf: [{ $ref: '#/definitions/asString' }, { $ref: '#/definitions/asObject' }],
|
1219
976
|
};
|
1220
|
-
const rule$
|
977
|
+
const rule$6 = {
|
1221
978
|
meta: {
|
1222
979
|
type: 'suggestion',
|
1223
980
|
docs: {
|
@@ -1462,7 +1219,7 @@ function checkNameFormat(params) {
|
|
1462
1219
|
const schemaOption$1 = {
|
1463
1220
|
oneOf: [{ $ref: '#/definitions/asString' }, { $ref: '#/definitions/asObject' }],
|
1464
1221
|
};
|
1465
|
-
const rule$
|
1222
|
+
const rule$7 = {
|
1466
1223
|
meta: {
|
1467
1224
|
type: 'suggestion',
|
1468
1225
|
docs: {
|
@@ -1574,18 +1331,18 @@ const rule$8 = {
|
|
1574
1331
|
style,
|
1575
1332
|
leadingUnderscore: options.leadingUnderscore,
|
1576
1333
|
trailingUnderscore: options.trailingUnderscore,
|
1577
|
-
prefix,
|
1578
|
-
suffix,
|
1579
|
-
forbiddenPrefixes,
|
1580
|
-
forbiddenSuffixes,
|
1334
|
+
prefix: prefix,
|
1335
|
+
suffix: suffix,
|
1336
|
+
forbiddenPrefixes: forbiddenPrefixes,
|
1337
|
+
forbiddenSuffixes: forbiddenSuffixes,
|
1581
1338
|
});
|
1582
1339
|
if (result.ok === false) {
|
1583
1340
|
context.report({
|
1584
1341
|
node,
|
1585
1342
|
message: result.errorMessage,
|
1586
1343
|
data: {
|
1587
|
-
prefix,
|
1588
|
-
suffix,
|
1344
|
+
prefix: prefix,
|
1345
|
+
suffix: suffix,
|
1589
1346
|
format: style,
|
1590
1347
|
forbiddenPrefixes: forbiddenPrefixes.join(', '),
|
1591
1348
|
forbiddenSuffixes: forbiddenSuffixes.join(', '),
|
@@ -1691,7 +1448,7 @@ const rule$8 = {
|
|
1691
1448
|
};
|
1692
1449
|
|
1693
1450
|
const NO_ANONYMOUS_OPERATIONS = 'NO_ANONYMOUS_OPERATIONS';
|
1694
|
-
const rule$
|
1451
|
+
const rule$8 = {
|
1695
1452
|
meta: {
|
1696
1453
|
type: 'suggestion',
|
1697
1454
|
docs: {
|
@@ -1749,7 +1506,7 @@ const rule$9 = {
|
|
1749
1506
|
};
|
1750
1507
|
|
1751
1508
|
const ERROR_MESSAGE_ID = 'NO_CASE_INSENSITIVE_ENUM_VALUES_DUPLICATES';
|
1752
|
-
const rule$
|
1509
|
+
const rule$9 = {
|
1753
1510
|
meta: {
|
1754
1511
|
type: 'suggestion',
|
1755
1512
|
docs: {
|
@@ -1804,7 +1561,7 @@ const rule$a = {
|
|
1804
1561
|
};
|
1805
1562
|
|
1806
1563
|
const NO_DEPRECATED = 'NO_DEPRECATED';
|
1807
|
-
const rule$
|
1564
|
+
const rule$a = {
|
1808
1565
|
meta: {
|
1809
1566
|
type: 'suggestion',
|
1810
1567
|
docs: {
|
@@ -1918,7 +1675,7 @@ const rule$b = {
|
|
1918
1675
|
};
|
1919
1676
|
|
1920
1677
|
const HASHTAG_COMMENT = 'HASHTAG_COMMENT';
|
1921
|
-
const rule$
|
1678
|
+
const rule$b = {
|
1922
1679
|
meta: {
|
1923
1680
|
messages: {
|
1924
1681
|
[HASHTAG_COMMENT]: 'Using hashtag (#) for adding GraphQL descriptions is not allowed. Prefer using """ for multiline, or " for a single line description.',
|
@@ -1993,7 +1750,7 @@ const rule$c = {
|
|
1993
1750
|
};
|
1994
1751
|
|
1995
1752
|
const NO_OPERATION_NAME_SUFFIX = 'NO_OPERATION_NAME_SUFFIX';
|
1996
|
-
const rule$
|
1753
|
+
const rule$c = {
|
1997
1754
|
meta: {
|
1998
1755
|
fixable: 'code',
|
1999
1756
|
type: 'suggestion',
|
@@ -2048,7 +1805,7 @@ const rule$d = {
|
|
2048
1805
|
|
2049
1806
|
const UNREACHABLE_TYPE = 'UNREACHABLE_TYPE';
|
2050
1807
|
const RULE_NAME = 'no-unreachable-types';
|
2051
|
-
const rule$
|
1808
|
+
const rule$d = {
|
2052
1809
|
meta: {
|
2053
1810
|
messages: {
|
2054
1811
|
[UNREACHABLE_TYPE]: `Type "{{ typeName }}" is unreachable`,
|
@@ -2123,7 +1880,7 @@ const rule$e = {
|
|
2123
1880
|
|
2124
1881
|
const UNUSED_FIELD = 'UNUSED_FIELD';
|
2125
1882
|
const RULE_NAME$1 = 'no-unused-fields';
|
2126
|
-
const rule$
|
1883
|
+
const rule$e = {
|
2127
1884
|
meta: {
|
2128
1885
|
messages: {
|
2129
1886
|
[UNUSED_FIELD]: `Field "{{fieldName}}" is unused`,
|
@@ -2310,7 +2067,7 @@ const MESSAGE_REQUIRE_DATE = 'MESSAGE_REQUIRE_DATE';
|
|
2310
2067
|
const MESSAGE_INVALID_FORMAT = 'MESSAGE_INVALID_FORMAT';
|
2311
2068
|
const MESSAGE_INVALID_DATE = 'MESSAGE_INVALID_DATE';
|
2312
2069
|
const MESSAGE_CAN_BE_REMOVED = 'MESSAGE_CAN_BE_REMOVED';
|
2313
|
-
const rule$
|
2070
|
+
const rule$f = {
|
2314
2071
|
meta: {
|
2315
2072
|
type: 'suggestion',
|
2316
2073
|
docs: {
|
@@ -2410,7 +2167,7 @@ const rule$g = {
|
|
2410
2167
|
},
|
2411
2168
|
};
|
2412
2169
|
|
2413
|
-
const rule$
|
2170
|
+
const rule$g = {
|
2414
2171
|
meta: {
|
2415
2172
|
docs: {
|
2416
2173
|
description: `Require all deprecation directives to specify a reason.`,
|
@@ -2500,7 +2257,7 @@ function verifyRule(context, node) {
|
|
2500
2257
|
}
|
2501
2258
|
}
|
2502
2259
|
}
|
2503
|
-
const rule$
|
2260
|
+
const rule$h = {
|
2504
2261
|
meta: {
|
2505
2262
|
docs: {
|
2506
2263
|
category: 'Best Practices',
|
@@ -2565,7 +2322,7 @@ const rule$i = {
|
|
2565
2322
|
};
|
2566
2323
|
|
2567
2324
|
const RULE_NAME$2 = 'require-field-of-type-query-in-mutation-result';
|
2568
|
-
const rule$
|
2325
|
+
const rule$i = {
|
2569
2326
|
meta: {
|
2570
2327
|
type: 'suggestion',
|
2571
2328
|
docs: {
|
@@ -2728,7 +2485,7 @@ const convertNode = (typeInfo) => (node, key, parent) => {
|
|
2728
2485
|
|
2729
2486
|
const REQUIRE_ID_WHEN_AVAILABLE = 'REQUIRE_ID_WHEN_AVAILABLE';
|
2730
2487
|
const DEFAULT_ID_FIELD_NAME = 'id';
|
2731
|
-
const rule$
|
2488
|
+
const rule$j = {
|
2732
2489
|
meta: {
|
2733
2490
|
type: 'suggestion',
|
2734
2491
|
docs: {
|
@@ -2864,7 +2621,7 @@ const rule$k = {
|
|
2864
2621
|
},
|
2865
2622
|
};
|
2866
2623
|
|
2867
|
-
const rule$
|
2624
|
+
const rule$k = {
|
2868
2625
|
meta: {
|
2869
2626
|
docs: {
|
2870
2627
|
category: 'Best Practices',
|
@@ -2986,7 +2743,7 @@ const shouldIgnoreNode = ({ node, exceptions }) => {
|
|
2986
2743
|
}
|
2987
2744
|
return false;
|
2988
2745
|
};
|
2989
|
-
const rule$
|
2746
|
+
const rule$l = {
|
2990
2747
|
meta: {
|
2991
2748
|
type: 'suggestion',
|
2992
2749
|
docs: {
|
@@ -3176,7 +2933,7 @@ const checkNode = (context, node, ruleName, messageId) => {
|
|
3176
2933
|
});
|
3177
2934
|
}
|
3178
2935
|
};
|
3179
|
-
const rule$
|
2936
|
+
const rule$m = {
|
3180
2937
|
meta: {
|
3181
2938
|
type: 'suggestion',
|
3182
2939
|
docs: {
|
@@ -3234,7 +2991,7 @@ const rule$n = {
|
|
3234
2991
|
|
3235
2992
|
const RULE_NAME$4 = 'unique-operation-name';
|
3236
2993
|
const UNIQUE_OPERATION_NAME = 'UNIQUE_OPERATION_NAME';
|
3237
|
-
const rule$
|
2994
|
+
const rule$n = {
|
3238
2995
|
meta: {
|
3239
2996
|
type: 'suggestion',
|
3240
2997
|
docs: {
|
@@ -3299,31 +3056,30 @@ const rule$o = {
|
|
3299
3056
|
*/
|
3300
3057
|
const rules = {
|
3301
3058
|
...GRAPHQL_JS_VALIDATIONS,
|
3302
|
-
|
3303
|
-
'avoid-
|
3304
|
-
'avoid-
|
3305
|
-
'avoid-
|
3306
|
-
'
|
3307
|
-
'
|
3308
|
-
'
|
3309
|
-
'
|
3310
|
-
'
|
3311
|
-
'no-
|
3312
|
-
'no-
|
3313
|
-
'no-
|
3314
|
-
'no-
|
3315
|
-
'no-
|
3316
|
-
'no-
|
3317
|
-
'
|
3318
|
-
'require-deprecation-
|
3319
|
-
'require-
|
3320
|
-
'require-
|
3321
|
-
'require-
|
3322
|
-
'
|
3323
|
-
'
|
3324
|
-
'
|
3325
|
-
'unique-
|
3326
|
-
'unique-operation-name': rule$o,
|
3059
|
+
'avoid-duplicate-fields': rule,
|
3060
|
+
'avoid-operation-name-prefix': rule$1,
|
3061
|
+
'avoid-scalar-result-type-on-mutation': rule$2,
|
3062
|
+
'avoid-typename-prefix': rule$3,
|
3063
|
+
'description-style': rule$4,
|
3064
|
+
'input-name': rule$5,
|
3065
|
+
'match-document-filename': rule$6,
|
3066
|
+
'naming-convention': rule$7,
|
3067
|
+
'no-anonymous-operations': rule$8,
|
3068
|
+
'no-case-insensitive-enum-values-duplicates': rule$9,
|
3069
|
+
'no-deprecated': rule$a,
|
3070
|
+
'no-hashtag-description': rule$b,
|
3071
|
+
'no-operation-name-suffix': rule$c,
|
3072
|
+
'no-unreachable-types': rule$d,
|
3073
|
+
'no-unused-fields': rule$e,
|
3074
|
+
'require-deprecation-date': rule$f,
|
3075
|
+
'require-deprecation-reason': rule$g,
|
3076
|
+
'require-description': rule$h,
|
3077
|
+
'require-field-of-type-query-in-mutation-result': rule$i,
|
3078
|
+
'require-id-when-available': rule$j,
|
3079
|
+
'selection-set-depth': rule$k,
|
3080
|
+
'strict-id-in-types': rule$l,
|
3081
|
+
'unique-fragment-name': rule$m,
|
3082
|
+
'unique-operation-name': rule$n,
|
3327
3083
|
};
|
3328
3084
|
|
3329
3085
|
const RELEVANT_KEYWORDS = ['gql', 'graphql', '/* GraphQL */'];
|
package/package.json
CHANGED
package/rules/index.d.ts
CHANGED
@@ -1,11 +1,4 @@
|
|
1
1
|
export declare const rules: {
|
2
|
-
alphabetize: import("..").GraphQLESLintRule<[{
|
3
|
-
fields?: ("ObjectTypeDefinition" | "InterfaceTypeDefinition" | "InputObjectTypeDefinition")[];
|
4
|
-
values?: "EnumTypeDefinition"[];
|
5
|
-
selections?: ("OperationDefinition" | "FragmentDefinition")[];
|
6
|
-
variables?: "OperationDefinition"[];
|
7
|
-
arguments?: ("Field" | "Directive" | "FieldDefinition" | "DirectiveDefinition")[];
|
8
|
-
}], false>;
|
9
2
|
'avoid-duplicate-fields': import("..").GraphQLESLintRule<[], false>;
|
10
3
|
'avoid-operation-name-prefix': import("..").GraphQLESLintRule<import("./avoid-operation-name-prefix").AvoidOperationNamePrefixConfig, false>;
|
11
4
|
'avoid-scalar-result-type-on-mutation': import("..").GraphQLESLintRule<any[], false>;
|
package/testkit.d.ts
CHANGED
@@ -2,7 +2,7 @@ import { RuleTester } from 'eslint';
|
|
2
2
|
import { ASTKindToNode } from 'graphql';
|
3
3
|
import { GraphQLESTreeNode } from './estree-parser';
|
4
4
|
import { GraphQLESLintRule, ParserOptions } from './types';
|
5
|
-
export declare type GraphQLESLintRuleListener<WithTypeInfo extends boolean
|
5
|
+
export declare type GraphQLESLintRuleListener<WithTypeInfo extends boolean> = {
|
6
6
|
[K in keyof ASTKindToNode]?: (node: GraphQLESTreeNode<ASTKindToNode[K], WithTypeInfo>) => void;
|
7
7
|
} & Record<string, any>;
|
8
8
|
export declare type GraphQLValidTestCase<Options> = Omit<RuleTester.ValidTestCase, 'options' | 'parserOptions'> & {
|
package/types.d.ts
CHANGED