@graphql-eslint/eslint-plugin 2.5.0-alpha-14532ce.0 â 2.5.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/configs/all.d.ts +3 -0
- package/configs/index.d.ts +3 -0
- package/docs/README.md +1 -0
- package/docs/rules/no-deprecated.md +2 -2
- package/docs/rules/no-root-type.md +56 -0
- package/index.js +115 -22
- package/index.mjs +115 -22
- package/package.json +1 -1
- package/rules/index.d.ts +3 -0
- package/rules/no-root-type.d.ts +7 -0
- package/testkit.d.ts +1 -1
package/configs/all.d.ts
CHANGED
@@ -15,6 +15,9 @@ export declare const allConfig: {
|
|
15
15
|
'@graphql-eslint/match-document-filename': string;
|
16
16
|
'@graphql-eslint/no-deprecated': string;
|
17
17
|
'@graphql-eslint/no-hashtag-description': string;
|
18
|
+
'@graphql-eslint/no-root-type': (string | {
|
19
|
+
disallow: string[];
|
20
|
+
})[];
|
18
21
|
'@graphql-eslint/no-unreachable-types': string;
|
19
22
|
'@graphql-eslint/no-unused-fields': string;
|
20
23
|
'@graphql-eslint/require-deprecation-date': string;
|
package/configs/index.d.ts
CHANGED
@@ -16,6 +16,9 @@ export declare const configs: {
|
|
16
16
|
'@graphql-eslint/match-document-filename': string;
|
17
17
|
'@graphql-eslint/no-deprecated': string;
|
18
18
|
'@graphql-eslint/no-hashtag-description': string;
|
19
|
+
'@graphql-eslint/no-root-type': (string | {
|
20
|
+
disallow: string[];
|
21
|
+
})[];
|
19
22
|
'@graphql-eslint/no-unreachable-types': string;
|
20
23
|
'@graphql-eslint/no-unused-fields': string;
|
21
24
|
'@graphql-eslint/require-deprecation-date': string;
|
package/docs/README.md
CHANGED
@@ -35,6 +35,7 @@ Name &nbs
|
|
35
35
|
[no-fragment-cycles](rules/no-fragment-cycles.md)|A GraphQL fragment is only valid when it does not have cycles in fragments usage.|đŽ||â
|
36
36
|
[no-hashtag-description](rules/no-hashtag-description.md)|Requires to use `"""` or `"` for adding a GraphQL description instead of `#`.|đ||
|
37
37
|
[no-operation-name-suffix](rules/no-operation-name-suffix.md)|Makes sure you are not adding the operation type to the name of the operation.|đ|đ§|â
|
38
|
+
[no-root-type](rules/no-root-type.md)|Disallow using root types for `read-only` or `write-only` schemas.|đ||
|
38
39
|
[no-undefined-variables](rules/no-undefined-variables.md)|A GraphQL operation is only valid if all variables encountered, both directly and via fragment spreads, are defined by that operation.|đŽ||â
|
39
40
|
[no-unreachable-types](rules/no-unreachable-types.md)|Requires all types to be reachable at some level by root level fields.|đ|đ§|
|
40
41
|
[no-unused-fields](rules/no-unused-fields.md)|Requires all fields to be used at some level by siblings operations.|đ|đ§|
|
@@ -0,0 +1,56 @@
|
|
1
|
+
# `no-root-type`
|
2
|
+
|
3
|
+
- Category: `Validation`
|
4
|
+
- Rule name: `@graphql-eslint/no-root-type`
|
5
|
+
- Requires GraphQL Schema: `true` [âšī¸](../../README.md#extended-linting-rules-with-graphql-schema)
|
6
|
+
- Requires GraphQL Operations: `false` [âšī¸](../../README.md#extended-linting-rules-with-siblings-operations)
|
7
|
+
|
8
|
+
Disallow using root types for `read-only` or `write-only` schemas.
|
9
|
+
|
10
|
+
## Usage Examples
|
11
|
+
|
12
|
+
### Incorrect (`read-only` schema)
|
13
|
+
|
14
|
+
```graphql
|
15
|
+
# eslint @graphql-eslint/no-root-type: ['error', { disallow: ['mutation', 'subscription'] }]
|
16
|
+
|
17
|
+
type Mutation {
|
18
|
+
createUser(input: CreateUserInput!): User!
|
19
|
+
}
|
20
|
+
```
|
21
|
+
|
22
|
+
### Incorrect (`write-only` schema)
|
23
|
+
|
24
|
+
```graphql
|
25
|
+
# eslint @graphql-eslint/no-root-type: ['error', { disallow: ['query'] }]
|
26
|
+
|
27
|
+
type Query {
|
28
|
+
users: [User!]!
|
29
|
+
}
|
30
|
+
```
|
31
|
+
|
32
|
+
### Correct (`read-only` schema)
|
33
|
+
|
34
|
+
```graphql
|
35
|
+
# eslint @graphql-eslint/no-root-type: ['error', { disallow: ['mutation', 'subscription'] }]
|
36
|
+
|
37
|
+
type Query {
|
38
|
+
users: [User!]!
|
39
|
+
}
|
40
|
+
```
|
41
|
+
|
42
|
+
## Config Schema
|
43
|
+
|
44
|
+
The schema defines the following properties:
|
45
|
+
|
46
|
+
### `disallow` (array, required)
|
47
|
+
|
48
|
+
Additional restrictions:
|
49
|
+
|
50
|
+
* Minimum items: `1`
|
51
|
+
* Unique items: `true`
|
52
|
+
|
53
|
+
## Resources
|
54
|
+
|
55
|
+
- [Rule source](../../packages/plugin/src/rules/no-root-type.ts)
|
56
|
+
- [Test source](../../packages/plugin/tests/no-root-type.spec.ts)
|
package/index.js
CHANGED
@@ -91,6 +91,7 @@ const allConfig = {
|
|
91
91
|
'@graphql-eslint/match-document-filename': 'error',
|
92
92
|
'@graphql-eslint/no-deprecated': 'error',
|
93
93
|
'@graphql-eslint/no-hashtag-description': 'error',
|
94
|
+
'@graphql-eslint/no-root-type': ['error', { disallow: ['subscription'] }],
|
94
95
|
'@graphql-eslint/no-unreachable-types': 'error',
|
95
96
|
'@graphql-eslint/no-unused-fields': 'error',
|
96
97
|
'@graphql-eslint/require-deprecation-date': 'error',
|
@@ -2065,9 +2066,100 @@ const rule$d = {
|
|
2065
2066
|
},
|
2066
2067
|
};
|
2067
2068
|
|
2069
|
+
const ROOT_TYPES = ['query', 'mutation', 'subscription'];
|
2070
|
+
const rule$e = {
|
2071
|
+
meta: {
|
2072
|
+
type: 'suggestion',
|
2073
|
+
docs: {
|
2074
|
+
category: 'Validation',
|
2075
|
+
description: 'Disallow using root types for `read-only` or `write-only` schemas.',
|
2076
|
+
url: 'https://github.com/dotansimha/graphql-eslint/blob/master/docs/rules/no-root-type.md',
|
2077
|
+
requiresSchema: true,
|
2078
|
+
examples: [
|
2079
|
+
{
|
2080
|
+
title: 'Incorrect (`read-only` schema)',
|
2081
|
+
usage: [{ disallow: ['mutation', 'subscription'] }],
|
2082
|
+
code: /* GraphQL */ `
|
2083
|
+
type Mutation {
|
2084
|
+
createUser(input: CreateUserInput!): User!
|
2085
|
+
}
|
2086
|
+
`,
|
2087
|
+
},
|
2088
|
+
{
|
2089
|
+
title: 'Incorrect (`write-only` schema)',
|
2090
|
+
usage: [{ disallow: ['query'] }],
|
2091
|
+
code: /* GraphQL */ `
|
2092
|
+
type Query {
|
2093
|
+
users: [User!]!
|
2094
|
+
}
|
2095
|
+
`,
|
2096
|
+
},
|
2097
|
+
{
|
2098
|
+
title: 'Correct (`read-only` schema)',
|
2099
|
+
usage: [{ disallow: ['mutation', 'subscription'] }],
|
2100
|
+
code: /* GraphQL */ `
|
2101
|
+
type Query {
|
2102
|
+
users: [User!]!
|
2103
|
+
}
|
2104
|
+
`,
|
2105
|
+
},
|
2106
|
+
],
|
2107
|
+
optionsForConfig: [{ disallow: ['subscription'] }],
|
2108
|
+
},
|
2109
|
+
schema: {
|
2110
|
+
type: 'array',
|
2111
|
+
minItems: 1,
|
2112
|
+
maxItems: 1,
|
2113
|
+
items: {
|
2114
|
+
type: 'object',
|
2115
|
+
additionalProperties: false,
|
2116
|
+
required: ['disallow'],
|
2117
|
+
properties: {
|
2118
|
+
disallow: {
|
2119
|
+
type: 'array',
|
2120
|
+
uniqueItems: true,
|
2121
|
+
minItems: 1,
|
2122
|
+
items: {
|
2123
|
+
enum: ROOT_TYPES,
|
2124
|
+
},
|
2125
|
+
},
|
2126
|
+
},
|
2127
|
+
},
|
2128
|
+
},
|
2129
|
+
},
|
2130
|
+
create(context) {
|
2131
|
+
const schema = requireGraphQLSchemaFromContext('no-root-type', context);
|
2132
|
+
const disallow = new Set(context.options[0].disallow);
|
2133
|
+
const rootTypeNames = [
|
2134
|
+
disallow.has('query') && schema.getQueryType(),
|
2135
|
+
disallow.has('mutation') && schema.getMutationType(),
|
2136
|
+
disallow.has('subscription') && schema.getSubscriptionType(),
|
2137
|
+
]
|
2138
|
+
.filter(Boolean)
|
2139
|
+
.map(type => type.name);
|
2140
|
+
if (rootTypeNames.length === 0) {
|
2141
|
+
return {};
|
2142
|
+
}
|
2143
|
+
const selector = [
|
2144
|
+
`:matches(${graphql.Kind.OBJECT_TYPE_DEFINITION}, ${graphql.Kind.OBJECT_TYPE_EXTENSION})`,
|
2145
|
+
'>',
|
2146
|
+
`${graphql.Kind.NAME}[value=/^(${rootTypeNames.join('|')})$/]`,
|
2147
|
+
].join(' ');
|
2148
|
+
return {
|
2149
|
+
[selector](node) {
|
2150
|
+
const typeName = node.value;
|
2151
|
+
context.report({
|
2152
|
+
loc: getLocation(node.loc, typeName),
|
2153
|
+
message: `Root type "${typeName}" is forbidden`,
|
2154
|
+
});
|
2155
|
+
},
|
2156
|
+
};
|
2157
|
+
},
|
2158
|
+
};
|
2159
|
+
|
2068
2160
|
const UNREACHABLE_TYPE = 'UNREACHABLE_TYPE';
|
2069
2161
|
const RULE_NAME = 'no-unreachable-types';
|
2070
|
-
const rule$
|
2162
|
+
const rule$f = {
|
2071
2163
|
meta: {
|
2072
2164
|
messages: {
|
2073
2165
|
[UNREACHABLE_TYPE]: `Type "{{ typeName }}" is unreachable`,
|
@@ -2143,7 +2235,7 @@ const rule$e = {
|
|
2143
2235
|
|
2144
2236
|
const UNUSED_FIELD = 'UNUSED_FIELD';
|
2145
2237
|
const RULE_NAME$1 = 'no-unused-fields';
|
2146
|
-
const rule$
|
2238
|
+
const rule$g = {
|
2147
2239
|
meta: {
|
2148
2240
|
messages: {
|
2149
2241
|
[UNUSED_FIELD]: `Field "{{fieldName}}" is unused`,
|
@@ -2331,7 +2423,7 @@ const MESSAGE_REQUIRE_DATE = 'MESSAGE_REQUIRE_DATE';
|
|
2331
2423
|
const MESSAGE_INVALID_FORMAT = 'MESSAGE_INVALID_FORMAT';
|
2332
2424
|
const MESSAGE_INVALID_DATE = 'MESSAGE_INVALID_DATE';
|
2333
2425
|
const MESSAGE_CAN_BE_REMOVED = 'MESSAGE_CAN_BE_REMOVED';
|
2334
|
-
const rule$
|
2426
|
+
const rule$h = {
|
2335
2427
|
meta: {
|
2336
2428
|
type: 'suggestion',
|
2337
2429
|
docs: {
|
@@ -2434,7 +2526,7 @@ const rule$g = {
|
|
2434
2526
|
},
|
2435
2527
|
};
|
2436
2528
|
|
2437
|
-
const rule$
|
2529
|
+
const rule$i = {
|
2438
2530
|
meta: {
|
2439
2531
|
docs: {
|
2440
2532
|
description: `Require all deprecation directives to specify a reason.`,
|
@@ -2514,7 +2606,7 @@ function verifyRule(context, node) {
|
|
2514
2606
|
}
|
2515
2607
|
}
|
2516
2608
|
}
|
2517
|
-
const rule$
|
2609
|
+
const rule$j = {
|
2518
2610
|
meta: {
|
2519
2611
|
docs: {
|
2520
2612
|
category: 'Best Practices',
|
@@ -2579,7 +2671,7 @@ const rule$i = {
|
|
2579
2671
|
};
|
2580
2672
|
|
2581
2673
|
const RULE_NAME$2 = 'require-field-of-type-query-in-mutation-result';
|
2582
|
-
const rule$
|
2674
|
+
const rule$k = {
|
2583
2675
|
meta: {
|
2584
2676
|
type: 'suggestion',
|
2585
2677
|
docs: {
|
@@ -2747,7 +2839,7 @@ const convertNode = (typeInfo) => (node, key, parent) => {
|
|
2747
2839
|
|
2748
2840
|
const REQUIRE_ID_WHEN_AVAILABLE = 'REQUIRE_ID_WHEN_AVAILABLE';
|
2749
2841
|
const DEFAULT_ID_FIELD_NAME = 'id';
|
2750
|
-
const rule$
|
2842
|
+
const rule$l = {
|
2751
2843
|
meta: {
|
2752
2844
|
type: 'suggestion',
|
2753
2845
|
docs: {
|
@@ -2883,7 +2975,7 @@ const rule$k = {
|
|
2883
2975
|
},
|
2884
2976
|
};
|
2885
2977
|
|
2886
|
-
const rule$
|
2978
|
+
const rule$m = {
|
2887
2979
|
meta: {
|
2888
2980
|
docs: {
|
2889
2981
|
category: 'Best Practices',
|
@@ -3005,7 +3097,7 @@ const shouldIgnoreNode = ({ node, exceptions }) => {
|
|
3005
3097
|
}
|
3006
3098
|
return false;
|
3007
3099
|
};
|
3008
|
-
const rule$
|
3100
|
+
const rule$n = {
|
3009
3101
|
meta: {
|
3010
3102
|
type: 'suggestion',
|
3011
3103
|
docs: {
|
@@ -3182,7 +3274,7 @@ const checkNode = (context, node, ruleName, messageId) => {
|
|
3182
3274
|
});
|
3183
3275
|
}
|
3184
3276
|
};
|
3185
|
-
const rule$
|
3277
|
+
const rule$o = {
|
3186
3278
|
meta: {
|
3187
3279
|
type: 'suggestion',
|
3188
3280
|
docs: {
|
@@ -3241,7 +3333,7 @@ const rule$n = {
|
|
3241
3333
|
|
3242
3334
|
const RULE_NAME$4 = 'unique-operation-name';
|
3243
3335
|
const UNIQUE_OPERATION_NAME = 'UNIQUE_OPERATION_NAME';
|
3244
|
-
const rule$
|
3336
|
+
const rule$p = {
|
3245
3337
|
meta: {
|
3246
3338
|
type: 'suggestion',
|
3247
3339
|
docs: {
|
@@ -3321,17 +3413,18 @@ const rules = {
|
|
3321
3413
|
'no-deprecated': rule$b,
|
3322
3414
|
'no-hashtag-description': rule$c,
|
3323
3415
|
'no-operation-name-suffix': rule$d,
|
3324
|
-
'no-
|
3325
|
-
'no-
|
3326
|
-
'
|
3327
|
-
'require-deprecation-
|
3328
|
-
'require-
|
3329
|
-
'require-
|
3330
|
-
'require-
|
3331
|
-
'
|
3332
|
-
'
|
3333
|
-
'
|
3334
|
-
'unique-
|
3416
|
+
'no-root-type': rule$e,
|
3417
|
+
'no-unreachable-types': rule$f,
|
3418
|
+
'no-unused-fields': rule$g,
|
3419
|
+
'require-deprecation-date': rule$h,
|
3420
|
+
'require-deprecation-reason': rule$i,
|
3421
|
+
'require-description': rule$j,
|
3422
|
+
'require-field-of-type-query-in-mutation-result': rule$k,
|
3423
|
+
'require-id-when-available': rule$l,
|
3424
|
+
'selection-set-depth': rule$m,
|
3425
|
+
'strict-id-in-types': rule$n,
|
3426
|
+
'unique-fragment-name': rule$o,
|
3427
|
+
'unique-operation-name': rule$p,
|
3335
3428
|
};
|
3336
3429
|
|
3337
3430
|
const RELEVANT_KEYWORDS = ['gql', 'graphql', '/* GraphQL */'];
|
package/index.mjs
CHANGED
@@ -85,6 +85,7 @@ const allConfig = {
|
|
85
85
|
'@graphql-eslint/match-document-filename': 'error',
|
86
86
|
'@graphql-eslint/no-deprecated': 'error',
|
87
87
|
'@graphql-eslint/no-hashtag-description': 'error',
|
88
|
+
'@graphql-eslint/no-root-type': ['error', { disallow: ['subscription'] }],
|
88
89
|
'@graphql-eslint/no-unreachable-types': 'error',
|
89
90
|
'@graphql-eslint/no-unused-fields': 'error',
|
90
91
|
'@graphql-eslint/require-deprecation-date': 'error',
|
@@ -2059,9 +2060,100 @@ const rule$d = {
|
|
2059
2060
|
},
|
2060
2061
|
};
|
2061
2062
|
|
2063
|
+
const ROOT_TYPES = ['query', 'mutation', 'subscription'];
|
2064
|
+
const rule$e = {
|
2065
|
+
meta: {
|
2066
|
+
type: 'suggestion',
|
2067
|
+
docs: {
|
2068
|
+
category: 'Validation',
|
2069
|
+
description: 'Disallow using root types for `read-only` or `write-only` schemas.',
|
2070
|
+
url: 'https://github.com/dotansimha/graphql-eslint/blob/master/docs/rules/no-root-type.md',
|
2071
|
+
requiresSchema: true,
|
2072
|
+
examples: [
|
2073
|
+
{
|
2074
|
+
title: 'Incorrect (`read-only` schema)',
|
2075
|
+
usage: [{ disallow: ['mutation', 'subscription'] }],
|
2076
|
+
code: /* GraphQL */ `
|
2077
|
+
type Mutation {
|
2078
|
+
createUser(input: CreateUserInput!): User!
|
2079
|
+
}
|
2080
|
+
`,
|
2081
|
+
},
|
2082
|
+
{
|
2083
|
+
title: 'Incorrect (`write-only` schema)',
|
2084
|
+
usage: [{ disallow: ['query'] }],
|
2085
|
+
code: /* GraphQL */ `
|
2086
|
+
type Query {
|
2087
|
+
users: [User!]!
|
2088
|
+
}
|
2089
|
+
`,
|
2090
|
+
},
|
2091
|
+
{
|
2092
|
+
title: 'Correct (`read-only` schema)',
|
2093
|
+
usage: [{ disallow: ['mutation', 'subscription'] }],
|
2094
|
+
code: /* GraphQL */ `
|
2095
|
+
type Query {
|
2096
|
+
users: [User!]!
|
2097
|
+
}
|
2098
|
+
`,
|
2099
|
+
},
|
2100
|
+
],
|
2101
|
+
optionsForConfig: [{ disallow: ['subscription'] }],
|
2102
|
+
},
|
2103
|
+
schema: {
|
2104
|
+
type: 'array',
|
2105
|
+
minItems: 1,
|
2106
|
+
maxItems: 1,
|
2107
|
+
items: {
|
2108
|
+
type: 'object',
|
2109
|
+
additionalProperties: false,
|
2110
|
+
required: ['disallow'],
|
2111
|
+
properties: {
|
2112
|
+
disallow: {
|
2113
|
+
type: 'array',
|
2114
|
+
uniqueItems: true,
|
2115
|
+
minItems: 1,
|
2116
|
+
items: {
|
2117
|
+
enum: ROOT_TYPES,
|
2118
|
+
},
|
2119
|
+
},
|
2120
|
+
},
|
2121
|
+
},
|
2122
|
+
},
|
2123
|
+
},
|
2124
|
+
create(context) {
|
2125
|
+
const schema = requireGraphQLSchemaFromContext('no-root-type', context);
|
2126
|
+
const disallow = new Set(context.options[0].disallow);
|
2127
|
+
const rootTypeNames = [
|
2128
|
+
disallow.has('query') && schema.getQueryType(),
|
2129
|
+
disallow.has('mutation') && schema.getMutationType(),
|
2130
|
+
disallow.has('subscription') && schema.getSubscriptionType(),
|
2131
|
+
]
|
2132
|
+
.filter(Boolean)
|
2133
|
+
.map(type => type.name);
|
2134
|
+
if (rootTypeNames.length === 0) {
|
2135
|
+
return {};
|
2136
|
+
}
|
2137
|
+
const selector = [
|
2138
|
+
`:matches(${Kind.OBJECT_TYPE_DEFINITION}, ${Kind.OBJECT_TYPE_EXTENSION})`,
|
2139
|
+
'>',
|
2140
|
+
`${Kind.NAME}[value=/^(${rootTypeNames.join('|')})$/]`,
|
2141
|
+
].join(' ');
|
2142
|
+
return {
|
2143
|
+
[selector](node) {
|
2144
|
+
const typeName = node.value;
|
2145
|
+
context.report({
|
2146
|
+
loc: getLocation(node.loc, typeName),
|
2147
|
+
message: `Root type "${typeName}" is forbidden`,
|
2148
|
+
});
|
2149
|
+
},
|
2150
|
+
};
|
2151
|
+
},
|
2152
|
+
};
|
2153
|
+
|
2062
2154
|
const UNREACHABLE_TYPE = 'UNREACHABLE_TYPE';
|
2063
2155
|
const RULE_NAME = 'no-unreachable-types';
|
2064
|
-
const rule$
|
2156
|
+
const rule$f = {
|
2065
2157
|
meta: {
|
2066
2158
|
messages: {
|
2067
2159
|
[UNREACHABLE_TYPE]: `Type "{{ typeName }}" is unreachable`,
|
@@ -2137,7 +2229,7 @@ const rule$e = {
|
|
2137
2229
|
|
2138
2230
|
const UNUSED_FIELD = 'UNUSED_FIELD';
|
2139
2231
|
const RULE_NAME$1 = 'no-unused-fields';
|
2140
|
-
const rule$
|
2232
|
+
const rule$g = {
|
2141
2233
|
meta: {
|
2142
2234
|
messages: {
|
2143
2235
|
[UNUSED_FIELD]: `Field "{{fieldName}}" is unused`,
|
@@ -2325,7 +2417,7 @@ const MESSAGE_REQUIRE_DATE = 'MESSAGE_REQUIRE_DATE';
|
|
2325
2417
|
const MESSAGE_INVALID_FORMAT = 'MESSAGE_INVALID_FORMAT';
|
2326
2418
|
const MESSAGE_INVALID_DATE = 'MESSAGE_INVALID_DATE';
|
2327
2419
|
const MESSAGE_CAN_BE_REMOVED = 'MESSAGE_CAN_BE_REMOVED';
|
2328
|
-
const rule$
|
2420
|
+
const rule$h = {
|
2329
2421
|
meta: {
|
2330
2422
|
type: 'suggestion',
|
2331
2423
|
docs: {
|
@@ -2428,7 +2520,7 @@ const rule$g = {
|
|
2428
2520
|
},
|
2429
2521
|
};
|
2430
2522
|
|
2431
|
-
const rule$
|
2523
|
+
const rule$i = {
|
2432
2524
|
meta: {
|
2433
2525
|
docs: {
|
2434
2526
|
description: `Require all deprecation directives to specify a reason.`,
|
@@ -2508,7 +2600,7 @@ function verifyRule(context, node) {
|
|
2508
2600
|
}
|
2509
2601
|
}
|
2510
2602
|
}
|
2511
|
-
const rule$
|
2603
|
+
const rule$j = {
|
2512
2604
|
meta: {
|
2513
2605
|
docs: {
|
2514
2606
|
category: 'Best Practices',
|
@@ -2573,7 +2665,7 @@ const rule$i = {
|
|
2573
2665
|
};
|
2574
2666
|
|
2575
2667
|
const RULE_NAME$2 = 'require-field-of-type-query-in-mutation-result';
|
2576
|
-
const rule$
|
2668
|
+
const rule$k = {
|
2577
2669
|
meta: {
|
2578
2670
|
type: 'suggestion',
|
2579
2671
|
docs: {
|
@@ -2741,7 +2833,7 @@ const convertNode = (typeInfo) => (node, key, parent) => {
|
|
2741
2833
|
|
2742
2834
|
const REQUIRE_ID_WHEN_AVAILABLE = 'REQUIRE_ID_WHEN_AVAILABLE';
|
2743
2835
|
const DEFAULT_ID_FIELD_NAME = 'id';
|
2744
|
-
const rule$
|
2836
|
+
const rule$l = {
|
2745
2837
|
meta: {
|
2746
2838
|
type: 'suggestion',
|
2747
2839
|
docs: {
|
@@ -2877,7 +2969,7 @@ const rule$k = {
|
|
2877
2969
|
},
|
2878
2970
|
};
|
2879
2971
|
|
2880
|
-
const rule$
|
2972
|
+
const rule$m = {
|
2881
2973
|
meta: {
|
2882
2974
|
docs: {
|
2883
2975
|
category: 'Best Practices',
|
@@ -2999,7 +3091,7 @@ const shouldIgnoreNode = ({ node, exceptions }) => {
|
|
2999
3091
|
}
|
3000
3092
|
return false;
|
3001
3093
|
};
|
3002
|
-
const rule$
|
3094
|
+
const rule$n = {
|
3003
3095
|
meta: {
|
3004
3096
|
type: 'suggestion',
|
3005
3097
|
docs: {
|
@@ -3176,7 +3268,7 @@ const checkNode = (context, node, ruleName, messageId) => {
|
|
3176
3268
|
});
|
3177
3269
|
}
|
3178
3270
|
};
|
3179
|
-
const rule$
|
3271
|
+
const rule$o = {
|
3180
3272
|
meta: {
|
3181
3273
|
type: 'suggestion',
|
3182
3274
|
docs: {
|
@@ -3235,7 +3327,7 @@ const rule$n = {
|
|
3235
3327
|
|
3236
3328
|
const RULE_NAME$4 = 'unique-operation-name';
|
3237
3329
|
const UNIQUE_OPERATION_NAME = 'UNIQUE_OPERATION_NAME';
|
3238
|
-
const rule$
|
3330
|
+
const rule$p = {
|
3239
3331
|
meta: {
|
3240
3332
|
type: 'suggestion',
|
3241
3333
|
docs: {
|
@@ -3315,17 +3407,18 @@ const rules = {
|
|
3315
3407
|
'no-deprecated': rule$b,
|
3316
3408
|
'no-hashtag-description': rule$c,
|
3317
3409
|
'no-operation-name-suffix': rule$d,
|
3318
|
-
'no-
|
3319
|
-
'no-
|
3320
|
-
'
|
3321
|
-
'require-deprecation-
|
3322
|
-
'require-
|
3323
|
-
'require-
|
3324
|
-
'require-
|
3325
|
-
'
|
3326
|
-
'
|
3327
|
-
'
|
3328
|
-
'unique-
|
3410
|
+
'no-root-type': rule$e,
|
3411
|
+
'no-unreachable-types': rule$f,
|
3412
|
+
'no-unused-fields': rule$g,
|
3413
|
+
'require-deprecation-date': rule$h,
|
3414
|
+
'require-deprecation-reason': rule$i,
|
3415
|
+
'require-description': rule$j,
|
3416
|
+
'require-field-of-type-query-in-mutation-result': rule$k,
|
3417
|
+
'require-id-when-available': rule$l,
|
3418
|
+
'selection-set-depth': rule$m,
|
3419
|
+
'strict-id-in-types': rule$n,
|
3420
|
+
'unique-fragment-name': rule$o,
|
3421
|
+
'unique-operation-name': rule$p,
|
3329
3422
|
};
|
3330
3423
|
|
3331
3424
|
const RELEVANT_KEYWORDS = ['gql', 'graphql', '/* GraphQL */'];
|
package/package.json
CHANGED
package/rules/index.d.ts
CHANGED
@@ -59,6 +59,9 @@ export declare const rules: {
|
|
59
59
|
'no-deprecated': import("..").GraphQLESLintRule<[], true>;
|
60
60
|
'no-hashtag-description': import("..").GraphQLESLintRule<any[], false>;
|
61
61
|
'no-operation-name-suffix': import("..").GraphQLESLintRule<any[], false>;
|
62
|
+
'no-root-type': import("..").GraphQLESLintRule<[{
|
63
|
+
disallow: ("subscription" | "query" | "mutation")[];
|
64
|
+
}], false>;
|
62
65
|
'no-unreachable-types': import("..").GraphQLESLintRule<any[], false>;
|
63
66
|
'no-unused-fields': import("..").GraphQLESLintRule<any[], false>;
|
64
67
|
'require-deprecation-date': import("..").GraphQLESLintRule<[{
|
@@ -0,0 +1,7 @@
|
|
1
|
+
import { GraphQLESLintRule } from '../types';
|
2
|
+
declare const ROOT_TYPES: ('query' | 'mutation' | 'subscription')[];
|
3
|
+
declare type NoRootTypeConfig = {
|
4
|
+
disallow: typeof ROOT_TYPES;
|
5
|
+
};
|
6
|
+
declare const rule: GraphQLESLintRule<[NoRootTypeConfig]>;
|
7
|
+
export default rule;
|
package/testkit.d.ts
CHANGED
@@ -6,7 +6,7 @@ export declare type GraphQLESLintRuleListener<WithTypeInfo extends boolean = fal
|
|
6
6
|
[K in keyof ASTKindToNode]?: (node: GraphQLESTreeNode<ASTKindToNode[K], WithTypeInfo>) => void;
|
7
7
|
} & Record<string, any>;
|
8
8
|
export declare type GraphQLValidTestCase<Options> = Omit<RuleTester.ValidTestCase, 'options' | 'parserOptions'> & {
|
9
|
-
name
|
9
|
+
name?: string;
|
10
10
|
options?: Options;
|
11
11
|
parserOptions?: ParserOptions;
|
12
12
|
};
|