@graphql-eslint/eslint-plugin 3.0.0-alpha-636cc2a.0 → 3.0.1-alpha-86a9e78.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 +14 -4
- package/configs/index.d.ts +5 -2
- package/configs/schema-all.d.ts +1 -0
- package/configs/schema-recommended.d.ts +4 -2
- package/docs/README.md +1 -1
- package/docs/rules/naming-convention.md +2 -16
- package/docs/rules/possible-type-extension.md +0 -2
- package/index.js +19 -22
- package/index.mjs +19 -22
- package/package.json +1 -1
- package/rules/index.d.ts +0 -7
- package/rules/naming-convention.d.ts +0 -1
package/README.md
CHANGED
@@ -180,17 +180,27 @@ You can find a list of [ESLint directives here](https://eslint.org/docs/2.13.1/u
|
|
180
180
|
|
181
181
|
You can find a complete list of [all available rules here](docs/README.md).
|
182
182
|
|
183
|
+
## Deprecated Rules
|
184
|
+
|
185
|
+
See [docs/deprecated-rules.md](docs/deprecated-rules.md).
|
186
|
+
|
183
187
|
## Available Configs
|
184
188
|
|
185
189
|
<!-- prettier-ignore-start -->
|
186
190
|
|Name|Description|
|
187
191
|
|:-:|-|
|
188
|
-
|[`schema-recommended`](packages/plugin/src/configs/schema-recommended.ts)|enables
|
189
|
-
|[`
|
190
|
-
|[`
|
191
|
-
|[`operations-all`](packages/plugin/src/configs/operations-all.ts)|enables all rules|
|
192
|
+
|[`schema-recommended`](packages/plugin/src/configs/schema-recommended.ts)|enables recommended rules for schema (SDL) development|
|
193
|
+
|[`schema-all`](packages/plugin/src/configs/schema-all.ts)|enables all rules for schema (SDL) development, except for those that require `parserOptions.operations` option|
|
194
|
+
|[`operations-recommended`](packages/plugin/src/configs/operations-recommended.ts) |enables recommended rules for consuming GraphQL (operations) development|
|
195
|
+
|[`operations-all`](packages/plugin/src/configs/operations-all.ts)|enables all rules for consuming GraphQL (operations) development|
|
192
196
|
<!-- prettier-ignore-end -->
|
193
197
|
|
198
|
+
> If you are in a project that develops the GraphQL schema, you'll need `schema` rules.
|
199
|
+
|
200
|
+
> If you are in a project that develops GraphQL operations (query/mutation/subscription), you'll need `operations` rules.
|
201
|
+
|
202
|
+
> If you are in a monorepo project, you probably need both sets of rules.
|
203
|
+
|
194
204
|
## Config usage
|
195
205
|
|
196
206
|
For example, to enable the `schema-recommended` config, enable it in your `.eslintrc` file with the `extends` option:
|
package/configs/index.d.ts
CHANGED
@@ -13,7 +13,10 @@ export declare const configs: {
|
|
13
13
|
'@graphql-eslint/lone-schema-definition': string;
|
14
14
|
'@graphql-eslint/naming-convention': (string | {
|
15
15
|
types: string;
|
16
|
-
|
16
|
+
FieldDefinition: string;
|
17
|
+
InputValueDefinition: string;
|
18
|
+
Argument: string;
|
19
|
+
DirectiveDefinition: string;
|
17
20
|
EnumValueDefinition: string;
|
18
21
|
'FieldDefinition[parent.name.value=Query]': {
|
19
22
|
forbiddenPrefixes: string[];
|
@@ -32,7 +35,6 @@ export declare const configs: {
|
|
32
35
|
'@graphql-eslint/no-hashtag-description': string;
|
33
36
|
'@graphql-eslint/no-typename-prefix': string;
|
34
37
|
'@graphql-eslint/no-unreachable-types': string;
|
35
|
-
'@graphql-eslint/possible-type-extension': string;
|
36
38
|
'@graphql-eslint/provided-required-arguments': string;
|
37
39
|
'@graphql-eslint/require-deprecation-reason': string;
|
38
40
|
'@graphql-eslint/require-description': (string | {
|
@@ -60,6 +62,7 @@ export declare const configs: {
|
|
60
62
|
'@graphql-eslint/no-root-type': string;
|
61
63
|
'@graphql-eslint/no-scalar-result-type-on-mutation': string;
|
62
64
|
'@graphql-eslint/no-unused-fields': string;
|
65
|
+
'@graphql-eslint/possible-type-extension': string;
|
63
66
|
'@graphql-eslint/require-deprecation-date': string;
|
64
67
|
'@graphql-eslint/require-field-of-type-query-in-mutation-result': string;
|
65
68
|
};
|
package/configs/schema-all.d.ts
CHANGED
@@ -10,6 +10,7 @@ declare const _default: {
|
|
10
10
|
'@graphql-eslint/no-root-type': string;
|
11
11
|
'@graphql-eslint/no-scalar-result-type-on-mutation': string;
|
12
12
|
'@graphql-eslint/no-unused-fields': string;
|
13
|
+
'@graphql-eslint/possible-type-extension': string;
|
13
14
|
'@graphql-eslint/require-deprecation-date': string;
|
14
15
|
'@graphql-eslint/require-field-of-type-query-in-mutation-result': string;
|
15
16
|
};
|
@@ -8,7 +8,10 @@ declare const _default: {
|
|
8
8
|
'@graphql-eslint/lone-schema-definition': string;
|
9
9
|
'@graphql-eslint/naming-convention': (string | {
|
10
10
|
types: string;
|
11
|
-
|
11
|
+
FieldDefinition: string;
|
12
|
+
InputValueDefinition: string;
|
13
|
+
Argument: string;
|
14
|
+
DirectiveDefinition: string;
|
12
15
|
EnumValueDefinition: string;
|
13
16
|
'FieldDefinition[parent.name.value=Query]': {
|
14
17
|
forbiddenPrefixes: string[];
|
@@ -27,7 +30,6 @@ declare const _default: {
|
|
27
30
|
'@graphql-eslint/no-hashtag-description': string;
|
28
31
|
'@graphql-eslint/no-typename-prefix': string;
|
29
32
|
'@graphql-eslint/no-unreachable-types': string;
|
30
|
-
'@graphql-eslint/possible-type-extension': string;
|
31
33
|
'@graphql-eslint/provided-required-arguments': string;
|
32
34
|
'@graphql-eslint/require-deprecation-reason': string;
|
33
35
|
'@graphql-eslint/require-description': (string | {
|
package/docs/README.md
CHANGED
@@ -42,7 +42,7 @@ Name &nbs
|
|
42
42
|
[one-field-subscriptions](rules/one-field-subscriptions.md)|A GraphQL subscription is valid only if it contains a single root field.|🔮||✅
|
43
43
|
[overlapping-fields-can-be-merged](rules/overlapping-fields-can-be-merged.md)|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.|🔮||✅
|
44
44
|
[possible-fragment-spread](rules/possible-fragment-spread.md)|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.|🔮||✅
|
45
|
-
[possible-type-extension](rules/possible-type-extension.md)|A type extension is only valid if the type is defined and has the same kind
|
45
|
+
[possible-type-extension](rules/possible-type-extension.md)|A type extension is only valid if the type is defined and has the same kind.|🔮||
|
46
46
|
[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.|🔮||✅
|
47
47
|
[require-deprecation-date](rules/require-deprecation-date.md)|Require deletion date on `@deprecated` directive. Suggest removing deprecated things after deprecated date.|🚀||
|
48
48
|
[require-deprecation-reason](rules/require-deprecation-reason.md)|Require all deprecation directives to specify a reason.|🚀||✅
|
@@ -14,7 +14,7 @@ Require names to follow specified conventions.
|
|
14
14
|
### Incorrect
|
15
15
|
|
16
16
|
```graphql
|
17
|
-
# eslint @graphql-eslint/naming-convention: ['error', { types: 'PascalCase',
|
17
|
+
# eslint @graphql-eslint/naming-convention: ['error', { types: 'PascalCase', FieldDefinition: 'camelCase' }]
|
18
18
|
|
19
19
|
type user {
|
20
20
|
first_name: String!
|
@@ -44,7 +44,7 @@ type Query {
|
|
44
44
|
### Correct
|
45
45
|
|
46
46
|
```graphql
|
47
|
-
# eslint @graphql-eslint/naming-convention: ['error', { types: 'PascalCase',
|
47
|
+
# eslint @graphql-eslint/naming-convention: ['error', { types: 'PascalCase', FieldDefinition: 'camelCase' }]
|
48
48
|
|
49
49
|
type User {
|
50
50
|
firstName: String
|
@@ -97,20 +97,6 @@ The object must be one of the following types:
|
|
97
97
|
* `asString`
|
98
98
|
* `asObject`
|
99
99
|
|
100
|
-
### `fields`
|
101
|
-
|
102
|
-
Includes:
|
103
|
-
|
104
|
-
- `FieldDefinition`
|
105
|
-
- `InputValueDefinition`
|
106
|
-
- `Argument`
|
107
|
-
- `DirectiveDefinition`
|
108
|
-
|
109
|
-
The object must be one of the following types:
|
110
|
-
|
111
|
-
* `asString`
|
112
|
-
* `asObject`
|
113
|
-
|
114
100
|
### `Argument`
|
115
101
|
|
116
102
|
Read more about this kind on [spec.graphql.org](https://spec.graphql.org/October2021/#Argument).
|
@@ -1,7 +1,5 @@
|
|
1
1
|
# `possible-type-extension`
|
2
2
|
|
3
|
-
✅ The `"extends": "plugin:@graphql-eslint/schema-recommended"` property in a configuration file enables this rule.
|
4
|
-
|
5
3
|
- Category: `Schema`
|
6
4
|
- Rule name: `@graphql-eslint/possible-type-extension`
|
7
5
|
- Requires GraphQL Schema: `false` [ℹ️](../../README.md#extended-linting-rules-with-graphql-schema)
|
package/index.js
CHANGED
@@ -38,7 +38,10 @@ const schemaRecommendedConfig = {
|
|
38
38
|
'error',
|
39
39
|
{
|
40
40
|
types: 'PascalCase',
|
41
|
-
|
41
|
+
FieldDefinition: 'camelCase',
|
42
|
+
InputValueDefinition: 'camelCase',
|
43
|
+
Argument: 'camelCase',
|
44
|
+
DirectiveDefinition: 'camelCase',
|
42
45
|
EnumValueDefinition: 'UPPER_CASE',
|
43
46
|
'FieldDefinition[parent.name.value=Query]': {
|
44
47
|
forbiddenPrefixes: ['query', 'get'],
|
@@ -58,7 +61,6 @@ const schemaRecommendedConfig = {
|
|
58
61
|
'@graphql-eslint/no-hashtag-description': 'error',
|
59
62
|
'@graphql-eslint/no-typename-prefix': 'error',
|
60
63
|
'@graphql-eslint/no-unreachable-types': 'error',
|
61
|
-
'@graphql-eslint/possible-type-extension': 'error',
|
62
64
|
'@graphql-eslint/provided-required-arguments': 'error',
|
63
65
|
'@graphql-eslint/require-deprecation-reason': 'error',
|
64
66
|
'@graphql-eslint/require-description': ['error', { types: true, DirectiveDefinition: true }],
|
@@ -90,6 +92,7 @@ const schemaAllConfig = {
|
|
90
92
|
'@graphql-eslint/no-root-type': 'off',
|
91
93
|
'@graphql-eslint/no-scalar-result-type-on-mutation': 'error',
|
92
94
|
'@graphql-eslint/no-unused-fields': 'off',
|
95
|
+
'@graphql-eslint/possible-type-extension': 'off',
|
93
96
|
'@graphql-eslint/require-deprecation-date': 'error',
|
94
97
|
'@graphql-eslint/require-field-of-type-query-in-mutation-result': 'error',
|
95
98
|
},
|
@@ -384,9 +387,9 @@ const validationToRule = (name, ruleName, docs, getDocumentNode) => {
|
|
384
387
|
[name]: {
|
385
388
|
meta: {
|
386
389
|
docs: {
|
390
|
+
recommended: true,
|
387
391
|
...docs,
|
388
392
|
graphQLJSRuleName: ruleName,
|
389
|
-
recommended: true,
|
390
393
|
requiresSchema,
|
391
394
|
url: `https://github.com/dotansimha/graphql-eslint/blob/master/docs/rules/${name}.md`,
|
392
395
|
description: `${docs.description}\n\n> This rule is a wrapper around a \`graphql-js\` validation function. [You can find its source code here](https://github.com/graphql/graphql-js/blob/main/src/validation/rules/${ruleName}Rule.ts).`,
|
@@ -562,6 +565,7 @@ const GRAPHQL_JS_VALIDATIONS = Object.assign({}, validationToRule('executable-de
|
|
562
565
|
category: 'Schema',
|
563
566
|
description: `A type extension is only valid if the type is defined and has the same kind.`,
|
564
567
|
requiresSchema: false,
|
568
|
+
recommended: false, // TODO: enable after https://github.com/dotansimha/graphql-eslint/issues/787 will be fixed
|
565
569
|
}), validationToRule('provided-required-arguments', 'ProvidedRequiredArguments', {
|
566
570
|
category: ['Schema', 'Operations'],
|
567
571
|
description: `A field or directive is only valid if all required (non-null without a default value) field arguments have been provided.`,
|
@@ -1247,7 +1251,6 @@ const rule$3 = {
|
|
1247
1251
|
},
|
1248
1252
|
};
|
1249
1253
|
|
1250
|
-
const FIELDS_KINDS = [graphql.Kind.FIELD_DEFINITION, graphql.Kind.INPUT_VALUE_DEFINITION, graphql.Kind.ARGUMENT, graphql.Kind.DIRECTIVE_DEFINITION];
|
1251
1254
|
const KindToDisplayName = {
|
1252
1255
|
// types
|
1253
1256
|
[graphql.Kind.OBJECT_TYPE_DEFINITION]: 'Type',
|
@@ -1289,7 +1292,7 @@ const rule$4 = {
|
|
1289
1292
|
examples: [
|
1290
1293
|
{
|
1291
1294
|
title: 'Incorrect',
|
1292
|
-
usage: [{ types: 'PascalCase',
|
1295
|
+
usage: [{ types: 'PascalCase', FieldDefinition: 'camelCase' }],
|
1293
1296
|
code: /* GraphQL */ `
|
1294
1297
|
type user {
|
1295
1298
|
first_name: String!
|
@@ -1316,7 +1319,7 @@ const rule$4 = {
|
|
1316
1319
|
},
|
1317
1320
|
{
|
1318
1321
|
title: 'Correct',
|
1319
|
-
usage: [{ types: 'PascalCase',
|
1322
|
+
usage: [{ types: 'PascalCase', FieldDefinition: 'camelCase' }],
|
1320
1323
|
code: /* GraphQL */ `
|
1321
1324
|
type User {
|
1322
1325
|
firstName: String
|
@@ -1346,7 +1349,10 @@ const rule$4 = {
|
|
1346
1349
|
schema: [
|
1347
1350
|
{
|
1348
1351
|
types: 'PascalCase',
|
1349
|
-
|
1352
|
+
FieldDefinition: 'camelCase',
|
1353
|
+
InputValueDefinition: 'camelCase',
|
1354
|
+
Argument: 'camelCase',
|
1355
|
+
DirectiveDefinition: 'camelCase',
|
1350
1356
|
EnumValueDefinition: 'UPPER_CASE',
|
1351
1357
|
'FieldDefinition[parent.name.value=Query]': {
|
1352
1358
|
forbiddenPrefixes: ['query', 'get'],
|
@@ -1417,10 +1423,6 @@ const rule$4 = {
|
|
1417
1423
|
...schemaOption$1,
|
1418
1424
|
description: `Includes:\n\n${TYPES_KINDS.map(kind => `- \`${kind}\``).join('\n')}`,
|
1419
1425
|
},
|
1420
|
-
fields: {
|
1421
|
-
...schemaOption$1,
|
1422
|
-
description: `Includes:\n\n${FIELDS_KINDS.map(kind => `- \`${kind}\``).join('\n')}`,
|
1423
|
-
},
|
1424
1426
|
...Object.fromEntries(ALLOWED_KINDS.map(kind => [
|
1425
1427
|
kind,
|
1426
1428
|
{
|
@@ -1452,12 +1454,9 @@ const rule$4 = {
|
|
1452
1454
|
},
|
1453
1455
|
create(context) {
|
1454
1456
|
const options = context.options[0] || {};
|
1455
|
-
const { allowLeadingUnderscore, allowTrailingUnderscore, types,
|
1457
|
+
const { allowLeadingUnderscore, allowTrailingUnderscore, types, ...restOptions } = options;
|
1456
1458
|
function normalisePropertyOption(kind) {
|
1457
|
-
|
1458
|
-
if (!style) {
|
1459
|
-
style = TYPES_KINDS.includes(kind) ? types : fields;
|
1460
|
-
}
|
1459
|
+
const style = restOptions[kind] || types;
|
1461
1460
|
return typeof style === 'object' ? style : { style };
|
1462
1461
|
}
|
1463
1462
|
const checkNode = (selector) => (node) => {
|
@@ -1520,7 +1519,7 @@ const rule$4 = {
|
|
1520
1519
|
if (!allowTrailingUnderscore) {
|
1521
1520
|
listeners['Name[value=/_$/]:matches([parent.kind!=Field], [parent.kind=Field][parent.alias])'] = checkUnderscore;
|
1522
1521
|
}
|
1523
|
-
const selectors = new Set([types && TYPES_KINDS,
|
1522
|
+
const selectors = new Set([types && TYPES_KINDS, Object.keys(restOptions)].flat().filter(Boolean));
|
1524
1523
|
for (const selector of selectors) {
|
1525
1524
|
listeners[selector] = checkNode(selector);
|
1526
1525
|
}
|
@@ -2698,13 +2697,11 @@ const rule$i = {
|
|
2698
2697
|
}
|
2699
2698
|
const selector = [
|
2700
2699
|
`:matches(${graphql.Kind.OBJECT_TYPE_DEFINITION}, ${graphql.Kind.OBJECT_TYPE_EXTENSION})[name.value=${mutationType.name}]`,
|
2701
|
-
|
2702
|
-
graphql.Kind.FIELD_DEFINITION,
|
2703
|
-
graphql.Kind.NAMED_TYPE,
|
2700
|
+
`> ${graphql.Kind.FIELD_DEFINITION} > .gqlType ${graphql.Kind.NAME}`,
|
2704
2701
|
].join(' ');
|
2705
2702
|
return {
|
2706
2703
|
[selector](node) {
|
2707
|
-
const typeName = node.
|
2704
|
+
const typeName = node.value;
|
2708
2705
|
const graphQLType = schema.getType(typeName);
|
2709
2706
|
if (graphql.isObjectType(graphQLType)) {
|
2710
2707
|
const { fields } = graphQLType.astNode;
|
@@ -2712,7 +2709,7 @@ const rule$i = {
|
|
2712
2709
|
if (!hasQueryType) {
|
2713
2710
|
context.report({
|
2714
2711
|
loc: getLocation(node.loc, typeName),
|
2715
|
-
message: `Mutation result type "${graphQLType.name}" must contain field of type "${queryType.name}"
|
2712
|
+
message: `Mutation result type "${graphQLType.name}" must contain field of type "${queryType.name}"`,
|
2716
2713
|
});
|
2717
2714
|
}
|
2718
2715
|
}
|
package/index.mjs
CHANGED
@@ -32,7 +32,10 @@ const schemaRecommendedConfig = {
|
|
32
32
|
'error',
|
33
33
|
{
|
34
34
|
types: 'PascalCase',
|
35
|
-
|
35
|
+
FieldDefinition: 'camelCase',
|
36
|
+
InputValueDefinition: 'camelCase',
|
37
|
+
Argument: 'camelCase',
|
38
|
+
DirectiveDefinition: 'camelCase',
|
36
39
|
EnumValueDefinition: 'UPPER_CASE',
|
37
40
|
'FieldDefinition[parent.name.value=Query]': {
|
38
41
|
forbiddenPrefixes: ['query', 'get'],
|
@@ -52,7 +55,6 @@ const schemaRecommendedConfig = {
|
|
52
55
|
'@graphql-eslint/no-hashtag-description': 'error',
|
53
56
|
'@graphql-eslint/no-typename-prefix': 'error',
|
54
57
|
'@graphql-eslint/no-unreachable-types': 'error',
|
55
|
-
'@graphql-eslint/possible-type-extension': 'error',
|
56
58
|
'@graphql-eslint/provided-required-arguments': 'error',
|
57
59
|
'@graphql-eslint/require-deprecation-reason': 'error',
|
58
60
|
'@graphql-eslint/require-description': ['error', { types: true, DirectiveDefinition: true }],
|
@@ -84,6 +86,7 @@ const schemaAllConfig = {
|
|
84
86
|
'@graphql-eslint/no-root-type': 'off',
|
85
87
|
'@graphql-eslint/no-scalar-result-type-on-mutation': 'error',
|
86
88
|
'@graphql-eslint/no-unused-fields': 'off',
|
89
|
+
'@graphql-eslint/possible-type-extension': 'off',
|
87
90
|
'@graphql-eslint/require-deprecation-date': 'error',
|
88
91
|
'@graphql-eslint/require-field-of-type-query-in-mutation-result': 'error',
|
89
92
|
},
|
@@ -378,9 +381,9 @@ const validationToRule = (name, ruleName, docs, getDocumentNode) => {
|
|
378
381
|
[name]: {
|
379
382
|
meta: {
|
380
383
|
docs: {
|
384
|
+
recommended: true,
|
381
385
|
...docs,
|
382
386
|
graphQLJSRuleName: ruleName,
|
383
|
-
recommended: true,
|
384
387
|
requiresSchema,
|
385
388
|
url: `https://github.com/dotansimha/graphql-eslint/blob/master/docs/rules/${name}.md`,
|
386
389
|
description: `${docs.description}\n\n> This rule is a wrapper around a \`graphql-js\` validation function. [You can find its source code here](https://github.com/graphql/graphql-js/blob/main/src/validation/rules/${ruleName}Rule.ts).`,
|
@@ -556,6 +559,7 @@ const GRAPHQL_JS_VALIDATIONS = Object.assign({}, validationToRule('executable-de
|
|
556
559
|
category: 'Schema',
|
557
560
|
description: `A type extension is only valid if the type is defined and has the same kind.`,
|
558
561
|
requiresSchema: false,
|
562
|
+
recommended: false, // TODO: enable after https://github.com/dotansimha/graphql-eslint/issues/787 will be fixed
|
559
563
|
}), validationToRule('provided-required-arguments', 'ProvidedRequiredArguments', {
|
560
564
|
category: ['Schema', 'Operations'],
|
561
565
|
description: `A field or directive is only valid if all required (non-null without a default value) field arguments have been provided.`,
|
@@ -1241,7 +1245,6 @@ const rule$3 = {
|
|
1241
1245
|
},
|
1242
1246
|
};
|
1243
1247
|
|
1244
|
-
const FIELDS_KINDS = [Kind.FIELD_DEFINITION, Kind.INPUT_VALUE_DEFINITION, Kind.ARGUMENT, Kind.DIRECTIVE_DEFINITION];
|
1245
1248
|
const KindToDisplayName = {
|
1246
1249
|
// types
|
1247
1250
|
[Kind.OBJECT_TYPE_DEFINITION]: 'Type',
|
@@ -1283,7 +1286,7 @@ const rule$4 = {
|
|
1283
1286
|
examples: [
|
1284
1287
|
{
|
1285
1288
|
title: 'Incorrect',
|
1286
|
-
usage: [{ types: 'PascalCase',
|
1289
|
+
usage: [{ types: 'PascalCase', FieldDefinition: 'camelCase' }],
|
1287
1290
|
code: /* GraphQL */ `
|
1288
1291
|
type user {
|
1289
1292
|
first_name: String!
|
@@ -1310,7 +1313,7 @@ const rule$4 = {
|
|
1310
1313
|
},
|
1311
1314
|
{
|
1312
1315
|
title: 'Correct',
|
1313
|
-
usage: [{ types: 'PascalCase',
|
1316
|
+
usage: [{ types: 'PascalCase', FieldDefinition: 'camelCase' }],
|
1314
1317
|
code: /* GraphQL */ `
|
1315
1318
|
type User {
|
1316
1319
|
firstName: String
|
@@ -1340,7 +1343,10 @@ const rule$4 = {
|
|
1340
1343
|
schema: [
|
1341
1344
|
{
|
1342
1345
|
types: 'PascalCase',
|
1343
|
-
|
1346
|
+
FieldDefinition: 'camelCase',
|
1347
|
+
InputValueDefinition: 'camelCase',
|
1348
|
+
Argument: 'camelCase',
|
1349
|
+
DirectiveDefinition: 'camelCase',
|
1344
1350
|
EnumValueDefinition: 'UPPER_CASE',
|
1345
1351
|
'FieldDefinition[parent.name.value=Query]': {
|
1346
1352
|
forbiddenPrefixes: ['query', 'get'],
|
@@ -1411,10 +1417,6 @@ const rule$4 = {
|
|
1411
1417
|
...schemaOption$1,
|
1412
1418
|
description: `Includes:\n\n${TYPES_KINDS.map(kind => `- \`${kind}\``).join('\n')}`,
|
1413
1419
|
},
|
1414
|
-
fields: {
|
1415
|
-
...schemaOption$1,
|
1416
|
-
description: `Includes:\n\n${FIELDS_KINDS.map(kind => `- \`${kind}\``).join('\n')}`,
|
1417
|
-
},
|
1418
1420
|
...Object.fromEntries(ALLOWED_KINDS.map(kind => [
|
1419
1421
|
kind,
|
1420
1422
|
{
|
@@ -1446,12 +1448,9 @@ const rule$4 = {
|
|
1446
1448
|
},
|
1447
1449
|
create(context) {
|
1448
1450
|
const options = context.options[0] || {};
|
1449
|
-
const { allowLeadingUnderscore, allowTrailingUnderscore, types,
|
1451
|
+
const { allowLeadingUnderscore, allowTrailingUnderscore, types, ...restOptions } = options;
|
1450
1452
|
function normalisePropertyOption(kind) {
|
1451
|
-
|
1452
|
-
if (!style) {
|
1453
|
-
style = TYPES_KINDS.includes(kind) ? types : fields;
|
1454
|
-
}
|
1453
|
+
const style = restOptions[kind] || types;
|
1455
1454
|
return typeof style === 'object' ? style : { style };
|
1456
1455
|
}
|
1457
1456
|
const checkNode = (selector) => (node) => {
|
@@ -1514,7 +1513,7 @@ const rule$4 = {
|
|
1514
1513
|
if (!allowTrailingUnderscore) {
|
1515
1514
|
listeners['Name[value=/_$/]:matches([parent.kind!=Field], [parent.kind=Field][parent.alias])'] = checkUnderscore;
|
1516
1515
|
}
|
1517
|
-
const selectors = new Set([types && TYPES_KINDS,
|
1516
|
+
const selectors = new Set([types && TYPES_KINDS, Object.keys(restOptions)].flat().filter(Boolean));
|
1518
1517
|
for (const selector of selectors) {
|
1519
1518
|
listeners[selector] = checkNode(selector);
|
1520
1519
|
}
|
@@ -2692,13 +2691,11 @@ const rule$i = {
|
|
2692
2691
|
}
|
2693
2692
|
const selector = [
|
2694
2693
|
`:matches(${Kind.OBJECT_TYPE_DEFINITION}, ${Kind.OBJECT_TYPE_EXTENSION})[name.value=${mutationType.name}]`,
|
2695
|
-
|
2696
|
-
Kind.FIELD_DEFINITION,
|
2697
|
-
Kind.NAMED_TYPE,
|
2694
|
+
`> ${Kind.FIELD_DEFINITION} > .gqlType ${Kind.NAME}`,
|
2698
2695
|
].join(' ');
|
2699
2696
|
return {
|
2700
2697
|
[selector](node) {
|
2701
|
-
const typeName = node.
|
2698
|
+
const typeName = node.value;
|
2702
2699
|
const graphQLType = schema.getType(typeName);
|
2703
2700
|
if (isObjectType$1(graphQLType)) {
|
2704
2701
|
const { fields } = graphQLType.astNode;
|
@@ -2706,7 +2703,7 @@ const rule$i = {
|
|
2706
2703
|
if (!hasQueryType) {
|
2707
2704
|
context.report({
|
2708
2705
|
loc: getLocation(node.loc, typeName),
|
2709
|
-
message: `Mutation result type "${graphQLType.name}" must contain field of type "${queryType.name}"
|
2706
|
+
message: `Mutation result type "${graphQLType.name}" must contain field of type "${queryType.name}"`,
|
2710
2707
|
});
|
2711
2708
|
}
|
2712
2709
|
}
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@graphql-eslint/eslint-plugin",
|
3
|
-
"version": "3.0.
|
3
|
+
"version": "3.0.1-alpha-86a9e78.0",
|
4
4
|
"sideEffects": false,
|
5
5
|
"peerDependencies": {
|
6
6
|
"graphql": "^0.8.0 || ^0.9.0 || ^0.10.0 || ^0.11.0 || ^0.12.0 || ^0.13.0 || ^14.0.0 || ^15.0.0 || ^16.0.0"
|
package/rules/index.d.ts
CHANGED
@@ -44,13 +44,6 @@ export declare const rules: {
|
|
44
44
|
forbiddenPrefixes?: string[];
|
45
45
|
forbiddenSuffixes?: string[];
|
46
46
|
};
|
47
|
-
fields?: ("PascalCase" | "camelCase" | "UPPER_CASE" | "snake_case") | {
|
48
|
-
style?: "PascalCase" | "camelCase" | "UPPER_CASE" | "snake_case";
|
49
|
-
suffix?: string;
|
50
|
-
prefix?: string;
|
51
|
-
forbiddenPrefixes?: string[];
|
52
|
-
forbiddenSuffixes?: string[];
|
53
|
-
};
|
54
47
|
} & {
|
55
48
|
[x: `OperationDefinition${string}`]: ("PascalCase" | "camelCase" | "UPPER_CASE" | "snake_case") | {
|
56
49
|
style?: "PascalCase" | "camelCase" | "UPPER_CASE" | "snake_case";
|