@graphql-eslint/eslint-plugin 2.4.0-alpha-0617395.0 → 2.4.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/docs/custom-rules.md +1 -1
- package/docs/rules/avoid-duplicate-fields.md +9 -7
- package/docs/rules/fragments-on-composite-type.md +2 -2
- package/docs/rules/one-field-subscriptions.md +2 -2
- package/docs/rules/possible-fragment-spread.md +2 -2
- package/docs/rules/possible-type-extension.md +2 -2
- package/docs/rules/unique-directive-names-per-location.md +2 -2
- package/docs/rules/value-literals-of-correct-type.md +2 -2
- package/index.js +241 -192
- package/index.mjs +242 -193
- package/package.json +1 -1
- package/rules/alphabetize.d.ts +6 -5
- package/rules/avoid-duplicate-fields.d.ts +1 -1
- package/rules/index.d.ts +7 -7
- package/rules/require-description.d.ts +2 -1
- package/testkit.d.ts +6 -3
- package/types.d.ts +1 -0
- package/utils.d.ts +6 -3
package/docs/custom-rules.md
CHANGED
@@ -58,7 +58,7 @@ This is useful if you wish to use other GraphQL tools that works with the origin
|
|
58
58
|
Here's an example for using original `graphql-js` validate method to validate `OperationDefinition`:
|
59
59
|
|
60
60
|
```ts
|
61
|
-
import { validate } from 'graphql
|
61
|
+
import { validate } from 'graphql';
|
62
62
|
import { requireGraphQLSchemaFromContext } from '@graphql-eslint/eslint-plugin';
|
63
63
|
|
64
64
|
export const rule = {
|
@@ -14,11 +14,11 @@ Checks for duplicate fields in selection set, variables in operation definition,
|
|
14
14
|
```graphql
|
15
15
|
# eslint @graphql-eslint/avoid-duplicate-fields: 'error'
|
16
16
|
|
17
|
-
query
|
17
|
+
query {
|
18
18
|
user {
|
19
|
-
name
|
19
|
+
name
|
20
20
|
email
|
21
|
-
name #
|
21
|
+
name # duplicate field
|
22
22
|
}
|
23
23
|
}
|
24
24
|
```
|
@@ -28,7 +28,7 @@ query getUserDetails {
|
|
28
28
|
```graphql
|
29
29
|
# eslint @graphql-eslint/avoid-duplicate-fields: 'error'
|
30
30
|
|
31
|
-
query
|
31
|
+
query {
|
32
32
|
users(
|
33
33
|
first: 100
|
34
34
|
skip: 50
|
@@ -45,9 +45,11 @@ query getUsers {
|
|
45
45
|
```graphql
|
46
46
|
# eslint @graphql-eslint/avoid-duplicate-fields: 'error'
|
47
47
|
|
48
|
-
query
|
49
|
-
|
50
|
-
|
48
|
+
query (
|
49
|
+
$first: Int!
|
50
|
+
$first: Int! # duplicate variable
|
51
|
+
) {
|
52
|
+
users(first: $first, skip: 50) {
|
51
53
|
id
|
52
54
|
}
|
53
55
|
}
|
@@ -13,5 +13,5 @@ Fragments use a type condition to determine if they apply, since fragments can o
|
|
13
13
|
|
14
14
|
## Resources
|
15
15
|
|
16
|
-
- [Rule source](https://github.com/graphql/graphql-js/blob/main/src/validation/rules/
|
17
|
-
- [Test source](https://github.com/graphql/graphql-js/tree/main/src/validation/__tests__/
|
16
|
+
- [Rule source](https://github.com/graphql/graphql-js/blob/main/src/validation/rules/FragmentsOnCompositeTypesRule.ts)
|
17
|
+
- [Test source](https://github.com/graphql/graphql-js/tree/main/src/validation/__tests__/FragmentsOnCompositeTypesRule-test.ts)
|
@@ -13,5 +13,5 @@ A GraphQL subscription is valid only if it contains a single root field.
|
|
13
13
|
|
14
14
|
## Resources
|
15
15
|
|
16
|
-
- [Rule source](https://github.com/graphql/graphql-js/blob/main/src/validation/rules/
|
17
|
-
- [Test source](https://github.com/graphql/graphql-js/tree/main/src/validation/__tests__/
|
16
|
+
- [Rule source](https://github.com/graphql/graphql-js/blob/main/src/validation/rules/SingleFieldSubscriptionsRule.ts)
|
17
|
+
- [Test source](https://github.com/graphql/graphql-js/tree/main/src/validation/__tests__/SingleFieldSubscriptionsRule-test.ts)
|
@@ -13,5 +13,5 @@ A fragment spread is only valid if the type condition could ever possibly be tru
|
|
13
13
|
|
14
14
|
## Resources
|
15
15
|
|
16
|
-
- [Rule source](https://github.com/graphql/graphql-js/blob/main/src/validation/rules/
|
17
|
-
- [Test source](https://github.com/graphql/graphql-js/tree/main/src/validation/__tests__/
|
16
|
+
- [Rule source](https://github.com/graphql/graphql-js/blob/main/src/validation/rules/PossibleFragmentSpreadsRule.ts)
|
17
|
+
- [Test source](https://github.com/graphql/graphql-js/tree/main/src/validation/__tests__/PossibleFragmentSpreadsRule-test.ts)
|
@@ -13,5 +13,5 @@ A type extension is only valid if the type is defined and has the same kind.
|
|
13
13
|
|
14
14
|
## Resources
|
15
15
|
|
16
|
-
- [Rule source](https://github.com/graphql/graphql-js/blob/main/src/validation/rules/
|
17
|
-
- [Test source](https://github.com/graphql/graphql-js/tree/main/src/validation/__tests__/
|
16
|
+
- [Rule source](https://github.com/graphql/graphql-js/blob/main/src/validation/rules/PossibleTypeExtensionsRule.ts)
|
17
|
+
- [Test source](https://github.com/graphql/graphql-js/tree/main/src/validation/__tests__/PossibleTypeExtensionsRule-test.ts)
|
@@ -13,5 +13,5 @@ A GraphQL document is only valid if all non-repeatable directives at a given loc
|
|
13
13
|
|
14
14
|
## Resources
|
15
15
|
|
16
|
-
- [Rule source](https://github.com/graphql/graphql-js/blob/main/src/validation/rules/
|
17
|
-
- [Test source](https://github.com/graphql/graphql-js/tree/main/src/validation/__tests__/
|
16
|
+
- [Rule source](https://github.com/graphql/graphql-js/blob/main/src/validation/rules/UniqueDirectivesPerLocationRule.ts)
|
17
|
+
- [Test source](https://github.com/graphql/graphql-js/tree/main/src/validation/__tests__/UniqueDirectivesPerLocationRule-test.ts)
|
@@ -13,5 +13,5 @@ A GraphQL document is only valid if all value literals are of the type expected
|
|
13
13
|
|
14
14
|
## Resources
|
15
15
|
|
16
|
-
- [Rule source](https://github.com/graphql/graphql-js/blob/main/src/validation/rules/
|
17
|
-
- [Test source](https://github.com/graphql/graphql-js/tree/main/src/validation/__tests__/
|
16
|
+
- [Rule source](https://github.com/graphql/graphql-js/blob/main/src/validation/rules/ValuesOfCorrectTypeRule.ts)
|
17
|
+
- [Test source](https://github.com/graphql/graphql-js/tree/main/src/validation/__tests__/ValuesOfCorrectTypeRule-test.ts)
|