@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.
@@ -14,20 +14,18 @@ export declare const configs: {
14
14
  '@graphql-eslint/naming-convention': (string | {
15
15
  types: string;
16
16
  fields: string;
17
- overrides: {
18
- EnumValueDefinition: string;
19
- 'FieldDefinition[parent.name.value=Query]': {
20
- forbiddenPrefixes: string[];
21
- forbiddenSuffixes: string[];
22
- };
23
- 'FieldDefinition[parent.name.value=Mutation]': {
24
- forbiddenPrefixes: string[];
25
- forbiddenSuffixes: string[];
26
- };
27
- 'FieldDefinition[parent.name.value=Subscription]': {
28
- forbiddenPrefixes: string[];
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
- overrides: {
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
- overrides: {
84
- Argument: string;
85
- VariableDefinition: string;
86
- OperationDefinition: {
87
- style: string;
88
- forbiddenPrefixes: string[];
89
- forbiddenSuffixes: string[];
90
- };
91
- FragmentDefinition: {
92
- style: string;
93
- forbiddenPrefixes: string[];
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
- overrides: {
14
- Argument: string;
15
- VariableDefinition: string;
16
- OperationDefinition: {
17
- style: string;
18
- forbiddenPrefixes: string[];
19
- forbiddenSuffixes: string[];
20
- };
21
- FragmentDefinition: {
22
- style: string;
23
- forbiddenPrefixes: string[];
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;
@@ -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
- overrides: {
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
- overrides: {
13
- EnumValueDefinition: string;
14
- 'FieldDefinition[parent.name.value=Query]': {
15
- forbiddenPrefixes: string[];
16
- forbiddenSuffixes: string[];
17
- };
18
- 'FieldDefinition[parent.name.value=Mutation]': {
19
- forbiddenPrefixes: string[];
20
- forbiddenSuffixes: string[];
21
- };
22
- 'FieldDefinition[parent.name.value=Subscription]': {
23
- forbiddenPrefixes: string[];
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 for `read-only` or `write-only` schemas.|🚀||
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.|🔮||✅
@@ -44,7 +44,7 @@ This element must be one of the following enum values:
44
44
  - `block`
45
45
  - `inline`
46
46
 
47
- Default: `"inline"`
47
+ Default: `"block"`
48
48
 
49
49
  ## Resources
50
50
 
@@ -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
- - [ObjectTypeDefinition](https://spec.graphql.org/October2021/#ObjectTypeDefinition)
43
- - [InterfaceTypeDefinition](https://spec.graphql.org/October2021/#InterfaceTypeDefinition)
44
- - [EnumTypeDefinition](https://spec.graphql.org/October2021/#EnumTypeDefinition)
45
- - [ScalarTypeDefinition](https://spec.graphql.org/October2021/#ScalarTypeDefinition)
46
- - [InputObjectTypeDefinition](https://spec.graphql.org/October2021/#InputObjectTypeDefinition)
47
- - [UnionTypeDefinition](https://spec.graphql.org/October2021/#UnionTypeDefinition)
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
- - [FieldDefinition](https://spec.graphql.org/October2021/#FieldDefinition)
59
- - [InputValueDefinition](https://spec.graphql.org/October2021/#InputValueDefinition)
60
- - [Argument](https://spec.graphql.org/October2021/#Argument)
61
- - [DirectiveDefinition](https://spec.graphql.org/October2021/#DirectiveDefinition)
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
- ### `allowLeadingUnderscore` (boolean)
82
+ ### `Argument`
69
83
 
70
- Default: `false`
84
+ Read more about this kind on [spec.graphql.org](https://spec.graphql.org/October2021/#Argument).
71
85
 
72
- ### `allowTrailingUnderscore` (boolean)
86
+ The object must be one of the following types:
73
87
 
74
- Default: `false`
88
+ * `asString`
89
+ * `asObject`
75
90
 
76
- ### `overrides` (object)
77
-
78
- May contain the following `ASTNode` names:
79
-
80
- - [Argument](https://spec.graphql.org/October2021/#Argument)
81
- - [DirectiveDefinition](https://spec.graphql.org/October2021/#DirectiveDefinition)
82
- - [EnumTypeDefinition](https://spec.graphql.org/October2021/#EnumTypeDefinition)
83
- - [EnumValueDefinition](https://spec.graphql.org/October2021/#EnumValueDefinition)
84
- - [FieldDefinition](https://spec.graphql.org/October2021/#FieldDefinition)
85
- - [FragmentDefinition](https://spec.graphql.org/October2021/#FragmentDefinition)
86
- - [InputObjectTypeDefinition](https://spec.graphql.org/October2021/#InputObjectTypeDefinition)
87
- - [InputValueDefinition](https://spec.graphql.org/October2021/#InputValueDefinition)
88
- - [InterfaceTypeDefinition](https://spec.graphql.org/October2021/#InterfaceTypeDefinition)
89
- - [ObjectTypeDefinition](https://spec.graphql.org/October2021/#ObjectTypeDefinition)
90
- - [OperationDefinition](https://spec.graphql.org/October2021/#OperationDefinition)
91
- - [ScalarTypeDefinition](https://spec.graphql.org/October2021/#ScalarTypeDefinition)
92
- - [UnionTypeDefinition](https://spec.graphql.org/October2021/#UnionTypeDefinition)
93
- - [VariableDefinition](https://spec.graphql.org/October2021/#VariableDefinition)
94
-
95
- > It's also possible to use a [`selector`](https://eslint.org/docs/developer-guide/selectors) that starts with `ASTNode` name
96
- >
97
- > Example: pattern property `FieldDefinition[parent.name.value=Query]` will match only fields for type `Query`
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
- Pattern properties of the `overrides` object:
199
+ ### `VariableDefinition`
100
200
 
101
- #### `^(Argument|DirectiveDefinition|EnumTypeDefinition|EnumValueDefinition|FieldDefinition|FragmentDefinition|InputObjectTypeDefinition|InputValueDefinition|InterfaceTypeDefinition|ObjectTypeDefinition|OperationDefinition|ScalarTypeDefinition|UnionTypeDefinition|VariableDefinition)(.+)?$`
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 for `read-only` or `write-only` schemas.
8
+ Disallow using root types `mutation` and/or `subscription`.
9
9
 
10
10
  ## Usage Examples
11
11
 
12
- ### Incorrect (`read-only` schema)
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
- ### 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)
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, overrides: { FieldDefinition: 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, overrides: { FieldDefinition: 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
- - [ObjectTypeDefinition](https://spec.graphql.org/October2021/#ObjectTypeDefinition)
47
- - [InterfaceTypeDefinition](https://spec.graphql.org/October2021/#InterfaceTypeDefinition)
48
- - [EnumTypeDefinition](https://spec.graphql.org/October2021/#EnumTypeDefinition)
49
- - [ScalarTypeDefinition](https://spec.graphql.org/October2021/#ScalarTypeDefinition)
50
- - [InputObjectTypeDefinition](https://spec.graphql.org/October2021/#InputObjectTypeDefinition)
51
- - [UnionTypeDefinition](https://spec.graphql.org/October2021/#UnionTypeDefinition)
46
+ - `ObjectTypeDefinition`
47
+ - `InterfaceTypeDefinition`
48
+ - `EnumTypeDefinition`
49
+ - `ScalarTypeDefinition`
50
+ - `InputObjectTypeDefinition`
51
+ - `UnionTypeDefinition`
52
52
 
53
- ### `overrides` (object)
53
+ ### `DirectiveDefinition` (boolean)
54
54
 
55
- Configuration for precise `ASTNode`
55
+ Read more about this kind on [spec.graphql.org](https://spec.graphql.org/October2021/#DirectiveDefinition).
56
56
 
57
- Properties of the `overrides` object:
57
+ ### `EnumTypeDefinition` (boolean)
58
58
 
59
- #### `ObjectTypeDefinition` (boolean)
59
+ Read more about this kind on [spec.graphql.org](https://spec.graphql.org/October2021/#EnumTypeDefinition).
60
60
 
61
- #### `InterfaceTypeDefinition` (boolean)
61
+ ### `EnumValueDefinition` (boolean)
62
62
 
63
- #### `EnumTypeDefinition` (boolean)
63
+ Read more about this kind on [spec.graphql.org](https://spec.graphql.org/October2021/#EnumValueDefinition).
64
64
 
65
- #### `ScalarTypeDefinition` (boolean)
65
+ ### `FieldDefinition` (boolean)
66
66
 
67
- #### `InputObjectTypeDefinition` (boolean)
67
+ Read more about this kind on [spec.graphql.org](https://spec.graphql.org/October2021/#FieldDefinition).
68
68
 
69
- #### `UnionTypeDefinition` (boolean)
69
+ ### `InputObjectTypeDefinition` (boolean)
70
70
 
71
- #### `FieldDefinition` (boolean)
71
+ Read more about this kind on [spec.graphql.org](https://spec.graphql.org/October2021/#InputObjectTypeDefinition).
72
72
 
73
- #### `InputValueDefinition` (boolean)
73
+ ### `InputValueDefinition` (boolean)
74
74
 
75
- #### `EnumValueDefinition` (boolean)
75
+ Read more about this kind on [spec.graphql.org](https://spec.graphql.org/October2021/#InputValueDefinition).
76
76
 
77
- #### `DirectiveDefinition` (boolean)
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