@graphql-eslint/eslint-plugin 3.14.4-alpha-20230111221804-f30b422 → 3.14.4-alpha-20230111225020-02d9c28

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.
Files changed (156) hide show
  1. package/README.md +5 -288
  2. package/cjs/documents.js +2 -105
  3. package/cjs/graphql-config.js +1 -1
  4. package/cjs/parser.js +9 -3
  5. package/cjs/rules/alphabetize.js +1 -1
  6. package/cjs/rules/description-style.js +1 -1
  7. package/cjs/rules/graphql-js-validation.js +1 -1
  8. package/cjs/rules/input-name.js +4 -4
  9. package/cjs/rules/lone-executable-definition.js +1 -1
  10. package/cjs/rules/match-document-filename.js +2 -3
  11. package/cjs/rules/naming-convention.js +1 -1
  12. package/cjs/rules/no-anonymous-operations.js +1 -1
  13. package/cjs/rules/no-case-insensitive-enum-values-duplicates.js +1 -1
  14. package/cjs/rules/no-deprecated.js +1 -1
  15. package/cjs/rules/no-duplicate-fields.js +1 -1
  16. package/cjs/rules/no-hashtag-description.js +1 -1
  17. package/cjs/rules/no-one-place-fragments.js +1 -1
  18. package/cjs/rules/no-root-type.js +1 -1
  19. package/cjs/rules/no-scalar-result-type-on-mutation.js +1 -1
  20. package/cjs/rules/no-typename-prefix.js +1 -1
  21. package/cjs/rules/no-unreachable-types.js +1 -1
  22. package/cjs/rules/no-unused-fields.js +1 -1
  23. package/cjs/rules/relay-arguments.js +4 -4
  24. package/cjs/rules/relay-connection-types.js +1 -1
  25. package/cjs/rules/relay-edge-types.js +1 -1
  26. package/cjs/rules/relay-page-info.js +1 -1
  27. package/cjs/rules/require-deprecation-date.js +1 -1
  28. package/cjs/rules/require-deprecation-reason.js +1 -1
  29. package/cjs/rules/require-description.js +1 -1
  30. package/cjs/rules/require-field-of-type-query-in-mutation-result.js +1 -1
  31. package/cjs/rules/require-id-when-available.js +1 -1
  32. package/cjs/rules/require-nullable-fields-with-oneof.js +1 -1
  33. package/cjs/rules/require-type-pattern-with-oneof.js +1 -1
  34. package/cjs/rules/selection-set-depth.js +1 -1
  35. package/cjs/rules/strict-id-in-types.js +1 -1
  36. package/cjs/rules/unique-fragment-name.js +1 -1
  37. package/cjs/rules/unique-operation-name.js +1 -1
  38. package/cjs/siblings.js +113 -0
  39. package/cjs/utils.js +3 -2
  40. package/docs/README.md +1 -85
  41. package/docs/custom-rules.md +1 -184
  42. package/docs/deprecated-rules.md +1 -24
  43. package/docs/parser-options.md +1 -107
  44. package/docs/parser.md +1 -67
  45. package/esm/documents.js +2 -105
  46. package/esm/graphql-config.js +1 -1
  47. package/esm/parser.js +10 -4
  48. package/esm/rules/alphabetize.js +1 -1
  49. package/esm/rules/description-style.js +1 -1
  50. package/esm/rules/graphql-js-validation.js +1 -1
  51. package/esm/rules/input-name.js +4 -4
  52. package/esm/rules/lone-executable-definition.js +1 -1
  53. package/esm/rules/match-document-filename.js +3 -4
  54. package/esm/rules/naming-convention.js +1 -1
  55. package/esm/rules/no-anonymous-operations.js +1 -1
  56. package/esm/rules/no-case-insensitive-enum-values-duplicates.js +1 -1
  57. package/esm/rules/no-deprecated.js +1 -1
  58. package/esm/rules/no-duplicate-fields.js +1 -1
  59. package/esm/rules/no-hashtag-description.js +1 -1
  60. package/esm/rules/no-one-place-fragments.js +1 -1
  61. package/esm/rules/no-root-type.js +1 -1
  62. package/esm/rules/no-scalar-result-type-on-mutation.js +1 -1
  63. package/esm/rules/no-typename-prefix.js +1 -1
  64. package/esm/rules/no-unreachable-types.js +1 -1
  65. package/esm/rules/no-unused-fields.js +1 -1
  66. package/esm/rules/relay-arguments.js +4 -4
  67. package/esm/rules/relay-connection-types.js +1 -1
  68. package/esm/rules/relay-edge-types.js +1 -1
  69. package/esm/rules/relay-page-info.js +1 -1
  70. package/esm/rules/require-deprecation-date.js +1 -1
  71. package/esm/rules/require-deprecation-reason.js +1 -1
  72. package/esm/rules/require-description.js +1 -1
  73. package/esm/rules/require-field-of-type-query-in-mutation-result.js +1 -1
  74. package/esm/rules/require-id-when-available.js +1 -1
  75. package/esm/rules/require-nullable-fields-with-oneof.js +1 -1
  76. package/esm/rules/require-type-pattern-with-oneof.js +1 -1
  77. package/esm/rules/selection-set-depth.js +1 -1
  78. package/esm/rules/strict-id-in-types.js +1 -1
  79. package/esm/rules/unique-fragment-name.js +1 -1
  80. package/esm/rules/unique-operation-name.js +1 -1
  81. package/esm/siblings.js +109 -0
  82. package/esm/utils.js +2 -1
  83. package/package.json +1 -1
  84. package/typings/documents.d.cts +2 -20
  85. package/typings/documents.d.ts +2 -20
  86. package/typings/rules/input-name.d.cts +1 -1
  87. package/typings/rules/input-name.d.ts +1 -1
  88. package/typings/siblings.d.cts +22 -0
  89. package/typings/siblings.d.ts +22 -0
  90. package/typings/types.d.cts +3 -2
  91. package/typings/types.d.ts +3 -2
  92. package/typings/utils.d.cts +2 -1
  93. package/typings/utils.d.ts +2 -1
  94. package/docs/rules/alphabetize.md +0 -194
  95. package/docs/rules/description-style.md +0 -57
  96. package/docs/rules/executable-definitions.md +0 -20
  97. package/docs/rules/fields-on-correct-type.md +0 -23
  98. package/docs/rules/fragments-on-composite-type.md +0 -20
  99. package/docs/rules/input-name.md +0 -80
  100. package/docs/rules/known-argument-names.md +0 -23
  101. package/docs/rules/known-directives.md +0 -48
  102. package/docs/rules/known-fragment-names.md +0 -72
  103. package/docs/rules/known-type-names.md +0 -24
  104. package/docs/rules/lone-anonymous-operation.md +0 -20
  105. package/docs/rules/lone-executable-definition.md +0 -59
  106. package/docs/rules/lone-schema-definition.md +0 -19
  107. package/docs/rules/match-document-filename.md +0 -181
  108. package/docs/rules/naming-convention.md +0 -320
  109. package/docs/rules/no-anonymous-operations.md +0 -43
  110. package/docs/rules/no-case-insensitive-enum-values-duplicates.md +0 -46
  111. package/docs/rules/no-deprecated.md +0 -88
  112. package/docs/rules/no-duplicate-fields.md +0 -69
  113. package/docs/rules/no-fragment-cycles.md +0 -19
  114. package/docs/rules/no-hashtag-description.md +0 -62
  115. package/docs/rules/no-one-place-fragments.md +0 -51
  116. package/docs/rules/no-root-type.md +0 -55
  117. package/docs/rules/no-scalar-result-type-on-mutation.md +0 -39
  118. package/docs/rules/no-typename-prefix.md +0 -42
  119. package/docs/rules/no-undefined-variables.md +0 -20
  120. package/docs/rules/no-unreachable-types.md +0 -52
  121. package/docs/rules/no-unused-fields.md +0 -64
  122. package/docs/rules/no-unused-fragments.md +0 -20
  123. package/docs/rules/no-unused-variables.md +0 -20
  124. package/docs/rules/one-field-subscriptions.md +0 -19
  125. package/docs/rules/overlapping-fields-can-be-merged.md +0 -20
  126. package/docs/rules/possible-fragment-spread.md +0 -21
  127. package/docs/rules/possible-type-extension.md +0 -19
  128. package/docs/rules/provided-required-arguments.md +0 -21
  129. package/docs/rules/relay-arguments.md +0 -59
  130. package/docs/rules/relay-connection-types.md +0 -43
  131. package/docs/rules/relay-edge-types.md +0 -60
  132. package/docs/rules/relay-page-info.md +0 -34
  133. package/docs/rules/require-deprecation-date.md +0 -59
  134. package/docs/rules/require-deprecation-reason.md +0 -49
  135. package/docs/rules/require-description.md +0 -147
  136. package/docs/rules/require-field-of-type-query-in-mutation-result.md +0 -50
  137. package/docs/rules/require-id-when-available.md +0 -91
  138. package/docs/rules/require-nullable-fields-with-oneof.md +0 -38
  139. package/docs/rules/require-type-pattern-with-oneof.md +0 -39
  140. package/docs/rules/scalar-leafs.md +0 -23
  141. package/docs/rules/selection-set-depth.md +0 -86
  142. package/docs/rules/strict-id-in-types.md +0 -129
  143. package/docs/rules/unique-argument-names.md +0 -19
  144. package/docs/rules/unique-directive-names-per-location.md +0 -21
  145. package/docs/rules/unique-directive-names.md +0 -19
  146. package/docs/rules/unique-enum-value-names.md +0 -16
  147. package/docs/rules/unique-field-definition-names.md +0 -19
  148. package/docs/rules/unique-fragment-name.md +0 -52
  149. package/docs/rules/unique-input-field-names.md +0 -19
  150. package/docs/rules/unique-operation-name.md +0 -56
  151. package/docs/rules/unique-operation-types.md +0 -19
  152. package/docs/rules/unique-type-names.md +0 -19
  153. package/docs/rules/unique-variable-names.md +0 -19
  154. package/docs/rules/value-literals-of-correct-type.md +0 -22
  155. package/docs/rules/variables-are-input-types.md +0 -20
  156. package/docs/rules/variables-in-allowed-position.md +0 -19
