@graphql-eslint/eslint-plugin 3.14.0-alpha-20221221133443-5be7fc6 → 3.14.0-alpha-20221222012949-5caade4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (231) hide show
  1. package/README.md +309 -0
  2. package/cjs/cache.js +30 -0
  3. package/cjs/configs/base.js +7 -0
  4. package/cjs/configs/index.js +16 -0
  5. package/cjs/configs/operations-all.js +31 -0
  6. package/cjs/configs/operations-recommended.js +56 -0
  7. package/cjs/configs/relay.js +12 -0
  8. package/cjs/configs/schema-all.js +23 -0
  9. package/cjs/configs/schema-recommended.js +52 -0
  10. package/cjs/documents.js +149 -0
  11. package/cjs/estree-converter/converter.js +62 -0
  12. package/cjs/estree-converter/index.js +6 -0
  13. package/cjs/estree-converter/types.js +2 -0
  14. package/cjs/estree-converter/utils.js +109 -0
  15. package/cjs/graphql-config.js +55 -0
  16. package/cjs/index.js +17 -0
  17. package/cjs/parser.js +61 -0
  18. package/cjs/processor.js +78 -0
  19. package/cjs/rules/alphabetize.js +348 -0
  20. package/cjs/rules/description-style.js +78 -0
  21. package/cjs/rules/graphql-js-validation.js +499 -0
  22. package/cjs/rules/index.js +68 -0
  23. package/cjs/rules/input-name.js +136 -0
  24. package/cjs/rules/lone-executable-definition.js +88 -0
  25. package/cjs/rules/match-document-filename.js +235 -0
  26. package/cjs/rules/naming-convention.js +310 -0
  27. package/cjs/rules/no-anonymous-operations.js +67 -0
  28. package/cjs/rules/no-case-insensitive-enum-values-duplicates.js +61 -0
  29. package/cjs/rules/no-deprecated.js +124 -0
  30. package/cjs/rules/no-duplicate-fields.js +112 -0
  31. package/cjs/rules/no-hashtag-description.js +89 -0
  32. package/cjs/rules/no-root-type.js +86 -0
  33. package/cjs/rules/no-scalar-result-type-on-mutation.js +66 -0
  34. package/cjs/rules/no-typename-prefix.js +65 -0
  35. package/cjs/rules/no-unreachable-types.js +158 -0
  36. package/cjs/rules/no-unused-fields.js +130 -0
  37. package/cjs/rules/relay-arguments.js +121 -0
  38. package/cjs/rules/relay-connection-types.js +107 -0
  39. package/cjs/rules/relay-edge-types.js +189 -0
  40. package/cjs/rules/relay-page-info.js +100 -0
  41. package/cjs/rules/require-deprecation-date.js +123 -0
  42. package/cjs/rules/require-deprecation-reason.js +56 -0
  43. package/cjs/rules/require-description.js +193 -0
  44. package/cjs/rules/require-field-of-type-query-in-mutation-result.js +72 -0
  45. package/cjs/rules/require-id-when-available.js +199 -0
  46. package/cjs/rules/selection-set-depth.js +135 -0
  47. package/cjs/rules/strict-id-in-types.js +162 -0
  48. package/cjs/rules/unique-fragment-name.js +90 -0
  49. package/cjs/rules/unique-operation-name.js +65 -0
  50. package/cjs/schema.js +42 -0
  51. package/cjs/testkit.js +183 -0
  52. package/cjs/types.js +2 -0
  53. package/cjs/utils.js +96 -0
  54. package/docs/README.md +82 -0
  55. package/docs/custom-rules.md +184 -0
  56. package/docs/deprecated-rules.md +24 -0
  57. package/docs/parser-options.md +95 -0
  58. package/docs/parser.md +67 -0
  59. package/docs/rules/alphabetize.md +194 -0
  60. package/docs/rules/description-style.md +57 -0
  61. package/docs/rules/executable-definitions.md +20 -0
  62. package/docs/rules/fields-on-correct-type.md +23 -0
  63. package/docs/rules/fragments-on-composite-type.md +20 -0
  64. package/docs/rules/input-name.md +80 -0
  65. package/docs/rules/known-argument-names.md +23 -0
  66. package/docs/rules/known-directives.md +48 -0
  67. package/docs/rules/known-fragment-names.md +72 -0
  68. package/docs/rules/known-type-names.md +24 -0
  69. package/docs/rules/lone-anonymous-operation.md +20 -0
  70. package/docs/rules/lone-executable-definition.md +59 -0
  71. package/docs/rules/lone-schema-definition.md +19 -0
  72. package/docs/rules/match-document-filename.md +181 -0
  73. package/docs/rules/naming-convention.md +320 -0
  74. package/docs/rules/no-anonymous-operations.md +43 -0
  75. package/docs/rules/no-case-insensitive-enum-values-duplicates.md +46 -0
  76. package/docs/rules/no-deprecated.md +88 -0
  77. package/docs/rules/no-duplicate-fields.md +69 -0
  78. package/docs/rules/no-fragment-cycles.md +19 -0
  79. package/docs/rules/no-hashtag-description.md +62 -0
  80. package/docs/rules/no-root-type.md +55 -0
  81. package/docs/rules/no-scalar-result-type-on-mutation.md +39 -0
  82. package/docs/rules/no-typename-prefix.md +42 -0
  83. package/docs/rules/no-undefined-variables.md +20 -0
  84. package/docs/rules/no-unreachable-types.md +52 -0
  85. package/docs/rules/no-unused-fields.md +64 -0
  86. package/docs/rules/no-unused-fragments.md +20 -0
  87. package/docs/rules/no-unused-variables.md +20 -0
  88. package/docs/rules/one-field-subscriptions.md +19 -0
  89. package/docs/rules/overlapping-fields-can-be-merged.md +20 -0
  90. package/docs/rules/possible-fragment-spread.md +21 -0
  91. package/docs/rules/possible-type-extension.md +19 -0
  92. package/docs/rules/provided-required-arguments.md +21 -0
  93. package/docs/rules/relay-arguments.md +59 -0
  94. package/docs/rules/relay-connection-types.md +43 -0
  95. package/docs/rules/relay-edge-types.md +60 -0
  96. package/docs/rules/relay-page-info.md +34 -0
  97. package/docs/rules/require-deprecation-date.md +59 -0
  98. package/docs/rules/require-deprecation-reason.md +49 -0
  99. package/docs/rules/require-description.md +147 -0
  100. package/docs/rules/require-field-of-type-query-in-mutation-result.md +50 -0
  101. package/docs/rules/require-id-when-available.md +91 -0
  102. package/docs/rules/scalar-leafs.md +23 -0
  103. package/docs/rules/selection-set-depth.md +86 -0
  104. package/docs/rules/strict-id-in-types.md +129 -0
  105. package/docs/rules/unique-argument-names.md +19 -0
  106. package/docs/rules/unique-directive-names-per-location.md +21 -0
  107. package/docs/rules/unique-directive-names.md +19 -0
  108. package/docs/rules/unique-enum-value-names.md +16 -0
  109. package/docs/rules/unique-field-definition-names.md +19 -0
  110. package/docs/rules/unique-fragment-name.md +52 -0
  111. package/docs/rules/unique-input-field-names.md +19 -0
  112. package/docs/rules/unique-operation-name.md +56 -0
  113. package/docs/rules/unique-operation-types.md +19 -0
  114. package/docs/rules/unique-type-names.md +19 -0
  115. package/docs/rules/unique-variable-names.md +19 -0
  116. package/docs/rules/value-literals-of-correct-type.md +22 -0
  117. package/docs/rules/variables-are-input-types.md +20 -0
  118. package/docs/rules/variables-in-allowed-position.md +19 -0
  119. package/package.json +8 -11
  120. package/{cache.d.ts → typings/cache.d.cts} +0 -0
  121. package/typings/cache.d.ts +10 -0
  122. package/typings/configs/base.d.cts +5 -0
  123. package/typings/configs/base.d.ts +5 -0
  124. package/typings/configs/index.d.cts +139 -0
  125. package/typings/configs/index.d.ts +139 -0
  126. package/typings/configs/operations-all.d.cts +20 -0
  127. package/typings/configs/operations-all.d.ts +20 -0
  128. package/typings/configs/operations-recommended.d.cts +50 -0
  129. package/typings/configs/operations-recommended.d.ts +50 -0
  130. package/typings/configs/relay.d.cts +10 -0
  131. package/typings/configs/relay.d.ts +10 -0
  132. package/typings/configs/schema-all.d.cts +15 -0
  133. package/typings/configs/schema-all.d.ts +15 -0
  134. package/typings/configs/schema-recommended.d.cts +47 -0
  135. package/typings/configs/schema-recommended.d.ts +47 -0
  136. package/{documents.d.ts → typings/documents.d.cts} +0 -0
  137. package/typings/documents.d.ts +21 -0
  138. package/{estree-converter/converter.d.ts → typings/estree-converter/converter.d.cts} +0 -0
  139. package/typings/estree-converter/converter.d.ts +3 -0
  140. package/{estree-converter/index.d.ts → typings/estree-converter/index.d.cts} +0 -0
  141. package/typings/estree-converter/index.d.ts +3 -0
  142. package/{estree-converter/types.d.ts → typings/estree-converter/types.d.cts} +0 -0
  143. package/typings/estree-converter/types.d.ts +40 -0
  144. package/{estree-converter/utils.d.ts → typings/estree-converter/utils.d.cts} +0 -0
  145. package/typings/estree-converter/utils.d.ts +13 -0
  146. package/{graphql-config.d.ts → typings/graphql-config.d.cts} +0 -0
  147. package/typings/graphql-config.d.ts +4 -0
  148. package/typings/index.d.cts +9 -0
  149. package/{index.d.ts → typings/index.d.ts} +1 -5
  150. package/{parser.d.ts → typings/parser.d.cts} +0 -0
  151. package/typings/parser.d.ts +2 -0
  152. package/{processor.d.ts → typings/processor.d.cts} +0 -0
  153. package/typings/processor.d.ts +6 -0
  154. package/{rules/alphabetize.d.ts → typings/rules/alphabetize.d.cts} +0 -0
  155. package/typings/rules/alphabetize.d.ts +76 -0
  156. package/{rules/description-style.d.ts → typings/rules/description-style.d.cts} +0 -0
  157. package/typings/rules/description-style.d.ts +20 -0
  158. package/{rules/graphql-js-validation.d.ts → typings/rules/graphql-js-validation.d.cts} +0 -0
  159. package/typings/rules/graphql-js-validation.d.ts +2 -0
  160. package/{rules/index.d.ts → typings/rules/index.d.cts} +0 -0
  161. package/typings/rules/index.d.ts +104 -0
  162. package/{rules/input-name.d.ts → typings/rules/input-name.d.cts} +0 -0
  163. package/typings/rules/input-name.d.ts +35 -0
  164. package/{rules/lone-executable-definition.d.ts → typings/rules/lone-executable-definition.d.cts} +0 -0
  165. package/typings/rules/lone-executable-definition.d.ts +26 -0
  166. package/{rules/match-document-filename.d.ts → typings/rules/match-document-filename.d.cts} +0 -0
  167. package/typings/rules/match-document-filename.d.ts +72 -0
  168. package/{rules/naming-convention.d.ts → typings/rules/naming-convention.d.cts} +0 -0
  169. package/typings/rules/naming-convention.d.ts +83 -0
  170. package/{rules/no-anonymous-operations.d.ts → typings/rules/no-anonymous-operations.d.cts} +0 -0
  171. package/{rules/no-case-insensitive-enum-values-duplicates.d.ts → typings/rules/no-anonymous-operations.d.ts} +0 -0
  172. package/{rules/no-hashtag-description.d.ts → typings/rules/no-case-insensitive-enum-values-duplicates.d.cts} +0 -0
  173. package/{rules/no-scalar-result-type-on-mutation.d.ts → typings/rules/no-case-insensitive-enum-values-duplicates.d.ts} +0 -0
  174. package/{rules/no-deprecated.d.ts → typings/rules/no-deprecated.d.cts} +0 -0
  175. package/typings/rules/no-deprecated.d.ts +2 -0
  176. package/{rules/no-duplicate-fields.d.ts → typings/rules/no-duplicate-fields.d.cts} +0 -0
  177. package/{rules/relay-page-info.d.ts → typings/rules/no-duplicate-fields.d.ts} +0 -0
  178. package/{rules/no-typename-prefix.d.ts → typings/rules/no-hashtag-description.d.cts} +0 -0
  179. package/{rules/no-unreachable-types.d.ts → typings/rules/no-hashtag-description.d.ts} +0 -0
  180. package/{rules/no-root-type.d.ts → typings/rules/no-root-type.d.cts} +0 -0
  181. package/typings/rules/no-root-type.d.ts +25 -0
  182. package/{rules/no-unused-fields.d.ts → typings/rules/no-scalar-result-type-on-mutation.d.cts} +0 -0
  183. package/{rules/unique-operation-name.d.ts → typings/rules/no-scalar-result-type-on-mutation.d.ts} +0 -0
  184. package/typings/rules/no-typename-prefix.d.cts +2 -0
  185. package/typings/rules/no-typename-prefix.d.ts +2 -0
  186. package/typings/rules/no-unreachable-types.d.cts +2 -0
  187. package/typings/rules/no-unreachable-types.d.ts +2 -0
  188. package/typings/rules/no-unused-fields.d.cts +2 -0
  189. package/typings/rules/no-unused-fields.d.ts +2 -0
  190. package/{rules/relay-arguments.d.ts → typings/rules/relay-arguments.d.cts} +0 -0
  191. package/typings/rules/relay-arguments.d.ts +21 -0
  192. package/{rules/relay-connection-types.d.ts → typings/rules/relay-connection-types.d.cts} +0 -0
  193. package/typings/rules/relay-connection-types.d.ts +4 -0
  194. package/{rules/relay-edge-types.d.ts → typings/rules/relay-edge-types.d.cts} +0 -0
  195. package/typings/rules/relay-edge-types.d.ts +31 -0
  196. package/{rules/require-deprecation-reason.d.ts → typings/rules/relay-page-info.d.cts} +0 -0
  197. package/{rules/require-field-of-type-query-in-mutation-result.d.ts → typings/rules/relay-page-info.d.ts} +0 -0
  198. package/{rules/require-deprecation-date.d.ts → typings/rules/require-deprecation-date.d.cts} +0 -0
  199. package/typings/rules/require-deprecation-date.d.ts +18 -0
  200. package/typings/rules/require-deprecation-reason.d.cts +2 -0
  201. package/typings/rules/require-deprecation-reason.d.ts +2 -0
  202. package/{rules/require-description.d.ts → typings/rules/require-description.d.cts} +0 -0
  203. package/typings/rules/require-description.d.ts +14 -0
  204. package/typings/rules/require-field-of-type-query-in-mutation-result.d.cts +2 -0
  205. package/typings/rules/require-field-of-type-query-in-mutation-result.d.ts +2 -0
  206. package/{rules/require-id-when-available.d.ts → typings/rules/require-id-when-available.d.cts} +0 -0
  207. package/typings/rules/require-id-when-available.d.ts +36 -0
  208. package/{rules/selection-set-depth.d.ts → typings/rules/selection-set-depth.d.cts} +0 -0
  209. package/typings/rules/selection-set-depth.d.ts +28 -0
  210. package/{rules/strict-id-in-types.d.ts → typings/rules/strict-id-in-types.d.cts} +0 -0
  211. package/typings/rules/strict-id-in-types.d.ts +57 -0
  212. package/{rules/unique-fragment-name.d.ts → typings/rules/unique-fragment-name.d.cts} +0 -0
  213. package/typings/rules/unique-fragment-name.d.ts +5 -0
  214. package/typings/rules/unique-operation-name.d.cts +2 -0
  215. package/typings/rules/unique-operation-name.d.ts +2 -0
  216. package/{schema.d.ts → typings/schema.d.cts} +0 -0
  217. package/typings/schema.d.ts +3 -0
  218. package/{testkit.d.ts → typings/testkit.d.cts} +0 -0
  219. package/typings/testkit.d.ts +27 -0
  220. package/{types.d.ts → typings/types.d.cts} +0 -0
  221. package/typings/types.d.ts +81 -0
  222. package/{utils.d.ts → typings/utils.d.cts} +0 -0
  223. package/typings/utils.d.ts +34 -0
  224. package/configs/base.json +0 -4
  225. package/configs/operations-all.json +0 -25
  226. package/configs/operations-recommended.json +0 -50
  227. package/configs/relay.json +0 -9
  228. package/configs/schema-all.json +0 -17
  229. package/configs/schema-recommended.json +0 -49
  230. package/index.js +0 -4995
  231. package/index.mjs +0 -4983
