@graphql-eslint/eslint-plugin 2.5.0-alpha-e34c5d6.0 â 2.5.0-alpha-14532ce.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 +0 -3
- package/configs/index.d.ts +0 -3
- package/docs/README.md +0 -1
- package/docs/rules/no-deprecated.md +2 -2
- package/index.js +22 -115
- package/index.mjs +22 -115
- package/package.json +7 -7
- package/rules/index.d.ts +0 -3
- package/testkit.d.ts +1 -1
- package/docs/rules/no-root-type.md +0 -56
- package/rules/no-root-type.d.ts +0 -7
package/configs/all.d.ts
CHANGED
@@ -15,9 +15,6 @@ 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
|
-
})[];
|
21
18
|
'@graphql-eslint/no-unreachable-types': string;
|
22
19
|
'@graphql-eslint/no-unused-fields': string;
|
23
20
|
'@graphql-eslint/require-deprecation-date': string;
|
package/configs/index.d.ts
CHANGED
@@ -16,9 +16,6 @@ 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
|
-
})[];
|
22
19
|
'@graphql-eslint/no-unreachable-types': string;
|
23
20
|
'@graphql-eslint/no-unused-fields': string;
|
24
21
|
'@graphql-eslint/require-deprecation-date': string;
|
package/docs/README.md
CHANGED
@@ -35,7 +35,6 @@ 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.|đ||
|
39
38
|
[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.|đŽ||â
|
40
39
|
[no-unreachable-types](rules/no-unreachable-types.md)|Requires all types to be reachable at some level by root level fields.|đ|đ§|
|
41
40
|
[no-unused-fields](rules/no-unused-fields.md)|Requires all fields to be used at some level by siblings operations.|đ|đ§|
|
package/index.js
CHANGED
@@ -91,7 +91,6 @@ 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'] }],
|
95
94
|
'@graphql-eslint/no-unreachable-types': 'error',
|
96
95
|
'@graphql-eslint/no-unused-fields': 'error',
|
97
96
|
'@graphql-eslint/require-deprecation-date': 'error',
|
@@ -2066,100 +2065,9 @@ const rule$d = {
|
|
2066
2065
|
},
|
2067
2066
|
};
|
2068
2067
|
|
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
|
-
|
2160
2068
|
const UNREACHABLE_TYPE = 'UNREACHABLE_TYPE';
|
2161
2069
|
const RULE_NAME = 'no-unreachable-types';
|
2162
|
-
const rule$
|
2070
|
+
const rule$e = {
|
2163
2071
|
meta: {
|
2164
2072
|
messages: {
|
2165
2073
|
[UNREACHABLE_TYPE]: `Type "{{ typeName }}" is unreachable`,
|
@@ -2235,7 +2143,7 @@ const rule$f = {
|
|
2235
2143
|
|
2236
2144
|
const UNUSED_FIELD = 'UNUSED_FIELD';
|
2237
2145
|
const RULE_NAME$1 = 'no-unused-fields';
|
2238
|
-
const rule$
|
2146
|
+
const rule$f = {
|
2239
2147
|
meta: {
|
2240
2148
|
messages: {
|
2241
2149
|
[UNUSED_FIELD]: `Field "{{fieldName}}" is unused`,
|
@@ -2423,7 +2331,7 @@ const MESSAGE_REQUIRE_DATE = 'MESSAGE_REQUIRE_DATE';
|
|
2423
2331
|
const MESSAGE_INVALID_FORMAT = 'MESSAGE_INVALID_FORMAT';
|
2424
2332
|
const MESSAGE_INVALID_DATE = 'MESSAGE_INVALID_DATE';
|
2425
2333
|
const MESSAGE_CAN_BE_REMOVED = 'MESSAGE_CAN_BE_REMOVED';
|
2426
|
-
const rule$
|
2334
|
+
const rule$g = {
|
2427
2335
|
meta: {
|
2428
2336
|
type: 'suggestion',
|
2429
2337
|
docs: {
|
@@ -2526,7 +2434,7 @@ const rule$h = {
|
|
2526
2434
|
},
|
2527
2435
|
};
|
2528
2436
|
|
2529
|
-
const rule$
|
2437
|
+
const rule$h = {
|
2530
2438
|
meta: {
|
2531
2439
|
docs: {
|
2532
2440
|
description: `Require all deprecation directives to specify a reason.`,
|
@@ -2606,7 +2514,7 @@ function verifyRule(context, node) {
|
|
2606
2514
|
}
|
2607
2515
|
}
|
2608
2516
|
}
|
2609
|
-
const rule$
|
2517
|
+
const rule$i = {
|
2610
2518
|
meta: {
|
2611
2519
|
docs: {
|
2612
2520
|
category: 'Best Practices',
|
@@ -2671,7 +2579,7 @@ const rule$j = {
|
|
2671
2579
|
};
|
2672
2580
|
|
2673
2581
|
const RULE_NAME$2 = 'require-field-of-type-query-in-mutation-result';
|
2674
|
-
const rule$
|
2582
|
+
const rule$j = {
|
2675
2583
|
meta: {
|
2676
2584
|
type: 'suggestion',
|
2677
2585
|
docs: {
|
@@ -2839,7 +2747,7 @@ const convertNode = (typeInfo) => (node, key, parent) => {
|
|
2839
2747
|
|
2840
2748
|
const REQUIRE_ID_WHEN_AVAILABLE = 'REQUIRE_ID_WHEN_AVAILABLE';
|
2841
2749
|
const DEFAULT_ID_FIELD_NAME = 'id';
|
2842
|
-
const rule$
|
2750
|
+
const rule$k = {
|
2843
2751
|
meta: {
|
2844
2752
|
type: 'suggestion',
|
2845
2753
|
docs: {
|
@@ -2975,7 +2883,7 @@ const rule$l = {
|
|
2975
2883
|
},
|
2976
2884
|
};
|
2977
2885
|
|
2978
|
-
const rule$
|
2886
|
+
const rule$l = {
|
2979
2887
|
meta: {
|
2980
2888
|
docs: {
|
2981
2889
|
category: 'Best Practices',
|
@@ -3097,7 +3005,7 @@ const shouldIgnoreNode = ({ node, exceptions }) => {
|
|
3097
3005
|
}
|
3098
3006
|
return false;
|
3099
3007
|
};
|
3100
|
-
const rule$
|
3008
|
+
const rule$m = {
|
3101
3009
|
meta: {
|
3102
3010
|
type: 'suggestion',
|
3103
3011
|
docs: {
|
@@ -3274,7 +3182,7 @@ const checkNode = (context, node, ruleName, messageId) => {
|
|
3274
3182
|
});
|
3275
3183
|
}
|
3276
3184
|
};
|
3277
|
-
const rule$
|
3185
|
+
const rule$n = {
|
3278
3186
|
meta: {
|
3279
3187
|
type: 'suggestion',
|
3280
3188
|
docs: {
|
@@ -3333,7 +3241,7 @@ const rule$o = {
|
|
3333
3241
|
|
3334
3242
|
const RULE_NAME$4 = 'unique-operation-name';
|
3335
3243
|
const UNIQUE_OPERATION_NAME = 'UNIQUE_OPERATION_NAME';
|
3336
|
-
const rule$
|
3244
|
+
const rule$o = {
|
3337
3245
|
meta: {
|
3338
3246
|
type: 'suggestion',
|
3339
3247
|
docs: {
|
@@ -3413,18 +3321,17 @@ const rules = {
|
|
3413
3321
|
'no-deprecated': rule$b,
|
3414
3322
|
'no-hashtag-description': rule$c,
|
3415
3323
|
'no-operation-name-suffix': rule$d,
|
3416
|
-
'no-
|
3417
|
-
'no-
|
3418
|
-
'
|
3419
|
-
'require-deprecation-
|
3420
|
-
'require-
|
3421
|
-
'require-
|
3422
|
-
'require-
|
3423
|
-
'
|
3424
|
-
'
|
3425
|
-
'
|
3426
|
-
'unique-
|
3427
|
-
'unique-operation-name': rule$p,
|
3324
|
+
'no-unreachable-types': rule$e,
|
3325
|
+
'no-unused-fields': rule$f,
|
3326
|
+
'require-deprecation-date': rule$g,
|
3327
|
+
'require-deprecation-reason': rule$h,
|
3328
|
+
'require-description': rule$i,
|
3329
|
+
'require-field-of-type-query-in-mutation-result': rule$j,
|
3330
|
+
'require-id-when-available': rule$k,
|
3331
|
+
'selection-set-depth': rule$l,
|
3332
|
+
'strict-id-in-types': rule$m,
|
3333
|
+
'unique-fragment-name': rule$n,
|
3334
|
+
'unique-operation-name': rule$o,
|
3428
3335
|
};
|
3429
3336
|
|
3430
3337
|
const RELEVANT_KEYWORDS = ['gql', 'graphql', '/* GraphQL */'];
|
package/index.mjs
CHANGED
@@ -85,7 +85,6 @@ 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'] }],
|
89
88
|
'@graphql-eslint/no-unreachable-types': 'error',
|
90
89
|
'@graphql-eslint/no-unused-fields': 'error',
|
91
90
|
'@graphql-eslint/require-deprecation-date': 'error',
|
@@ -2060,100 +2059,9 @@ const rule$d = {
|
|
2060
2059
|
},
|
2061
2060
|
};
|
2062
2061
|
|
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
|
-
|
2154
2062
|
const UNREACHABLE_TYPE = 'UNREACHABLE_TYPE';
|
2155
2063
|
const RULE_NAME = 'no-unreachable-types';
|
2156
|
-
const rule$
|
2064
|
+
const rule$e = {
|
2157
2065
|
meta: {
|
2158
2066
|
messages: {
|
2159
2067
|
[UNREACHABLE_TYPE]: `Type "{{ typeName }}" is unreachable`,
|
@@ -2229,7 +2137,7 @@ const rule$f = {
|
|
2229
2137
|
|
2230
2138
|
const UNUSED_FIELD = 'UNUSED_FIELD';
|
2231
2139
|
const RULE_NAME$1 = 'no-unused-fields';
|
2232
|
-
const rule$
|
2140
|
+
const rule$f = {
|
2233
2141
|
meta: {
|
2234
2142
|
messages: {
|
2235
2143
|
[UNUSED_FIELD]: `Field "{{fieldName}}" is unused`,
|
@@ -2417,7 +2325,7 @@ const MESSAGE_REQUIRE_DATE = 'MESSAGE_REQUIRE_DATE';
|
|
2417
2325
|
const MESSAGE_INVALID_FORMAT = 'MESSAGE_INVALID_FORMAT';
|
2418
2326
|
const MESSAGE_INVALID_DATE = 'MESSAGE_INVALID_DATE';
|
2419
2327
|
const MESSAGE_CAN_BE_REMOVED = 'MESSAGE_CAN_BE_REMOVED';
|
2420
|
-
const rule$
|
2328
|
+
const rule$g = {
|
2421
2329
|
meta: {
|
2422
2330
|
type: 'suggestion',
|
2423
2331
|
docs: {
|
@@ -2520,7 +2428,7 @@ const rule$h = {
|
|
2520
2428
|
},
|
2521
2429
|
};
|
2522
2430
|
|
2523
|
-
const rule$
|
2431
|
+
const rule$h = {
|
2524
2432
|
meta: {
|
2525
2433
|
docs: {
|
2526
2434
|
description: `Require all deprecation directives to specify a reason.`,
|
@@ -2600,7 +2508,7 @@ function verifyRule(context, node) {
|
|
2600
2508
|
}
|
2601
2509
|
}
|
2602
2510
|
}
|
2603
|
-
const rule$
|
2511
|
+
const rule$i = {
|
2604
2512
|
meta: {
|
2605
2513
|
docs: {
|
2606
2514
|
category: 'Best Practices',
|
@@ -2665,7 +2573,7 @@ const rule$j = {
|
|
2665
2573
|
};
|
2666
2574
|
|
2667
2575
|
const RULE_NAME$2 = 'require-field-of-type-query-in-mutation-result';
|
2668
|
-
const rule$
|
2576
|
+
const rule$j = {
|
2669
2577
|
meta: {
|
2670
2578
|
type: 'suggestion',
|
2671
2579
|
docs: {
|
@@ -2833,7 +2741,7 @@ const convertNode = (typeInfo) => (node, key, parent) => {
|
|
2833
2741
|
|
2834
2742
|
const REQUIRE_ID_WHEN_AVAILABLE = 'REQUIRE_ID_WHEN_AVAILABLE';
|
2835
2743
|
const DEFAULT_ID_FIELD_NAME = 'id';
|
2836
|
-
const rule$
|
2744
|
+
const rule$k = {
|
2837
2745
|
meta: {
|
2838
2746
|
type: 'suggestion',
|
2839
2747
|
docs: {
|
@@ -2969,7 +2877,7 @@ const rule$l = {
|
|
2969
2877
|
},
|
2970
2878
|
};
|
2971
2879
|
|
2972
|
-
const rule$
|
2880
|
+
const rule$l = {
|
2973
2881
|
meta: {
|
2974
2882
|
docs: {
|
2975
2883
|
category: 'Best Practices',
|
@@ -3091,7 +2999,7 @@ const shouldIgnoreNode = ({ node, exceptions }) => {
|
|
3091
2999
|
}
|
3092
3000
|
return false;
|
3093
3001
|
};
|
3094
|
-
const rule$
|
3002
|
+
const rule$m = {
|
3095
3003
|
meta: {
|
3096
3004
|
type: 'suggestion',
|
3097
3005
|
docs: {
|
@@ -3268,7 +3176,7 @@ const checkNode = (context, node, ruleName, messageId) => {
|
|
3268
3176
|
});
|
3269
3177
|
}
|
3270
3178
|
};
|
3271
|
-
const rule$
|
3179
|
+
const rule$n = {
|
3272
3180
|
meta: {
|
3273
3181
|
type: 'suggestion',
|
3274
3182
|
docs: {
|
@@ -3327,7 +3235,7 @@ const rule$o = {
|
|
3327
3235
|
|
3328
3236
|
const RULE_NAME$4 = 'unique-operation-name';
|
3329
3237
|
const UNIQUE_OPERATION_NAME = 'UNIQUE_OPERATION_NAME';
|
3330
|
-
const rule$
|
3238
|
+
const rule$o = {
|
3331
3239
|
meta: {
|
3332
3240
|
type: 'suggestion',
|
3333
3241
|
docs: {
|
@@ -3407,18 +3315,17 @@ const rules = {
|
|
3407
3315
|
'no-deprecated': rule$b,
|
3408
3316
|
'no-hashtag-description': rule$c,
|
3409
3317
|
'no-operation-name-suffix': rule$d,
|
3410
|
-
'no-
|
3411
|
-
'no-
|
3412
|
-
'
|
3413
|
-
'require-deprecation-
|
3414
|
-
'require-
|
3415
|
-
'require-
|
3416
|
-
'require-
|
3417
|
-
'
|
3418
|
-
'
|
3419
|
-
'
|
3420
|
-
'unique-
|
3421
|
-
'unique-operation-name': rule$p,
|
3318
|
+
'no-unreachable-types': rule$e,
|
3319
|
+
'no-unused-fields': rule$f,
|
3320
|
+
'require-deprecation-date': rule$g,
|
3321
|
+
'require-deprecation-reason': rule$h,
|
3322
|
+
'require-description': rule$i,
|
3323
|
+
'require-field-of-type-query-in-mutation-result': rule$j,
|
3324
|
+
'require-id-when-available': rule$k,
|
3325
|
+
'selection-set-depth': rule$l,
|
3326
|
+
'strict-id-in-types': rule$m,
|
3327
|
+
'unique-fragment-name': rule$n,
|
3328
|
+
'unique-operation-name': rule$o,
|
3422
3329
|
};
|
3423
3330
|
|
3424
3331
|
const RELEVANT_KEYWORDS = ['gql', 'graphql', '/* GraphQL */'];
|
package/package.json
CHANGED
@@ -1,19 +1,19 @@
|
|
1
1
|
{
|
2
2
|
"name": "@graphql-eslint/eslint-plugin",
|
3
|
-
"version": "2.5.0-alpha-
|
3
|
+
"version": "2.5.0-alpha-14532ce.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"
|
7
7
|
},
|
8
8
|
"dependencies": {
|
9
9
|
"@babel/code-frame": "7.16.0",
|
10
|
-
"@graphql-tools/code-file-loader": "
|
11
|
-
"@graphql-tools/graphql-tag-pluck": "
|
12
|
-
"@graphql-tools/import": "
|
13
|
-
"@graphql-tools/utils": "
|
14
|
-
"graphql-config": "
|
10
|
+
"@graphql-tools/code-file-loader": "7.2.2",
|
11
|
+
"@graphql-tools/graphql-tag-pluck": "7.1.3",
|
12
|
+
"@graphql-tools/import": "6.6.1",
|
13
|
+
"@graphql-tools/utils": "8.5.3",
|
14
|
+
"graphql-config": "4.1.0",
|
15
15
|
"graphql-depth-limit": "1.1.0",
|
16
|
-
"lodash.lowercase": "
|
16
|
+
"lodash.lowercase": "4.3.0"
|
17
17
|
},
|
18
18
|
"repository": "https://github.com/dotansimha/graphql-eslint",
|
19
19
|
"author": "Dotan Simha <dotansimha@gmail.com>",
|
package/rules/index.d.ts
CHANGED
@@ -59,9 +59,6 @@ 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>;
|
65
62
|
'no-unreachable-types': import("..").GraphQLESLintRule<any[], false>;
|
66
63
|
'no-unused-fields': import("..").GraphQLESLintRule<any[], false>;
|
67
64
|
'require-deprecation-date': import("..").GraphQLESLintRule<[{
|
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
|
};
|
@@ -1,56 +0,0 @@
|
|
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/rules/no-root-type.d.ts
DELETED
@@ -1,7 +0,0 @@
|
|
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;
|