@graphql-eslint/eslint-plugin 2.3.0-alpha-4c161e5.0 → 2.4.0-alpha-e5163e1.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/README.md +1 -1
- package/docs/custom-rules.md +2 -2
- package/estree-parser/converter.d.ts +2 -3
- package/estree-parser/estree-ast.d.ts +2 -2
- package/index.js +29 -14
- package/index.mjs +29 -14
- package/package.json +1 -1
- package/rules/graphql-js-validation.d.ts +3 -2
package/README.md
CHANGED
@@ -46,7 +46,7 @@ npm install --save-dev @graphql-eslint/eslint-plugin
|
|
46
46
|
|
47
47
|
### Configuration
|
48
48
|
|
49
|
-
To get started, create an override configuration for your ESLint, while applying it to
|
49
|
+
To get started, create an override configuration for your ESLint, while applying it to `.graphql` files (do that even if you are declaring your operations in code files):
|
50
50
|
|
51
51
|
```json
|
52
52
|
{
|
package/docs/custom-rules.md
CHANGED
@@ -38,7 +38,7 @@ const rule: GraphQLESLintRule = {
|
|
38
38
|
So what happens here?
|
39
39
|
|
40
40
|
1. `@graphql-eslint/eslint-plugin` handles the parsing process for your GraphQL content. It will load the GraphQL files (either from code files or from `.graphql` files with SDL), parse it using GraphQL parser, converts it to ESTree structure and let ESLint do the rest.
|
41
|
-
1.
|
41
|
+
1. Your rule is being loaded by ESLint, and executes just like any other ESLint rule.
|
42
42
|
1. Our custom rule asks ESLint to run our function for every `OperationDefinition` found.
|
43
43
|
1. If the `OperationDefinition` node doesn't have a valid `name` - we report an error to ESLint.
|
44
44
|
|
@@ -49,7 +49,7 @@ You can scan the `packages/plugin/src/rules` directory in this repo for referenc
|
|
49
49
|
## Accessing original GraphQL AST nodes
|
50
50
|
|
51
51
|
Since our parser converts GraphQL AST to ESTree structure, there are some minor differences in the structure of the objects.
|
52
|
-
If you are using TypeScript, and you typed your rule with `GraphQLESLintRule` - you'll see that each `node` is a bit different from
|
52
|
+
If you are using TypeScript, and you typed your rule with `GraphQLESLintRule` - you'll see that each `node` is a bit different from the AST nodes of GraphQL (you can read more about that in [graphql-eslint parser documentation](./parser.md)).
|
53
53
|
|
54
54
|
If you need access to the original GraphQL AST `node`, you can use `.rawNode()` method on each node you get from the AST structure of ESLint.
|
55
55
|
|
@@ -1,7 +1,6 @@
|
|
1
1
|
import { GraphQLESTreeNode } from './estree-ast';
|
2
2
|
import { ASTNode, TypeInfo } from 'graphql';
|
3
|
-
import { Comment } from 'estree';
|
4
3
|
export declare function convertToESTree<T extends ASTNode>(node: T, typeInfo?: TypeInfo): {
|
5
|
-
rootTree: GraphQLESTreeNode<T>;
|
6
|
-
comments: Comment[];
|
4
|
+
rootTree: GraphQLESTreeNode<T, false>;
|
5
|
+
comments: import("estree").Comment[];
|
7
6
|
};
|
@@ -5,7 +5,7 @@ export declare type SafeGraphQLType<T extends ASTNode | ValueNode> = Omit<T exte
|
|
5
5
|
} ? Omit<T, 'type'> & {
|
6
6
|
readonly gqlType: TypeNode;
|
7
7
|
} : T, 'loc'>;
|
8
|
-
export declare type SingleESTreeNode<T
|
8
|
+
export declare type SingleESTreeNode<T, WithTypeInfo extends boolean> = T extends ASTNode | ValueNode ? SafeGraphQLType<T> & Pick<BaseNode, 'leadingComments' | 'loc' | 'range'> & {
|
9
9
|
type: T['kind'];
|
10
10
|
gqlLocation: Location;
|
11
11
|
} & (WithTypeInfo extends true ? {
|
@@ -21,7 +21,7 @@ export declare type SingleESTreeNode<T extends any, WithTypeInfo extends boolean
|
|
21
21
|
gqlType?: ReturnType<TypeInfo['getType']>;
|
22
22
|
};
|
23
23
|
} : {}) : T;
|
24
|
-
export declare type GraphQLESTreeNode<T
|
24
|
+
export declare type GraphQLESTreeNode<T, WithTypeInfo extends boolean = false> = T extends ASTNode | ValueNode ? {
|
25
25
|
rawNode: () => T;
|
26
26
|
} & {
|
27
27
|
[K in keyof SingleESTreeNode<T, WithTypeInfo>]: SingleESTreeNode<T, WithTypeInfo>[K] extends ReadonlyArray<infer Nested> ? GraphQLESTreeNode<Nested, WithTypeInfo>[] : SingleESTreeNode<T, WithTypeInfo>[K] extends ASTNode ? GraphQLESTreeNode<SingleESTreeNode<T, WithTypeInfo>[K], WithTypeInfo> : SingleESTreeNode<T, WithTypeInfo>[K];
|
package/index.js
CHANGED
@@ -320,6 +320,14 @@ const validationToRule = (name, ruleName, docs, getDocumentNode) => {
|
|
320
320
|
},
|
321
321
|
};
|
322
322
|
};
|
323
|
+
const importFiles = (context) => {
|
324
|
+
const code = context.getSourceCode().text;
|
325
|
+
if (!isGraphQLImportFile(code)) {
|
326
|
+
return null;
|
327
|
+
}
|
328
|
+
// Import documents because file contains '#import' comments
|
329
|
+
return _import.processImport(context.getFilename());
|
330
|
+
};
|
323
331
|
const GRAPHQL_JS_VALIDATIONS = Object.assign({}, validationToRule('executable-definitions', 'ExecutableDefinitions', {
|
324
332
|
description: `A GraphQL document is only valid for execution if all definitions are either operation or fragment definitions.`,
|
325
333
|
}), validationToRule('fields-on-correct-type', 'FieldsOnCorrectType', {
|
@@ -396,14 +404,7 @@ const GRAPHQL_JS_VALIDATIONS = Object.assign({}, validationToRule('executable-de
|
|
396
404
|
\``,
|
397
405
|
},
|
398
406
|
],
|
399
|
-
},
|
400
|
-
const code = context.getSourceCode().text;
|
401
|
-
if (!isGraphQLImportFile(code)) {
|
402
|
-
return null;
|
403
|
-
}
|
404
|
-
// Import documents because file contains '#import' comments
|
405
|
-
return _import.processImport(context.getFilename());
|
406
|
-
}), validationToRule('known-type-names', 'KnownTypeNames', {
|
407
|
+
}, importFiles), validationToRule('known-type-names', 'KnownTypeNames', {
|
407
408
|
description: `A GraphQL document is only valid if referenced types (specifically variable definitions and fragment conditions) are defined by the type schema.`,
|
408
409
|
}), validationToRule('lone-anonymous-operation', 'LoneAnonymousOperation', {
|
409
410
|
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.`,
|
@@ -414,7 +415,7 @@ const GRAPHQL_JS_VALIDATIONS = Object.assign({}, validationToRule('executable-de
|
|
414
415
|
description: `A GraphQL fragment is only valid when it does not have cycles in fragments usage.`,
|
415
416
|
}), validationToRule('no-undefined-variables', 'NoUndefinedVariables', {
|
416
417
|
description: `A GraphQL operation is only valid if all variables encountered, both directly and via fragment spreads, are defined by that operation.`,
|
417
|
-
}), validationToRule('no-unused-fragments', 'NoUnusedFragments', {
|
418
|
+
}, importFiles), validationToRule('no-unused-fragments', 'NoUnusedFragments', {
|
418
419
|
description: `A GraphQL document is only valid if all fragment definitions are spread within operations, or spread within other fragments spread within operations.`,
|
419
420
|
requiresSiblings: true,
|
420
421
|
}, context => {
|
@@ -445,7 +446,7 @@ const GRAPHQL_JS_VALIDATIONS = Object.assign({}, validationToRule('executable-de
|
|
445
446
|
return getParentNode(context.getFilename());
|
446
447
|
}), validationToRule('no-unused-variables', 'NoUnusedVariables', {
|
447
448
|
description: `A GraphQL operation is only valid if all variables defined by an operation are used, either directly or within a spread fragment.`,
|
448
|
-
}), validationToRule('overlapping-fields-can-be-merged', 'OverlappingFieldsCanBeMerged', {
|
449
|
+
}, importFiles), validationToRule('overlapping-fields-can-be-merged', 'OverlappingFieldsCanBeMerged', {
|
449
450
|
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.`,
|
450
451
|
}), validationToRule('possible-fragment-spread', 'PossibleFragmentSpreads', {
|
451
452
|
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.`,
|
@@ -789,6 +790,7 @@ const rule$1 = {
|
|
789
790
|
messages: {
|
790
791
|
[AVOID_DUPLICATE_FIELDS]: `{{ type }} "{{ fieldName }}" defined multiple times.`,
|
791
792
|
},
|
793
|
+
schema: [],
|
792
794
|
},
|
793
795
|
create(context) {
|
794
796
|
return {
|
@@ -959,6 +961,7 @@ const rule$3 = {
|
|
959
961
|
},
|
960
962
|
],
|
961
963
|
},
|
964
|
+
schema: [],
|
962
965
|
},
|
963
966
|
create(context) {
|
964
967
|
const schema = requireGraphQLSchemaFromContext('avoid-scalar-result-type-on-mutation', context);
|
@@ -1014,6 +1017,7 @@ const rule$4 = {
|
|
1014
1017
|
messages: {
|
1015
1018
|
[AVOID_TYPENAME_PREFIX]: `Field "{{ fieldName }}" starts with the name of the parent type "{{ typeName }}"`,
|
1016
1019
|
},
|
1020
|
+
schema: [],
|
1017
1021
|
},
|
1018
1022
|
create(context) {
|
1019
1023
|
return {
|
@@ -1727,6 +1731,7 @@ const rule$9 = {
|
|
1727
1731
|
messages: {
|
1728
1732
|
[NO_ANONYMOUS_OPERATIONS]: `Anonymous GraphQL operations are forbidden. Please make sure to name your {{ operation }}!`,
|
1729
1733
|
},
|
1734
|
+
schema: [],
|
1730
1735
|
},
|
1731
1736
|
create(context) {
|
1732
1737
|
return {
|
@@ -1790,6 +1795,7 @@ const rule$a = {
|
|
1790
1795
|
messages: {
|
1791
1796
|
[ERROR_MESSAGE_ID]: `Case-insensitive enum values duplicates are not allowed! Found: "{{ found }}"`,
|
1792
1797
|
},
|
1798
|
+
schema: [],
|
1793
1799
|
},
|
1794
1800
|
create(context) {
|
1795
1801
|
return {
|
@@ -1884,6 +1890,7 @@ const rule$b = {
|
|
1884
1890
|
messages: {
|
1885
1891
|
[NO_DEPRECATED]: `This {{ type }} is marked as deprecated in your GraphQL schema {{ reason }}`,
|
1886
1892
|
},
|
1893
|
+
schema: [],
|
1887
1894
|
},
|
1888
1895
|
create(context) {
|
1889
1896
|
return {
|
@@ -1891,7 +1898,7 @@ const rule$b = {
|
|
1891
1898
|
requireGraphQLSchemaFromContext('no-deprecated', context);
|
1892
1899
|
const typeInfo = node.typeInfo();
|
1893
1900
|
if (typeInfo && typeInfo.enumValue) {
|
1894
|
-
if (typeInfo.enumValue.
|
1901
|
+
if (typeInfo.enumValue.deprecationReason) {
|
1895
1902
|
context.report({
|
1896
1903
|
loc: node.loc,
|
1897
1904
|
messageId: NO_DEPRECATED,
|
@@ -1907,7 +1914,7 @@ const rule$b = {
|
|
1907
1914
|
requireGraphQLSchemaFromContext('no-deprecated', context);
|
1908
1915
|
const typeInfo = node.typeInfo();
|
1909
1916
|
if (typeInfo && typeInfo.fieldDef) {
|
1910
|
-
if (typeInfo.fieldDef.
|
1917
|
+
if (typeInfo.fieldDef.deprecationReason) {
|
1911
1918
|
context.report({
|
1912
1919
|
loc: node.loc,
|
1913
1920
|
messageId: NO_DEPRECATED,
|
@@ -1970,6 +1977,7 @@ const rule$c = {
|
|
1970
1977
|
],
|
1971
1978
|
},
|
1972
1979
|
type: 'suggestion',
|
1980
|
+
schema: [],
|
1973
1981
|
},
|
1974
1982
|
create(context) {
|
1975
1983
|
return {
|
@@ -2030,6 +2038,7 @@ const rule$d = {
|
|
2030
2038
|
messages: {
|
2031
2039
|
[NO_OPERATION_NAME_SUFFIX]: `Unnecessary "{{ invalidSuffix }}" suffix in your operation name!`,
|
2032
2040
|
},
|
2041
|
+
schema: [],
|
2033
2042
|
},
|
2034
2043
|
create(context) {
|
2035
2044
|
return {
|
@@ -2095,6 +2104,7 @@ const rule$e = {
|
|
2095
2104
|
},
|
2096
2105
|
fixable: 'code',
|
2097
2106
|
type: 'suggestion',
|
2107
|
+
schema: [],
|
2098
2108
|
},
|
2099
2109
|
create(context) {
|
2100
2110
|
const reachableTypes = requireReachableTypesFromContext(RULE_NAME, context);
|
@@ -2186,6 +2196,7 @@ const rule$f = {
|
|
2186
2196
|
},
|
2187
2197
|
fixable: 'code',
|
2188
2198
|
type: 'suggestion',
|
2199
|
+
schema: [],
|
2189
2200
|
},
|
2190
2201
|
create(context) {
|
2191
2202
|
const usedFields = requireUsedFieldsFromContext(RULE_NAME$1, context);
|
@@ -2451,6 +2462,7 @@ const rule$h = {
|
|
2451
2462
|
],
|
2452
2463
|
},
|
2453
2464
|
type: 'suggestion',
|
2465
|
+
schema: [],
|
2454
2466
|
},
|
2455
2467
|
create(context) {
|
2456
2468
|
return {
|
@@ -2515,7 +2527,7 @@ const rule$i = {
|
|
2515
2527
|
examples: [
|
2516
2528
|
{
|
2517
2529
|
title: 'Incorrect',
|
2518
|
-
usage: [{ on: [
|
2530
|
+
usage: [{ on: [graphql.Kind.OBJECT_TYPE_DEFINITION, graphql.Kind.FIELD_DEFINITION] }],
|
2519
2531
|
code: /* GraphQL */ `
|
2520
2532
|
type someTypeName {
|
2521
2533
|
name: String
|
@@ -2524,7 +2536,7 @@ const rule$i = {
|
|
2524
2536
|
},
|
2525
2537
|
{
|
2526
2538
|
title: 'Correct',
|
2527
|
-
usage: [{ on: [
|
2539
|
+
usage: [{ on: [graphql.Kind.OBJECT_TYPE_DEFINITION, graphql.Kind.FIELD_DEFINITION] }],
|
2528
2540
|
code: /* GraphQL */ `
|
2529
2541
|
"""
|
2530
2542
|
Some type description
|
@@ -2609,6 +2621,7 @@ const rule$j = {
|
|
2609
2621
|
},
|
2610
2622
|
],
|
2611
2623
|
},
|
2624
|
+
schema: [],
|
2612
2625
|
},
|
2613
2626
|
create(context) {
|
2614
2627
|
const schema = requireGraphQLSchemaFromContext(RULE_NAME$2, context);
|
@@ -3228,6 +3241,7 @@ const rule$n = {
|
|
3228
3241
|
messages: {
|
3229
3242
|
[UNIQUE_FRAGMENT_NAME]: 'Fragment named "{{ documentName }}" already defined in:\n{{ summary }}',
|
3230
3243
|
},
|
3244
|
+
schema: [],
|
3231
3245
|
},
|
3232
3246
|
create(context) {
|
3233
3247
|
return {
|
@@ -3290,6 +3304,7 @@ const rule$o = {
|
|
3290
3304
|
messages: {
|
3291
3305
|
[UNIQUE_OPERATION_NAME]: 'Operation named "{{ documentName }}" already defined in:\n{{ summary }}',
|
3292
3306
|
},
|
3307
|
+
schema: [],
|
3293
3308
|
},
|
3294
3309
|
create(context) {
|
3295
3310
|
return {
|
package/index.mjs
CHANGED
@@ -314,6 +314,14 @@ const validationToRule = (name, ruleName, docs, getDocumentNode) => {
|
|
314
314
|
},
|
315
315
|
};
|
316
316
|
};
|
317
|
+
const importFiles = (context) => {
|
318
|
+
const code = context.getSourceCode().text;
|
319
|
+
if (!isGraphQLImportFile(code)) {
|
320
|
+
return null;
|
321
|
+
}
|
322
|
+
// Import documents because file contains '#import' comments
|
323
|
+
return processImport(context.getFilename());
|
324
|
+
};
|
317
325
|
const GRAPHQL_JS_VALIDATIONS = Object.assign({}, validationToRule('executable-definitions', 'ExecutableDefinitions', {
|
318
326
|
description: `A GraphQL document is only valid for execution if all definitions are either operation or fragment definitions.`,
|
319
327
|
}), validationToRule('fields-on-correct-type', 'FieldsOnCorrectType', {
|
@@ -390,14 +398,7 @@ const GRAPHQL_JS_VALIDATIONS = Object.assign({}, validationToRule('executable-de
|
|
390
398
|
\``,
|
391
399
|
},
|
392
400
|
],
|
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', {
|
401
|
+
}, importFiles), validationToRule('known-type-names', 'KnownTypeNames', {
|
401
402
|
description: `A GraphQL document is only valid if referenced types (specifically variable definitions and fragment conditions) are defined by the type schema.`,
|
402
403
|
}), validationToRule('lone-anonymous-operation', 'LoneAnonymousOperation', {
|
403
404
|
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.`,
|
@@ -408,7 +409,7 @@ const GRAPHQL_JS_VALIDATIONS = Object.assign({}, validationToRule('executable-de
|
|
408
409
|
description: `A GraphQL fragment is only valid when it does not have cycles in fragments usage.`,
|
409
410
|
}), validationToRule('no-undefined-variables', 'NoUndefinedVariables', {
|
410
411
|
description: `A GraphQL operation is only valid if all variables encountered, both directly and via fragment spreads, are defined by that operation.`,
|
411
|
-
}), validationToRule('no-unused-fragments', 'NoUnusedFragments', {
|
412
|
+
}, importFiles), validationToRule('no-unused-fragments', 'NoUnusedFragments', {
|
412
413
|
description: `A GraphQL document is only valid if all fragment definitions are spread within operations, or spread within other fragments spread within operations.`,
|
413
414
|
requiresSiblings: true,
|
414
415
|
}, context => {
|
@@ -439,7 +440,7 @@ const GRAPHQL_JS_VALIDATIONS = Object.assign({}, validationToRule('executable-de
|
|
439
440
|
return getParentNode(context.getFilename());
|
440
441
|
}), validationToRule('no-unused-variables', 'NoUnusedVariables', {
|
441
442
|
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', {
|
443
|
+
}, importFiles), validationToRule('overlapping-fields-can-be-merged', 'OverlappingFieldsCanBeMerged', {
|
443
444
|
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
445
|
}), validationToRule('possible-fragment-spread', 'PossibleFragmentSpreads', {
|
445
446
|
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.`,
|
@@ -783,6 +784,7 @@ const rule$1 = {
|
|
783
784
|
messages: {
|
784
785
|
[AVOID_DUPLICATE_FIELDS]: `{{ type }} "{{ fieldName }}" defined multiple times.`,
|
785
786
|
},
|
787
|
+
schema: [],
|
786
788
|
},
|
787
789
|
create(context) {
|
788
790
|
return {
|
@@ -953,6 +955,7 @@ const rule$3 = {
|
|
953
955
|
},
|
954
956
|
],
|
955
957
|
},
|
958
|
+
schema: [],
|
956
959
|
},
|
957
960
|
create(context) {
|
958
961
|
const schema = requireGraphQLSchemaFromContext('avoid-scalar-result-type-on-mutation', context);
|
@@ -1008,6 +1011,7 @@ const rule$4 = {
|
|
1008
1011
|
messages: {
|
1009
1012
|
[AVOID_TYPENAME_PREFIX]: `Field "{{ fieldName }}" starts with the name of the parent type "{{ typeName }}"`,
|
1010
1013
|
},
|
1014
|
+
schema: [],
|
1011
1015
|
},
|
1012
1016
|
create(context) {
|
1013
1017
|
return {
|
@@ -1721,6 +1725,7 @@ const rule$9 = {
|
|
1721
1725
|
messages: {
|
1722
1726
|
[NO_ANONYMOUS_OPERATIONS]: `Anonymous GraphQL operations are forbidden. Please make sure to name your {{ operation }}!`,
|
1723
1727
|
},
|
1728
|
+
schema: [],
|
1724
1729
|
},
|
1725
1730
|
create(context) {
|
1726
1731
|
return {
|
@@ -1784,6 +1789,7 @@ const rule$a = {
|
|
1784
1789
|
messages: {
|
1785
1790
|
[ERROR_MESSAGE_ID]: `Case-insensitive enum values duplicates are not allowed! Found: "{{ found }}"`,
|
1786
1791
|
},
|
1792
|
+
schema: [],
|
1787
1793
|
},
|
1788
1794
|
create(context) {
|
1789
1795
|
return {
|
@@ -1878,6 +1884,7 @@ const rule$b = {
|
|
1878
1884
|
messages: {
|
1879
1885
|
[NO_DEPRECATED]: `This {{ type }} is marked as deprecated in your GraphQL schema {{ reason }}`,
|
1880
1886
|
},
|
1887
|
+
schema: [],
|
1881
1888
|
},
|
1882
1889
|
create(context) {
|
1883
1890
|
return {
|
@@ -1885,7 +1892,7 @@ const rule$b = {
|
|
1885
1892
|
requireGraphQLSchemaFromContext('no-deprecated', context);
|
1886
1893
|
const typeInfo = node.typeInfo();
|
1887
1894
|
if (typeInfo && typeInfo.enumValue) {
|
1888
|
-
if (typeInfo.enumValue.
|
1895
|
+
if (typeInfo.enumValue.deprecationReason) {
|
1889
1896
|
context.report({
|
1890
1897
|
loc: node.loc,
|
1891
1898
|
messageId: NO_DEPRECATED,
|
@@ -1901,7 +1908,7 @@ const rule$b = {
|
|
1901
1908
|
requireGraphQLSchemaFromContext('no-deprecated', context);
|
1902
1909
|
const typeInfo = node.typeInfo();
|
1903
1910
|
if (typeInfo && typeInfo.fieldDef) {
|
1904
|
-
if (typeInfo.fieldDef.
|
1911
|
+
if (typeInfo.fieldDef.deprecationReason) {
|
1905
1912
|
context.report({
|
1906
1913
|
loc: node.loc,
|
1907
1914
|
messageId: NO_DEPRECATED,
|
@@ -1964,6 +1971,7 @@ const rule$c = {
|
|
1964
1971
|
],
|
1965
1972
|
},
|
1966
1973
|
type: 'suggestion',
|
1974
|
+
schema: [],
|
1967
1975
|
},
|
1968
1976
|
create(context) {
|
1969
1977
|
return {
|
@@ -2024,6 +2032,7 @@ const rule$d = {
|
|
2024
2032
|
messages: {
|
2025
2033
|
[NO_OPERATION_NAME_SUFFIX]: `Unnecessary "{{ invalidSuffix }}" suffix in your operation name!`,
|
2026
2034
|
},
|
2035
|
+
schema: [],
|
2027
2036
|
},
|
2028
2037
|
create(context) {
|
2029
2038
|
return {
|
@@ -2089,6 +2098,7 @@ const rule$e = {
|
|
2089
2098
|
},
|
2090
2099
|
fixable: 'code',
|
2091
2100
|
type: 'suggestion',
|
2101
|
+
schema: [],
|
2092
2102
|
},
|
2093
2103
|
create(context) {
|
2094
2104
|
const reachableTypes = requireReachableTypesFromContext(RULE_NAME, context);
|
@@ -2180,6 +2190,7 @@ const rule$f = {
|
|
2180
2190
|
},
|
2181
2191
|
fixable: 'code',
|
2182
2192
|
type: 'suggestion',
|
2193
|
+
schema: [],
|
2183
2194
|
},
|
2184
2195
|
create(context) {
|
2185
2196
|
const usedFields = requireUsedFieldsFromContext(RULE_NAME$1, context);
|
@@ -2445,6 +2456,7 @@ const rule$h = {
|
|
2445
2456
|
],
|
2446
2457
|
},
|
2447
2458
|
type: 'suggestion',
|
2459
|
+
schema: [],
|
2448
2460
|
},
|
2449
2461
|
create(context) {
|
2450
2462
|
return {
|
@@ -2509,7 +2521,7 @@ const rule$i = {
|
|
2509
2521
|
examples: [
|
2510
2522
|
{
|
2511
2523
|
title: 'Incorrect',
|
2512
|
-
usage: [{ on: [
|
2524
|
+
usage: [{ on: [Kind.OBJECT_TYPE_DEFINITION, Kind.FIELD_DEFINITION] }],
|
2513
2525
|
code: /* GraphQL */ `
|
2514
2526
|
type someTypeName {
|
2515
2527
|
name: String
|
@@ -2518,7 +2530,7 @@ const rule$i = {
|
|
2518
2530
|
},
|
2519
2531
|
{
|
2520
2532
|
title: 'Correct',
|
2521
|
-
usage: [{ on: [
|
2533
|
+
usage: [{ on: [Kind.OBJECT_TYPE_DEFINITION, Kind.FIELD_DEFINITION] }],
|
2522
2534
|
code: /* GraphQL */ `
|
2523
2535
|
"""
|
2524
2536
|
Some type description
|
@@ -2603,6 +2615,7 @@ const rule$j = {
|
|
2603
2615
|
},
|
2604
2616
|
],
|
2605
2617
|
},
|
2618
|
+
schema: [],
|
2606
2619
|
},
|
2607
2620
|
create(context) {
|
2608
2621
|
const schema = requireGraphQLSchemaFromContext(RULE_NAME$2, context);
|
@@ -3222,6 +3235,7 @@ const rule$n = {
|
|
3222
3235
|
messages: {
|
3223
3236
|
[UNIQUE_FRAGMENT_NAME]: 'Fragment named "{{ documentName }}" already defined in:\n{{ summary }}',
|
3224
3237
|
},
|
3238
|
+
schema: [],
|
3225
3239
|
},
|
3226
3240
|
create(context) {
|
3227
3241
|
return {
|
@@ -3284,6 +3298,7 @@ const rule$o = {
|
|
3284
3298
|
messages: {
|
3285
3299
|
[UNIQUE_OPERATION_NAME]: 'Operation named "{{ documentName }}" already defined in:\n{{ summary }}',
|
3286
3300
|
},
|
3301
|
+
schema: [],
|
3287
3302
|
},
|
3288
3303
|
create(context) {
|
3289
3304
|
return {
|
package/package.json
CHANGED
@@ -1,5 +1,6 @@
|
|
1
|
-
import { GraphQLSchema, DocumentNode, ASTNode
|
1
|
+
import { GraphQLSchema, DocumentNode, ASTNode } from 'graphql';
|
2
2
|
import { GraphQLESLintRule, GraphQLESLintRuleContext } from '../types';
|
3
3
|
import { GraphQLESTreeNode } from '../estree-parser';
|
4
|
-
|
4
|
+
import { SDLValidationRule } from 'graphql/validation/ValidationContext';
|
5
|
+
export declare function validateDoc(sourceNode: GraphQLESTreeNode<ASTNode>, context: GraphQLESLintRuleContext, schema: GraphQLSchema | null, documentNode: DocumentNode, rules: ReadonlyArray<SDLValidationRule>, ruleName?: string | null): void;
|
5
6
|
export declare const GRAPHQL_JS_VALIDATIONS: Record<string, GraphQLESLintRule<any[], false>>;
|