@graphql-eslint/eslint-plugin 3.0.0-alpha-698204a.0 → 3.0.0-alpha-2918431.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/index.d.ts +24 -30
- package/configs/operations-recommended.d.ts +11 -13
- package/configs/schema-all.d.ts +1 -3
- package/configs/schema-recommended.d.ts +12 -14
- package/docs/README.md +1 -1
- package/docs/rules/description-style.md +1 -1
- package/docs/rules/naming-convention.md +138 -38
- package/docs/rules/no-root-type.md +3 -14
- package/docs/rules/require-description.md +35 -21
- package/index.js +103 -127
- package/index.mjs +103 -127
- package/package.json +1 -1
- package/rules/index.d.ts +110 -112
- package/rules/naming-convention.d.ts +2 -3
- package/rules/no-root-type.d.ts +1 -1
- package/rules/require-description.d.ts +2 -3
package/configs/index.d.ts
CHANGED
@@ -14,20 +14,18 @@ export declare const configs: {
|
|
14
14
|
'@graphql-eslint/naming-convention': (string | {
|
15
15
|
types: string;
|
16
16
|
fields: string;
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
forbiddenSuffixes: string[];
|
30
|
-
};
|
17
|
+
EnumValueDefinition: string;
|
18
|
+
'FieldDefinition[parent.name.value=Query]': {
|
19
|
+
forbiddenPrefixes: string[];
|
20
|
+
forbiddenSuffixes: string[];
|
21
|
+
};
|
22
|
+
'FieldDefinition[parent.name.value=Mutation]': {
|
23
|
+
forbiddenPrefixes: string[];
|
24
|
+
forbiddenSuffixes: string[];
|
25
|
+
};
|
26
|
+
'FieldDefinition[parent.name.value=Subscription]': {
|
27
|
+
forbiddenPrefixes: string[];
|
28
|
+
forbiddenSuffixes: string[];
|
31
29
|
};
|
32
30
|
})[];
|
33
31
|
'@graphql-eslint/no-case-insensitive-enum-values-duplicates': string;
|
@@ -61,9 +59,7 @@ export declare const configs: {
|
|
61
59
|
'@graphql-eslint/require-deprecation-date': string;
|
62
60
|
'@graphql-eslint/require-description': (string | {
|
63
61
|
types: boolean;
|
64
|
-
|
65
|
-
DirectiveDefinition: boolean;
|
66
|
-
};
|
62
|
+
DirectiveDefinition: boolean;
|
67
63
|
})[];
|
68
64
|
'@graphql-eslint/require-field-of-type-query-in-mutation-result': string;
|
69
65
|
};
|
@@ -80,19 +76,17 @@ export declare const configs: {
|
|
80
76
|
'@graphql-eslint/known-type-names': string;
|
81
77
|
'@graphql-eslint/lone-anonymous-operation': string;
|
82
78
|
'@graphql-eslint/naming-convention': (string | {
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
forbiddenSuffixes: string[];
|
95
|
-
};
|
79
|
+
Argument: string;
|
80
|
+
VariableDefinition: string;
|
81
|
+
OperationDefinition: {
|
82
|
+
style: string;
|
83
|
+
forbiddenPrefixes: string[];
|
84
|
+
forbiddenSuffixes: string[];
|
85
|
+
};
|
86
|
+
FragmentDefinition: {
|
87
|
+
style: string;
|
88
|
+
forbiddenPrefixes: string[];
|
89
|
+
forbiddenSuffixes: string[];
|
96
90
|
};
|
97
91
|
})[];
|
98
92
|
'@graphql-eslint/no-anonymous-operations': string;
|
@@ -10,19 +10,17 @@ declare const _default: {
|
|
10
10
|
'@graphql-eslint/known-type-names': string;
|
11
11
|
'@graphql-eslint/lone-anonymous-operation': string;
|
12
12
|
'@graphql-eslint/naming-convention': (string | {
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
forbiddenSuffixes: string[];
|
25
|
-
};
|
13
|
+
Argument: string;
|
14
|
+
VariableDefinition: string;
|
15
|
+
OperationDefinition: {
|
16
|
+
style: string;
|
17
|
+
forbiddenPrefixes: string[];
|
18
|
+
forbiddenSuffixes: string[];
|
19
|
+
};
|
20
|
+
FragmentDefinition: {
|
21
|
+
style: string;
|
22
|
+
forbiddenPrefixes: string[];
|
23
|
+
forbiddenSuffixes: string[];
|
26
24
|
};
|
27
25
|
})[];
|
28
26
|
'@graphql-eslint/no-anonymous-operations': string;
|
package/configs/schema-all.d.ts
CHANGED
@@ -13,9 +13,7 @@ declare const _default: {
|
|
13
13
|
'@graphql-eslint/require-deprecation-date': string;
|
14
14
|
'@graphql-eslint/require-description': (string | {
|
15
15
|
types: boolean;
|
16
|
-
|
17
|
-
DirectiveDefinition: boolean;
|
18
|
-
};
|
16
|
+
DirectiveDefinition: boolean;
|
19
17
|
})[];
|
20
18
|
'@graphql-eslint/require-field-of-type-query-in-mutation-result': string;
|
21
19
|
};
|
@@ -9,20 +9,18 @@ declare const _default: {
|
|
9
9
|
'@graphql-eslint/naming-convention': (string | {
|
10
10
|
types: string;
|
11
11
|
fields: string;
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
forbiddenSuffixes: string[];
|
25
|
-
};
|
12
|
+
EnumValueDefinition: string;
|
13
|
+
'FieldDefinition[parent.name.value=Query]': {
|
14
|
+
forbiddenPrefixes: string[];
|
15
|
+
forbiddenSuffixes: string[];
|
16
|
+
};
|
17
|
+
'FieldDefinition[parent.name.value=Mutation]': {
|
18
|
+
forbiddenPrefixes: string[];
|
19
|
+
forbiddenSuffixes: string[];
|
20
|
+
};
|
21
|
+
'FieldDefinition[parent.name.value=Subscription]': {
|
22
|
+
forbiddenPrefixes: string[];
|
23
|
+
forbiddenSuffixes: string[];
|
26
24
|
};
|
27
25
|
})[];
|
28
26
|
'@graphql-eslint/no-case-insensitive-enum-values-duplicates': string;
|
package/docs/README.md
CHANGED
@@ -31,7 +31,7 @@ Name &nbs
|
|
31
31
|
[no-duplicate-fields](rules/no-duplicate-fields.md)|Checks for duplicate fields in selection set, variables in operation definition, or in arguments set of a field.|🚀||✅
|
32
32
|
[no-fragment-cycles](rules/no-fragment-cycles.md)|A GraphQL fragment is only valid when it does not have cycles in fragments usage.|🔮||✅
|
33
33
|
[no-hashtag-description](rules/no-hashtag-description.md)|Requires to use `"""` or `"` for adding a GraphQL description instead of `#`.|🚀||✅
|
34
|
-
[no-root-type](rules/no-root-type.md)|Disallow using root types
|
34
|
+
[no-root-type](rules/no-root-type.md)|Disallow using root types `mutation` and/or `subscription`.|🚀||
|
35
35
|
[no-scalar-result-type-on-mutation](rules/no-scalar-result-type-on-mutation.md)|Avoid scalar result type on mutation type to make sure to return a valid state.|🚀||
|
36
36
|
[no-typename-prefix](rules/no-typename-prefix.md)|Enforces users to avoid using the type name in a field name while defining your schema.|🚀||✅
|
37
37
|
[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.|🔮||✅
|
@@ -33,18 +33,32 @@ type User {
|
|
33
33
|
|
34
34
|
## Config Schema
|
35
35
|
|
36
|
+
> It's possible to use a [`selector`](https://eslint.org/docs/developer-guide/selectors) that starts with allowed `ASTNode` names which are described below.
|
37
|
+
>
|
38
|
+
> Paste or drop code into the editor in [ASTExplorer](https://astexplorer.net) and inspect the generated AST to compose your selector.
|
39
|
+
>
|
40
|
+
> Example: pattern property `FieldDefinition[parent.name.value=Query]` will match only fields for type `Query`.
|
41
|
+
|
36
42
|
The schema defines the following properties:
|
37
43
|
|
44
|
+
### `allowLeadingUnderscore` (boolean)
|
45
|
+
|
46
|
+
Default: `false`
|
47
|
+
|
48
|
+
### `allowTrailingUnderscore` (boolean)
|
49
|
+
|
50
|
+
Default: `false`
|
51
|
+
|
38
52
|
### `types`
|
39
53
|
|
40
54
|
Includes:
|
41
55
|
|
42
|
-
-
|
43
|
-
-
|
44
|
-
-
|
45
|
-
-
|
46
|
-
-
|
47
|
-
-
|
56
|
+
- `ObjectTypeDefinition`
|
57
|
+
- `InterfaceTypeDefinition`
|
58
|
+
- `EnumTypeDefinition`
|
59
|
+
- `ScalarTypeDefinition`
|
60
|
+
- `InputObjectTypeDefinition`
|
61
|
+
- `UnionTypeDefinition`
|
48
62
|
|
49
63
|
The object must be one of the following types:
|
50
64
|
|
@@ -55,50 +69,136 @@ The object must be one of the following types:
|
|
55
69
|
|
56
70
|
Includes:
|
57
71
|
|
58
|
-
-
|
59
|
-
-
|
60
|
-
-
|
61
|
-
-
|
72
|
+
- `FieldDefinition`
|
73
|
+
- `InputValueDefinition`
|
74
|
+
- `Argument`
|
75
|
+
- `DirectiveDefinition`
|
62
76
|
|
63
77
|
The object must be one of the following types:
|
64
78
|
|
65
79
|
* `asString`
|
66
80
|
* `asObject`
|
67
81
|
|
68
|
-
### `
|
82
|
+
### `Argument`
|
69
83
|
|
70
|
-
|
84
|
+
Read more about this kind on [spec.graphql.org](https://spec.graphql.org/October2021/#Argument).
|
71
85
|
|
72
|
-
|
86
|
+
The object must be one of the following types:
|
73
87
|
|
74
|
-
|
88
|
+
* `asString`
|
89
|
+
* `asObject`
|
75
90
|
|
76
|
-
### `
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
91
|
+
### `DirectiveDefinition`
|
92
|
+
|
93
|
+
Read more about this kind on [spec.graphql.org](https://spec.graphql.org/October2021/#DirectiveDefinition).
|
94
|
+
|
95
|
+
The object must be one of the following types:
|
96
|
+
|
97
|
+
* `asString`
|
98
|
+
* `asObject`
|
99
|
+
|
100
|
+
### `EnumTypeDefinition`
|
101
|
+
|
102
|
+
Read more about this kind on [spec.graphql.org](https://spec.graphql.org/October2021/#EnumTypeDefinition).
|
103
|
+
|
104
|
+
The object must be one of the following types:
|
105
|
+
|
106
|
+
* `asString`
|
107
|
+
* `asObject`
|
108
|
+
|
109
|
+
### `EnumValueDefinition`
|
110
|
+
|
111
|
+
Read more about this kind on [spec.graphql.org](https://spec.graphql.org/October2021/#EnumValueDefinition).
|
112
|
+
|
113
|
+
The object must be one of the following types:
|
114
|
+
|
115
|
+
* `asString`
|
116
|
+
* `asObject`
|
117
|
+
|
118
|
+
### `FieldDefinition`
|
119
|
+
|
120
|
+
Read more about this kind on [spec.graphql.org](https://spec.graphql.org/October2021/#FieldDefinition).
|
121
|
+
|
122
|
+
The object must be one of the following types:
|
123
|
+
|
124
|
+
* `asString`
|
125
|
+
* `asObject`
|
126
|
+
|
127
|
+
### `FragmentDefinition`
|
128
|
+
|
129
|
+
Read more about this kind on [spec.graphql.org](https://spec.graphql.org/October2021/#FragmentDefinition).
|
130
|
+
|
131
|
+
The object must be one of the following types:
|
132
|
+
|
133
|
+
* `asString`
|
134
|
+
* `asObject`
|
135
|
+
|
136
|
+
### `InputObjectTypeDefinition`
|
137
|
+
|
138
|
+
Read more about this kind on [spec.graphql.org](https://spec.graphql.org/October2021/#InputObjectTypeDefinition).
|
139
|
+
|
140
|
+
The object must be one of the following types:
|
141
|
+
|
142
|
+
* `asString`
|
143
|
+
* `asObject`
|
144
|
+
|
145
|
+
### `InputValueDefinition`
|
146
|
+
|
147
|
+
Read more about this kind on [spec.graphql.org](https://spec.graphql.org/October2021/#InputValueDefinition).
|
148
|
+
|
149
|
+
The object must be one of the following types:
|
150
|
+
|
151
|
+
* `asString`
|
152
|
+
* `asObject`
|
153
|
+
|
154
|
+
### `InterfaceTypeDefinition`
|
155
|
+
|
156
|
+
Read more about this kind on [spec.graphql.org](https://spec.graphql.org/October2021/#InterfaceTypeDefinition).
|
157
|
+
|
158
|
+
The object must be one of the following types:
|
159
|
+
|
160
|
+
* `asString`
|
161
|
+
* `asObject`
|
162
|
+
|
163
|
+
### `ObjectTypeDefinition`
|
164
|
+
|
165
|
+
Read more about this kind on [spec.graphql.org](https://spec.graphql.org/October2021/#ObjectTypeDefinition).
|
166
|
+
|
167
|
+
The object must be one of the following types:
|
168
|
+
|
169
|
+
* `asString`
|
170
|
+
* `asObject`
|
171
|
+
|
172
|
+
### `OperationDefinition`
|
173
|
+
|
174
|
+
Read more about this kind on [spec.graphql.org](https://spec.graphql.org/October2021/#OperationDefinition).
|
175
|
+
|
176
|
+
The object must be one of the following types:
|
177
|
+
|
178
|
+
* `asString`
|
179
|
+
* `asObject`
|
180
|
+
|
181
|
+
### `ScalarTypeDefinition`
|
182
|
+
|
183
|
+
Read more about this kind on [spec.graphql.org](https://spec.graphql.org/October2021/#ScalarTypeDefinition).
|
184
|
+
|
185
|
+
The object must be one of the following types:
|
186
|
+
|
187
|
+
* `asString`
|
188
|
+
* `asObject`
|
189
|
+
|
190
|
+
### `UnionTypeDefinition`
|
191
|
+
|
192
|
+
Read more about this kind on [spec.graphql.org](https://spec.graphql.org/October2021/#UnionTypeDefinition).
|
193
|
+
|
194
|
+
The object must be one of the following types:
|
195
|
+
|
196
|
+
* `asString`
|
197
|
+
* `asObject`
|
98
198
|
|
99
|
-
|
199
|
+
### `VariableDefinition`
|
100
200
|
|
101
|
-
|
201
|
+
Read more about this kind on [spec.graphql.org](https://spec.graphql.org/October2021/#VariableDefinition).
|
102
202
|
|
103
203
|
The object must be one of the following types:
|
104
204
|
|
@@ -5,11 +5,11 @@
|
|
5
5
|
- Requires GraphQL Schema: `true` [ℹ️](../../README.md#extended-linting-rules-with-graphql-schema)
|
6
6
|
- Requires GraphQL Operations: `false` [ℹ️](../../README.md#extended-linting-rules-with-siblings-operations)
|
7
7
|
|
8
|
-
Disallow using root types
|
8
|
+
Disallow using root types `mutation` and/or `subscription`.
|
9
9
|
|
10
10
|
## Usage Examples
|
11
11
|
|
12
|
-
### Incorrect
|
12
|
+
### Incorrect
|
13
13
|
|
14
14
|
```graphql
|
15
15
|
# eslint @graphql-eslint/no-root-type: ['error', { disallow: ['mutation', 'subscription'] }]
|
@@ -19,17 +19,7 @@ type Mutation {
|
|
19
19
|
}
|
20
20
|
```
|
21
21
|
|
22
|
-
###
|
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)
|
22
|
+
### Correct
|
33
23
|
|
34
24
|
```graphql
|
35
25
|
# eslint @graphql-eslint/no-root-type: ['error', { disallow: ['mutation', 'subscription'] }]
|
@@ -47,7 +37,6 @@ The schema defines the following properties:
|
|
47
37
|
|
48
38
|
The elements of the array can contain the following enum values:
|
49
39
|
|
50
|
-
- `query`
|
51
40
|
- `mutation`
|
52
41
|
- `subscription`
|
53
42
|
|
@@ -12,7 +12,7 @@ Enforce descriptions in your type definitions.
|
|
12
12
|
### Incorrect
|
13
13
|
|
14
14
|
```graphql
|
15
|
-
# eslint @graphql-eslint/require-description: ['error', { types: true,
|
15
|
+
# eslint @graphql-eslint/require-description: ['error', { types: true, FieldDefinition: true }]
|
16
16
|
|
17
17
|
type someTypeName {
|
18
18
|
name: String
|
@@ -22,7 +22,7 @@ type someTypeName {
|
|
22
22
|
### Correct
|
23
23
|
|
24
24
|
```graphql
|
25
|
-
# eslint @graphql-eslint/require-description: ['error', { types: true,
|
25
|
+
# eslint @graphql-eslint/require-description: ['error', { types: true, FieldDefinition: true }]
|
26
26
|
|
27
27
|
"""
|
28
28
|
Some type description
|
@@ -43,38 +43,52 @@ The schema defines the following properties:
|
|
43
43
|
|
44
44
|
Includes:
|
45
45
|
|
46
|
-
-
|
47
|
-
-
|
48
|
-
-
|
49
|
-
-
|
50
|
-
-
|
51
|
-
-
|
46
|
+
- `ObjectTypeDefinition`
|
47
|
+
- `InterfaceTypeDefinition`
|
48
|
+
- `EnumTypeDefinition`
|
49
|
+
- `ScalarTypeDefinition`
|
50
|
+
- `InputObjectTypeDefinition`
|
51
|
+
- `UnionTypeDefinition`
|
52
52
|
|
53
|
-
### `
|
53
|
+
### `DirectiveDefinition` (boolean)
|
54
54
|
|
55
|
-
|
55
|
+
Read more about this kind on [spec.graphql.org](https://spec.graphql.org/October2021/#DirectiveDefinition).
|
56
56
|
|
57
|
-
|
57
|
+
### `EnumTypeDefinition` (boolean)
|
58
58
|
|
59
|
-
|
59
|
+
Read more about this kind on [spec.graphql.org](https://spec.graphql.org/October2021/#EnumTypeDefinition).
|
60
60
|
|
61
|
-
|
61
|
+
### `EnumValueDefinition` (boolean)
|
62
62
|
|
63
|
-
|
63
|
+
Read more about this kind on [spec.graphql.org](https://spec.graphql.org/October2021/#EnumValueDefinition).
|
64
64
|
|
65
|
-
|
65
|
+
### `FieldDefinition` (boolean)
|
66
66
|
|
67
|
-
|
67
|
+
Read more about this kind on [spec.graphql.org](https://spec.graphql.org/October2021/#FieldDefinition).
|
68
68
|
|
69
|
-
|
69
|
+
### `InputObjectTypeDefinition` (boolean)
|
70
70
|
|
71
|
-
|
71
|
+
Read more about this kind on [spec.graphql.org](https://spec.graphql.org/October2021/#InputObjectTypeDefinition).
|
72
72
|
|
73
|
-
|
73
|
+
### `InputValueDefinition` (boolean)
|
74
74
|
|
75
|
-
|
75
|
+
Read more about this kind on [spec.graphql.org](https://spec.graphql.org/October2021/#InputValueDefinition).
|
76
76
|
|
77
|
-
|
77
|
+
### `InterfaceTypeDefinition` (boolean)
|
78
|
+
|
79
|
+
Read more about this kind on [spec.graphql.org](https://spec.graphql.org/October2021/#InterfaceTypeDefinition).
|
80
|
+
|
81
|
+
### `ObjectTypeDefinition` (boolean)
|
82
|
+
|
83
|
+
Read more about this kind on [spec.graphql.org](https://spec.graphql.org/October2021/#ObjectTypeDefinition).
|
84
|
+
|
85
|
+
### `ScalarTypeDefinition` (boolean)
|
86
|
+
|
87
|
+
Read more about this kind on [spec.graphql.org](https://spec.graphql.org/October2021/#ScalarTypeDefinition).
|
88
|
+
|
89
|
+
### `UnionTypeDefinition` (boolean)
|
90
|
+
|
91
|
+
Read more about this kind on [spec.graphql.org](https://spec.graphql.org/October2021/#UnionTypeDefinition).
|
78
92
|
|
79
93
|
## Resources
|
80
94
|
|