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