@graphql-eslint/eslint-plugin 3.6.0 â 3.8.0-alpha-c1d1797.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/docs/README.md +1 -1
- package/docs/rules/require-description.md +18 -1
- package/index.js +58 -30
- package/index.mjs +58 -30
- package/package.json +3 -3
- package/rules/index.d.ts +1 -14
- package/rules/require-description.d.ts +2 -2
package/docs/README.md
CHANGED
@@ -44,7 +44,7 @@ Name &nbs
|
|
44
44
|
[provided-required-arguments](rules/provided-required-arguments.md)|A field or directive is only valid if all required (non-null without a default value) field arguments have been provided.|![recommended][]|đŽ
|
45
45
|
[require-deprecation-date](rules/require-deprecation-date.md)|Require deletion date on `@deprecated` directive. Suggest removing deprecated things after deprecated date.|![all][]|đ
|
46
46
|
[require-deprecation-reason](rules/require-deprecation-reason.md)|Require all deprecation directives to specify a reason.|![recommended][]|đ
|
47
|
-
[require-description](rules/require-description.md)|Enforce descriptions in
|
47
|
+
[require-description](rules/require-description.md)|Enforce descriptions in type definitions and operations.|![recommended][]|đ
|
48
48
|
[require-field-of-type-query-in-mutation-result](rules/require-field-of-type-query-in-mutation-result.md)|Allow the client in one round-trip not only to call mutation but also to get a wagon of data to update their application.|![all][]|đ
|
49
49
|
[require-id-when-available](rules/require-id-when-available.md)|Enforce selecting specific fields when they are available on the GraphQL type.|![recommended][]|đ
|
50
50
|
[scalar-leafs](rules/scalar-leafs.md)|A GraphQL document is valid only if all leaf fields (fields without sub selections) are of scalar or enum types.|![recommended][]|đŽ
|
@@ -7,7 +7,7 @@
|
|
7
7
|
- Requires GraphQL Schema: `false` [âšī¸](../../README.md#extended-linting-rules-with-graphql-schema)
|
8
8
|
- Requires GraphQL Operations: `false` [âšī¸](../../README.md#extended-linting-rules-with-siblings-operations)
|
9
9
|
|
10
|
-
Enforce descriptions in
|
10
|
+
Enforce descriptions in type definitions and operations.
|
11
11
|
|
12
12
|
## Usage Examples
|
13
13
|
|
@@ -37,6 +37,17 @@ type someTypeName {
|
|
37
37
|
}
|
38
38
|
```
|
39
39
|
|
40
|
+
### Correct
|
41
|
+
|
42
|
+
```graphql
|
43
|
+
# eslint @graphql-eslint/require-description: ['error', { OperationDefinition: true }]
|
44
|
+
|
45
|
+
# Create a new user
|
46
|
+
mutation createUser {
|
47
|
+
# ...
|
48
|
+
}
|
49
|
+
```
|
50
|
+
|
40
51
|
## Config Schema
|
41
52
|
|
42
53
|
The schema defines the following properties:
|
@@ -84,6 +95,12 @@ Read more about this kind on [spec.graphql.org](https://spec.graphql.org/October
|
|
84
95
|
|
85
96
|
Read more about this kind on [spec.graphql.org](https://spec.graphql.org/October2021/#ObjectTypeDefinition).
|
86
97
|
|
98
|
+
### `OperationDefinition` (boolean)
|
99
|
+
|
100
|
+
Read more about this kind on [spec.graphql.org](https://spec.graphql.org/October2021/#OperationDefinition).
|
101
|
+
|
102
|
+
> You must use only comment syntax `#` and not description syntax `"""` or `"`.
|
103
|
+
|
87
104
|
### `ScalarTypeDefinition` (boolean)
|
88
105
|
|
89
106
|
Read more about this kind on [spec.graphql.org](https://spec.graphql.org/October2021/#ScalarTypeDefinition).
|
package/index.js
CHANGED
@@ -2625,20 +2625,21 @@ const rule$g = {
|
|
2625
2625
|
},
|
2626
2626
|
};
|
2627
2627
|
|
2628
|
-
const
|
2628
|
+
const RULE_ID$2 = 'require-description';
|
2629
2629
|
const ALLOWED_KINDS$1 = [
|
2630
2630
|
...TYPES_KINDS,
|
2631
2631
|
graphql.Kind.FIELD_DEFINITION,
|
2632
2632
|
graphql.Kind.INPUT_VALUE_DEFINITION,
|
2633
2633
|
graphql.Kind.ENUM_VALUE_DEFINITION,
|
2634
2634
|
graphql.Kind.DIRECTIVE_DEFINITION,
|
2635
|
+
graphql.Kind.OPERATION_DEFINITION,
|
2635
2636
|
];
|
2636
2637
|
const rule$h = {
|
2637
2638
|
meta: {
|
2638
2639
|
docs: {
|
2639
2640
|
category: 'Schema',
|
2640
|
-
description: 'Enforce descriptions in
|
2641
|
-
url:
|
2641
|
+
description: 'Enforce descriptions in type definitions and operations.',
|
2642
|
+
url: `https://github.com/dotansimha/graphql-eslint/blob/master/docs/rules/${RULE_ID$2}.md`,
|
2642
2643
|
examples: [
|
2643
2644
|
{
|
2644
2645
|
title: 'Incorrect',
|
@@ -2662,6 +2663,16 @@ const rule$h = {
|
|
2662
2663
|
"""
|
2663
2664
|
name: String
|
2664
2665
|
}
|
2666
|
+
`,
|
2667
|
+
},
|
2668
|
+
{
|
2669
|
+
title: 'Correct',
|
2670
|
+
usage: [{ OperationDefinition: true }],
|
2671
|
+
code: /* GraphQL */ `
|
2672
|
+
# Create a new user
|
2673
|
+
mutation createUser {
|
2674
|
+
# ...
|
2675
|
+
}
|
2665
2676
|
`,
|
2666
2677
|
},
|
2667
2678
|
],
|
@@ -2675,7 +2686,7 @@ const rule$h = {
|
|
2675
2686
|
},
|
2676
2687
|
type: 'suggestion',
|
2677
2688
|
messages: {
|
2678
|
-
[
|
2689
|
+
[RULE_ID$2]: 'Description is required for nodes of type "{{ nodeType }}"',
|
2679
2690
|
},
|
2680
2691
|
schema: {
|
2681
2692
|
type: 'array',
|
@@ -2690,19 +2701,19 @@ const rule$h = {
|
|
2690
2701
|
type: 'boolean',
|
2691
2702
|
description: `Includes:\n\n${TYPES_KINDS.map(kind => `- \`${kind}\``).join('\n')}`,
|
2692
2703
|
},
|
2693
|
-
...Object.fromEntries([...ALLOWED_KINDS$1].sort().map(kind =>
|
2694
|
-
kind
|
2695
|
-
{
|
2696
|
-
|
2697
|
-
|
2698
|
-
}
|
2699
|
-
|
2704
|
+
...Object.fromEntries([...ALLOWED_KINDS$1].sort().map(kind => {
|
2705
|
+
let description = `Read more about this kind on [spec.graphql.org](https://spec.graphql.org/October2021/#${kind}).`;
|
2706
|
+
if (kind === graphql.Kind.OPERATION_DEFINITION) {
|
2707
|
+
description += '\n\n> You must use only comment syntax `#` and not description syntax `"""` or `"`.';
|
2708
|
+
}
|
2709
|
+
return [kind, { type: 'boolean', description }];
|
2710
|
+
})),
|
2700
2711
|
},
|
2701
2712
|
},
|
2702
2713
|
},
|
2703
2714
|
},
|
2704
2715
|
create(context) {
|
2705
|
-
const { types, ...restOptions } = context.options[0];
|
2716
|
+
const { types, ...restOptions } = context.options[0] || {};
|
2706
2717
|
const kinds = new Set(types ? TYPES_KINDS : []);
|
2707
2718
|
for (const [kind, isEnabled] of Object.entries(restOptions)) {
|
2708
2719
|
if (isEnabled) {
|
@@ -2716,11 +2727,26 @@ const rule$h = {
|
|
2716
2727
|
return {
|
2717
2728
|
[selector](node) {
|
2718
2729
|
var _a;
|
2719
|
-
|
2720
|
-
|
2730
|
+
let description = '';
|
2731
|
+
const isOperation = node.kind === graphql.Kind.OPERATION_DEFINITION;
|
2732
|
+
if (isOperation) {
|
2733
|
+
const rawNode = node.rawNode();
|
2734
|
+
const { prev, line } = rawNode.loc.startToken;
|
2735
|
+
if (prev.kind === graphql.TokenKind.COMMENT) {
|
2736
|
+
const value = prev.value.trim();
|
2737
|
+
const linesBefore = line - prev.line;
|
2738
|
+
if (!value.startsWith('eslint') && linesBefore === 1) {
|
2739
|
+
description = value;
|
2740
|
+
}
|
2741
|
+
}
|
2742
|
+
}
|
2743
|
+
else {
|
2744
|
+
description = ((_a = node.description) === null || _a === void 0 ? void 0 : _a.value.trim()) || '';
|
2745
|
+
}
|
2746
|
+
if (description.length === 0) {
|
2721
2747
|
context.report({
|
2722
|
-
loc: getLocation(node.name.loc, node.name.value),
|
2723
|
-
messageId:
|
2748
|
+
loc: isOperation ? getLocation(node.loc, node.operation) : getLocation(node.name.loc, node.name.value),
|
2749
|
+
messageId: RULE_ID$2,
|
2724
2750
|
data: {
|
2725
2751
|
nodeType: node.kind,
|
2726
2752
|
},
|
@@ -2896,7 +2922,7 @@ const convertNode = (typeInfo) => (node, key, parent) => {
|
|
2896
2922
|
}
|
2897
2923
|
};
|
2898
2924
|
|
2899
|
-
const RULE_ID$
|
2925
|
+
const RULE_ID$3 = 'require-id-when-available';
|
2900
2926
|
const MESSAGE_ID = 'REQUIRE_ID_WHEN_AVAILABLE';
|
2901
2927
|
const DEFAULT_ID_FIELD_NAME = 'id';
|
2902
2928
|
const rule$j = {
|
@@ -2905,7 +2931,7 @@ const rule$j = {
|
|
2905
2931
|
docs: {
|
2906
2932
|
category: 'Operations',
|
2907
2933
|
description: 'Enforce selecting specific fields when they are available on the GraphQL type.',
|
2908
|
-
url: `https://github.com/dotansimha/graphql-eslint/blob/master/docs/rules/${RULE_ID$
|
2934
|
+
url: `https://github.com/dotansimha/graphql-eslint/blob/master/docs/rules/${RULE_ID$3}.md`,
|
2909
2935
|
requiresSchema: true,
|
2910
2936
|
requiresSiblings: true,
|
2911
2937
|
examples: [
|
@@ -2979,8 +3005,8 @@ const rule$j = {
|
|
2979
3005
|
},
|
2980
3006
|
},
|
2981
3007
|
create(context) {
|
2982
|
-
requireGraphQLSchemaFromContext(RULE_ID$
|
2983
|
-
const siblings = requireSiblingsOperations(RULE_ID$
|
3008
|
+
requireGraphQLSchemaFromContext(RULE_ID$3, context);
|
3009
|
+
const siblings = requireSiblingsOperations(RULE_ID$3, context);
|
2984
3010
|
const { fieldName = DEFAULT_ID_FIELD_NAME } = context.options[0] || {};
|
2985
3011
|
const idNames = utils.asArray(fieldName);
|
2986
3012
|
const isFound = (s) => s.kind === graphql.Kind.FIELD && idNames.includes(s.name.value);
|
@@ -3042,13 +3068,13 @@ const rule$j = {
|
|
3042
3068
|
},
|
3043
3069
|
};
|
3044
3070
|
|
3045
|
-
const RULE_ID$
|
3071
|
+
const RULE_ID$4 = 'selection-set-depth';
|
3046
3072
|
const rule$k = {
|
3047
3073
|
meta: {
|
3048
3074
|
docs: {
|
3049
3075
|
category: 'Operations',
|
3050
3076
|
description: `Limit the complexity of the GraphQL operations solely by their depth. Based on [graphql-depth-limit](https://github.com/stems/graphql-depth-limit).`,
|
3051
|
-
url: `https://github.com/dotansimha/graphql-eslint/blob/master/docs/rules/${RULE_ID$
|
3077
|
+
url: `https://github.com/dotansimha/graphql-eslint/blob/master/docs/rules/${RULE_ID$4}.md`,
|
3052
3078
|
requiresSiblings: true,
|
3053
3079
|
examples: [
|
3054
3080
|
{
|
@@ -3122,10 +3148,10 @@ const rule$k = {
|
|
3122
3148
|
create(context) {
|
3123
3149
|
let siblings = null;
|
3124
3150
|
try {
|
3125
|
-
siblings = requireSiblingsOperations(RULE_ID$
|
3151
|
+
siblings = requireSiblingsOperations(RULE_ID$4, context);
|
3126
3152
|
}
|
3127
3153
|
catch (e) {
|
3128
|
-
logger.warn(`Rule "${RULE_ID$
|
3154
|
+
logger.warn(`Rule "${RULE_ID$4}" works best with siblings operations loaded. For more info: http://bit.ly/graphql-eslint-operations`);
|
3129
3155
|
}
|
3130
3156
|
const { maxDepth } = context.options[0];
|
3131
3157
|
const ignore = context.options[0].ignore || [];
|
@@ -3150,14 +3176,14 @@ const rule$k = {
|
|
3150
3176
|
});
|
3151
3177
|
}
|
3152
3178
|
catch (e) {
|
3153
|
-
logger.warn(`Rule "${RULE_ID$
|
3179
|
+
logger.warn(`Rule "${RULE_ID$4}" check failed due to a missing siblings operations. For more info: http://bit.ly/graphql-eslint-operations`, e);
|
3154
3180
|
}
|
3155
3181
|
},
|
3156
3182
|
};
|
3157
3183
|
},
|
3158
3184
|
};
|
3159
3185
|
|
3160
|
-
const RULE_ID$
|
3186
|
+
const RULE_ID$5 = 'strict-id-in-types';
|
3161
3187
|
const rule$l = {
|
3162
3188
|
meta: {
|
3163
3189
|
type: 'suggestion',
|
@@ -3165,7 +3191,7 @@ const rule$l = {
|
|
3165
3191
|
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.`,
|
3166
3192
|
category: 'Schema',
|
3167
3193
|
recommended: true,
|
3168
|
-
url: `https://github.com/dotansimha/graphql-eslint/blob/master/docs/rules/${RULE_ID$
|
3194
|
+
url: `https://github.com/dotansimha/graphql-eslint/blob/master/docs/rules/${RULE_ID$5}.md`,
|
3169
3195
|
requiresSchema: true,
|
3170
3196
|
examples: [
|
3171
3197
|
{
|
@@ -3279,7 +3305,7 @@ const rule$l = {
|
|
3279
3305
|
},
|
3280
3306
|
},
|
3281
3307
|
messages: {
|
3282
|
-
[RULE_ID$
|
3308
|
+
[RULE_ID$5]: `{{ typeName }} must have exactly one non-nullable unique identifier. Accepted name(s): {{ acceptedNamesString }}; Accepted type(s): {{ acceptedTypesString }}.`,
|
3283
3309
|
},
|
3284
3310
|
},
|
3285
3311
|
create(context) {
|
@@ -3289,7 +3315,7 @@ const rule$l = {
|
|
3289
3315
|
exceptions: {},
|
3290
3316
|
...context.options[0],
|
3291
3317
|
};
|
3292
|
-
const schema = requireGraphQLSchemaFromContext(RULE_ID$
|
3318
|
+
const schema = requireGraphQLSchemaFromContext(RULE_ID$5, context);
|
3293
3319
|
const rootTypeNames = [schema.getQueryType(), schema.getMutationType(), schema.getSubscriptionType()]
|
3294
3320
|
.filter(Boolean)
|
3295
3321
|
.map(type => type.name);
|
@@ -3319,7 +3345,7 @@ const rule$l = {
|
|
3319
3345
|
if (validIds.length !== 1) {
|
3320
3346
|
context.report({
|
3321
3347
|
loc: getLocation(node.name.loc, typeName),
|
3322
|
-
messageId: RULE_ID$
|
3348
|
+
messageId: RULE_ID$5,
|
3323
3349
|
data: {
|
3324
3350
|
typeName,
|
3325
3351
|
acceptedNamesString: options.acceptedIdNames.join(', '),
|
@@ -3749,6 +3775,8 @@ function loadGraphQLConfig(options) {
|
|
3749
3775
|
const onDiskConfig = options.skipGraphQLConfig
|
3750
3776
|
? null
|
3751
3777
|
: graphqlConfig.loadConfigSync({
|
3778
|
+
// load config relative to the file being linted
|
3779
|
+
rootDir: options.filePath ? path.dirname(options.filePath) : undefined,
|
3752
3780
|
throwOnEmpty: false,
|
3753
3781
|
throwOnMissing: false,
|
3754
3782
|
extensions: [addCodeFileLoaderExtension],
|
package/index.mjs
CHANGED
@@ -2619,20 +2619,21 @@ const rule$g = {
|
|
2619
2619
|
},
|
2620
2620
|
};
|
2621
2621
|
|
2622
|
-
const
|
2622
|
+
const RULE_ID$2 = 'require-description';
|
2623
2623
|
const ALLOWED_KINDS$1 = [
|
2624
2624
|
...TYPES_KINDS,
|
2625
2625
|
Kind.FIELD_DEFINITION,
|
2626
2626
|
Kind.INPUT_VALUE_DEFINITION,
|
2627
2627
|
Kind.ENUM_VALUE_DEFINITION,
|
2628
2628
|
Kind.DIRECTIVE_DEFINITION,
|
2629
|
+
Kind.OPERATION_DEFINITION,
|
2629
2630
|
];
|
2630
2631
|
const rule$h = {
|
2631
2632
|
meta: {
|
2632
2633
|
docs: {
|
2633
2634
|
category: 'Schema',
|
2634
|
-
description: 'Enforce descriptions in
|
2635
|
-
url:
|
2635
|
+
description: 'Enforce descriptions in type definitions and operations.',
|
2636
|
+
url: `https://github.com/dotansimha/graphql-eslint/blob/master/docs/rules/${RULE_ID$2}.md`,
|
2636
2637
|
examples: [
|
2637
2638
|
{
|
2638
2639
|
title: 'Incorrect',
|
@@ -2656,6 +2657,16 @@ const rule$h = {
|
|
2656
2657
|
"""
|
2657
2658
|
name: String
|
2658
2659
|
}
|
2660
|
+
`,
|
2661
|
+
},
|
2662
|
+
{
|
2663
|
+
title: 'Correct',
|
2664
|
+
usage: [{ OperationDefinition: true }],
|
2665
|
+
code: /* GraphQL */ `
|
2666
|
+
# Create a new user
|
2667
|
+
mutation createUser {
|
2668
|
+
# ...
|
2669
|
+
}
|
2659
2670
|
`,
|
2660
2671
|
},
|
2661
2672
|
],
|
@@ -2669,7 +2680,7 @@ const rule$h = {
|
|
2669
2680
|
},
|
2670
2681
|
type: 'suggestion',
|
2671
2682
|
messages: {
|
2672
|
-
[
|
2683
|
+
[RULE_ID$2]: 'Description is required for nodes of type "{{ nodeType }}"',
|
2673
2684
|
},
|
2674
2685
|
schema: {
|
2675
2686
|
type: 'array',
|
@@ -2684,19 +2695,19 @@ const rule$h = {
|
|
2684
2695
|
type: 'boolean',
|
2685
2696
|
description: `Includes:\n\n${TYPES_KINDS.map(kind => `- \`${kind}\``).join('\n')}`,
|
2686
2697
|
},
|
2687
|
-
...Object.fromEntries([...ALLOWED_KINDS$1].sort().map(kind =>
|
2688
|
-
kind
|
2689
|
-
{
|
2690
|
-
|
2691
|
-
|
2692
|
-
}
|
2693
|
-
|
2698
|
+
...Object.fromEntries([...ALLOWED_KINDS$1].sort().map(kind => {
|
2699
|
+
let description = `Read more about this kind on [spec.graphql.org](https://spec.graphql.org/October2021/#${kind}).`;
|
2700
|
+
if (kind === Kind.OPERATION_DEFINITION) {
|
2701
|
+
description += '\n\n> You must use only comment syntax `#` and not description syntax `"""` or `"`.';
|
2702
|
+
}
|
2703
|
+
return [kind, { type: 'boolean', description }];
|
2704
|
+
})),
|
2694
2705
|
},
|
2695
2706
|
},
|
2696
2707
|
},
|
2697
2708
|
},
|
2698
2709
|
create(context) {
|
2699
|
-
const { types, ...restOptions } = context.options[0];
|
2710
|
+
const { types, ...restOptions } = context.options[0] || {};
|
2700
2711
|
const kinds = new Set(types ? TYPES_KINDS : []);
|
2701
2712
|
for (const [kind, isEnabled] of Object.entries(restOptions)) {
|
2702
2713
|
if (isEnabled) {
|
@@ -2710,11 +2721,26 @@ const rule$h = {
|
|
2710
2721
|
return {
|
2711
2722
|
[selector](node) {
|
2712
2723
|
var _a;
|
2713
|
-
|
2714
|
-
|
2724
|
+
let description = '';
|
2725
|
+
const isOperation = node.kind === Kind.OPERATION_DEFINITION;
|
2726
|
+
if (isOperation) {
|
2727
|
+
const rawNode = node.rawNode();
|
2728
|
+
const { prev, line } = rawNode.loc.startToken;
|
2729
|
+
if (prev.kind === TokenKind.COMMENT) {
|
2730
|
+
const value = prev.value.trim();
|
2731
|
+
const linesBefore = line - prev.line;
|
2732
|
+
if (!value.startsWith('eslint') && linesBefore === 1) {
|
2733
|
+
description = value;
|
2734
|
+
}
|
2735
|
+
}
|
2736
|
+
}
|
2737
|
+
else {
|
2738
|
+
description = ((_a = node.description) === null || _a === void 0 ? void 0 : _a.value.trim()) || '';
|
2739
|
+
}
|
2740
|
+
if (description.length === 0) {
|
2715
2741
|
context.report({
|
2716
|
-
loc: getLocation(node.name.loc, node.name.value),
|
2717
|
-
messageId:
|
2742
|
+
loc: isOperation ? getLocation(node.loc, node.operation) : getLocation(node.name.loc, node.name.value),
|
2743
|
+
messageId: RULE_ID$2,
|
2718
2744
|
data: {
|
2719
2745
|
nodeType: node.kind,
|
2720
2746
|
},
|
@@ -2890,7 +2916,7 @@ const convertNode = (typeInfo) => (node, key, parent) => {
|
|
2890
2916
|
}
|
2891
2917
|
};
|
2892
2918
|
|
2893
|
-
const RULE_ID$
|
2919
|
+
const RULE_ID$3 = 'require-id-when-available';
|
2894
2920
|
const MESSAGE_ID = 'REQUIRE_ID_WHEN_AVAILABLE';
|
2895
2921
|
const DEFAULT_ID_FIELD_NAME = 'id';
|
2896
2922
|
const rule$j = {
|
@@ -2899,7 +2925,7 @@ const rule$j = {
|
|
2899
2925
|
docs: {
|
2900
2926
|
category: 'Operations',
|
2901
2927
|
description: 'Enforce selecting specific fields when they are available on the GraphQL type.',
|
2902
|
-
url: `https://github.com/dotansimha/graphql-eslint/blob/master/docs/rules/${RULE_ID$
|
2928
|
+
url: `https://github.com/dotansimha/graphql-eslint/blob/master/docs/rules/${RULE_ID$3}.md`,
|
2903
2929
|
requiresSchema: true,
|
2904
2930
|
requiresSiblings: true,
|
2905
2931
|
examples: [
|
@@ -2973,8 +2999,8 @@ const rule$j = {
|
|
2973
2999
|
},
|
2974
3000
|
},
|
2975
3001
|
create(context) {
|
2976
|
-
requireGraphQLSchemaFromContext(RULE_ID$
|
2977
|
-
const siblings = requireSiblingsOperations(RULE_ID$
|
3002
|
+
requireGraphQLSchemaFromContext(RULE_ID$3, context);
|
3003
|
+
const siblings = requireSiblingsOperations(RULE_ID$3, context);
|
2978
3004
|
const { fieldName = DEFAULT_ID_FIELD_NAME } = context.options[0] || {};
|
2979
3005
|
const idNames = asArray(fieldName);
|
2980
3006
|
const isFound = (s) => s.kind === Kind.FIELD && idNames.includes(s.name.value);
|
@@ -3036,13 +3062,13 @@ const rule$j = {
|
|
3036
3062
|
},
|
3037
3063
|
};
|
3038
3064
|
|
3039
|
-
const RULE_ID$
|
3065
|
+
const RULE_ID$4 = 'selection-set-depth';
|
3040
3066
|
const rule$k = {
|
3041
3067
|
meta: {
|
3042
3068
|
docs: {
|
3043
3069
|
category: 'Operations',
|
3044
3070
|
description: `Limit the complexity of the GraphQL operations solely by their depth. Based on [graphql-depth-limit](https://github.com/stems/graphql-depth-limit).`,
|
3045
|
-
url: `https://github.com/dotansimha/graphql-eslint/blob/master/docs/rules/${RULE_ID$
|
3071
|
+
url: `https://github.com/dotansimha/graphql-eslint/blob/master/docs/rules/${RULE_ID$4}.md`,
|
3046
3072
|
requiresSiblings: true,
|
3047
3073
|
examples: [
|
3048
3074
|
{
|
@@ -3116,10 +3142,10 @@ const rule$k = {
|
|
3116
3142
|
create(context) {
|
3117
3143
|
let siblings = null;
|
3118
3144
|
try {
|
3119
|
-
siblings = requireSiblingsOperations(RULE_ID$
|
3145
|
+
siblings = requireSiblingsOperations(RULE_ID$4, context);
|
3120
3146
|
}
|
3121
3147
|
catch (e) {
|
3122
|
-
logger.warn(`Rule "${RULE_ID$
|
3148
|
+
logger.warn(`Rule "${RULE_ID$4}" works best with siblings operations loaded. For more info: http://bit.ly/graphql-eslint-operations`);
|
3123
3149
|
}
|
3124
3150
|
const { maxDepth } = context.options[0];
|
3125
3151
|
const ignore = context.options[0].ignore || [];
|
@@ -3144,14 +3170,14 @@ const rule$k = {
|
|
3144
3170
|
});
|
3145
3171
|
}
|
3146
3172
|
catch (e) {
|
3147
|
-
logger.warn(`Rule "${RULE_ID$
|
3173
|
+
logger.warn(`Rule "${RULE_ID$4}" check failed due to a missing siblings operations. For more info: http://bit.ly/graphql-eslint-operations`, e);
|
3148
3174
|
}
|
3149
3175
|
},
|
3150
3176
|
};
|
3151
3177
|
},
|
3152
3178
|
};
|
3153
3179
|
|
3154
|
-
const RULE_ID$
|
3180
|
+
const RULE_ID$5 = 'strict-id-in-types';
|
3155
3181
|
const rule$l = {
|
3156
3182
|
meta: {
|
3157
3183
|
type: 'suggestion',
|
@@ -3159,7 +3185,7 @@ const rule$l = {
|
|
3159
3185
|
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.`,
|
3160
3186
|
category: 'Schema',
|
3161
3187
|
recommended: true,
|
3162
|
-
url: `https://github.com/dotansimha/graphql-eslint/blob/master/docs/rules/${RULE_ID$
|
3188
|
+
url: `https://github.com/dotansimha/graphql-eslint/blob/master/docs/rules/${RULE_ID$5}.md`,
|
3163
3189
|
requiresSchema: true,
|
3164
3190
|
examples: [
|
3165
3191
|
{
|
@@ -3273,7 +3299,7 @@ const rule$l = {
|
|
3273
3299
|
},
|
3274
3300
|
},
|
3275
3301
|
messages: {
|
3276
|
-
[RULE_ID$
|
3302
|
+
[RULE_ID$5]: `{{ typeName }} must have exactly one non-nullable unique identifier. Accepted name(s): {{ acceptedNamesString }}; Accepted type(s): {{ acceptedTypesString }}.`,
|
3277
3303
|
},
|
3278
3304
|
},
|
3279
3305
|
create(context) {
|
@@ -3283,7 +3309,7 @@ const rule$l = {
|
|
3283
3309
|
exceptions: {},
|
3284
3310
|
...context.options[0],
|
3285
3311
|
};
|
3286
|
-
const schema = requireGraphQLSchemaFromContext(RULE_ID$
|
3312
|
+
const schema = requireGraphQLSchemaFromContext(RULE_ID$5, context);
|
3287
3313
|
const rootTypeNames = [schema.getQueryType(), schema.getMutationType(), schema.getSubscriptionType()]
|
3288
3314
|
.filter(Boolean)
|
3289
3315
|
.map(type => type.name);
|
@@ -3313,7 +3339,7 @@ const rule$l = {
|
|
3313
3339
|
if (validIds.length !== 1) {
|
3314
3340
|
context.report({
|
3315
3341
|
loc: getLocation(node.name.loc, typeName),
|
3316
|
-
messageId: RULE_ID$
|
3342
|
+
messageId: RULE_ID$5,
|
3317
3343
|
data: {
|
3318
3344
|
typeName,
|
3319
3345
|
acceptedNamesString: options.acceptedIdNames.join(', '),
|
@@ -3743,6 +3769,8 @@ function loadGraphQLConfig(options) {
|
|
3743
3769
|
const onDiskConfig = options.skipGraphQLConfig
|
3744
3770
|
? null
|
3745
3771
|
: loadConfigSync({
|
3772
|
+
// load config relative to the file being linted
|
3773
|
+
rootDir: options.filePath ? dirname(options.filePath) : undefined,
|
3746
3774
|
throwOnEmpty: false,
|
3747
3775
|
throwOnMissing: false,
|
3748
3776
|
extensions: [addCodeFileLoaderExtension],
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@graphql-eslint/eslint-plugin",
|
3
|
-
"version": "3.
|
3
|
+
"version": "3.8.0-alpha-c1d1797.0",
|
4
4
|
"description": "GraphQL plugin for ESLint",
|
5
5
|
"sideEffects": false,
|
6
6
|
"peerDependencies": {
|
@@ -9,8 +9,8 @@
|
|
9
9
|
"dependencies": {
|
10
10
|
"@babel/code-frame": "7.16.7",
|
11
11
|
"@graphql-tools/code-file-loader": "7.2.3",
|
12
|
-
"@graphql-tools/graphql-tag-pluck": "7.1.
|
13
|
-
"@graphql-tools/utils": "8.
|
12
|
+
"@graphql-tools/graphql-tag-pluck": "7.1.5",
|
13
|
+
"@graphql-tools/utils": "8.6.1",
|
14
14
|
"chalk": "4.1.2",
|
15
15
|
"graphql-config": "4.1.0",
|
16
16
|
"graphql-depth-limit": "1.1.0",
|
package/rules/index.d.ts
CHANGED
@@ -33,20 +33,7 @@ export declare const rules: {
|
|
33
33
|
argumentName?: string;
|
34
34
|
}], false>;
|
35
35
|
'require-deprecation-reason': import("..").GraphQLESLintRule<any[], false>;
|
36
|
-
'require-description': import("..").GraphQLESLintRule<[
|
37
|
-
types?: boolean;
|
38
|
-
} & {
|
39
|
-
ScalarTypeDefinition?: boolean;
|
40
|
-
ObjectTypeDefinition?: boolean;
|
41
|
-
FieldDefinition?: boolean;
|
42
|
-
InputValueDefinition?: boolean;
|
43
|
-
InterfaceTypeDefinition?: boolean;
|
44
|
-
UnionTypeDefinition?: boolean;
|
45
|
-
EnumTypeDefinition?: boolean;
|
46
|
-
EnumValueDefinition?: boolean;
|
47
|
-
InputObjectTypeDefinition?: boolean;
|
48
|
-
DirectiveDefinition?: boolean;
|
49
|
-
}], false>;
|
36
|
+
'require-description': import("..").GraphQLESLintRule<[import("./require-description").RequireDescriptionRuleConfig], false>;
|
50
37
|
'require-field-of-type-query-in-mutation-result': import("..").GraphQLESLintRule<any[], false>;
|
51
38
|
'require-id-when-available': import("..").GraphQLESLintRule<[import("./require-id-when-available").RequireIdWhenAvailableRuleConfig], true>;
|
52
39
|
'selection-set-depth': import("..").GraphQLESLintRule<[{
|
@@ -1,8 +1,8 @@
|
|
1
1
|
import { Kind } from 'graphql';
|
2
2
|
import { GraphQLESLintRule } from '../types';
|
3
|
-
declare const ALLOWED_KINDS: readonly [Kind.OBJECT_TYPE_DEFINITION, Kind.INTERFACE_TYPE_DEFINITION, Kind.ENUM_TYPE_DEFINITION, Kind.SCALAR_TYPE_DEFINITION, Kind.INPUT_OBJECT_TYPE_DEFINITION, Kind.UNION_TYPE_DEFINITION, Kind.FIELD_DEFINITION, Kind.INPUT_VALUE_DEFINITION, Kind.ENUM_VALUE_DEFINITION, Kind.DIRECTIVE_DEFINITION];
|
3
|
+
declare const ALLOWED_KINDS: readonly [Kind.OBJECT_TYPE_DEFINITION, Kind.INTERFACE_TYPE_DEFINITION, Kind.ENUM_TYPE_DEFINITION, Kind.SCALAR_TYPE_DEFINITION, Kind.INPUT_OBJECT_TYPE_DEFINITION, Kind.UNION_TYPE_DEFINITION, Kind.FIELD_DEFINITION, Kind.INPUT_VALUE_DEFINITION, Kind.ENUM_VALUE_DEFINITION, Kind.DIRECTIVE_DEFINITION, Kind.OPERATION_DEFINITION];
|
4
4
|
declare type AllowedKind = typeof ALLOWED_KINDS[number];
|
5
|
-
declare type RequireDescriptionRuleConfig = {
|
5
|
+
export declare type RequireDescriptionRuleConfig = {
|
6
6
|
types?: boolean;
|
7
7
|
} & {
|
8
8
|
[key in AllowedKind]?: boolean;
|