@@ -0,0 +1,39 @@
1
+ # `no-scalar-result-type-on-mutation`
2
+
3
+ 💡 This rule provides
4
+ [suggestions](https://eslint.org/docs/developer-guide/working-with-rules#providing-suggestions)
5
+
6
+ - Category: `Schema`
7
+ - Rule name: `@graphql-eslint/no-scalar-result-type-on-mutation`
8
+ - Requires GraphQL Schema: `true` [ℹ️](../../README.md#extended-linting-rules-with-graphql-schema)
9
+ - Requires GraphQL Operations: `false`
10
+ [ℹ️](../../README.md#extended-linting-rules-with-siblings-operations)
11
+
12
+ Avoid scalar result type on mutation type to make sure to return a valid state.
13
+
14
+ ## Usage Examples
15
+
16
+ ### Incorrect
17
+
18
+ ```graphql
19
+ # eslint @graphql-eslint/no-scalar-result-type-on-mutation: 'error'
20
+
21
+ type Mutation {
22
+ createUser: Boolean
23
+ }
24
+ ```
25
+
26
+ ### Correct
27
+
28
+ ```graphql
29
+ # eslint @graphql-eslint/no-scalar-result-type-on-mutation: 'error'
30
+
31
+ type Mutation {
32
+ createUser: User!
33
+ }
34
+ ```
35
+
36
+ ## Resources
37
+
38
+ - [Rule source](../../packages/plugin/src/rules/no-scalar-result-type-on-mutation.ts)
39
+ - [Test source](../../packages/plugin/tests/no-scalar-result-type-on-mutation.spec.ts)
@@ -0,0 +1,42 @@
1
+ # `no-typename-prefix`
2
+
3
+ ✅ The `"extends": "plugin:@graphql-eslint/schema-recommended"` property in a configuration file
4
+ enables this rule.
5
+
6
+ 💡 This rule provides
7
+ [suggestions](https://eslint.org/docs/developer-guide/working-with-rules#providing-suggestions)
8
+
9
+ - Category: `Schema`
10
+ - Rule name: `@graphql-eslint/no-typename-prefix`
11
+ - Requires GraphQL Schema: `false` [ℹ️](../../README.md#extended-linting-rules-with-graphql-schema)
12
+ - Requires GraphQL Operations: `false`
13
+ [ℹ️](../../README.md#extended-linting-rules-with-siblings-operations)
14
+
15
+ Enforces users to avoid using the type name in a field name while defining your schema.
16
+
17
+ ## Usage Examples
18
+
19
+ ### Incorrect
20
+
21
+ ```graphql
22
+ # eslint @graphql-eslint/no-typename-prefix: 'error'
23
+
24
+ type User {
25
+ userId: ID!
26
+ }
27
+ ```
28
+
29
+ ### Correct
30
+
31
+ ```graphql
32
+ # eslint @graphql-eslint/no-typename-prefix: 'error'
33
+
34
+ type User {
35
+ id: ID!
36
+ }
37
+ ```
38
+
39
+ ## Resources
40
+
41
+ - [Rule source](../../packages/plugin/src/rules/no-typename-prefix.ts)
42
+ - [Test source](../../packages/plugin/tests/no-typename-prefix.spec.ts)
@@ -0,0 +1,20 @@
1
+ # `no-undefined-variables`
2
+
3
+ ✅ The `"extends": "plugin:@graphql-eslint/operations-recommended"` property in a configuration file
4
+ enables this rule.
5
+
6
+ - Category: `Operations`
7
+ - Rule name: `@graphql-eslint/no-undefined-variables`
8
+ - Requires GraphQL Schema: `true` [ℹ️](../../README.md#extended-linting-rules-with-graphql-schema)
9
+ - Requires GraphQL Operations: `true`
10
+ [ℹ️](../../README.md#extended-linting-rules-with-siblings-operations)
11
+
12
+ A GraphQL operation is only valid if all variables encountered, both directly and via fragment
13
+ spreads, are defined by that operation.
14
+
15
+ > This rule is a wrapper around a `graphql-js` validation function.
16
+
17
+ ## Resources
18
+
19
+ - [Rule source](https://github.com/graphql/graphql-js/blob/main/src/validation/rules/NoUndefinedVariablesRule.ts)
20
+ - [Test source](https://github.com/graphql/graphql-js/tree/main/src/validation/__tests__/NoUndefinedVariablesRule-test.ts)
@@ -0,0 +1,52 @@
1
+ # `no-unreachable-types`
2
+
3
+ ✅ The `"extends": "plugin:@graphql-eslint/schema-recommended"` property in a configuration file
4
+ enables this rule.
5
+
6
+ 💡 This rule provides
7
+ [suggestions](https://eslint.org/docs/developer-guide/working-with-rules#providing-suggestions)
8
+
9
+ - Category: `Schema`
10
+ - Rule name: `@graphql-eslint/no-unreachable-types`
11
+ - Requires GraphQL Schema: `true` [ℹ️](../../README.md#extended-linting-rules-with-graphql-schema)
12
+ - Requires GraphQL Operations: `false`
13
+ [ℹ️](../../README.md#extended-linting-rules-with-siblings-operations)
14
+
15
+ Requires all types to be reachable at some level by root level fields.
16
+
17
+ ## Usage Examples
18
+
19
+ ### Incorrect
20
+
21
+ ```graphql
22
+ # eslint @graphql-eslint/no-unreachable-types: 'error'
23
+
24
+ type User {
25
+ id: ID!
26
+ name: String
27
+ }
28
+
29
+ type Query {
30
+ me: String
31
+ }
32
+ ```
33
+
34
+ ### Correct
35
+
36
+ ```graphql
37
+ # eslint @graphql-eslint/no-unreachable-types: 'error'
38
+
39
+ type User {
40
+ id: ID!
41
+ name: String
42
+ }
43
+
44
+ type Query {
45
+ me: User
46
+ }
47
+ ```
48
+
49
+ ## Resources
50
+
51
+ - [Rule source](../../packages/plugin/src/rules/no-unreachable-types.ts)
52
+ - [Test source](../../packages/plugin/tests/no-unreachable-types.spec.ts)
@@ -0,0 +1,64 @@
1
+ # `no-unused-fields`
2
+
3
+ 💡 This rule provides
4
+ [suggestions](https://eslint.org/docs/developer-guide/working-with-rules#providing-suggestions)
5
+
6
+ - Category: `Schema`
7
+ - Rule name: `@graphql-eslint/no-unused-fields`
8
+ - Requires GraphQL Schema: `true` [ℹ️](../../README.md#extended-linting-rules-with-graphql-schema)
9
+ - Requires GraphQL Operations: `true`
10
+ [ℹ️](../../README.md#extended-linting-rules-with-siblings-operations)
11
+
12
+ Requires all fields to be used at some level by siblings operations.
13
+
14
+ ## Usage Examples
15
+
16
+ ### Incorrect
17
+
18
+ ```graphql
19
+ # eslint @graphql-eslint/no-unused-fields: 'error'
20
+
21
+ type User {
22
+ id: ID!
23
+ name: String
24
+ someUnusedField: String
25
+ }
26
+
27
+ type Query {
28
+ me: User
29
+ }
30
+
31
+ query {
32
+ me {
33
+ id
34
+ name
35
+ }
36
+ }
37
+ ```
38
+
39
+ ### Correct
40
+
41
+ ```graphql
42
+ # eslint @graphql-eslint/no-unused-fields: 'error'
43
+
44
+ type User {
45
+ id: ID!
46
+ name: String
47
+ }
48
+
49
+ type Query {
50
+ me: User
51
+ }
52
+
53
+ query {
54
+ me {
55
+ id
56
+ name
57
+ }
58
+ }
59
+ ```
60
+
61
+ ## Resources
62
+
63
+ - [Rule source](../../packages/plugin/src/rules/no-unused-fields.ts)
64
+ - [Test source](../../packages/plugin/tests/no-unused-fields.spec.ts)
@@ -0,0 +1,20 @@
1
+ # `no-unused-fragments`
2
+
3
+ ✅ The `"extends": "plugin:@graphql-eslint/operations-recommended"` property in a configuration file
4
+ enables this rule.
5
+
6
+ - Category: `Operations`
7
+ - Rule name: `@graphql-eslint/no-unused-fragments`
8
+ - Requires GraphQL Schema: `true` [ℹ️](../../README.md#extended-linting-rules-with-graphql-schema)
9
+ - Requires GraphQL Operations: `true`
10
+ [ℹ️](../../README.md#extended-linting-rules-with-siblings-operations)
11
+
12
+ A GraphQL document is only valid if all fragment definitions are spread within operations, or spread
13
+ within other fragments spread within operations.
14
+
15
+ > This rule is a wrapper around a `graphql-js` validation function.
16
+
17
+ ## Resources
18
+
19
+ - [Rule source](https://github.com/graphql/graphql-js/blob/main/src/validation/rules/NoUnusedFragmentsRule.ts)
20
+ - [Test source](https://github.com/graphql/graphql-js/tree/main/src/validation/__tests__/NoUnusedFragmentsRule-test.ts)
@@ -0,0 +1,20 @@
1
+ # `no-unused-variables`
2
+
3
+ ✅ The `"extends": "plugin:@graphql-eslint/operations-recommended"` property in a configuration file
4
+ enables this rule.
5
+
6
+ - Category: `Operations`
7
+ - Rule name: `@graphql-eslint/no-unused-variables`
8
+ - Requires GraphQL Schema: `true` [ℹ️](../../README.md#extended-linting-rules-with-graphql-schema)
9
+ - Requires GraphQL Operations: `true`
10
+ [ℹ️](../../README.md#extended-linting-rules-with-siblings-operations)
11
+
12
+ A GraphQL operation is only valid if all variables defined by an operation are used, either directly
13
+ or within a spread fragment.
14
+
15
+ > This rule is a wrapper around a `graphql-js` validation function.
16
+
17
+ ## Resources
18
+
19
+ - [Rule source](https://github.com/graphql/graphql-js/blob/main/src/validation/rules/NoUnusedVariablesRule.ts)
20
+ - [Test source](https://github.com/graphql/graphql-js/tree/main/src/validation/__tests__/NoUnusedVariablesRule-test.ts)
@@ -0,0 +1,19 @@
1
+ # `one-field-subscriptions`
2
+
3
+ ✅ The `"extends": "plugin:@graphql-eslint/operations-recommended"` property in a configuration file
4
+ enables this rule.
5
+
6
+ - Category: `Operations`
7
+ - Rule name: `@graphql-eslint/one-field-subscriptions`
8
+ - Requires GraphQL Schema: `true` [ℹ️](../../README.md#extended-linting-rules-with-graphql-schema)
9
+ - Requires GraphQL Operations: `false`
10
+ [ℹ️](../../README.md#extended-linting-rules-with-siblings-operations)
11
+
12
+ A GraphQL subscription is valid only if it contains a single root field.
13
+
14
+ > This rule is a wrapper around a `graphql-js` validation function.
15
+
16
+ ## Resources
17
+
18
+ - [Rule source](https://github.com/graphql/graphql-js/blob/main/src/validation/rules/SingleFieldSubscriptionsRule.ts)
19
+ - [Test source](https://github.com/graphql/graphql-js/tree/main/src/validation/__tests__/SingleFieldSubscriptionsRule-test.ts)
@@ -0,0 +1,20 @@
1
+ # `overlapping-fields-can-be-merged`
2
+
3
+ ✅ The `"extends": "plugin:@graphql-eslint/operations-recommended"` property in a configuration file
4
+ enables this rule.
5
+
6
+ - Category: `Operations`
7
+ - Rule name: `@graphql-eslint/overlapping-fields-can-be-merged`
8
+ - Requires GraphQL Schema: `true` [ℹ️](../../README.md#extended-linting-rules-with-graphql-schema)
9
+ - Requires GraphQL Operations: `false`
10
+ [ℹ️](../../README.md#extended-linting-rules-with-siblings-operations)
11
+
12
+ A selection set is only valid if all fields (including spreading any fragments) either correspond to
13
+ distinct response names or can be merged without ambiguity.
14
+
15
+ > This rule is a wrapper around a `graphql-js` validation function.
16
+
17
+ ## Resources
18
+
19
+ - [Rule source](https://github.com/graphql/graphql-js/blob/main/src/validation/rules/OverlappingFieldsCanBeMergedRule.ts)
20
+ - [Test source](https://github.com/graphql/graphql-js/tree/main/src/validation/__tests__/OverlappingFieldsCanBeMergedRule-test.ts)
@@ -0,0 +1,21 @@
1
+ # `possible-fragment-spread`
2
+
3
+ ✅ The `"extends": "plugin:@graphql-eslint/operations-recommended"` property in a configuration file
4
+ enables this rule.
5
+
6
+ - Category: `Operations`
7
+ - Rule name: `@graphql-eslint/possible-fragment-spread`
8
+ - Requires GraphQL Schema: `true` [ℹ️](../../README.md#extended-linting-rules-with-graphql-schema)
9
+ - Requires GraphQL Operations: `false`
10
+ [ℹ️](../../README.md#extended-linting-rules-with-siblings-operations)
11
+
12
+ A fragment spread is only valid if the type condition could ever possibly be true: if there is a
13
+ non-empty intersection of the possible parent types, and possible types which pass the type
14
+ condition.
15
+
16
+ > This rule is a wrapper around a `graphql-js` validation function.
17
+
18
+ ## Resources
19
+
20
+ - [Rule source](https://github.com/graphql/graphql-js/blob/main/src/validation/rules/PossibleFragmentSpreadsRule.ts)
21
+ - [Test source](https://github.com/graphql/graphql-js/tree/main/src/validation/__tests__/PossibleFragmentSpreadsRule-test.ts)
@@ -0,0 +1,19 @@
1
+ # `possible-type-extension`
2
+
3
+ 💡 This rule provides
4
+ [suggestions](https://eslint.org/docs/developer-guide/working-with-rules#providing-suggestions)
5
+
6
+ - Category: `Schema`
7
+ - Rule name: `@graphql-eslint/possible-type-extension`
8
+ - Requires GraphQL Schema: `true` [ℹ️](../../README.md#extended-linting-rules-with-graphql-schema)
9
+ - Requires GraphQL Operations: `false`
10
+ [ℹ️](../../README.md#extended-linting-rules-with-siblings-operations)
11
+
12
+ A type extension is only valid if the type is defined and has the same kind.
13
+
14
+ > This rule is a wrapper around a `graphql-js` validation function.
15
+
16
+ ## Resources
17
+
18
+ - [Rule source](https://github.com/graphql/graphql-js/blob/main/src/validation/rules/PossibleTypeExtensionsRule.ts)
19
+ - [Test source](https://github.com/graphql/graphql-js/tree/main/src/validation/__tests__/PossibleTypeExtensionsRule-test.ts)
@@ -0,0 +1,21 @@
1
+ # `provided-required-arguments`
2
+
3
+ ✅ The `"extends": "plugin:@graphql-eslint/schema-recommended"` and
4
+ `"plugin:@graphql-eslint/operations-recommended"` property in a configuration file enables this
5
+ rule.
6
+
7
+ - Category: `Schema & Operations`
8
+ - Rule name: `@graphql-eslint/provided-required-arguments`
9
+ - Requires GraphQL Schema: `true` [ℹ️](../../README.md#extended-linting-rules-with-graphql-schema)
10
+ - Requires GraphQL Operations: `false`
11
+ [ℹ️](../../README.md#extended-linting-rules-with-siblings-operations)
12
+
13
+ A field or directive is only valid if all required (non-null without a default value) field
14
+ arguments have been provided.
15
+
16
+ > This rule is a wrapper around a `graphql-js` validation function.
17
+
18
+ ## Resources
19
+
20
+ - [Rule source](https://github.com/graphql/graphql-js/blob/main/src/validation/rules/ProvidedRequiredArgumentsRule.ts)
21
+ - [Test source](https://github.com/graphql/graphql-js/tree/main/src/validation/__tests__/ProvidedRequiredArgumentsRule-test.ts)
@@ -0,0 +1,59 @@
1
+ # `relay-arguments`
2
+
3
+ - Category: `Schema`
4
+ - Rule name: `@graphql-eslint/relay-arguments`
5
+ - Requires GraphQL Schema: `false` [ℹ️](../../README.md#extended-linting-rules-with-graphql-schema)
6
+ - Requires GraphQL Operations: `false`
7
+ [ℹ️](../../README.md#extended-linting-rules-with-siblings-operations)
8
+
9
+ Set of rules to follow Relay specification for Arguments.
10
+
11
+ - A field that returns a Connection type must include forward pagination arguments (`first` and
12
+ `after`), backward pagination arguments (`last` and `before`), or both
13
+
14
+ Forward pagination arguments
15
+
16
+ - `first` takes a non-negative integer
17
+ - `after` takes the Cursor type
18
+
19
+ Backward pagination arguments
20
+
21
+ - `last` takes a non-negative integer
22
+ - `before` takes the Cursor type
23
+
24
+ ## Usage Examples
25
+
26
+ ### Incorrect
27
+
28
+ ```graphql
29
+ # eslint @graphql-eslint/relay-arguments: 'error'
30
+
31
+ type User {
32
+ posts: PostConnection
33
+ }
34
+ ```
35
+
36
+ ### Correct
37
+
38
+ ```graphql
39
+ # eslint @graphql-eslint/relay-arguments: 'error'
40
+
41
+ type User {
42
+ posts(after: String, first: Int, before: String, last: Int): PostConnection
43
+ }
44
+ ```
45
+
46
+ ## Config Schema
47
+
48
+ The schema defines the following properties:
49
+
50
+ ### `includeBoth` (boolean)
51
+
52
+ Enforce including both forward and backward pagination arguments
53
+
54
+ Default: `true`
55
+
56
+ ## Resources
57
+
58
+ - [Rule source](../../packages/plugin/src/rules/relay-arguments.ts)
59
+ - [Test source](../../packages/plugin/tests/relay-arguments.spec.ts)
@@ -0,0 +1,43 @@
1
+ # `relay-connection-types`
2
+
3
+ - Category: `Schema`
4
+ - Rule name: `@graphql-eslint/relay-connection-types`
5
+ - Requires GraphQL Schema: `false` [ℹ️](../../README.md#extended-linting-rules-with-graphql-schema)
6
+ - Requires GraphQL Operations: `false`
7
+ [ℹ️](../../README.md#extended-linting-rules-with-siblings-operations)
8
+
9
+ Set of rules to follow Relay specification for Connection types.
10
+
11
+ - Any type whose name ends in "Connection" is considered by spec to be a `Connection type`
12
+ - Connection type must be an Object type
13
+ - Connection type must contain a field `edges` that return a list type that wraps an edge type
14
+ - Connection type must contain a field `pageInfo` that return a non-null `PageInfo` Object type
15
+
16
+ ## Usage Examples
17
+
18
+ ### Incorrect
19
+
20
+ ```graphql
21
+ # eslint @graphql-eslint/relay-connection-types: 'error'
22
+
23
+ type UserPayload { # should be an Object type with `Connection` suffix
24
+ edges: UserEdge! # should return a list type
25
+ pageInfo: PageInfo # should return a non-null `PageInfo` Object type
26
+ }
27
+ ```
28
+
29
+ ### Correct
30
+
31
+ ```graphql
32
+ # eslint @graphql-eslint/relay-connection-types: 'error'
33
+
34
+ type UserConnection {
35
+ edges: [UserEdge]
36
+ pageInfo: PageInfo!
37
+ }
38
+ ```
39
+
40
+ ## Resources
41
+
42
+ - [Rule source](../../packages/plugin/src/rules/relay-connection-types.ts)
43
+ - [Test source](../../packages/plugin/tests/relay-connection-types.spec.ts)
@@ -0,0 +1,60 @@
1
+ # `relay-edge-types`
2
+
3
+ - Category: `Schema`
4
+ - Rule name: `@graphql-eslint/relay-edge-types`
5
+ - Requires GraphQL Schema: `true` [ℹ️](../../README.md#extended-linting-rules-with-graphql-schema)
6
+ - Requires GraphQL Operations: `false`
7
+ [ℹ️](../../README.md#extended-linting-rules-with-siblings-operations)
8
+
9
+ Set of rules to follow Relay specification for Edge types.
10
+
11
+ - A type that is returned in list form by a connection type's `edges` field is considered by this
12
+ spec to be an Edge type
13
+ - Edge type must be an Object type
14
+ - Edge type must contain a field `node` that return either Scalar, Enum, Object, Interface, Union,
15
+ or a non-null wrapper around one of those types. Notably, this field cannot return a list
16
+ - Edge type must contain a field `cursor` that return either String, Scalar, or a non-null wrapper
17
+ around one of those types
18
+ - Edge type name must end in "Edge" _(optional)_
19
+ - Edge type's field `node` must implement `Node` interface _(optional)_
20
+ - A list type should only wrap an edge type _(optional)_
21
+
22
+ ## Usage Examples
23
+
24
+ ### Correct
25
+
26
+ ```graphql
27
+ # eslint @graphql-eslint/relay-edge-types: 'error'
28
+
29
+ type UserConnection {
30
+ edges: [UserEdge]
31
+ pageInfo: PageInfo!
32
+ }
33
+ ```
34
+
35
+ ## Config Schema
36
+
37
+ The schema defines the following properties:
38
+
39
+ ### `withEdgeSuffix` (boolean)
40
+
41
+ Edge type name must end in "Edge".
42
+
43
+ Default: `true`
44
+
45
+ ### `shouldImplementNode` (boolean)
46
+
47
+ Edge type's field `node` must implement `Node` interface.
48
+
49
+ Default: `true`
50
+
51
+ ### `listTypeCanWrapOnlyEdgeType` (boolean)
52
+
53
+ A list type should only wrap an edge type.
54
+
55
+ Default: `true`
56
+
57
+ ## Resources
58
+
59
+ - [Rule source](../../packages/plugin/src/rules/relay-edge-types.ts)
60
+ - [Test source](../../packages/plugin/tests/relay-edge-types.spec.ts)
@@ -0,0 +1,34 @@
1
+ # `relay-page-info`
2
+
3
+ - Category: `Schema`
4
+ - Rule name: `@graphql-eslint/relay-page-info`
5
+ - Requires GraphQL Schema: `true` [ℹ️](../../README.md#extended-linting-rules-with-graphql-schema)
6
+ - Requires GraphQL Operations: `false`
7
+ [ℹ️](../../README.md#extended-linting-rules-with-siblings-operations)
8
+
9
+ Set of rules to follow Relay specification for `PageInfo` object.
10
+
11
+ - `PageInfo` must be an Object type
12
+ - `PageInfo` must contain fields `hasPreviousPage` and `hasNextPage`, that return non-null Boolean
13
+ - `PageInfo` must contain fields `startCursor` and `endCursor`, that return either String or Scalar,
14
+ which can be null if there are no results
15
+
16
+ ## Usage Examples
17
+
18
+ ### Correct
19
+
20
+ ```graphql
21
+ # eslint @graphql-eslint/relay-page-info: 'error'
22
+
23
+ type PageInfo {
24
+ hasPreviousPage: Boolean!
25
+ hasNextPage: Boolean!
26
+ startCursor: String
27
+ endCursor: String
28
+ }
29
+ ```
30
+
31
+ ## Resources
32
+
33
+ - [Rule source](../../packages/plugin/src/rules/relay-page-info.ts)
34
+ - [Test source](../../packages/plugin/tests/relay-page-info.spec.ts)
@@ -0,0 +1,59 @@
1
+ # `require-deprecation-date`
2
+
3
+ 💡 This rule provides
4
+ [suggestions](https://eslint.org/docs/developer-guide/working-with-rules#providing-suggestions)
5
+
6
+ - Category: `Schema`
7
+ - Rule name: `@graphql-eslint/require-deprecation-date`
8
+ - Requires GraphQL Schema: `false` [ℹ️](../../README.md#extended-linting-rules-with-graphql-schema)
9
+ - Requires GraphQL Operations: `false`
10
+ [ℹ️](../../README.md#extended-linting-rules-with-siblings-operations)
11
+
12
+ Require deletion date on `@deprecated` directive. Suggest removing deprecated things after
13
+ deprecated date.
14
+
15
+ ## Usage Examples
16
+
17
+ ### Incorrect
18
+
19
+ ```graphql
20
+ # eslint @graphql-eslint/require-deprecation-date: 'error'
21
+
22
+ type User {
23
+ firstname: String @deprecated
24
+ firstName: String
25
+ }
26
+ ```
27
+
28
+ ### Incorrect
29
+
30
+ ```graphql
31
+ # eslint @graphql-eslint/require-deprecation-date: 'error'
32
+
33
+ type User {
34
+ firstname: String @deprecated(reason: "Use 'firstName' instead")
35
+ firstName: String
36
+ }
37
+ ```
38
+
39
+ ### Correct
40
+
41
+ ```graphql
42
+ # eslint @graphql-eslint/require-deprecation-date: 'error'
43
+
44
+ type User {
45
+ firstname: String @deprecated(reason: "Use 'firstName' instead", deletionDate: "25/12/2022")
46
+ firstName: String
47
+ }
48
+ ```
49
+
50
+ ## Config Schema
51
+
52
+ The schema defines the following properties:
53
+
54
+ ### `argumentName` (string)
55
+
56
+ ## Resources
57
+
58
+ - [Rule source](../../packages/plugin/src/rules/require-deprecation-date.ts)
59
+ - [Test source](../../packages/plugin/tests/require-deprecation-date.spec.ts)
@@ -0,0 +1,49 @@
1
+ # `require-deprecation-reason`
2
+
3
+ ✅ The `"extends": "plugin:@graphql-eslint/schema-recommended"` property in a configuration file
4
+ enables this rule.
5
+
6
+ - Category: `Schema`
7
+ - Rule name: `@graphql-eslint/require-deprecation-reason`
8
+ - Requires GraphQL Schema: `false` [ℹ️](../../README.md#extended-linting-rules-with-graphql-schema)
9
+ - Requires GraphQL Operations: `false`
10
+ [ℹ️](../../README.md#extended-linting-rules-with-siblings-operations)
11
+
12
+ Require all deprecation directives to specify a reason.
13
+
14
+ ## Usage Examples
15
+
16
+ ### Incorrect
17
+
18
+ ```graphql
19
+ # eslint @graphql-eslint/require-deprecation-reason: 'error'
20
+
21
+ type MyType {
22
+ name: String @deprecated
23
+ }
24
+ ```
25
+
26
+ ### Incorrect
27
+
28
+ ```graphql
29
+ # eslint @graphql-eslint/require-deprecation-reason: 'error'
30
+
31
+ type MyType {
32
+ name: String @deprecated(reason: "")
33
+ }
34
+ ```
35
+
36
+ ### Correct
37
+
38
+ ```graphql
39
+ # eslint @graphql-eslint/require-deprecation-reason: 'error'
40
+
41
+ type MyType {
42
+ name: String @deprecated(reason: "no longer relevant, please use fullName field")
43
+ }
44
+ ```
45
+
46
+ ## Resources
47
+
48
+ - [Rule source](../../packages/plugin/src/rules/require-deprecation-reason.ts)
49
+ - [Test source](../../packages/plugin/tests/require-deprecation-reason.spec.ts)