@@ -1,194 +0,0 @@
1
- # `alphabetize`
2
-
3
- 🔧 The `--fix` option on the
4
- [command line](https://eslint.org/docs/user-guide/command-line-interface#--fix) can automatically
5
- fix some of the problems reported by this rule.
6
-
7
- - Category: `Schema & Operations`
8
- - Rule name: `@graphql-eslint/alphabetize`
9
- - Requires GraphQL Schema: `false` [ℹ️](../../README.md#extended-linting-rules-with-graphql-schema)
10
- - Requires GraphQL Operations: `false`
11
- [ℹ️](../../README.md#extended-linting-rules-with-siblings-operations)
12
-
13
- Enforce arrange in alphabetical order for type fields, enum values, input object fields, operation
14
- selections and more.
15
-
16
- ## Usage Examples
17
-
18
- ### Incorrect
19
-
20
- ```graphql
21
- # eslint @graphql-eslint/alphabetize: ['error', { fields: ['ObjectTypeDefinition'] }]
22
-
23
- type User {
24
- password: String
25
- firstName: String! # should be before "password"
26
- age: Int # should be before "firstName"
27
- lastName: String!
28
- }
29
- ```
30
-
31
- ### Correct
32
-
33
- ```graphql
34
- # eslint @graphql-eslint/alphabetize: ['error', { fields: ['ObjectTypeDefinition'] }]
35
-
36
- type User {
37
- age: Int
38
- firstName: String!
39
- lastName: String!
40
- password: String
41
- }
42
- ```
43
-
44
- ### Incorrect
45
-
46
- ```graphql
47
- # eslint @graphql-eslint/alphabetize: ['error', { values: ['EnumTypeDefinition'] }]
48
-
49
- enum Role {
50
- SUPER_ADMIN
51
- ADMIN # should be before "SUPER_ADMIN"
52
- USER
53
- GOD # should be before "USER"
54
- }
55
- ```
56
-
57
- ### Correct
58
-
59
- ```graphql
60
- # eslint @graphql-eslint/alphabetize: ['error', { values: ['EnumTypeDefinition'] }]
61
-
62
- enum Role {
63
- ADMIN
64
- GOD
65
- SUPER_ADMIN
66
- USER
67
- }
68
- ```
69
-
70
- ### Incorrect
71
-
72
- ```graphql
73
- # eslint @graphql-eslint/alphabetize: ['error', { selections: ['OperationDefinition'] }]
74
-
75
- query {
76
- me {
77
- firstName
78
- lastName
79
- email # should be before "lastName"
80
- }
81
- }
82
- ```
83
-
84
- ### Correct
85
-
86
- ```graphql
87
- # eslint @graphql-eslint/alphabetize: ['error', { selections: ['OperationDefinition'] }]
88
-
89
- query {
90
- me {
91
- email
92
- firstName
93
- lastName
94
- }
95
- }
96
- ```
97
-
98
- ## Config Schema
99
-
100
- The schema defines the following properties:
101
-
102
- ### `fields` (array)
103
-
104
- Fields of `type`, `interface`, and `input`.
105
-
106
- The elements of the array can contain the following enum values:
107
-
108
- - `ObjectTypeDefinition`
109
- - `InterfaceTypeDefinition`
110
- - `InputObjectTypeDefinition`
111
-
112
- Additional restrictions:
113
-
114
- - Minimum items: `1`
115
- - Unique items: `true`
116
-
117
- ### `values` (array)
118
-
119
- Values of `enum`.
120
-
121
- The elements of the array can contain the following enum values:
122
-
123
- - `EnumTypeDefinition`
124
-
125
- Additional restrictions:
126
-
127
- - Minimum items: `1`
128
- - Unique items: `true`
129
-
130
- ### `selections` (array)
131
-
132
- Selections of `fragment` and operations `query`, `mutation` and `subscription`.
133
-
134
- The elements of the array can contain the following enum values:
135
-
136
- - `OperationDefinition`
137
- - `FragmentDefinition`
138
-
139
- Additional restrictions:
140
-
141
- - Minimum items: `1`
142
- - Unique items: `true`
143
-
144
- ### `variables` (array)
145
-
146
- Variables of operations `query`, `mutation` and `subscription`.
147
-
148
- The elements of the array can contain the following enum values:
149
-
150
- - `OperationDefinition`
151
-
152
- Additional restrictions:
153
-
154
- - Minimum items: `1`
155
- - Unique items: `true`
156
-
157
- ### `arguments` (array)
158
-
159
- Arguments of fields and directives.
160
-
161
- The elements of the array can contain the following enum values:
162
-
163
- - `FieldDefinition`
164
- - `Field`
165
- - `DirectiveDefinition`
166
- - `Directive`
167
-
168
- Additional restrictions:
169
-
170
- - Minimum items: `1`
171
- - Unique items: `true`
172
-
173
- ### `definitions` (boolean)
174
-
175
- Definitions – `type`, `interface`, `enum`, `scalar`, `input`, `union` and `directive`.
176
-
177
- Default: `false`
178
-
179
- ### `groups` (array)
180
-
181
- Custom order group. Example: `['id', '*', 'createdAt', 'updatedAt']` where `*` says for everything
182
- else.
183
-
184
- The object is an array with all elements of the type `string`.
185
-
186
- Additional restrictions:
187
-
188
- - Minimum items: `2`
189
- - Unique items: `true`
190
-
191
- ## Resources
192
-
193
- - [Rule source](../../packages/plugin/src/rules/alphabetize.ts)
194
- - [Test source](../../packages/plugin/tests/alphabetize.spec.ts)
@@ -1,57 +0,0 @@
1
- # `description-style`
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/description-style`
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
- Require all comments to follow the same style (either block or inline).
16
-
17
- ## Usage Examples
18
-
19
- ### Incorrect
20
-
21
- ```graphql
22
- # eslint @graphql-eslint/description-style: ['error', { style: 'inline' }]
23
-
24
- """ Description """
25
- type someTypeName {
26
- # ...
27
- }
28
- ```
29
-
30
- ### Correct
31
-
32
- ```graphql
33
- # eslint @graphql-eslint/description-style: ['error', { style: 'inline' }]
34
-
35
- " Description "
36
- type someTypeName {
37
- # ...
38
- }
39
- ```
40
-
41
- ## Config Schema
42
-
43
- The schema defines the following properties:
44
-
45
- ### `style` (enum)
46
-
47
- This element must be one of the following enum values:
48
-
49
- - `block`
50
- - `inline`
51
-
52
- Default: `"block"`
53
-
54
- ## Resources
55
-
56
- - [Rule source](../../packages/plugin/src/rules/description-style.ts)
57
- - [Test source](../../packages/plugin/tests/description-style.spec.ts)
@@ -1,20 +0,0 @@
1
- # `executable-definitions`
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/executable-definitions`
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 document is only valid for execution if all definitions are either operation or fragment
13
- definitions.
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/ExecutableDefinitionsRule.ts)
20
- - [Test source](https://github.com/graphql/graphql-js/tree/main/src/validation/__tests__/ExecutableDefinitionsRule-test.ts)
@@ -1,23 +0,0 @@
1
- # `fields-on-correct-type`
2
-
3
- ✅ The `"extends": "plugin:@graphql-eslint/operations-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: `Operations`
10
- - Rule name: `@graphql-eslint/fields-on-correct-type`
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
- A GraphQL document is only valid if all fields selected are defined by the parent type, or are an
16
- allowed meta field such as `__typename`.
17
-
18
- > This rule is a wrapper around a `graphql-js` validation function.
19
-
20
- ## Resources
21
-
22
- - [Rule source](https://github.com/graphql/graphql-js/blob/main/src/validation/rules/FieldsOnCorrectTypeRule.ts)
23
- - [Test source](https://github.com/graphql/graphql-js/tree/main/src/validation/__tests__/FieldsOnCorrectTypeRule-test.ts)
@@ -1,20 +0,0 @@
1
- # `fragments-on-composite-type`
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/fragments-on-composite-type`
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
- Fragments use a type condition to determine if they apply, since fragments can only be spread into a
13
- composite type (object, interface, or union), the type condition must also be a composite type.
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/FragmentsOnCompositeTypesRule.ts)
20
- - [Test source](https://github.com/graphql/graphql-js/tree/main/src/validation/__tests__/FragmentsOnCompositeTypesRule-test.ts)
@@ -1,80 +0,0 @@
1
- # `input-name`
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/input-name`
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 mutation argument to be always called "input" and input type to be called Mutation name +
13
- "Input". Using the same name for all input parameters will make your schemas easier to consume and
14
- more predictable. Using the same name as mutation for InputType will make it easier to find
15
- mutations that InputType belongs to.
16
-
17
- ## Usage Examples
18
-
19
- ### Incorrect
20
-
21
- ```graphql
22
- # eslint @graphql-eslint/input-name: ['error', { checkInputType: true }]
23
-
24
- type Mutation {
25
- SetMessage(message: InputMessage): String
26
- }
27
- ```
28
-
29
- ### Correct (with checkInputType)
30
-
31
- ```graphql
32
- # eslint @graphql-eslint/input-name: ['error', { checkInputType: true }]
33
-
34
- type Mutation {
35
- SetMessage(input: SetMessageInput): String
36
- }
37
- ```
38
-
39
- ### Correct (without checkInputType)
40
-
41
- ```graphql
42
- # eslint @graphql-eslint/input-name: ['error', { checkInputType: false }]
43
-
44
- type Mutation {
45
- SetMessage(input: AnyInputTypeName): String
46
- }
47
- ```
48
-
49
- ## Config Schema
50
-
51
- The schema defines the following properties:
52
-
53
- ### `checkInputType` (boolean)
54
-
55
- Check that the input type name follows the convention <mutationName>Input
56
-
57
- Default: `false`
58
-
59
- ### `caseSensitiveInputType` (boolean)
60
-
61
- Allow for case discrepancies in the input type name
62
-
63
- Default: `true`
64
-
65
- ### `checkQueries` (boolean)
66
-
67
- Apply the rule to Queries
68
-
69
- Default: `false`
70
-
71
- ### `checkMutations` (boolean)
72
-
73
- Apply the rule to Mutations
74
-
75
- Default: `true`
76
-
77
- ## Resources
78
-
79
- - [Rule source](../../packages/plugin/src/rules/input-name.ts)
80
- - [Test source](../../packages/plugin/tests/input-name.spec.ts)
@@ -1,23 +0,0 @@
1
- # `known-argument-names`
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
- 💡 This rule provides
8
- [suggestions](https://eslint.org/docs/developer-guide/working-with-rules#providing-suggestions)
9
-
10
- - Category: `Schema & Operations`
11
- - Rule name: `@graphql-eslint/known-argument-names`
12
- - Requires GraphQL Schema: `true` [ℹ️](../../README.md#extended-linting-rules-with-graphql-schema)
13
- - Requires GraphQL Operations: `false`
14
- [ℹ️](../../README.md#extended-linting-rules-with-siblings-operations)
15
-
16
- A GraphQL field is only valid if all supplied arguments are defined by that field.
17
-
18
- > This rule is a wrapper around a `graphql-js` validation function.
19
-
20
- ## Resources
21
-
22
- - [Rule source](https://github.com/graphql/graphql-js/blob/main/src/validation/rules/KnownArgumentNamesRule.ts)
23
- - [Test source](https://github.com/graphql/graphql-js/tree/main/src/validation/__tests__/KnownArgumentNamesRule-test.ts)
@@ -1,48 +0,0 @@
1
- # `known-directives`
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/known-directives`
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 GraphQL document is only valid if all `@directive`s are known by the schema and legally
14
- positioned.
15
-
16
- > This rule is a wrapper around a `graphql-js` validation function.
17
-
18
- ## Usage Examples
19
-
20
- ### Valid
21
-
22
- ```graphql
23
- # eslint @graphql-eslint/known-directives: ['error', { ignoreClientDirectives: ['client'] }]
24
-
25
- {
26
- product {
27
- someClientField @client
28
- }
29
- }
30
- ```
31
-
32
- ## Config Schema
33
-
34
- The schema defines the following properties:
35
-
36
- ### `ignoreClientDirectives` (array, required)
37
-
38
- The object is an array with all elements of the type `string`.
39
-
40
- Additional restrictions:
41
-
42
- - Minimum items: `1`
43
- - Unique items: `true`
44
-
45
- ## Resources
46
-
47
- - [Rule source](https://github.com/graphql/graphql-js/blob/main/src/validation/rules/KnownDirectivesRule.ts)
48
- - [Test source](https://github.com/graphql/graphql-js/tree/main/src/validation/__tests__/KnownDirectivesRule-test.ts)
@@ -1,72 +0,0 @@
1
- # `known-fragment-names`
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/known-fragment-names`
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` fragment spreads refer to fragments defined in
13
- the same document.
14
-
15
- > This rule is a wrapper around a `graphql-js` validation function.
16
-
17
- ## Usage Examples
18
-
19
- ### Incorrect
20
-
21
- ```graphql
22
- # eslint @graphql-eslint/known-fragment-names: 'error'
23
-
24
- query {
25
- user {
26
- id
27
- ...UserFields # fragment not defined in the document
28
- }
29
- }
30
- ```
31
-
32
- ### Correct
33
-
34
- ```graphql
35
- # eslint @graphql-eslint/known-fragment-names: 'error'
36
-
37
- fragment UserFields on User {
38
- firstName
39
- lastName
40
- }
41
-
42
- query {
43
- user {
44
- id
45
- ...UserFields
46
- }
47
- }
48
- ```
49
-
50
- ### Correct (`UserFields` fragment located in a separate file)
51
-
52
- ```graphql
53
- # eslint @graphql-eslint/known-fragment-names: 'error'
54
-
55
- # user.gql
56
- query {
57
- user {
58
- id
59
- ...UserFields
60
- }
61
- }
62
-
63
- # user-fields.gql
64
- fragment UserFields on User {
65
- id
66
- }
67
- ```
68
-
69
- ## Resources
70
-
71
- - [Rule source](https://github.com/graphql/graphql-js/blob/main/src/validation/rules/KnownFragmentNamesRule.ts)
72
- - [Test source](https://github.com/graphql/graphql-js/tree/main/src/validation/__tests__/KnownFragmentNamesRule-test.ts)
@@ -1,24 +0,0 @@
1
- # `known-type-names`
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
- 💡 This rule provides
8
- [suggestions](https://eslint.org/docs/developer-guide/working-with-rules#providing-suggestions)
9
-
10
- - Category: `Schema & Operations`
11
- - Rule name: `@graphql-eslint/known-type-names`
12
- - Requires GraphQL Schema: `true` [ℹ️](../../README.md#extended-linting-rules-with-graphql-schema)
13
- - Requires GraphQL Operations: `false`
14
- [ℹ️](../../README.md#extended-linting-rules-with-siblings-operations)
15
-
16
- A GraphQL document is only valid if referenced types (specifically variable definitions and fragment
17
- conditions) are defined by the type schema.
18
-
19
- > This rule is a wrapper around a `graphql-js` validation function.
20
-
21
- ## Resources
22
-
23
- - [Rule source](https://github.com/graphql/graphql-js/blob/main/src/validation/rules/KnownTypeNamesRule.ts)
24
- - [Test source](https://github.com/graphql/graphql-js/tree/main/src/validation/__tests__/KnownTypeNamesRule-test.ts)
@@ -1,20 +0,0 @@
1
- # `lone-anonymous-operation`
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/lone-anonymous-operation`
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 document that contains an anonymous operation (the `query` short-hand) is only valid if it
13
- contains only that one operation definition.
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/LoneAnonymousOperationRule.ts)
20
- - [Test source](https://github.com/graphql/graphql-js/tree/main/src/validation/__tests__/LoneAnonymousOperationRule-test.ts)
@@ -1,59 +0,0 @@
1
- # `lone-executable-definition`
2
-
3
- - Category: `Operations`
4
- - Rule name: `@graphql-eslint/lone-executable-definition`
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
- Require queries, mutations, subscriptions or fragments to be located in separate files.
10
-
11
- ## Usage Examples
12
-
13
- ### Incorrect
14
-
15
- ```graphql
16
- # eslint @graphql-eslint/lone-executable-definition: 'error'
17
-
18
- query Foo {
19
- id
20
- }
21
- fragment Bar on Baz {
22
- id
23
- }
24
- ```
25
-
26
- ### Correct
27
-
28
- ```graphql
29
- # eslint @graphql-eslint/lone-executable-definition: 'error'
30
-
31
- query Foo {
32
- id
33
- }
34
- ```
35
-
36
- ## Config Schema
37
-
38
- The schema defines the following properties:
39
-
40
- ### `ignore` (array)
41
-
42
- Allow certain definitions to be placed alongside others.
43
-
44
- The elements of the array can contain the following enum values:
45
-
46
- - `fragment`
47
- - `query`
48
- - `mutation`
49
- - `subscription`
50
-
51
- Additional restrictions:
52
-
53
- - Minimum items: `1`
54
- - Unique items: `true`
55
-
56
- ## Resources
57
-
58
- - [Rule source](../../packages/plugin/src/rules/lone-executable-definition.ts)
59
- - [Test source](../../packages/plugin/tests/lone-executable-definition.spec.ts)
@@ -1,19 +0,0 @@
1
- # `lone-schema-definition`
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/lone-schema-definition`
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
- A GraphQL document is only valid if it contains only one schema definition.
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/LoneSchemaDefinitionRule.ts)
19
- - [Test source](https://github.com/graphql/graphql-js/tree/main/src/validation/__tests__/LoneSchemaDefinitionRule-test.ts)