@graphql-eslint/eslint-plugin 3.0.0-alpha-2918431.0 → 3.0.0-alpha-4613dfe.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/configs/index.d.ts +4 -4
- package/configs/schema-all.d.ts +0 -4
- package/configs/schema-recommended.d.ts +4 -0
- package/docs/README.md +1 -1
- package/docs/rules/naming-convention.md +48 -8
- package/docs/rules/require-description.md +2 -0
- package/index.js +46 -9
- package/index.mjs +46 -9
- package/package.json +1 -1
package/README.md
CHANGED
@@ -187,7 +187,7 @@ You can find a complete list of [all available rules here](docs/README.md).
|
|
187
187
|
|:-:|-|
|
188
188
|
|[`schema-recommended`](packages/plugin/src/configs/schema-recommended.ts)|enables all recommended rules|
|
189
189
|
|[`operations-recommended`](packages/plugin/src/configs/operations-recommended.ts) |enables all recommended rules|
|
190
|
-
|[`schema-all`](packages/plugin/src/configs/schema-all.ts)|enables all rules
|
190
|
+
|[`schema-all`](packages/plugin/src/configs/schema-all.ts)|enables all rules, except for those that require `parserOptions.operations` option)|
|
191
191
|
|[`operations-all`](packages/plugin/src/configs/operations-all.ts)|enables all rules|
|
192
192
|
<!-- prettier-ignore-end -->
|
193
193
|
|
package/configs/index.d.ts
CHANGED
@@ -35,6 +35,10 @@ export declare const configs: {
|
|
35
35
|
'@graphql-eslint/possible-type-extension': string;
|
36
36
|
'@graphql-eslint/provided-required-arguments': string;
|
37
37
|
'@graphql-eslint/require-deprecation-reason': string;
|
38
|
+
'@graphql-eslint/require-description': (string | {
|
39
|
+
types: boolean;
|
40
|
+
DirectiveDefinition: boolean;
|
41
|
+
})[];
|
38
42
|
'@graphql-eslint/strict-id-in-types': string;
|
39
43
|
'@graphql-eslint/unique-directive-names': string;
|
40
44
|
'@graphql-eslint/unique-directive-names-per-location': string;
|
@@ -57,10 +61,6 @@ export declare const configs: {
|
|
57
61
|
'@graphql-eslint/no-scalar-result-type-on-mutation': string;
|
58
62
|
'@graphql-eslint/no-unused-fields': string;
|
59
63
|
'@graphql-eslint/require-deprecation-date': string;
|
60
|
-
'@graphql-eslint/require-description': (string | {
|
61
|
-
types: boolean;
|
62
|
-
DirectiveDefinition: boolean;
|
63
|
-
})[];
|
64
64
|
'@graphql-eslint/require-field-of-type-query-in-mutation-result': string;
|
65
65
|
};
|
66
66
|
};
|
package/configs/schema-all.d.ts
CHANGED
@@ -11,10 +11,6 @@ declare const _default: {
|
|
11
11
|
'@graphql-eslint/no-scalar-result-type-on-mutation': string;
|
12
12
|
'@graphql-eslint/no-unused-fields': string;
|
13
13
|
'@graphql-eslint/require-deprecation-date': string;
|
14
|
-
'@graphql-eslint/require-description': (string | {
|
15
|
-
types: boolean;
|
16
|
-
DirectiveDefinition: boolean;
|
17
|
-
})[];
|
18
14
|
'@graphql-eslint/require-field-of-type-query-in-mutation-result': string;
|
19
15
|
};
|
20
16
|
};
|
@@ -30,6 +30,10 @@ declare const _default: {
|
|
30
30
|
'@graphql-eslint/possible-type-extension': string;
|
31
31
|
'@graphql-eslint/provided-required-arguments': string;
|
32
32
|
'@graphql-eslint/require-deprecation-reason': string;
|
33
|
+
'@graphql-eslint/require-description': (string | {
|
34
|
+
types: boolean;
|
35
|
+
DirectiveDefinition: boolean;
|
36
|
+
})[];
|
33
37
|
'@graphql-eslint/strict-id-in-types': string;
|
34
38
|
'@graphql-eslint/unique-directive-names': string;
|
35
39
|
'@graphql-eslint/unique-directive-names-per-location': string;
|
package/docs/README.md
CHANGED
@@ -46,7 +46,7 @@ Name &nbs
|
|
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.|🚀||✅
|
49
|
-
[require-description](rules/require-description.md)|Enforce descriptions in your type definitions
|
49
|
+
[require-description](rules/require-description.md)|Enforce descriptions in your type definitions.|🚀||✅
|
50
50
|
[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.|🚀||
|
51
51
|
[require-id-when-available](rules/require-id-when-available.md)|Enforce selecting specific fields when they are available on the GraphQL type.|🚀||✅
|
52
52
|
[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.|🔮||✅
|
@@ -21,6 +21,26 @@ type user {
|
|
21
21
|
}
|
22
22
|
```
|
23
23
|
|
24
|
+
### Incorrect
|
25
|
+
|
26
|
+
```graphql
|
27
|
+
# eslint @graphql-eslint/naming-convention: ['error', { FragmentDefinition: { style: 'PascalCase', forbiddenSuffixes: ['Fragment'] } }]
|
28
|
+
|
29
|
+
fragment UserFragment on User {
|
30
|
+
# ...
|
31
|
+
}
|
32
|
+
```
|
33
|
+
|
34
|
+
### Incorrect
|
35
|
+
|
36
|
+
```graphql
|
37
|
+
# eslint @graphql-eslint/naming-convention: ['error', { 'FieldDefinition[parent.name.value=Query]': { forbiddenPrefixes: ['get'] } }]
|
38
|
+
|
39
|
+
type Query {
|
40
|
+
getUsers: [User!]!
|
41
|
+
}
|
42
|
+
```
|
43
|
+
|
24
44
|
### Correct
|
25
45
|
|
26
46
|
```graphql
|
@@ -31,6 +51,26 @@ type User {
|
|
31
51
|
}
|
32
52
|
```
|
33
53
|
|
54
|
+
### Correct
|
55
|
+
|
56
|
+
```graphql
|
57
|
+
# eslint @graphql-eslint/naming-convention: ['error', { FragmentDefinition: { style: 'PascalCase', forbiddenSuffixes: ['Fragment'] } }]
|
58
|
+
|
59
|
+
fragment UserFields on User {
|
60
|
+
# ...
|
61
|
+
}
|
62
|
+
```
|
63
|
+
|
64
|
+
### Correct
|
65
|
+
|
66
|
+
```graphql
|
67
|
+
# eslint @graphql-eslint/naming-convention: ['error', { 'FieldDefinition[parent.name.value=Query]': { forbiddenPrefixes: ['get'] } }]
|
68
|
+
|
69
|
+
type Query {
|
70
|
+
users: [User!]!
|
71
|
+
}
|
72
|
+
```
|
73
|
+
|
34
74
|
## Config Schema
|
35
75
|
|
36
76
|
> It's possible to use a [`selector`](https://eslint.org/docs/developer-guide/selectors) that starts with allowed `ASTNode` names which are described below.
|
@@ -41,14 +81,6 @@ type User {
|
|
41
81
|
|
42
82
|
The schema defines the following properties:
|
43
83
|
|
44
|
-
### `allowLeadingUnderscore` (boolean)
|
45
|
-
|
46
|
-
Default: `false`
|
47
|
-
|
48
|
-
### `allowTrailingUnderscore` (boolean)
|
49
|
-
|
50
|
-
Default: `false`
|
51
|
-
|
52
84
|
### `types`
|
53
85
|
|
54
86
|
Includes:
|
@@ -205,6 +237,14 @@ The object must be one of the following types:
|
|
205
237
|
* `asString`
|
206
238
|
* `asObject`
|
207
239
|
|
240
|
+
### `allowLeadingUnderscore` (boolean)
|
241
|
+
|
242
|
+
Default: `false`
|
243
|
+
|
244
|
+
### `allowTrailingUnderscore` (boolean)
|
245
|
+
|
246
|
+
Default: `false`
|
247
|
+
|
208
248
|
---
|
209
249
|
|
210
250
|
# Sub Schemas
|
@@ -1,5 +1,7 @@
|
|
1
1
|
# `require-description`
|
2
2
|
|
3
|
+
✅ The `"extends": "plugin:@graphql-eslint/schema-recommended"` property in a configuration file enables this rule.
|
4
|
+
|
3
5
|
- Category: `Schema`
|
4
6
|
- Rule name: `@graphql-eslint/require-description`
|
5
7
|
- Requires GraphQL Schema: `false` [ℹ️](../../README.md#extended-linting-rules-with-graphql-schema)
|
package/index.js
CHANGED
@@ -61,6 +61,7 @@ const schemaRecommendedConfig = {
|
|
61
61
|
'@graphql-eslint/possible-type-extension': 'error',
|
62
62
|
'@graphql-eslint/provided-required-arguments': 'error',
|
63
63
|
'@graphql-eslint/require-deprecation-reason': 'error',
|
64
|
+
'@graphql-eslint/require-description': ['error', { types: true, DirectiveDefinition: true }],
|
64
65
|
'@graphql-eslint/strict-id-in-types': 'error',
|
65
66
|
'@graphql-eslint/unique-directive-names': 'error',
|
66
67
|
'@graphql-eslint/unique-directive-names-per-location': 'error',
|
@@ -90,7 +91,6 @@ const schemaAllConfig = {
|
|
90
91
|
'@graphql-eslint/no-scalar-result-type-on-mutation': 'error',
|
91
92
|
'@graphql-eslint/no-unused-fields': 'off',
|
92
93
|
'@graphql-eslint/require-deprecation-date': 'error',
|
93
|
-
'@graphql-eslint/require-description': ['error', { types: true, DirectiveDefinition: true }],
|
94
94
|
'@graphql-eslint/require-field-of-type-query-in-mutation-result': 'error',
|
95
95
|
},
|
96
96
|
};
|
@@ -1295,6 +1295,24 @@ const rule$4 = {
|
|
1295
1295
|
type user {
|
1296
1296
|
first_name: String!
|
1297
1297
|
}
|
1298
|
+
`,
|
1299
|
+
},
|
1300
|
+
{
|
1301
|
+
title: 'Incorrect',
|
1302
|
+
usage: [{ FragmentDefinition: { style: 'PascalCase', forbiddenSuffixes: ['Fragment'] } }],
|
1303
|
+
code: /* GraphQL */ `
|
1304
|
+
fragment UserFragment on User {
|
1305
|
+
# ...
|
1306
|
+
}
|
1307
|
+
`,
|
1308
|
+
},
|
1309
|
+
{
|
1310
|
+
title: 'Incorrect',
|
1311
|
+
usage: [{ 'FieldDefinition[parent.name.value=Query]': { forbiddenPrefixes: ['get'] } }],
|
1312
|
+
code: /* GraphQL */ `
|
1313
|
+
type Query {
|
1314
|
+
getUsers: [User!]!
|
1315
|
+
}
|
1298
1316
|
`,
|
1299
1317
|
},
|
1300
1318
|
{
|
@@ -1304,6 +1322,24 @@ const rule$4 = {
|
|
1304
1322
|
type User {
|
1305
1323
|
firstName: String
|
1306
1324
|
}
|
1325
|
+
`,
|
1326
|
+
},
|
1327
|
+
{
|
1328
|
+
title: 'Correct',
|
1329
|
+
usage: [{ FragmentDefinition: { style: 'PascalCase', forbiddenSuffixes: ['Fragment'] } }],
|
1330
|
+
code: /* GraphQL */ `
|
1331
|
+
fragment UserFields on User {
|
1332
|
+
# ...
|
1333
|
+
}
|
1334
|
+
`,
|
1335
|
+
},
|
1336
|
+
{
|
1337
|
+
title: 'Correct',
|
1338
|
+
usage: [{ 'FieldDefinition[parent.name.value=Query]': { forbiddenPrefixes: ['get'] } }],
|
1339
|
+
code: /* GraphQL */ `
|
1340
|
+
type Query {
|
1341
|
+
users: [User!]!
|
1342
|
+
}
|
1307
1343
|
`,
|
1308
1344
|
},
|
1309
1345
|
],
|
@@ -1379,14 +1415,6 @@ const rule$4 = {
|
|
1379
1415
|
type: 'object',
|
1380
1416
|
additionalProperties: false,
|
1381
1417
|
properties: {
|
1382
|
-
allowLeadingUnderscore: {
|
1383
|
-
type: 'boolean',
|
1384
|
-
default: false,
|
1385
|
-
},
|
1386
|
-
allowTrailingUnderscore: {
|
1387
|
-
type: 'boolean',
|
1388
|
-
default: false,
|
1389
|
-
},
|
1390
1418
|
types: {
|
1391
1419
|
...schemaOption$1,
|
1392
1420
|
description: `Includes:\n\n${TYPES_KINDS.map(kind => `- \`${kind}\``).join('\n')}`,
|
@@ -1402,6 +1430,14 @@ const rule$4 = {
|
|
1402
1430
|
description: `Read more about this kind on [spec.graphql.org](https://spec.graphql.org/October2021/#${kind}).`,
|
1403
1431
|
},
|
1404
1432
|
])),
|
1433
|
+
allowLeadingUnderscore: {
|
1434
|
+
type: 'boolean',
|
1435
|
+
default: false,
|
1436
|
+
},
|
1437
|
+
allowTrailingUnderscore: {
|
1438
|
+
type: 'boolean',
|
1439
|
+
default: false,
|
1440
|
+
},
|
1405
1441
|
},
|
1406
1442
|
patternProperties: {
|
1407
1443
|
[`^(${ALLOWED_KINDS.join('|')})(.+)?$`]: schemaOption$1,
|
@@ -2554,6 +2590,7 @@ const rule$h = {
|
|
2554
2590
|
[graphql.Kind.DIRECTIVE_DEFINITION]: true,
|
2555
2591
|
},
|
2556
2592
|
],
|
2593
|
+
recommended: true,
|
2557
2594
|
},
|
2558
2595
|
type: 'suggestion',
|
2559
2596
|
messages: {
|
package/index.mjs
CHANGED
@@ -55,6 +55,7 @@ const schemaRecommendedConfig = {
|
|
55
55
|
'@graphql-eslint/possible-type-extension': 'error',
|
56
56
|
'@graphql-eslint/provided-required-arguments': 'error',
|
57
57
|
'@graphql-eslint/require-deprecation-reason': 'error',
|
58
|
+
'@graphql-eslint/require-description': ['error', { types: true, DirectiveDefinition: true }],
|
58
59
|
'@graphql-eslint/strict-id-in-types': 'error',
|
59
60
|
'@graphql-eslint/unique-directive-names': 'error',
|
60
61
|
'@graphql-eslint/unique-directive-names-per-location': 'error',
|
@@ -84,7 +85,6 @@ const schemaAllConfig = {
|
|
84
85
|
'@graphql-eslint/no-scalar-result-type-on-mutation': 'error',
|
85
86
|
'@graphql-eslint/no-unused-fields': 'off',
|
86
87
|
'@graphql-eslint/require-deprecation-date': 'error',
|
87
|
-
'@graphql-eslint/require-description': ['error', { types: true, DirectiveDefinition: true }],
|
88
88
|
'@graphql-eslint/require-field-of-type-query-in-mutation-result': 'error',
|
89
89
|
},
|
90
90
|
};
|
@@ -1289,6 +1289,24 @@ const rule$4 = {
|
|
1289
1289
|
type user {
|
1290
1290
|
first_name: String!
|
1291
1291
|
}
|
1292
|
+
`,
|
1293
|
+
},
|
1294
|
+
{
|
1295
|
+
title: 'Incorrect',
|
1296
|
+
usage: [{ FragmentDefinition: { style: 'PascalCase', forbiddenSuffixes: ['Fragment'] } }],
|
1297
|
+
code: /* GraphQL */ `
|
1298
|
+
fragment UserFragment on User {
|
1299
|
+
# ...
|
1300
|
+
}
|
1301
|
+
`,
|
1302
|
+
},
|
1303
|
+
{
|
1304
|
+
title: 'Incorrect',
|
1305
|
+
usage: [{ 'FieldDefinition[parent.name.value=Query]': { forbiddenPrefixes: ['get'] } }],
|
1306
|
+
code: /* GraphQL */ `
|
1307
|
+
type Query {
|
1308
|
+
getUsers: [User!]!
|
1309
|
+
}
|
1292
1310
|
`,
|
1293
1311
|
},
|
1294
1312
|
{
|
@@ -1298,6 +1316,24 @@ const rule$4 = {
|
|
1298
1316
|
type User {
|
1299
1317
|
firstName: String
|
1300
1318
|
}
|
1319
|
+
`,
|
1320
|
+
},
|
1321
|
+
{
|
1322
|
+
title: 'Correct',
|
1323
|
+
usage: [{ FragmentDefinition: { style: 'PascalCase', forbiddenSuffixes: ['Fragment'] } }],
|
1324
|
+
code: /* GraphQL */ `
|
1325
|
+
fragment UserFields on User {
|
1326
|
+
# ...
|
1327
|
+
}
|
1328
|
+
`,
|
1329
|
+
},
|
1330
|
+
{
|
1331
|
+
title: 'Correct',
|
1332
|
+
usage: [{ 'FieldDefinition[parent.name.value=Query]': { forbiddenPrefixes: ['get'] } }],
|
1333
|
+
code: /* GraphQL */ `
|
1334
|
+
type Query {
|
1335
|
+
users: [User!]!
|
1336
|
+
}
|
1301
1337
|
`,
|
1302
1338
|
},
|
1303
1339
|
],
|
@@ -1373,14 +1409,6 @@ const rule$4 = {
|
|
1373
1409
|
type: 'object',
|
1374
1410
|
additionalProperties: false,
|
1375
1411
|
properties: {
|
1376
|
-
allowLeadingUnderscore: {
|
1377
|
-
type: 'boolean',
|
1378
|
-
default: false,
|
1379
|
-
},
|
1380
|
-
allowTrailingUnderscore: {
|
1381
|
-
type: 'boolean',
|
1382
|
-
default: false,
|
1383
|
-
},
|
1384
1412
|
types: {
|
1385
1413
|
...schemaOption$1,
|
1386
1414
|
description: `Includes:\n\n${TYPES_KINDS.map(kind => `- \`${kind}\``).join('\n')}`,
|
@@ -1396,6 +1424,14 @@ const rule$4 = {
|
|
1396
1424
|
description: `Read more about this kind on [spec.graphql.org](https://spec.graphql.org/October2021/#${kind}).`,
|
1397
1425
|
},
|
1398
1426
|
])),
|
1427
|
+
allowLeadingUnderscore: {
|
1428
|
+
type: 'boolean',
|
1429
|
+
default: false,
|
1430
|
+
},
|
1431
|
+
allowTrailingUnderscore: {
|
1432
|
+
type: 'boolean',
|
1433
|
+
default: false,
|
1434
|
+
},
|
1399
1435
|
},
|
1400
1436
|
patternProperties: {
|
1401
1437
|
[`^(${ALLOWED_KINDS.join('|')})(.+)?$`]: schemaOption$1,
|
@@ -2548,6 +2584,7 @@ const rule$h = {
|
|
2548
2584
|
[Kind.DIRECTIVE_DEFINITION]: true,
|
2549
2585
|
},
|
2550
2586
|
],
|
2587
|
+
recommended: true,
|
2551
2588
|
},
|
2552
2589
|
type: 'suggestion',
|
2553
2590
|
messages: {
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@graphql-eslint/eslint-plugin",
|
3
|
-
"version": "3.0.0-alpha-
|
3
|
+
"version": "3.0.0-alpha-4613dfe.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"
|