@graphql-eslint/eslint-plugin 3.0.0-alpha-5388f29.0 → 3.0.0-alpha-580615a.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 +69 -60
- package/configs/all.d.ts +9 -1
- package/configs/index.d.ts +9 -1
- package/docs/README.md +1 -0
- package/docs/custom-rules.md +36 -36
- package/docs/rules/naming-convention.md +25 -25
- package/docs/rules/no-root-type.md +56 -0
- package/docs/rules/require-description.md +35 -6
- package/estree-parser/converter.d.ts +2 -3
- package/index.js +196 -70
- package/index.mjs +197 -71
- package/package.json +9 -8
- package/rules/alphabetize.d.ts +5 -5
- package/rules/index.d.ts +18 -3
- package/rules/no-root-type.d.ts +7 -0
- package/rules/require-description.d.ts +10 -5
- package/utils.d.ts +3 -3
@@ -12,7 +12,7 @@ Enforce descriptions in your type definitions.
|
|
12
12
|
### Incorrect
|
13
13
|
|
14
14
|
```graphql
|
15
|
-
# eslint @graphql-eslint/require-description: ['error', {
|
15
|
+
# eslint @graphql-eslint/require-description: ['error', { types: true, overrides: { FieldDefinition: true } }]
|
16
16
|
|
17
17
|
type someTypeName {
|
18
18
|
name: String
|
@@ -22,7 +22,7 @@ type someTypeName {
|
|
22
22
|
### Correct
|
23
23
|
|
24
24
|
```graphql
|
25
|
-
# eslint @graphql-eslint/require-description: ['error', {
|
25
|
+
# eslint @graphql-eslint/require-description: ['error', { types: true, overrides: { FieldDefinition: true } }]
|
26
26
|
|
27
27
|
"""
|
28
28
|
Some type description
|
@@ -39,13 +39,42 @@ type someTypeName {
|
|
39
39
|
|
40
40
|
The schema defines the following properties:
|
41
41
|
|
42
|
-
### `
|
42
|
+
### `types` (boolean)
|
43
43
|
|
44
|
-
|
44
|
+
Includes:
|
45
45
|
|
46
|
-
|
46
|
+
- [ObjectTypeDefinition](https://spec.graphql.org/October2021/#ObjectTypeDefinition)
|
47
|
+
- [InterfaceTypeDefinition](https://spec.graphql.org/October2021/#InterfaceTypeDefinition)
|
48
|
+
- [EnumTypeDefinition](https://spec.graphql.org/October2021/#EnumTypeDefinition)
|
49
|
+
- [ScalarTypeDefinition](https://spec.graphql.org/October2021/#ScalarTypeDefinition)
|
50
|
+
- [InputObjectTypeDefinition](https://spec.graphql.org/October2021/#InputObjectTypeDefinition)
|
51
|
+
- [UnionTypeDefinition](https://spec.graphql.org/October2021/#UnionTypeDefinition)
|
47
52
|
|
48
|
-
|
53
|
+
### `overrides` (object)
|
54
|
+
|
55
|
+
Configuration for precise `ASTNode`
|
56
|
+
|
57
|
+
Properties of the `overrides` object:
|
58
|
+
|
59
|
+
#### `ObjectTypeDefinition` (boolean)
|
60
|
+
|
61
|
+
#### `InterfaceTypeDefinition` (boolean)
|
62
|
+
|
63
|
+
#### `EnumTypeDefinition` (boolean)
|
64
|
+
|
65
|
+
#### `ScalarTypeDefinition` (boolean)
|
66
|
+
|
67
|
+
#### `InputObjectTypeDefinition` (boolean)
|
68
|
+
|
69
|
+
#### `UnionTypeDefinition` (boolean)
|
70
|
+
|
71
|
+
#### `FieldDefinition` (boolean)
|
72
|
+
|
73
|
+
#### `InputValueDefinition` (boolean)
|
74
|
+
|
75
|
+
#### `EnumValueDefinition` (boolean)
|
76
|
+
|
77
|
+
#### `DirectiveDefinition` (boolean)
|
49
78
|
|
50
79
|
## Resources
|
51
80
|
|
@@ -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
|
};
|
package/index.js
CHANGED
@@ -118,10 +118,11 @@ const allConfig = {
|
|
118
118
|
'@graphql-eslint/match-document-filename': 'error',
|
119
119
|
'@graphql-eslint/no-deprecated': 'error',
|
120
120
|
'@graphql-eslint/no-hashtag-description': 'error',
|
121
|
+
'@graphql-eslint/no-root-type': ['error', { disallow: ['subscription'] }],
|
121
122
|
'@graphql-eslint/no-unreachable-types': 'error',
|
122
123
|
'@graphql-eslint/no-unused-fields': 'error',
|
123
124
|
'@graphql-eslint/require-deprecation-date': 'error',
|
124
|
-
'@graphql-eslint/require-description': 'error',
|
125
|
+
'@graphql-eslint/require-description': ['error', { types: true, overrides: { DirectiveDefinition: true } }],
|
125
126
|
'@graphql-eslint/require-field-of-type-query-in-mutation-result': 'error',
|
126
127
|
'@graphql-eslint/require-id-when-available': 'error',
|
127
128
|
'@graphql-eslint/selection-set-depth': 'error',
|
@@ -176,7 +177,7 @@ function getLexer(source) {
|
|
176
177
|
throw new Error(`Unsupported GraphQL version! Please make sure to use GraphQL v14 or newer!`);
|
177
178
|
}
|
178
179
|
function extractTokens(source) {
|
179
|
-
const lexer = getLexer(
|
180
|
+
const lexer = getLexer(source);
|
180
181
|
const tokens = [];
|
181
182
|
let token = lexer.advance();
|
182
183
|
while (token && token.kind !== '<EOF>') {
|
@@ -545,11 +546,23 @@ const GRAPHQL_JS_VALIDATIONS = Object.assign({}, validationToRule('executable-de
|
|
545
546
|
}));
|
546
547
|
|
547
548
|
const ALPHABETIZE = 'ALPHABETIZE';
|
548
|
-
const fieldsEnum = [
|
549
|
+
const fieldsEnum = [
|
550
|
+
graphql.Kind.OBJECT_TYPE_DEFINITION,
|
551
|
+
graphql.Kind.INTERFACE_TYPE_DEFINITION,
|
552
|
+
graphql.Kind.INPUT_OBJECT_TYPE_DEFINITION,
|
553
|
+
];
|
549
554
|
const valuesEnum = [graphql.Kind.ENUM_TYPE_DEFINITION];
|
550
|
-
const selectionsEnum = [
|
555
|
+
const selectionsEnum = [
|
556
|
+
graphql.Kind.OPERATION_DEFINITION,
|
557
|
+
graphql.Kind.FRAGMENT_DEFINITION,
|
558
|
+
];
|
551
559
|
const variablesEnum = [graphql.Kind.OPERATION_DEFINITION];
|
552
|
-
const argumentsEnum = [
|
560
|
+
const argumentsEnum = [
|
561
|
+
graphql.Kind.FIELD_DEFINITION,
|
562
|
+
graphql.Kind.FIELD,
|
563
|
+
graphql.Kind.DIRECTIVE_DEFINITION,
|
564
|
+
graphql.Kind.DIRECTIVE,
|
565
|
+
];
|
553
566
|
const rule = {
|
554
567
|
meta: {
|
555
568
|
type: 'suggestion',
|
@@ -1582,11 +1595,11 @@ const rule$8 = {
|
|
1582
1595
|
properties: {
|
1583
1596
|
types: {
|
1584
1597
|
...schemaOption$1,
|
1585
|
-
description: `Includes:\n\n${TYPES_KINDS.map(kind => `-
|
1598
|
+
description: `Includes:\n\n${TYPES_KINDS.map(kind => `- [${kind}](https://spec.graphql.org/October2021/#${kind})`).join('\n')}`,
|
1586
1599
|
},
|
1587
1600
|
fields: {
|
1588
1601
|
...schemaOption$1,
|
1589
|
-
description: `Includes:\n\n${FIELDS_KINDS.map(kind => `-
|
1602
|
+
description: `Includes:\n\n${FIELDS_KINDS.map(kind => `- [${kind}](https://spec.graphql.org/October2021/#${kind})`).join('\n')}`,
|
1590
1603
|
},
|
1591
1604
|
allowLeadingUnderscore: {
|
1592
1605
|
type: 'boolean',
|
@@ -1602,7 +1615,7 @@ const rule$8 = {
|
|
1602
1615
|
description: [
|
1603
1616
|
'May contain the following `ASTNode` names:',
|
1604
1617
|
'',
|
1605
|
-
...ALLOWED_KINDS.map(kind => `-
|
1618
|
+
...ALLOWED_KINDS.map(kind => `- [${kind}](https://spec.graphql.org/October2021/#${kind})`),
|
1606
1619
|
'',
|
1607
1620
|
"> It's also possible to use a [`selector`](https://eslint.org/docs/developer-guide/selectors) that starts with `ASTNode` name",
|
1608
1621
|
'>',
|
@@ -1885,7 +1898,7 @@ const rule$b = {
|
|
1885
1898
|
requireGraphQLSchemaFromContext('no-deprecated', context);
|
1886
1899
|
const typeInfo = node.typeInfo();
|
1887
1900
|
if (typeInfo && typeInfo.enumValue) {
|
1888
|
-
if (typeInfo.enumValue.
|
1901
|
+
if (typeInfo.enumValue.deprecationReason) {
|
1889
1902
|
const enumValueName = node.value;
|
1890
1903
|
context.report({
|
1891
1904
|
loc: getLocation(node.loc, enumValueName),
|
@@ -1902,7 +1915,7 @@ const rule$b = {
|
|
1902
1915
|
requireGraphQLSchemaFromContext('no-deprecated', context);
|
1903
1916
|
const typeInfo = node.typeInfo();
|
1904
1917
|
if (typeInfo && typeInfo.fieldDef) {
|
1905
|
-
if (typeInfo.fieldDef.
|
1918
|
+
if (typeInfo.fieldDef.deprecationReason) {
|
1906
1919
|
const fieldName = node.name.value;
|
1907
1920
|
context.report({
|
1908
1921
|
loc: getLocation(node.loc, fieldName),
|
@@ -2059,9 +2072,100 @@ const rule$d = {
|
|
2059
2072
|
},
|
2060
2073
|
};
|
2061
2074
|
|
2075
|
+
const ROOT_TYPES = ['query', 'mutation', 'subscription'];
|
2076
|
+
const rule$e = {
|
2077
|
+
meta: {
|
2078
|
+
type: 'suggestion',
|
2079
|
+
docs: {
|
2080
|
+
category: 'Validation',
|
2081
|
+
description: 'Disallow using root types for `read-only` or `write-only` schemas.',
|
2082
|
+
url: 'https://github.com/dotansimha/graphql-eslint/blob/master/docs/rules/no-root-type.md',
|
2083
|
+
requiresSchema: true,
|
2084
|
+
examples: [
|
2085
|
+
{
|
2086
|
+
title: 'Incorrect (`read-only` schema)',
|
2087
|
+
usage: [{ disallow: ['mutation', 'subscription'] }],
|
2088
|
+
code: /* GraphQL */ `
|
2089
|
+
type Mutation {
|
2090
|
+
createUser(input: CreateUserInput!): User!
|
2091
|
+
}
|
2092
|
+
`,
|
2093
|
+
},
|
2094
|
+
{
|
2095
|
+
title: 'Incorrect (`write-only` schema)',
|
2096
|
+
usage: [{ disallow: ['query'] }],
|
2097
|
+
code: /* GraphQL */ `
|
2098
|
+
type Query {
|
2099
|
+
users: [User!]!
|
2100
|
+
}
|
2101
|
+
`,
|
2102
|
+
},
|
2103
|
+
{
|
2104
|
+
title: 'Correct (`read-only` schema)',
|
2105
|
+
usage: [{ disallow: ['mutation', 'subscription'] }],
|
2106
|
+
code: /* GraphQL */ `
|
2107
|
+
type Query {
|
2108
|
+
users: [User!]!
|
2109
|
+
}
|
2110
|
+
`,
|
2111
|
+
},
|
2112
|
+
],
|
2113
|
+
optionsForConfig: [{ disallow: ['subscription'] }],
|
2114
|
+
},
|
2115
|
+
schema: {
|
2116
|
+
type: 'array',
|
2117
|
+
minItems: 1,
|
2118
|
+
maxItems: 1,
|
2119
|
+
items: {
|
2120
|
+
type: 'object',
|
2121
|
+
additionalProperties: false,
|
2122
|
+
required: ['disallow'],
|
2123
|
+
properties: {
|
2124
|
+
disallow: {
|
2125
|
+
type: 'array',
|
2126
|
+
uniqueItems: true,
|
2127
|
+
minItems: 1,
|
2128
|
+
items: {
|
2129
|
+
enum: ROOT_TYPES,
|
2130
|
+
},
|
2131
|
+
},
|
2132
|
+
},
|
2133
|
+
},
|
2134
|
+
},
|
2135
|
+
},
|
2136
|
+
create(context) {
|
2137
|
+
const schema = requireGraphQLSchemaFromContext('no-root-type', context);
|
2138
|
+
const disallow = new Set(context.options[0].disallow);
|
2139
|
+
const rootTypeNames = [
|
2140
|
+
disallow.has('query') && schema.getQueryType(),
|
2141
|
+
disallow.has('mutation') && schema.getMutationType(),
|
2142
|
+
disallow.has('subscription') && schema.getSubscriptionType(),
|
2143
|
+
]
|
2144
|
+
.filter(Boolean)
|
2145
|
+
.map(type => type.name);
|
2146
|
+
if (rootTypeNames.length === 0) {
|
2147
|
+
return {};
|
2148
|
+
}
|
2149
|
+
const selector = [
|
2150
|
+
`:matches(${graphql.Kind.OBJECT_TYPE_DEFINITION}, ${graphql.Kind.OBJECT_TYPE_EXTENSION})`,
|
2151
|
+
'>',
|
2152
|
+
`${graphql.Kind.NAME}[value=/^(${rootTypeNames.join('|')})$/]`,
|
2153
|
+
].join(' ');
|
2154
|
+
return {
|
2155
|
+
[selector](node) {
|
2156
|
+
const typeName = node.value;
|
2157
|
+
context.report({
|
2158
|
+
loc: getLocation(node.loc, typeName),
|
2159
|
+
message: `Root type "${typeName}" is forbidden`,
|
2160
|
+
});
|
2161
|
+
},
|
2162
|
+
};
|
2163
|
+
},
|
2164
|
+
};
|
2165
|
+
|
2062
2166
|
const UNREACHABLE_TYPE = 'UNREACHABLE_TYPE';
|
2063
2167
|
const RULE_NAME = 'no-unreachable-types';
|
2064
|
-
const rule$
|
2168
|
+
const rule$f = {
|
2065
2169
|
meta: {
|
2066
2170
|
messages: {
|
2067
2171
|
[UNREACHABLE_TYPE]: `Type "{{ typeName }}" is unreachable`,
|
@@ -2137,7 +2241,7 @@ const rule$e = {
|
|
2137
2241
|
|
2138
2242
|
const UNUSED_FIELD = 'UNUSED_FIELD';
|
2139
2243
|
const RULE_NAME$1 = 'no-unused-fields';
|
2140
|
-
const rule$
|
2244
|
+
const rule$g = {
|
2141
2245
|
meta: {
|
2142
2246
|
messages: {
|
2143
2247
|
[UNUSED_FIELD]: `Field "{{fieldName}}" is unused`,
|
@@ -2326,7 +2430,7 @@ const MESSAGE_REQUIRE_DATE = 'MESSAGE_REQUIRE_DATE';
|
|
2326
2430
|
const MESSAGE_INVALID_FORMAT = 'MESSAGE_INVALID_FORMAT';
|
2327
2431
|
const MESSAGE_INVALID_DATE = 'MESSAGE_INVALID_DATE';
|
2328
2432
|
const MESSAGE_CAN_BE_REMOVED = 'MESSAGE_CAN_BE_REMOVED';
|
2329
|
-
const rule$
|
2433
|
+
const rule$h = {
|
2330
2434
|
meta: {
|
2331
2435
|
type: 'suggestion',
|
2332
2436
|
docs: {
|
@@ -2429,7 +2533,7 @@ const rule$g = {
|
|
2429
2533
|
},
|
2430
2534
|
};
|
2431
2535
|
|
2432
|
-
const rule$
|
2536
|
+
const rule$i = {
|
2433
2537
|
meta: {
|
2434
2538
|
docs: {
|
2435
2539
|
description: `Require all deprecation directives to specify a reason.`,
|
@@ -2484,41 +2588,23 @@ const rule$h = {
|
|
2484
2588
|
};
|
2485
2589
|
|
2486
2590
|
const REQUIRE_DESCRIPTION_ERROR = 'REQUIRE_DESCRIPTION_ERROR';
|
2487
|
-
const
|
2488
|
-
|
2489
|
-
graphql.Kind.OBJECT_TYPE_DEFINITION,
|
2591
|
+
const ALLOWED_KINDS$1 = [
|
2592
|
+
...TYPES_KINDS,
|
2490
2593
|
graphql.Kind.FIELD_DEFINITION,
|
2491
2594
|
graphql.Kind.INPUT_VALUE_DEFINITION,
|
2492
|
-
graphql.Kind.INTERFACE_TYPE_DEFINITION,
|
2493
|
-
graphql.Kind.UNION_TYPE_DEFINITION,
|
2494
|
-
graphql.Kind.ENUM_TYPE_DEFINITION,
|
2495
2595
|
graphql.Kind.ENUM_VALUE_DEFINITION,
|
2496
|
-
graphql.Kind.INPUT_OBJECT_TYPE_DEFINITION,
|
2497
2596
|
graphql.Kind.DIRECTIVE_DEFINITION,
|
2498
2597
|
];
|
2499
|
-
|
2500
|
-
if (node) {
|
2501
|
-
if (!node.description || !node.description.value || node.description.value.trim().length === 0) {
|
2502
|
-
context.report({
|
2503
|
-
loc: getLocation(('name' in node ? node.name : node).loc, 'name' in node ? node.name.value : 'schema'),
|
2504
|
-
messageId: REQUIRE_DESCRIPTION_ERROR,
|
2505
|
-
data: {
|
2506
|
-
nodeType: node.kind,
|
2507
|
-
},
|
2508
|
-
});
|
2509
|
-
}
|
2510
|
-
}
|
2511
|
-
}
|
2512
|
-
const rule$i = {
|
2598
|
+
const rule$j = {
|
2513
2599
|
meta: {
|
2514
2600
|
docs: {
|
2515
2601
|
category: 'Best Practices',
|
2516
|
-
description:
|
2517
|
-
url:
|
2602
|
+
description: 'Enforce descriptions in your type definitions.',
|
2603
|
+
url: 'https://github.com/dotansimha/graphql-eslint/blob/master/docs/rules/require-description.md',
|
2518
2604
|
examples: [
|
2519
2605
|
{
|
2520
2606
|
title: 'Incorrect',
|
2521
|
-
usage: [{
|
2607
|
+
usage: [{ types: true, overrides: { FieldDefinition: true } }],
|
2522
2608
|
code: /* GraphQL */ `
|
2523
2609
|
type someTypeName {
|
2524
2610
|
name: String
|
@@ -2527,7 +2613,7 @@ const rule$i = {
|
|
2527
2613
|
},
|
2528
2614
|
{
|
2529
2615
|
title: 'Correct',
|
2530
|
-
usage: [{
|
2616
|
+
usage: [{ types: true, overrides: { FieldDefinition: true } }],
|
2531
2617
|
code: /* GraphQL */ `
|
2532
2618
|
"""
|
2533
2619
|
Some type description
|
@@ -2541,40 +2627,74 @@ const rule$i = {
|
|
2541
2627
|
`,
|
2542
2628
|
},
|
2543
2629
|
],
|
2630
|
+
optionsForConfig: [
|
2631
|
+
{
|
2632
|
+
types: true,
|
2633
|
+
overrides: {
|
2634
|
+
[graphql.Kind.DIRECTIVE_DEFINITION]: true,
|
2635
|
+
},
|
2636
|
+
},
|
2637
|
+
],
|
2544
2638
|
},
|
2545
2639
|
type: 'suggestion',
|
2546
2640
|
messages: {
|
2547
|
-
[REQUIRE_DESCRIPTION_ERROR]:
|
2641
|
+
[REQUIRE_DESCRIPTION_ERROR]: 'Description is required for nodes of type "{{ nodeType }}"',
|
2548
2642
|
},
|
2549
2643
|
schema: {
|
2550
2644
|
type: 'array',
|
2551
|
-
additionalItems: false,
|
2552
2645
|
minItems: 1,
|
2553
2646
|
maxItems: 1,
|
2554
2647
|
items: {
|
2555
2648
|
type: 'object',
|
2556
|
-
|
2649
|
+
additionalProperties: false,
|
2650
|
+
minProperties: 1,
|
2557
2651
|
properties: {
|
2558
|
-
|
2559
|
-
type: '
|
2560
|
-
|
2561
|
-
|
2562
|
-
|
2563
|
-
|
2564
|
-
|
2565
|
-
|
2652
|
+
types: {
|
2653
|
+
type: 'boolean',
|
2654
|
+
description: `Includes:\n\n${TYPES_KINDS.map(kind => `- [${kind}](https://spec.graphql.org/October2021/#${kind})`).join('\n')}`,
|
2655
|
+
},
|
2656
|
+
overrides: {
|
2657
|
+
type: 'object',
|
2658
|
+
description: 'Configuration for precise `ASTNode`',
|
2659
|
+
additionalProperties: false,
|
2660
|
+
properties: Object.fromEntries(ALLOWED_KINDS$1.map(kind => [kind, { type: 'boolean' }])),
|
2566
2661
|
},
|
2567
2662
|
},
|
2568
2663
|
},
|
2569
2664
|
},
|
2570
2665
|
},
|
2571
2666
|
create(context) {
|
2572
|
-
|
2667
|
+
const { types, overrides = {} } = context.options[0];
|
2668
|
+
const kinds = new Set(types ? TYPES_KINDS : []);
|
2669
|
+
for (const [kind, isEnabled] of Object.entries(overrides)) {
|
2670
|
+
if (isEnabled) {
|
2671
|
+
kinds.add(kind);
|
2672
|
+
}
|
2673
|
+
else {
|
2674
|
+
kinds.delete(kind);
|
2675
|
+
}
|
2676
|
+
}
|
2677
|
+
const selector = [...kinds].join(',');
|
2678
|
+
return {
|
2679
|
+
[selector](node) {
|
2680
|
+
var _a;
|
2681
|
+
const description = ((_a = node.description) === null || _a === void 0 ? void 0 : _a.value) || '';
|
2682
|
+
if (description.trim().length === 0) {
|
2683
|
+
context.report({
|
2684
|
+
loc: getLocation(node.name.loc, node.name.value),
|
2685
|
+
messageId: REQUIRE_DESCRIPTION_ERROR,
|
2686
|
+
data: {
|
2687
|
+
nodeType: node.kind,
|
2688
|
+
},
|
2689
|
+
});
|
2690
|
+
}
|
2691
|
+
},
|
2692
|
+
};
|
2573
2693
|
},
|
2574
2694
|
};
|
2575
2695
|
|
2576
2696
|
const RULE_NAME$2 = 'require-field-of-type-query-in-mutation-result';
|
2577
|
-
const rule$
|
2697
|
+
const rule$k = {
|
2578
2698
|
meta: {
|
2579
2699
|
type: 'suggestion',
|
2580
2700
|
docs: {
|
@@ -2742,7 +2862,7 @@ const convertNode = (typeInfo) => (node, key, parent) => {
|
|
2742
2862
|
|
2743
2863
|
const REQUIRE_ID_WHEN_AVAILABLE = 'REQUIRE_ID_WHEN_AVAILABLE';
|
2744
2864
|
const DEFAULT_ID_FIELD_NAME = 'id';
|
2745
|
-
const rule$
|
2865
|
+
const rule$l = {
|
2746
2866
|
meta: {
|
2747
2867
|
type: 'suggestion',
|
2748
2868
|
docs: {
|
@@ -2878,7 +2998,7 @@ const rule$k = {
|
|
2878
2998
|
},
|
2879
2999
|
};
|
2880
3000
|
|
2881
|
-
const rule$
|
3001
|
+
const rule$m = {
|
2882
3002
|
meta: {
|
2883
3003
|
docs: {
|
2884
3004
|
category: 'Best Practices',
|
@@ -3000,7 +3120,7 @@ const shouldIgnoreNode = ({ node, exceptions }) => {
|
|
3000
3120
|
}
|
3001
3121
|
return false;
|
3002
3122
|
};
|
3003
|
-
const rule$
|
3123
|
+
const rule$n = {
|
3004
3124
|
meta: {
|
3005
3125
|
type: 'suggestion',
|
3006
3126
|
docs: {
|
@@ -3177,7 +3297,7 @@ const checkNode = (context, node, ruleName, messageId) => {
|
|
3177
3297
|
});
|
3178
3298
|
}
|
3179
3299
|
};
|
3180
|
-
const rule$
|
3300
|
+
const rule$o = {
|
3181
3301
|
meta: {
|
3182
3302
|
type: 'suggestion',
|
3183
3303
|
docs: {
|
@@ -3236,7 +3356,7 @@ const rule$n = {
|
|
3236
3356
|
|
3237
3357
|
const RULE_NAME$4 = 'unique-operation-name';
|
3238
3358
|
const UNIQUE_OPERATION_NAME = 'UNIQUE_OPERATION_NAME';
|
3239
|
-
const rule$
|
3359
|
+
const rule$p = {
|
3240
3360
|
meta: {
|
3241
3361
|
type: 'suggestion',
|
3242
3362
|
docs: {
|
@@ -3316,17 +3436,18 @@ const rules = {
|
|
3316
3436
|
'no-deprecated': rule$b,
|
3317
3437
|
'no-hashtag-description': rule$c,
|
3318
3438
|
'no-operation-name-suffix': rule$d,
|
3319
|
-
'no-
|
3320
|
-
'no-
|
3321
|
-
'
|
3322
|
-
'require-deprecation-
|
3323
|
-
'require-
|
3324
|
-
'require-
|
3325
|
-
'require-
|
3326
|
-
'
|
3327
|
-
'
|
3328
|
-
'
|
3329
|
-
'unique-
|
3439
|
+
'no-root-type': rule$e,
|
3440
|
+
'no-unreachable-types': rule$f,
|
3441
|
+
'no-unused-fields': rule$g,
|
3442
|
+
'require-deprecation-date': rule$h,
|
3443
|
+
'require-deprecation-reason': rule$i,
|
3444
|
+
'require-description': rule$j,
|
3445
|
+
'require-field-of-type-query-in-mutation-result': rule$k,
|
3446
|
+
'require-id-when-available': rule$l,
|
3447
|
+
'selection-set-depth': rule$m,
|
3448
|
+
'strict-id-in-types': rule$n,
|
3449
|
+
'unique-fragment-name': rule$o,
|
3450
|
+
'unique-operation-name': rule$p,
|
3330
3451
|
};
|
3331
3452
|
|
3332
3453
|
const RELEVANT_KEYWORDS = ['gql', 'graphql', '/* GraphQL */'];
|
@@ -3629,7 +3750,12 @@ function getReachableTypes(schema) {
|
|
3629
3750
|
Directive: collect,
|
3630
3751
|
NamedType: collect,
|
3631
3752
|
};
|
3632
|
-
for (const type of [
|
3753
|
+
for (const type of [
|
3754
|
+
schema,
|
3755
|
+
schema.getQueryType(),
|
3756
|
+
schema.getMutationType(),
|
3757
|
+
schema.getSubscriptionType(),
|
3758
|
+
]) {
|
3633
3759
|
if (type) {
|
3634
3760
|
graphql.visit(type.astNode, visitor);
|
3635
3761
|
}
|
@@ -3688,7 +3814,7 @@ function parseForESLint(code, options = {}) {
|
|
3688
3814
|
noLocation: false,
|
3689
3815
|
});
|
3690
3816
|
const { rootTree, comments } = convertToESTree(graphqlAst.document, schema ? new graphql.TypeInfo(schema) : null);
|
3691
|
-
const tokens = extractTokens(code);
|
3817
|
+
const tokens = extractTokens(new graphql.Source(code, filePath));
|
3692
3818
|
return {
|
3693
3819
|
services: parserServices,
|
3694
3820
|
parserServices,
|