@graphql-eslint/eslint-plugin 3.0.0-alpha-0a66b90.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/README.md +19 -8
- package/configs/base.d.ts +5 -0
- package/configs/index.d.ts +78 -121
- package/configs/operations-all.d.ts +19 -0
- package/configs/operations-recommended.d.ts +51 -0
- package/configs/schema-all.d.ts +21 -0
- package/configs/schema-recommended.d.ts +42 -0
- package/docs/README.md +10 -18
- package/docs/deprecated-rules.md +21 -0
- package/docs/rules/alphabetize.md +1 -1
- package/docs/rules/description-style.md +5 -3
- package/docs/rules/executable-definitions.md +2 -2
- package/docs/rules/fields-on-correct-type.md +2 -2
- package/docs/rules/fragments-on-composite-type.md +2 -2
- package/docs/rules/input-name.md +1 -1
- package/docs/rules/known-argument-names.md +2 -2
- package/docs/rules/known-directives.md +2 -2
- package/docs/rules/known-fragment-names.md +2 -2
- package/docs/rules/known-type-names.md +2 -2
- package/docs/rules/lone-anonymous-operation.md +2 -2
- package/docs/rules/lone-schema-definition.md +2 -2
- package/docs/rules/match-document-filename.md +6 -4
- package/docs/rules/naming-convention.md +140 -41
- package/docs/rules/no-anonymous-operations.md +2 -2
- package/docs/rules/no-case-insensitive-enum-values-duplicates.md +2 -2
- package/docs/rules/no-deprecated.md +3 -1
- package/docs/rules/{avoid-duplicate-fields.md → no-duplicate-fields.md} +10 -8
- package/docs/rules/no-fragment-cycles.md +2 -2
- package/docs/rules/no-hashtag-description.md +3 -1
- package/docs/rules/no-root-type.md +9 -14
- package/docs/rules/{avoid-scalar-result-type-on-mutation.md → no-scalar-result-type-on-mutation.md} +7 -7
- package/docs/rules/no-typename-prefix.md +37 -0
- package/docs/rules/no-undefined-variables.md +2 -2
- package/docs/rules/no-unreachable-types.md +3 -1
- package/docs/rules/no-unused-fields.md +1 -1
- package/docs/rules/no-unused-fragments.md +2 -2
- package/docs/rules/no-unused-variables.md +2 -2
- package/docs/rules/one-field-subscriptions.md +2 -2
- package/docs/rules/overlapping-fields-can-be-merged.md +2 -2
- package/docs/rules/possible-fragment-spread.md +2 -2
- package/docs/rules/possible-type-extension.md +2 -2
- package/docs/rules/provided-required-arguments.md +2 -2
- package/docs/rules/require-deprecation-date.md +1 -1
- package/docs/rules/require-deprecation-reason.md +2 -2
- package/docs/rules/require-description.md +36 -22
- package/docs/rules/require-field-of-type-query-in-mutation-result.md +1 -1
- package/docs/rules/require-id-when-available.md +3 -1
- package/docs/rules/scalar-leafs.md +2 -2
- package/docs/rules/selection-set-depth.md +9 -2
- package/docs/rules/strict-id-in-types.md +16 -10
- package/docs/rules/unique-argument-names.md +2 -2
- package/docs/rules/unique-directive-names-per-location.md +2 -2
- package/docs/rules/unique-directive-names.md +2 -2
- package/docs/rules/unique-enum-value-names.md +2 -2
- package/docs/rules/unique-field-definition-names.md +2 -2
- package/docs/rules/unique-fragment-name.md +1 -1
- package/docs/rules/unique-input-field-names.md +2 -2
- package/docs/rules/unique-operation-name.md +1 -1
- package/docs/rules/unique-operation-types.md +2 -2
- package/docs/rules/unique-type-names.md +2 -2
- package/docs/rules/unique-variable-names.md +2 -2
- package/docs/rules/value-literals-of-correct-type.md +2 -2
- package/docs/rules/variables-are-input-types.md +2 -2
- package/docs/rules/variables-in-allowed-position.md +2 -2
- package/index.js +651 -724
- package/index.mjs +652 -725
- package/package.json +1 -1
- package/rules/alphabetize.d.ts +8 -10
- package/rules/description-style.d.ts +4 -6
- package/rules/index.d.ts +115 -119
- package/rules/input-name.d.ts +1 -1
- package/rules/match-document-filename.d.ts +8 -10
- package/rules/naming-convention.d.ts +3 -4
- package/rules/{avoid-duplicate-fields.d.ts → no-duplicate-fields.d.ts} +0 -0
- package/rules/no-root-type.d.ts +1 -1
- package/rules/{avoid-scalar-result-type-on-mutation.d.ts → no-scalar-result-type-on-mutation.d.ts} +0 -0
- package/rules/{avoid-typename-prefix.d.ts → no-typename-prefix.d.ts} +0 -0
- package/rules/require-description.d.ts +2 -3
- package/rules/require-id-when-available.d.ts +3 -3
- package/rules/selection-set-depth.d.ts +3 -3
- package/rules/strict-id-in-types.d.ts +6 -8
- package/types.d.ts +9 -5
- package/configs/all.d.ts +0 -104
- package/configs/recommended.d.ts +0 -72
- package/docs/rules/avoid-operation-name-prefix.md +0 -50
- package/docs/rules/avoid-typename-prefix.md +0 -37
- package/docs/rules/no-operation-name-suffix.md +0 -38
- package/rules/avoid-operation-name-prefix.d.ts +0 -9
- package/rules/no-operation-name-suffix.d.ts +0 -3
@@ -1,8 +1,8 @@
|
|
1
1
|
# `known-directives`
|
2
2
|
|
3
|
-
✅ The `"extends": "plugin:@graphql-eslint/recommended"` property in a configuration file enables this rule.
|
3
|
+
✅ The `"extends": "plugin:@graphql-eslint/schema-recommended"` and `"plugin:@graphql-eslint/operations-recommended"` property in a configuration file enables this rule.
|
4
4
|
|
5
|
-
- Category: `
|
5
|
+
- Category: `Schema & Operations`
|
6
6
|
- Rule name: `@graphql-eslint/known-directives`
|
7
7
|
- Requires GraphQL Schema: `true` [ℹ️](../../README.md#extended-linting-rules-with-graphql-schema)
|
8
8
|
- Requires GraphQL Operations: `false` [ℹ️](../../README.md#extended-linting-rules-with-siblings-operations)
|
@@ -1,8 +1,8 @@
|
|
1
1
|
# `known-fragment-names`
|
2
2
|
|
3
|
-
✅ The `"extends": "plugin:@graphql-eslint/recommended"` property in a configuration file enables this rule.
|
3
|
+
✅ The `"extends": "plugin:@graphql-eslint/operations-recommended"` property in a configuration file enables this rule.
|
4
4
|
|
5
|
-
- Category: `
|
5
|
+
- Category: `Operations`
|
6
6
|
- Rule name: `@graphql-eslint/known-fragment-names`
|
7
7
|
- Requires GraphQL Schema: `true` [ℹ️](../../README.md#extended-linting-rules-with-graphql-schema)
|
8
8
|
- Requires GraphQL Operations: `false` [ℹ️](../../README.md#extended-linting-rules-with-siblings-operations)
|
@@ -1,8 +1,8 @@
|
|
1
1
|
# `known-type-names`
|
2
2
|
|
3
|
-
✅ The `"extends": "plugin:@graphql-eslint/recommended"` property in a configuration file enables this rule.
|
3
|
+
✅ The `"extends": "plugin:@graphql-eslint/schema-recommended"` and `"plugin:@graphql-eslint/operations-recommended"` property in a configuration file enables this rule.
|
4
4
|
|
5
|
-
- Category: `
|
5
|
+
- Category: `Schema & Operations`
|
6
6
|
- Rule name: `@graphql-eslint/known-type-names`
|
7
7
|
- Requires GraphQL Schema: `true` [ℹ️](../../README.md#extended-linting-rules-with-graphql-schema)
|
8
8
|
- Requires GraphQL Operations: `false` [ℹ️](../../README.md#extended-linting-rules-with-siblings-operations)
|
@@ -1,8 +1,8 @@
|
|
1
1
|
# `lone-anonymous-operation`
|
2
2
|
|
3
|
-
✅ The `"extends": "plugin:@graphql-eslint/recommended"` property in a configuration file enables this rule.
|
3
|
+
✅ The `"extends": "plugin:@graphql-eslint/operations-recommended"` property in a configuration file enables this rule.
|
4
4
|
|
5
|
-
- Category: `
|
5
|
+
- Category: `Operations`
|
6
6
|
- Rule name: `@graphql-eslint/lone-anonymous-operation`
|
7
7
|
- Requires GraphQL Schema: `true` [ℹ️](../../README.md#extended-linting-rules-with-graphql-schema)
|
8
8
|
- Requires GraphQL Operations: `false` [ℹ️](../../README.md#extended-linting-rules-with-siblings-operations)
|
@@ -1,8 +1,8 @@
|
|
1
1
|
# `lone-schema-definition`
|
2
2
|
|
3
|
-
✅ The `"extends": "plugin:@graphql-eslint/recommended"` property in a configuration file enables this rule.
|
3
|
+
✅ The `"extends": "plugin:@graphql-eslint/schema-recommended"` property in a configuration file enables this rule.
|
4
4
|
|
5
|
-
- Category: `
|
5
|
+
- Category: `Schema`
|
6
6
|
- Rule name: `@graphql-eslint/lone-schema-definition`
|
7
7
|
- Requires GraphQL Schema: `false` [ℹ️](../../README.md#extended-linting-rules-with-graphql-schema)
|
8
8
|
- Requires GraphQL Operations: `false` [ℹ️](../../README.md#extended-linting-rules-with-siblings-operations)
|
@@ -1,6 +1,6 @@
|
|
1
1
|
# `match-document-filename`
|
2
2
|
|
3
|
-
- Category: `
|
3
|
+
- Category: `Operations`
|
4
4
|
- Rule name: `@graphql-eslint/match-document-filename`
|
5
5
|
- Requires GraphQL Schema: `false` [ℹ️](../../README.md#extended-linting-rules-with-graphql-schema)
|
6
6
|
- Requires GraphQL Operations: `false` [ℹ️](../../README.md#extended-linting-rules-with-siblings-operations)
|
@@ -88,7 +88,7 @@ query UserById {
|
|
88
88
|
|
89
89
|
The schema defines the following properties:
|
90
90
|
|
91
|
-
### `fileExtension` (
|
91
|
+
### `fileExtension` (enum)
|
92
92
|
|
93
93
|
This element must be one of the following enum values:
|
94
94
|
|
@@ -129,7 +129,7 @@ The object must be one of the following types:
|
|
129
129
|
|
130
130
|
The schema defines the following additional types:
|
131
131
|
|
132
|
-
## `asString` (
|
132
|
+
## `asString` (enum)
|
133
133
|
|
134
134
|
One of: `camelCase`, `PascalCase`, `snake_case`, `UPPER_CASE`, `kebab-case`
|
135
135
|
|
@@ -137,7 +137,7 @@ One of: `camelCase`, `PascalCase`, `snake_case`, `UPPER_CASE`, `kebab-case`
|
|
137
137
|
|
138
138
|
Properties of the `asObject` object:
|
139
139
|
|
140
|
-
### `style` (
|
140
|
+
### `style` (enum)
|
141
141
|
|
142
142
|
This element must be one of the following enum values:
|
143
143
|
|
@@ -147,6 +147,8 @@ This element must be one of the following enum values:
|
|
147
147
|
- `UPPER_CASE`
|
148
148
|
- `kebab-case`
|
149
149
|
|
150
|
+
### `suffix` (string)
|
151
|
+
|
150
152
|
## Resources
|
151
153
|
|
152
154
|
- [Rule source](../../packages/plugin/src/rules/match-document-filename.ts)
|
@@ -1,8 +1,8 @@
|
|
1
1
|
# `naming-convention`
|
2
2
|
|
3
|
-
✅ The `"extends": "plugin:@graphql-eslint/recommended"` property in a configuration file enables this rule.
|
3
|
+
✅ The `"extends": "plugin:@graphql-eslint/schema-recommended"` and `"plugin:@graphql-eslint/operations-recommended"` property in a configuration file enables this rule.
|
4
4
|
|
5
|
-
- Category: `
|
5
|
+
- Category: `Schema & Operations`
|
6
6
|
- Rule name: `@graphql-eslint/naming-convention`
|
7
7
|
- Requires GraphQL Schema: `false` [ℹ️](../../README.md#extended-linting-rules-with-graphql-schema)
|
8
8
|
- Requires GraphQL Operations: `false` [ℹ️](../../README.md#extended-linting-rules-with-siblings-operations)
|
@@ -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,51 +69,136 @@ The object must be one of the following types:
|
|
55
69
|
|
56
70
|
Includes:
|
57
71
|
|
58
|
-
-
|
59
|
-
-
|
60
|
-
-
|
61
|
-
-
|
62
|
-
- [DirectiveDefinition](https://spec.graphql.org/October2021/#DirectiveDefinition)
|
72
|
+
- `FieldDefinition`
|
73
|
+
- `InputValueDefinition`
|
74
|
+
- `Argument`
|
75
|
+
- `DirectiveDefinition`
|
63
76
|
|
64
77
|
The object must be one of the following types:
|
65
78
|
|
66
79
|
* `asString`
|
67
80
|
* `asObject`
|
68
81
|
|
69
|
-
### `
|
82
|
+
### `Argument`
|
70
83
|
|
71
|
-
|
84
|
+
Read more about this kind on [spec.graphql.org](https://spec.graphql.org/October2021/#Argument).
|
72
85
|
|
73
|
-
|
86
|
+
The object must be one of the following types:
|
74
87
|
|
75
|
-
|
88
|
+
* `asString`
|
89
|
+
* `asObject`
|
76
90
|
|
77
|
-
### `
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
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`
|
99
198
|
|
100
|
-
|
199
|
+
### `VariableDefinition`
|
101
200
|
|
102
|
-
|
201
|
+
Read more about this kind on [spec.graphql.org](https://spec.graphql.org/October2021/#VariableDefinition).
|
103
202
|
|
104
203
|
The object must be one of the following types:
|
105
204
|
|
@@ -1,8 +1,8 @@
|
|
1
1
|
# `no-anonymous-operations`
|
2
2
|
|
3
|
-
✅ The `"extends": "plugin:@graphql-eslint/recommended"` property in a configuration file enables this rule.
|
3
|
+
✅ The `"extends": "plugin:@graphql-eslint/operations-recommended"` property in a configuration file enables this rule.
|
4
4
|
|
5
|
-
- Category: `
|
5
|
+
- Category: `Operations`
|
6
6
|
- Rule name: `@graphql-eslint/no-anonymous-operations`
|
7
7
|
- Requires GraphQL Schema: `false` [ℹ️](../../README.md#extended-linting-rules-with-graphql-schema)
|
8
8
|
- Requires GraphQL Operations: `false` [ℹ️](../../README.md#extended-linting-rules-with-siblings-operations)
|
@@ -1,10 +1,10 @@
|
|
1
1
|
# `no-case-insensitive-enum-values-duplicates`
|
2
2
|
|
3
|
-
✅ The `"extends": "plugin:@graphql-eslint/recommended"` property in a configuration file enables this rule.
|
3
|
+
✅ The `"extends": "plugin:@graphql-eslint/schema-recommended"` property in a configuration file enables this rule.
|
4
4
|
|
5
5
|
🔧 The `--fix` option on the [command line](https://eslint.org/docs/user-guide/command-line-interface#--fix) can automatically fix some of the problems reported by this rule.
|
6
6
|
|
7
|
-
- Category: `
|
7
|
+
- Category: `Schema`
|
8
8
|
- Rule name: `@graphql-eslint/no-case-insensitive-enum-values-duplicates`
|
9
9
|
- Requires GraphQL Schema: `false` [ℹ️](../../README.md#extended-linting-rules-with-graphql-schema)
|
10
10
|
- Requires GraphQL Operations: `false` [ℹ️](../../README.md#extended-linting-rules-with-siblings-operations)
|
@@ -1,6 +1,8 @@
|
|
1
1
|
# `no-deprecated`
|
2
2
|
|
3
|
-
|
3
|
+
✅ The `"extends": "plugin:@graphql-eslint/operations-recommended"` property in a configuration file enables this rule.
|
4
|
+
|
5
|
+
- Category: `Operations`
|
4
6
|
- Rule name: `@graphql-eslint/no-deprecated`
|
5
7
|
- Requires GraphQL Schema: `true` [ℹ️](../../README.md#extended-linting-rules-with-graphql-schema)
|
6
8
|
- Requires GraphQL Operations: `false` [ℹ️](../../README.md#extended-linting-rules-with-siblings-operations)
|
@@ -1,7 +1,9 @@
|
|
1
|
-
# `
|
1
|
+
# `no-duplicate-fields`
|
2
2
|
|
3
|
-
|
4
|
-
|
3
|
+
✅ The `"extends": "plugin:@graphql-eslint/operations-recommended"` property in a configuration file enables this rule.
|
4
|
+
|
5
|
+
- Category: `Operations`
|
6
|
+
- Rule name: `@graphql-eslint/no-duplicate-fields`
|
5
7
|
- Requires GraphQL Schema: `false` [ℹ️](../../README.md#extended-linting-rules-with-graphql-schema)
|
6
8
|
- Requires GraphQL Operations: `false` [ℹ️](../../README.md#extended-linting-rules-with-siblings-operations)
|
7
9
|
|
@@ -12,7 +14,7 @@ Checks for duplicate fields in selection set, variables in operation definition,
|
|
12
14
|
### Incorrect
|
13
15
|
|
14
16
|
```graphql
|
15
|
-
# eslint @graphql-eslint/
|
17
|
+
# eslint @graphql-eslint/no-duplicate-fields: 'error'
|
16
18
|
|
17
19
|
query {
|
18
20
|
user {
|
@@ -26,7 +28,7 @@ query {
|
|
26
28
|
### Incorrect
|
27
29
|
|
28
30
|
```graphql
|
29
|
-
# eslint @graphql-eslint/
|
31
|
+
# eslint @graphql-eslint/no-duplicate-fields: 'error'
|
30
32
|
|
31
33
|
query {
|
32
34
|
users(
|
@@ -43,7 +45,7 @@ query {
|
|
43
45
|
### Incorrect
|
44
46
|
|
45
47
|
```graphql
|
46
|
-
# eslint @graphql-eslint/
|
48
|
+
# eslint @graphql-eslint/no-duplicate-fields: 'error'
|
47
49
|
|
48
50
|
query (
|
49
51
|
$first: Int!
|
@@ -57,5 +59,5 @@ query (
|
|
57
59
|
|
58
60
|
## Resources
|
59
61
|
|
60
|
-
- [Rule source](../../packages/plugin/src/rules/
|
61
|
-
- [Test source](../../packages/plugin/tests/
|
62
|
+
- [Rule source](../../packages/plugin/src/rules/no-duplicate-fields.ts)
|
63
|
+
- [Test source](../../packages/plugin/tests/no-duplicate-fields.spec.ts)
|
@@ -1,8 +1,8 @@
|
|
1
1
|
# `no-fragment-cycles`
|
2
2
|
|
3
|
-
✅ The `"extends": "plugin:@graphql-eslint/recommended"` property in a configuration file enables this rule.
|
3
|
+
✅ The `"extends": "plugin:@graphql-eslint/operations-recommended"` property in a configuration file enables this rule.
|
4
4
|
|
5
|
-
- Category: `
|
5
|
+
- Category: `Operations`
|
6
6
|
- Rule name: `@graphql-eslint/no-fragment-cycles`
|
7
7
|
- Requires GraphQL Schema: `true` [ℹ️](../../README.md#extended-linting-rules-with-graphql-schema)
|
8
8
|
- Requires GraphQL Operations: `false` [ℹ️](../../README.md#extended-linting-rules-with-siblings-operations)
|
@@ -1,6 +1,8 @@
|
|
1
1
|
# `no-hashtag-description`
|
2
2
|
|
3
|
-
|
3
|
+
✅ The `"extends": "plugin:@graphql-eslint/schema-recommended"` property in a configuration file enables this rule.
|
4
|
+
|
5
|
+
- Category: `Schema`
|
4
6
|
- Rule name: `@graphql-eslint/no-hashtag-description`
|
5
7
|
- Requires GraphQL Schema: `false` [ℹ️](../../README.md#extended-linting-rules-with-graphql-schema)
|
6
8
|
- Requires GraphQL Operations: `false` [ℹ️](../../README.md#extended-linting-rules-with-siblings-operations)
|
@@ -1,15 +1,15 @@
|
|
1
1
|
# `no-root-type`
|
2
2
|
|
3
|
-
- Category: `
|
3
|
+
- Category: `Schema`
|
4
4
|
- Rule name: `@graphql-eslint/no-root-type`
|
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'] }]
|
@@ -45,6 +35,11 @@ The schema defines the following properties:
|
|
45
35
|
|
46
36
|
### `disallow` (array, required)
|
47
37
|
|
38
|
+
The elements of the array can contain the following enum values:
|
39
|
+
|
40
|
+
- `mutation`
|
41
|
+
- `subscription`
|
42
|
+
|
48
43
|
Additional restrictions:
|
49
44
|
|
50
45
|
* Minimum items: `1`
|
package/docs/rules/{avoid-scalar-result-type-on-mutation.md → no-scalar-result-type-on-mutation.md}
RENAMED
@@ -1,7 +1,7 @@
|
|
1
|
-
# `
|
1
|
+
# `no-scalar-result-type-on-mutation`
|
2
2
|
|
3
|
-
- Category: `
|
4
|
-
- Rule name: `@graphql-eslint/
|
3
|
+
- Category: `Schema`
|
4
|
+
- Rule name: `@graphql-eslint/no-scalar-result-type-on-mutation`
|
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
|
|
@@ -12,7 +12,7 @@ Avoid scalar result type on mutation type to make sure to return a valid state.
|
|
12
12
|
### Incorrect
|
13
13
|
|
14
14
|
```graphql
|
15
|
-
# eslint @graphql-eslint/
|
15
|
+
# eslint @graphql-eslint/no-scalar-result-type-on-mutation: 'error'
|
16
16
|
|
17
17
|
type Mutation {
|
18
18
|
createUser: Boolean
|
@@ -22,7 +22,7 @@ type Mutation {
|
|
22
22
|
### Correct
|
23
23
|
|
24
24
|
```graphql
|
25
|
-
# eslint @graphql-eslint/
|
25
|
+
# eslint @graphql-eslint/no-scalar-result-type-on-mutation: 'error'
|
26
26
|
|
27
27
|
type Mutation {
|
28
28
|
createUser: User!
|
@@ -31,5 +31,5 @@ type Mutation {
|
|
31
31
|
|
32
32
|
## Resources
|
33
33
|
|
34
|
-
- [Rule source](../../packages/plugin/src/rules/
|
35
|
-
- [Test source](../../packages/plugin/tests/
|
34
|
+
- [Rule source](../../packages/plugin/src/rules/no-scalar-result-type-on-mutation.ts)
|
35
|
+
- [Test source](../../packages/plugin/tests/no-scalar-result-type-on-mutation.spec.ts)
|
@@ -0,0 +1,37 @@
|
|
1
|
+
# `no-typename-prefix`
|
2
|
+
|
3
|
+
✅ The `"extends": "plugin:@graphql-eslint/schema-recommended"` property in a configuration file enables this rule.
|
4
|
+
|
5
|
+
- Category: `Schema`
|
6
|
+
- Rule name: `@graphql-eslint/no-typename-prefix`
|
7
|
+
- Requires GraphQL Schema: `false` [ℹ️](../../README.md#extended-linting-rules-with-graphql-schema)
|
8
|
+
- Requires GraphQL Operations: `false` [ℹ️](../../README.md#extended-linting-rules-with-siblings-operations)
|
9
|
+
|
10
|
+
Enforces users to avoid using the type name in a field name while defining your schema.
|
11
|
+
|
12
|
+
## Usage Examples
|
13
|
+
|
14
|
+
### Incorrect
|
15
|
+
|
16
|
+
```graphql
|
17
|
+
# eslint @graphql-eslint/no-typename-prefix: 'error'
|
18
|
+
|
19
|
+
type User {
|
20
|
+
userId: ID!
|
21
|
+
}
|
22
|
+
```
|
23
|
+
|
24
|
+
### Correct
|
25
|
+
|
26
|
+
```graphql
|
27
|
+
# eslint @graphql-eslint/no-typename-prefix: 'error'
|
28
|
+
|
29
|
+
type User {
|
30
|
+
id: ID!
|
31
|
+
}
|
32
|
+
```
|
33
|
+
|
34
|
+
## Resources
|
35
|
+
|
36
|
+
- [Rule source](../../packages/plugin/src/rules/no-typename-prefix.ts)
|
37
|
+
- [Test source](../../packages/plugin/tests/no-typename-prefix.spec.ts)
|
@@ -1,8 +1,8 @@
|
|
1
1
|
# `no-undefined-variables`
|
2
2
|
|
3
|
-
✅ The `"extends": "plugin:@graphql-eslint/recommended"` property in a configuration file enables this rule.
|
3
|
+
✅ The `"extends": "plugin:@graphql-eslint/operations-recommended"` property in a configuration file enables this rule.
|
4
4
|
|
5
|
-
- Category: `
|
5
|
+
- Category: `Operations`
|
6
6
|
- Rule name: `@graphql-eslint/no-undefined-variables`
|
7
7
|
- Requires GraphQL Schema: `true` [ℹ️](../../README.md#extended-linting-rules-with-graphql-schema)
|
8
8
|
- Requires GraphQL Operations: `false` [ℹ️](../../README.md#extended-linting-rules-with-siblings-operations)
|
@@ -1,8 +1,10 @@
|
|
1
1
|
# `no-unreachable-types`
|
2
2
|
|
3
|
+
✅ The `"extends": "plugin:@graphql-eslint/schema-recommended"` property in a configuration file enables this rule.
|
4
|
+
|
3
5
|
🔧 The `--fix` option on the [command line](https://eslint.org/docs/user-guide/command-line-interface#--fix) can automatically fix some of the problems reported by this rule.
|
4
6
|
|
5
|
-
- Category: `
|
7
|
+
- Category: `Schema`
|
6
8
|
- Rule name: `@graphql-eslint/no-unreachable-types`
|
7
9
|
- Requires GraphQL Schema: `true` [ℹ️](../../README.md#extended-linting-rules-with-graphql-schema)
|
8
10
|
- Requires GraphQL Operations: `false` [ℹ️](../../README.md#extended-linting-rules-with-siblings-operations)
|
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
🔧 The `--fix` option on the [command line](https://eslint.org/docs/user-guide/command-line-interface#--fix) can automatically fix some of the problems reported by this rule.
|
4
4
|
|
5
|
-
- Category: `
|
5
|
+
- Category: `Schema`
|
6
6
|
- Rule name: `@graphql-eslint/no-unused-fields`
|
7
7
|
- Requires GraphQL Schema: `true` [ℹ️](../../README.md#extended-linting-rules-with-graphql-schema)
|
8
8
|
- Requires GraphQL Operations: `true` [ℹ️](../../README.md#extended-linting-rules-with-siblings-operations)
|
@@ -1,8 +1,8 @@
|
|
1
1
|
# `no-unused-fragments`
|
2
2
|
|
3
|
-
✅ The `"extends": "plugin:@graphql-eslint/recommended"` property in a configuration file enables this rule.
|
3
|
+
✅ The `"extends": "plugin:@graphql-eslint/operations-recommended"` property in a configuration file enables this rule.
|
4
4
|
|
5
|
-
- Category: `
|
5
|
+
- Category: `Operations`
|
6
6
|
- Rule name: `@graphql-eslint/no-unused-fragments`
|
7
7
|
- Requires GraphQL Schema: `true` [ℹ️](../../README.md#extended-linting-rules-with-graphql-schema)
|
8
8
|
- Requires GraphQL Operations: `true` [ℹ️](../../README.md#extended-linting-rules-with-siblings-operations)
|
@@ -1,8 +1,8 @@
|
|
1
1
|
# `no-unused-variables`
|
2
2
|
|
3
|
-
✅ The `"extends": "plugin:@graphql-eslint/recommended"` property in a configuration file enables this rule.
|
3
|
+
✅ The `"extends": "plugin:@graphql-eslint/operations-recommended"` property in a configuration file enables this rule.
|
4
4
|
|
5
|
-
- Category: `
|
5
|
+
- Category: `Operations`
|
6
6
|
- Rule name: `@graphql-eslint/no-unused-variables`
|
7
7
|
- Requires GraphQL Schema: `true` [ℹ️](../../README.md#extended-linting-rules-with-graphql-schema)
|
8
8
|
- Requires GraphQL Operations: `false` [ℹ️](../../README.md#extended-linting-rules-with-siblings-operations)
|
@@ -1,8 +1,8 @@
|
|
1
1
|
# `one-field-subscriptions`
|
2
2
|
|
3
|
-
✅ The `"extends": "plugin:@graphql-eslint/recommended"` property in a configuration file enables this rule.
|
3
|
+
✅ The `"extends": "plugin:@graphql-eslint/operations-recommended"` property in a configuration file enables this rule.
|
4
4
|
|
5
|
-
- Category: `
|
5
|
+
- Category: `Operations`
|
6
6
|
- Rule name: `@graphql-eslint/one-field-subscriptions`
|
7
7
|
- Requires GraphQL Schema: `true` [ℹ️](../../README.md#extended-linting-rules-with-graphql-schema)
|
8
8
|
- Requires GraphQL Operations: `false` [ℹ️](../../README.md#extended-linting-rules-with-siblings-operations)
|
@@ -1,8 +1,8 @@
|
|
1
1
|
# `overlapping-fields-can-be-merged`
|
2
2
|
|
3
|
-
✅ The `"extends": "plugin:@graphql-eslint/recommended"` property in a configuration file enables this rule.
|
3
|
+
✅ The `"extends": "plugin:@graphql-eslint/operations-recommended"` property in a configuration file enables this rule.
|
4
4
|
|
5
|
-
- Category: `
|
5
|
+
- Category: `Operations`
|
6
6
|
- Rule name: `@graphql-eslint/overlapping-fields-can-be-merged`
|
7
7
|
- Requires GraphQL Schema: `true` [ℹ️](../../README.md#extended-linting-rules-with-graphql-schema)
|
8
8
|
- Requires GraphQL Operations: `false` [ℹ️](../../README.md#extended-linting-rules-with-siblings-operations)
|
@@ -1,8 +1,8 @@
|
|
1
1
|
# `possible-fragment-spread`
|
2
2
|
|
3
|
-
✅ The `"extends": "plugin:@graphql-eslint/recommended"` property in a configuration file enables this rule.
|
3
|
+
✅ The `"extends": "plugin:@graphql-eslint/operations-recommended"` property in a configuration file enables this rule.
|
4
4
|
|
5
|
-
- Category: `
|
5
|
+
- Category: `Operations`
|
6
6
|
- Rule name: `@graphql-eslint/possible-fragment-spread`
|
7
7
|
- Requires GraphQL Schema: `true` [ℹ️](../../README.md#extended-linting-rules-with-graphql-schema)
|
8
8
|
- Requires GraphQL Operations: `false` [ℹ️](../../README.md#extended-linting-rules-with-siblings-operations)
|