@graphql-eslint/eslint-plugin 2.4.0-alpha-a96ed5f.0 → 2.4.0-alpha-a7d7d78.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.
Files changed (62) hide show
  1. package/docs/README.md +1 -1
  2. package/docs/rules/alphabetize.md +6 -1
  3. package/docs/rules/avoid-duplicate-fields.md +6 -1
  4. package/docs/rules/avoid-operation-name-prefix.md +5 -1
  5. package/docs/rules/avoid-scalar-result-type-on-mutation.md +6 -1
  6. package/docs/rules/avoid-typename-prefix.md +6 -1
  7. package/docs/rules/description-style.md +6 -1
  8. package/docs/rules/executable-definitions.md +6 -1
  9. package/docs/rules/fields-on-correct-type.md +6 -1
  10. package/docs/rules/fragments-on-composite-type.md +6 -1
  11. package/docs/rules/input-name.md +6 -1
  12. package/docs/rules/known-argument-names.md +6 -1
  13. package/docs/rules/known-directives.md +6 -1
  14. package/docs/rules/known-fragment-names.md +6 -1
  15. package/docs/rules/known-type-names.md +6 -1
  16. package/docs/rules/lone-anonymous-operation.md +6 -1
  17. package/docs/rules/lone-schema-definition.md +6 -1
  18. package/docs/rules/match-document-filename.md +6 -1
  19. package/docs/rules/naming-convention.md +6 -1
  20. package/docs/rules/no-anonymous-operations.md +6 -1
  21. package/docs/rules/no-case-insensitive-enum-values-duplicates.md +5 -1
  22. package/docs/rules/no-deprecated.md +6 -1
  23. package/docs/rules/no-fragment-cycles.md +6 -1
  24. package/docs/rules/no-hashtag-description.md +6 -1
  25. package/docs/rules/no-operation-name-suffix.md +5 -1
  26. package/docs/rules/no-undefined-variables.md +6 -1
  27. package/docs/rules/no-unreachable-types.md +6 -1
  28. package/docs/rules/no-unused-fields.md +6 -1
  29. package/docs/rules/no-unused-fragments.md +6 -1
  30. package/docs/rules/no-unused-variables.md +6 -1
  31. package/docs/rules/one-field-subscriptions.md +6 -1
  32. package/docs/rules/overlapping-fields-can-be-merged.md +6 -1
  33. package/docs/rules/possible-fragment-spread.md +6 -1
  34. package/docs/rules/possible-type-extension.md +6 -1
  35. package/docs/rules/provided-required-arguments.md +6 -1
  36. package/docs/rules/require-deprecation-date.md +6 -1
  37. package/docs/rules/require-deprecation-reason.md +6 -1
  38. package/docs/rules/require-description.md +6 -1
  39. package/docs/rules/require-field-of-type-query-in-mutation-result.md +6 -1
  40. package/docs/rules/require-id-when-available.md +6 -1
  41. package/docs/rules/scalar-leafs.md +6 -1
  42. package/docs/rules/selection-set-depth.md +6 -1
  43. package/docs/rules/strict-id-in-types.md +6 -1
  44. package/docs/rules/unique-argument-names.md +6 -1
  45. package/docs/rules/unique-directive-names-per-location.md +6 -1
  46. package/docs/rules/unique-directive-names.md +6 -1
  47. package/docs/rules/unique-enum-value-names.md +6 -1
  48. package/docs/rules/unique-field-definition-names.md +6 -1
  49. package/docs/rules/unique-fragment-name.md +6 -1
  50. package/docs/rules/unique-input-field-names.md +6 -1
  51. package/docs/rules/unique-operation-name.md +6 -1
  52. package/docs/rules/unique-operation-types.md +6 -1
  53. package/docs/rules/unique-type-names.md +6 -1
  54. package/docs/rules/unique-variable-names.md +6 -1
  55. package/docs/rules/value-literals-of-correct-type.md +6 -1
  56. package/docs/rules/variables-are-input-types.md +6 -1
  57. package/docs/rules/variables-in-allowed-position.md +6 -1
  58. package/index.js +51 -25
  59. package/index.mjs +51 -25
  60. package/package.json +1 -1
  61. package/types.d.ts +1 -0
  62. package/utils.d.ts +1 -0
package/docs/README.md CHANGED
@@ -73,4 +73,4 @@ Name            &nbs
73
73
 
74
74
  - [Writing Custom Rules](custom-rules.md)
75
75
  - [How the parser works?](parser.md)
76
- - [`parserOptions`](parser-options.md)
76
+ - [`parserOptions`](parser-options.md)
@@ -137,4 +137,9 @@ The elements of the array must contain the following properties:
137
137
  - `FieldDefinition`
138
138
  - `Field`
139
139
  - `DirectiveDefinition`
140
- - `Directive`
140
+ - `Directive`
141
+
142
+ ## Resources
143
+
144
+ - [Rule source](../../packages/plugin/src/rules/alphabetize.ts)
145
+ - [Test source](../../packages/plugin/tests/alphabetize.spec.ts)
@@ -51,4 +51,9 @@ query getUsers($first: Int!, $first: Int!) {
51
51
  id
52
52
  }
53
53
  }
54
- ```
54
+ ```
55
+
56
+ ## Resources
57
+
58
+ - [Rule source](../../packages/plugin/src/rules/avoid-duplicate-fields.ts)
59
+ - [Test source](../../packages/plugin/tests/avoid-duplicate-fields.spec.ts)
@@ -43,4 +43,8 @@ The object is an array with all elements of the type `string`.
43
43
 
44
44
  Additional restrictions:
45
45
 
46
- * Minimum items: `1`
46
+ * Minimum items: `1`
47
+
48
+ ## Resources
49
+
50
+ - [Rule source](../../packages/plugin/src/rules/avoid-operation-name-prefix.ts)
@@ -27,4 +27,9 @@ type Mutation {
27
27
  type Mutation {
28
28
  createUser: User!
29
29
  }
30
- ```
30
+ ```
31
+
32
+ ## Resources
33
+
34
+ - [Rule source](../../packages/plugin/src/rules/avoid-scalar-result-type-on-mutation.ts)
35
+ - [Test source](../../packages/plugin/tests/avoid-scalar-result-type-on-mutation.spec.ts)
@@ -29,4 +29,9 @@ type User {
29
29
  type User {
30
30
  id: ID!
31
31
  }
32
- ```
32
+ ```
33
+
34
+ ## Resources
35
+
36
+ - [Rule source](../../packages/plugin/src/rules/avoid-typename-prefix.ts)
37
+ - [Test source](../../packages/plugin/tests/avoid-typename-prefix.spec.ts)
@@ -42,4 +42,9 @@ This element must be one of the following enum values:
42
42
  * `block`
43
43
  * `inline`
44
44
 
45
- Default: `"inline"`
45
+ Default: `"inline"`
46
+
47
+ ## Resources
48
+
49
+ - [Rule source](../../packages/plugin/src/rules/description-style.ts)
50
+ - [Test source](../../packages/plugin/tests/description-style.spec.ts)
@@ -9,4 +9,9 @@
9
9
 
10
10
  A GraphQL document is only valid for execution if all definitions are either operation or fragment definitions.
11
11
 
12
- > This rule is a wrapper around a `graphql-js` validation function. [You can find its source code here](https://github.com/graphql/graphql-js/blob/main/src/validation/rules/ExecutableDefinitionsRule.ts).
12
+ > This rule is a wrapper around a `graphql-js` validation function. [You can find its source code here](https://github.com/graphql/graphql-js/blob/main/src/validation/rules/ExecutableDefinitionsRule.ts).
13
+
14
+ ## Resources
15
+
16
+ - [Rule source](https://github.com/graphql/graphql-js/blob/main/src/validation/rules/ExecutableDefinitionsRule.ts)
17
+ - [Test source](https://github.com/graphql/graphql-js/tree/main/src/validation/__tests__/ExecutableDefinitionsRule-test.ts)
@@ -9,4 +9,9 @@
9
9
 
10
10
  A GraphQL document is only valid if all fields selected are defined by the parent type, or are an allowed meta field such as `__typename`.
11
11
 
12
- > This rule is a wrapper around a `graphql-js` validation function. [You can find its source code here](https://github.com/graphql/graphql-js/blob/main/src/validation/rules/FieldsOnCorrectTypeRule.ts).
12
+ > This rule is a wrapper around a `graphql-js` validation function. [You can find its source code here](https://github.com/graphql/graphql-js/blob/main/src/validation/rules/FieldsOnCorrectTypeRule.ts).
13
+
14
+ ## Resources
15
+
16
+ - [Rule source](https://github.com/graphql/graphql-js/blob/main/src/validation/rules/FieldsOnCorrectTypeRule.ts)
17
+ - [Test source](https://github.com/graphql/graphql-js/tree/main/src/validation/__tests__/FieldsOnCorrectTypeRule-test.ts)
@@ -9,4 +9,9 @@
9
9
 
10
10
  Fragments use a type condition to determine if they apply, since fragments can only be spread into a composite type (object, interface, or union), the type condition must also be a composite type.
11
11
 
12
- > This rule is a wrapper around a `graphql-js` validation function. [You can find its source code here](https://github.com/graphql/graphql-js/blob/main/src/validation/rules/FragmentsOnCompositeTypesRule.ts).
12
+ > This rule is a wrapper around a `graphql-js` validation function. [You can find its source code here](https://github.com/graphql/graphql-js/blob/main/src/validation/rules/FragmentsOnCompositeTypesRule.ts).
13
+
14
+ ## Resources
15
+
16
+ - [Rule source](https://github.com/graphql/graphql-js/blob/main/src/validation/rules/FragmentsOnCompositeTypeRule.ts)
17
+ - [Test source](https://github.com/graphql/graphql-js/tree/main/src/validation/__tests__/FragmentsOnCompositeTypeRule-test.ts)
@@ -66,4 +66,9 @@ Default: `false`
66
66
 
67
67
  Apply the rule to Mutations
68
68
 
69
- Default: `true`
69
+ Default: `true`
70
+
71
+ ## Resources
72
+
73
+ - [Rule source](../../packages/plugin/src/rules/input-name.ts)
74
+ - [Test source](../../packages/plugin/tests/input-name.spec.ts)
@@ -9,4 +9,9 @@
9
9
 
10
10
  A GraphQL field is only valid if all supplied arguments are defined by that field.
11
11
 
12
- > This rule is a wrapper around a `graphql-js` validation function. [You can find its source code here](https://github.com/graphql/graphql-js/blob/main/src/validation/rules/KnownArgumentNamesRule.ts).
12
+ > This rule is a wrapper around a `graphql-js` validation function. [You can find its source code here](https://github.com/graphql/graphql-js/blob/main/src/validation/rules/KnownArgumentNamesRule.ts).
13
+
14
+ ## Resources
15
+
16
+ - [Rule source](https://github.com/graphql/graphql-js/blob/main/src/validation/rules/KnownArgumentNamesRule.ts)
17
+ - [Test source](https://github.com/graphql/graphql-js/tree/main/src/validation/__tests__/KnownArgumentNamesRule-test.ts)
@@ -9,4 +9,9 @@
9
9
 
10
10
  A GraphQL document is only valid if all `@directives` are known by the schema and legally positioned.
11
11
 
12
- > This rule is a wrapper around a `graphql-js` validation function. [You can find its source code here](https://github.com/graphql/graphql-js/blob/main/src/validation/rules/KnownDirectivesRule.ts).
12
+ > This rule is a wrapper around a `graphql-js` validation function. [You can find its source code here](https://github.com/graphql/graphql-js/blob/main/src/validation/rules/KnownDirectivesRule.ts).
13
+
14
+ ## Resources
15
+
16
+ - [Rule source](https://github.com/graphql/graphql-js/blob/main/src/validation/rules/KnownDirectivesRule.ts)
17
+ - [Test source](https://github.com/graphql/graphql-js/tree/main/src/validation/__tests__/KnownDirectivesRule-test.ts)
@@ -82,4 +82,9 @@ const GET_USER = /* GraphQL */ `
82
82
  # Will give false positive error 'Unknown fragment "UserFields"'
83
83
  ${USER_FIELDS}
84
84
  `
85
- ```
85
+ ```
86
+
87
+ ## Resources
88
+
89
+ - [Rule source](https://github.com/graphql/graphql-js/blob/main/src/validation/rules/KnownFragmentNamesRule.ts)
90
+ - [Test source](https://github.com/graphql/graphql-js/tree/main/src/validation/__tests__/KnownFragmentNamesRule-test.ts)
@@ -9,4 +9,9 @@
9
9
 
10
10
  A GraphQL document is only valid if referenced types (specifically variable definitions and fragment conditions) are defined by the type schema.
11
11
 
12
- > This rule is a wrapper around a `graphql-js` validation function. [You can find its source code here](https://github.com/graphql/graphql-js/blob/main/src/validation/rules/KnownTypeNamesRule.ts).
12
+ > This rule is a wrapper around a `graphql-js` validation function. [You can find its source code here](https://github.com/graphql/graphql-js/blob/main/src/validation/rules/KnownTypeNamesRule.ts).
13
+
14
+ ## Resources
15
+
16
+ - [Rule source](https://github.com/graphql/graphql-js/blob/main/src/validation/rules/KnownTypeNamesRule.ts)
17
+ - [Test source](https://github.com/graphql/graphql-js/tree/main/src/validation/__tests__/KnownTypeNamesRule-test.ts)
@@ -9,4 +9,9 @@
9
9
 
10
10
  A GraphQL document is only valid if when it contains an anonymous operation (the query short-hand) that it contains only that one operation definition.
11
11
 
12
- > This rule is a wrapper around a `graphql-js` validation function. [You can find its source code here](https://github.com/graphql/graphql-js/blob/main/src/validation/rules/LoneAnonymousOperationRule.ts).
12
+ > This rule is a wrapper around a `graphql-js` validation function. [You can find its source code here](https://github.com/graphql/graphql-js/blob/main/src/validation/rules/LoneAnonymousOperationRule.ts).
13
+
14
+ ## Resources
15
+
16
+ - [Rule source](https://github.com/graphql/graphql-js/blob/main/src/validation/rules/LoneAnonymousOperationRule.ts)
17
+ - [Test source](https://github.com/graphql/graphql-js/tree/main/src/validation/__tests__/LoneAnonymousOperationRule-test.ts)
@@ -9,4 +9,9 @@
9
9
 
10
10
  A GraphQL document is only valid if it contains only one schema definition.
11
11
 
12
- > This rule is a wrapper around a `graphql-js` validation function. [You can find its source code here](https://github.com/graphql/graphql-js/blob/main/src/validation/rules/LoneSchemaDefinitionRule.ts).
12
+ > This rule is a wrapper around a `graphql-js` validation function. [You can find its source code here](https://github.com/graphql/graphql-js/blob/main/src/validation/rules/LoneSchemaDefinitionRule.ts).
13
+
14
+ ## Resources
15
+
16
+ - [Rule source](https://github.com/graphql/graphql-js/blob/main/src/validation/rules/LoneSchemaDefinitionRule.ts)
17
+ - [Test source](https://github.com/graphql/graphql-js/tree/main/src/validation/__tests__/LoneSchemaDefinitionRule-test.ts)
@@ -145,4 +145,9 @@ This element must be one of the following enum values:
145
145
  * `PascalCase`
146
146
  * `snake_case`
147
147
  * `UPPER_CASE`
148
- * `kebab-case`
148
+ * `kebab-case`
149
+
150
+ ## Resources
151
+
152
+ - [Rule source](../../packages/plugin/src/rules/match-document-filename.ts)
153
+ - [Test source](../../packages/plugin/tests/match-document-filename.spec.ts)
@@ -178,4 +178,9 @@ The object is an array with all elements of the type `string`.
178
178
 
179
179
  Additional restrictions:
180
180
 
181
- * Minimum items: `1`
181
+ * Minimum items: `1`
182
+
183
+ ## Resources
184
+
185
+ - [Rule source](../../packages/plugin/src/rules/naming-convention.ts)
186
+ - [Test source](../../packages/plugin/tests/naming-convention.spec.ts)
@@ -29,4 +29,9 @@ query {
29
29
  query user {
30
30
  # ...
31
31
  }
32
- ```
32
+ ```
33
+
34
+ ## Resources
35
+
36
+ - [Rule source](../../packages/plugin/src/rules/no-anonymous-operations.ts)
37
+ - [Test source](../../packages/plugin/tests/no-anonymous-operations.spec.ts)
@@ -35,4 +35,8 @@ enum MyEnum {
35
35
  Value2
36
36
  Value3
37
37
  }
38
- ```
38
+ ```
39
+
40
+ ## Resources
41
+
42
+ - [Rule source](../../packages/plugin/src/rules/no-case-insensitive-enum-values-duplicates.ts)
@@ -73,4 +73,9 @@ query user {
73
73
  fullName
74
74
  }
75
75
  }
76
- ```
76
+ ```
77
+
78
+ ## Resources
79
+
80
+ - [Rule source](../../packages/plugin/src/rules/no-deprecated.ts)
81
+ - [Test source](../../packages/plugin/tests/no-deprecated.spec.ts)
@@ -9,4 +9,9 @@
9
9
 
10
10
  A GraphQL fragment is only valid when it does not have cycles in fragments usage.
11
11
 
12
- > This rule is a wrapper around a `graphql-js` validation function. [You can find its source code here](https://github.com/graphql/graphql-js/blob/main/src/validation/rules/NoFragmentCyclesRule.ts).
12
+ > This rule is a wrapper around a `graphql-js` validation function. [You can find its source code here](https://github.com/graphql/graphql-js/blob/main/src/validation/rules/NoFragmentCyclesRule.ts).
13
+
14
+ ## Resources
15
+
16
+ - [Rule source](https://github.com/graphql/graphql-js/blob/main/src/validation/rules/NoFragmentCyclesRule.ts)
17
+ - [Test source](https://github.com/graphql/graphql-js/tree/main/src/validation/__tests__/NoFragmentCyclesRule-test.ts)
@@ -47,4 +47,9 @@ type User {
47
47
  id: ID! # This one is also valid, since it comes after the AST object
48
48
  name: String
49
49
  }
50
- ```
50
+ ```
51
+
52
+ ## Resources
53
+
54
+ - [Rule source](../../packages/plugin/src/rules/no-hashtag-description.ts)
55
+ - [Test source](../../packages/plugin/tests/no-hashtag-description.spec.ts)
@@ -31,4 +31,8 @@ query userQuery {
31
31
  query user {
32
32
  # ...
33
33
  }
34
- ```
34
+ ```
35
+
36
+ ## Resources
37
+
38
+ - [Rule source](../../packages/plugin/src/rules/no-operation-name-suffix.ts)
@@ -9,4 +9,9 @@
9
9
 
10
10
  A GraphQL operation is only valid if all variables encountered, both directly and via fragment spreads, are defined by that operation.
11
11
 
12
- > This rule is a wrapper around a `graphql-js` validation function. [You can find its source code here](https://github.com/graphql/graphql-js/blob/main/src/validation/rules/NoUndefinedVariablesRule.ts).
12
+ > This rule is a wrapper around a `graphql-js` validation function. [You can find its source code here](https://github.com/graphql/graphql-js/blob/main/src/validation/rules/NoUndefinedVariablesRule.ts).
13
+
14
+ ## Resources
15
+
16
+ - [Rule source](https://github.com/graphql/graphql-js/blob/main/src/validation/rules/NoUndefinedVariablesRule.ts)
17
+ - [Test source](https://github.com/graphql/graphql-js/tree/main/src/validation/__tests__/NoUndefinedVariablesRule-test.ts)
@@ -39,4 +39,9 @@ type User {
39
39
  type Query {
40
40
  me: User
41
41
  }
42
- ```
42
+ ```
43
+
44
+ ## Resources
45
+
46
+ - [Rule source](../../packages/plugin/src/rules/no-unreachable-types.ts)
47
+ - [Test source](../../packages/plugin/tests/no-unreachable-types.spec.ts)
@@ -54,4 +54,9 @@ query {
54
54
  name
55
55
  }
56
56
  }
57
- ```
57
+ ```
58
+
59
+ ## Resources
60
+
61
+ - [Rule source](../../packages/plugin/src/rules/no-unused-fields.ts)
62
+ - [Test source](../../packages/plugin/tests/no-unused-fields.spec.ts)
@@ -9,4 +9,9 @@
9
9
 
10
10
  A GraphQL document is only valid if all fragment definitions are spread within operations, or spread within other fragments spread within operations.
11
11
 
12
- > This rule is a wrapper around a `graphql-js` validation function. [You can find its source code here](https://github.com/graphql/graphql-js/blob/main/src/validation/rules/NoUnusedFragmentsRule.ts).
12
+ > This rule is a wrapper around a `graphql-js` validation function. [You can find its source code here](https://github.com/graphql/graphql-js/blob/main/src/validation/rules/NoUnusedFragmentsRule.ts).
13
+
14
+ ## Resources
15
+
16
+ - [Rule source](https://github.com/graphql/graphql-js/blob/main/src/validation/rules/NoUnusedFragmentsRule.ts)
17
+ - [Test source](https://github.com/graphql/graphql-js/tree/main/src/validation/__tests__/NoUnusedFragmentsRule-test.ts)
@@ -9,4 +9,9 @@
9
9
 
10
10
  A GraphQL operation is only valid if all variables defined by an operation are used, either directly or within a spread fragment.
11
11
 
12
- > This rule is a wrapper around a `graphql-js` validation function. [You can find its source code here](https://github.com/graphql/graphql-js/blob/main/src/validation/rules/NoUnusedVariablesRule.ts).
12
+ > This rule is a wrapper around a `graphql-js` validation function. [You can find its source code here](https://github.com/graphql/graphql-js/blob/main/src/validation/rules/NoUnusedVariablesRule.ts).
13
+
14
+ ## Resources
15
+
16
+ - [Rule source](https://github.com/graphql/graphql-js/blob/main/src/validation/rules/NoUnusedVariablesRule.ts)
17
+ - [Test source](https://github.com/graphql/graphql-js/tree/main/src/validation/__tests__/NoUnusedVariablesRule-test.ts)
@@ -9,4 +9,9 @@
9
9
 
10
10
  A GraphQL subscription is valid only if it contains a single root field.
11
11
 
12
- > This rule is a wrapper around a `graphql-js` validation function. [You can find its source code here](https://github.com/graphql/graphql-js/blob/main/src/validation/rules/SingleFieldSubscriptionsRule.ts).
12
+ > This rule is a wrapper around a `graphql-js` validation function. [You can find its source code here](https://github.com/graphql/graphql-js/blob/main/src/validation/rules/SingleFieldSubscriptionsRule.ts).
13
+
14
+ ## Resources
15
+
16
+ - [Rule source](https://github.com/graphql/graphql-js/blob/main/src/validation/rules/OneFieldSubscriptionsRule.ts)
17
+ - [Test source](https://github.com/graphql/graphql-js/tree/main/src/validation/__tests__/OneFieldSubscriptionsRule-test.ts)
@@ -9,4 +9,9 @@
9
9
 
10
10
  A selection set is only valid if all fields (including spreading any fragments) either correspond to distinct response names or can be merged without ambiguity.
11
11
 
12
- > This rule is a wrapper around a `graphql-js` validation function. [You can find its source code here](https://github.com/graphql/graphql-js/blob/main/src/validation/rules/OverlappingFieldsCanBeMergedRule.ts).
12
+ > This rule is a wrapper around a `graphql-js` validation function. [You can find its source code here](https://github.com/graphql/graphql-js/blob/main/src/validation/rules/OverlappingFieldsCanBeMergedRule.ts).
13
+
14
+ ## Resources
15
+
16
+ - [Rule source](https://github.com/graphql/graphql-js/blob/main/src/validation/rules/OverlappingFieldsCanBeMergedRule.ts)
17
+ - [Test source](https://github.com/graphql/graphql-js/tree/main/src/validation/__tests__/OverlappingFieldsCanBeMergedRule-test.ts)
@@ -9,4 +9,9 @@
9
9
 
10
10
  A fragment spread is only valid if the type condition could ever possibly be true: if there is a non-empty intersection of the possible parent types, and possible types which pass the type condition.
11
11
 
12
- > This rule is a wrapper around a `graphql-js` validation function. [You can find its source code here](https://github.com/graphql/graphql-js/blob/main/src/validation/rules/PossibleFragmentSpreadsRule.ts).
12
+ > This rule is a wrapper around a `graphql-js` validation function. [You can find its source code here](https://github.com/graphql/graphql-js/blob/main/src/validation/rules/PossibleFragmentSpreadsRule.ts).
13
+
14
+ ## Resources
15
+
16
+ - [Rule source](https://github.com/graphql/graphql-js/blob/main/src/validation/rules/PossibleFragmentSpreadRule.ts)
17
+ - [Test source](https://github.com/graphql/graphql-js/tree/main/src/validation/__tests__/PossibleFragmentSpreadRule-test.ts)
@@ -9,4 +9,9 @@
9
9
 
10
10
  A type extension is only valid if the type is defined and has the same kind.
11
11
 
12
- > This rule is a wrapper around a `graphql-js` validation function. [You can find its source code here](https://github.com/graphql/graphql-js/blob/main/src/validation/rules/PossibleTypeExtensionsRule.ts).
12
+ > This rule is a wrapper around a `graphql-js` validation function. [You can find its source code here](https://github.com/graphql/graphql-js/blob/main/src/validation/rules/PossibleTypeExtensionsRule.ts).
13
+
14
+ ## Resources
15
+
16
+ - [Rule source](https://github.com/graphql/graphql-js/blob/main/src/validation/rules/PossibleTypeExtensionRule.ts)
17
+ - [Test source](https://github.com/graphql/graphql-js/tree/main/src/validation/__tests__/PossibleTypeExtensionRule-test.ts)
@@ -9,4 +9,9 @@
9
9
 
10
10
  A field or directive is only valid if all required (non-null without a default value) field arguments have been provided.
11
11
 
12
- > This rule is a wrapper around a `graphql-js` validation function. [You can find its source code here](https://github.com/graphql/graphql-js/blob/main/src/validation/rules/ProvidedRequiredArgumentsRule.ts).
12
+ > This rule is a wrapper around a `graphql-js` validation function. [You can find its source code here](https://github.com/graphql/graphql-js/blob/main/src/validation/rules/ProvidedRequiredArgumentsRule.ts).
13
+
14
+ ## Resources
15
+
16
+ - [Rule source](https://github.com/graphql/graphql-js/blob/main/src/validation/rules/ProvidedRequiredArgumentsRule.ts)
17
+ - [Test source](https://github.com/graphql/graphql-js/tree/main/src/validation/__tests__/ProvidedRequiredArgumentsRule-test.ts)
@@ -46,4 +46,9 @@ type User {
46
46
 
47
47
  The schema defines the following properties:
48
48
 
49
- ### `argumentName` (string)
49
+ ### `argumentName` (string)
50
+
51
+ ## Resources
52
+
53
+ - [Rule source](../../packages/plugin/src/rules/require-deprecation-date.ts)
54
+ - [Test source](../../packages/plugin/tests/require-deprecation-date.spec.ts)
@@ -39,4 +39,9 @@ type MyType {
39
39
  type MyType {
40
40
  name: String @deprecated(reason: "no longer relevant, please use fullName field")
41
41
  }
42
- ```
42
+ ```
43
+
44
+ ## Resources
45
+
46
+ - [Rule source](../../packages/plugin/src/rules/require-deprecation-reason.ts)
47
+ - [Test source](../../packages/plugin/tests/require-deprecation-reason.spec.ts)
@@ -45,4 +45,9 @@ The object is an array with all elements of the type `string`.
45
45
 
46
46
  Additional restrictions:
47
47
 
48
- * Minimum items: `1`
48
+ * Minimum items: `1`
49
+
50
+ ## Resources
51
+
52
+ - [Rule source](../../packages/plugin/src/rules/require-description.ts)
53
+ - [Test source](../../packages/plugin/tests/require-description.spec.ts)
@@ -39,4 +39,9 @@ type CreateUserPayload {
39
39
  type Mutation {
40
40
  createUser: CreateUserPayload!
41
41
  }
42
- ```
42
+ ```
43
+
44
+ ## Resources
45
+
46
+ - [Rule source](../../packages/plugin/src/rules/require-field-of-type-query-in-mutation-result.ts)
47
+ - [Test source](../../packages/plugin/tests/require-field-of-type-query-in-mutation-result.spec.ts)
@@ -54,4 +54,9 @@ The schema defines the following properties:
54
54
 
55
55
  ### `fieldName` (string)
56
56
 
57
- Default: `"id"`
57
+ Default: `"id"`
58
+
59
+ ## Resources
60
+
61
+ - [Rule source](../../packages/plugin/src/rules/require-id-when-available.ts)
62
+ - [Test source](../../packages/plugin/tests/require-id-when-available.spec.ts)
@@ -9,4 +9,9 @@
9
9
 
10
10
  A GraphQL document is valid only if all leaf fields (fields without sub selections) are of scalar or enum types.
11
11
 
12
- > This rule is a wrapper around a `graphql-js` validation function. [You can find its source code here](https://github.com/graphql/graphql-js/blob/main/src/validation/rules/ScalarLeafsRule.ts).
12
+ > This rule is a wrapper around a `graphql-js` validation function. [You can find its source code here](https://github.com/graphql/graphql-js/blob/main/src/validation/rules/ScalarLeafsRule.ts).
13
+
14
+ ## Resources
15
+
16
+ - [Rule source](https://github.com/graphql/graphql-js/blob/main/src/validation/rules/ScalarLeafsRule.ts)
17
+ - [Test source](https://github.com/graphql/graphql-js/tree/main/src/validation/__tests__/ScalarLeafsRule-test.ts)
@@ -59,4 +59,9 @@ The schema defines the following properties:
59
59
 
60
60
  ### `ignore` (array)
61
61
 
62
- The object is an array with all elements of the type `string`.
62
+ The object is an array with all elements of the type `string`.
63
+
64
+ ## Resources
65
+
66
+ - [Rule source](../../packages/plugin/src/rules/selection-set-depth.ts)
67
+ - [Test source](../../packages/plugin/tests/selection-set-depth.spec.ts)
@@ -114,4 +114,9 @@ Default:
114
114
 
115
115
  ```
116
116
  []
117
- ```
117
+ ```
118
+
119
+ ## Resources
120
+
121
+ - [Rule source](../../packages/plugin/src/rules/strict-id-in-types.ts)
122
+ - [Test source](../../packages/plugin/tests/strict-id-in-types.spec.ts)
@@ -9,4 +9,9 @@
9
9
 
10
10
  A GraphQL field or directive is only valid if all supplied arguments are uniquely named.
11
11
 
12
- > This rule is a wrapper around a `graphql-js` validation function. [You can find its source code here](https://github.com/graphql/graphql-js/blob/main/src/validation/rules/UniqueArgumentNamesRule.ts).
12
+ > This rule is a wrapper around a `graphql-js` validation function. [You can find its source code here](https://github.com/graphql/graphql-js/blob/main/src/validation/rules/UniqueArgumentNamesRule.ts).
13
+
14
+ ## Resources
15
+
16
+ - [Rule source](https://github.com/graphql/graphql-js/blob/main/src/validation/rules/UniqueArgumentNamesRule.ts)
17
+ - [Test source](https://github.com/graphql/graphql-js/tree/main/src/validation/__tests__/UniqueArgumentNamesRule-test.ts)
@@ -9,4 +9,9 @@
9
9
 
10
10
  A GraphQL document is only valid if all non-repeatable directives at a given location are uniquely named.
11
11
 
12
- > This rule is a wrapper around a `graphql-js` validation function. [You can find its source code here](https://github.com/graphql/graphql-js/blob/main/src/validation/rules/UniqueDirectivesPerLocationRule.ts).
12
+ > This rule is a wrapper around a `graphql-js` validation function. [You can find its source code here](https://github.com/graphql/graphql-js/blob/main/src/validation/rules/UniqueDirectivesPerLocationRule.ts).
13
+
14
+ ## Resources
15
+
16
+ - [Rule source](https://github.com/graphql/graphql-js/blob/main/src/validation/rules/UniqueDirectiveNamesPerLocationRule.ts)
17
+ - [Test source](https://github.com/graphql/graphql-js/tree/main/src/validation/__tests__/UniqueDirectiveNamesPerLocationRule-test.ts)
@@ -9,4 +9,9 @@
9
9
 
10
10
  A GraphQL document is only valid if all defined directives have unique names.
11
11
 
12
- > This rule is a wrapper around a `graphql-js` validation function. [You can find its source code here](https://github.com/graphql/graphql-js/blob/main/src/validation/rules/UniqueDirectiveNamesRule.ts).
12
+ > This rule is a wrapper around a `graphql-js` validation function. [You can find its source code here](https://github.com/graphql/graphql-js/blob/main/src/validation/rules/UniqueDirectiveNamesRule.ts).
13
+
14
+ ## Resources
15
+
16
+ - [Rule source](https://github.com/graphql/graphql-js/blob/main/src/validation/rules/UniqueDirectiveNamesRule.ts)
17
+ - [Test source](https://github.com/graphql/graphql-js/tree/main/src/validation/__tests__/UniqueDirectiveNamesRule-test.ts)
@@ -9,4 +9,9 @@
9
9
 
10
10
  A GraphQL enum type is only valid if all its values are uniquely named.
11
11
 
12
- > This rule is a wrapper around a `graphql-js` validation function. [You can find its source code here](https://github.com/graphql/graphql-js/blob/main/src/validation/rules/UniqueEnumValueNamesRule.ts).
12
+ > This rule is a wrapper around a `graphql-js` validation function. [You can find its source code here](https://github.com/graphql/graphql-js/blob/main/src/validation/rules/UniqueEnumValueNamesRule.ts).
13
+
14
+ ## Resources
15
+
16
+ - [Rule source](https://github.com/graphql/graphql-js/blob/main/src/validation/rules/UniqueEnumValueNamesRule.ts)
17
+ - [Test source](https://github.com/graphql/graphql-js/tree/main/src/validation/__tests__/UniqueEnumValueNamesRule-test.ts)
@@ -9,4 +9,9 @@
9
9
 
10
10
  A GraphQL complex type is only valid if all its fields are uniquely named.
11
11
 
12
- > This rule is a wrapper around a `graphql-js` validation function. [You can find its source code here](https://github.com/graphql/graphql-js/blob/main/src/validation/rules/UniqueFieldDefinitionNamesRule.ts).
12
+ > This rule is a wrapper around a `graphql-js` validation function. [You can find its source code here](https://github.com/graphql/graphql-js/blob/main/src/validation/rules/UniqueFieldDefinitionNamesRule.ts).
13
+
14
+ ## Resources
15
+
16
+ - [Rule source](https://github.com/graphql/graphql-js/blob/main/src/validation/rules/UniqueFieldDefinitionNamesRule.ts)
17
+ - [Test source](https://github.com/graphql/graphql-js/tree/main/src/validation/__tests__/UniqueFieldDefinitionNamesRule-test.ts)
@@ -43,4 +43,9 @@ fragment AllUserFields on User {
43
43
  fragment UserFields on User {
44
44
  id
45
45
  }
46
- ```
46
+ ```
47
+
48
+ ## Resources
49
+
50
+ - [Rule source](../../packages/plugin/src/rules/unique-fragment-name.ts)
51
+ - [Test source](../../packages/plugin/tests/unique-fragment-name.spec.ts)
@@ -9,4 +9,9 @@
9
9
 
10
10
  A GraphQL input object value is only valid if all supplied fields are uniquely named.
11
11
 
12
- > This rule is a wrapper around a `graphql-js` validation function. [You can find its source code here](https://github.com/graphql/graphql-js/blob/main/src/validation/rules/UniqueInputFieldNamesRule.ts).
12
+ > This rule is a wrapper around a `graphql-js` validation function. [You can find its source code here](https://github.com/graphql/graphql-js/blob/main/src/validation/rules/UniqueInputFieldNamesRule.ts).
13
+
14
+ ## Resources
15
+
16
+ - [Rule source](https://github.com/graphql/graphql-js/blob/main/src/validation/rules/UniqueInputFieldNamesRule.ts)
17
+ - [Test source](https://github.com/graphql/graphql-js/tree/main/src/validation/__tests__/UniqueInputFieldNamesRule-test.ts)
@@ -47,4 +47,9 @@ query me {
47
47
  id
48
48
  }
49
49
  }
50
- ```
50
+ ```
51
+
52
+ ## Resources
53
+
54
+ - [Rule source](../../packages/plugin/src/rules/unique-operation-name.ts)
55
+ - [Test source](../../packages/plugin/tests/unique-operation-name.spec.ts)
@@ -9,4 +9,9 @@
9
9
 
10
10
  A GraphQL document is only valid if it has only one type per operation.
11
11
 
12
- > This rule is a wrapper around a `graphql-js` validation function. [You can find its source code here](https://github.com/graphql/graphql-js/blob/main/src/validation/rules/UniqueOperationTypesRule.ts).
12
+ > This rule is a wrapper around a `graphql-js` validation function. [You can find its source code here](https://github.com/graphql/graphql-js/blob/main/src/validation/rules/UniqueOperationTypesRule.ts).
13
+
14
+ ## Resources
15
+
16
+ - [Rule source](https://github.com/graphql/graphql-js/blob/main/src/validation/rules/UniqueOperationTypesRule.ts)
17
+ - [Test source](https://github.com/graphql/graphql-js/tree/main/src/validation/__tests__/UniqueOperationTypesRule-test.ts)
@@ -9,4 +9,9 @@
9
9
 
10
10
  A GraphQL document is only valid if all defined types have unique names.
11
11
 
12
- > This rule is a wrapper around a `graphql-js` validation function. [You can find its source code here](https://github.com/graphql/graphql-js/blob/main/src/validation/rules/UniqueTypeNamesRule.ts).
12
+ > This rule is a wrapper around a `graphql-js` validation function. [You can find its source code here](https://github.com/graphql/graphql-js/blob/main/src/validation/rules/UniqueTypeNamesRule.ts).
13
+
14
+ ## Resources
15
+
16
+ - [Rule source](https://github.com/graphql/graphql-js/blob/main/src/validation/rules/UniqueTypeNamesRule.ts)
17
+ - [Test source](https://github.com/graphql/graphql-js/tree/main/src/validation/__tests__/UniqueTypeNamesRule-test.ts)
@@ -9,4 +9,9 @@
9
9
 
10
10
  A GraphQL operation is only valid if all its variables are uniquely named.
11
11
 
12
- > This rule is a wrapper around a `graphql-js` validation function. [You can find its source code here](https://github.com/graphql/graphql-js/blob/main/src/validation/rules/UniqueVariableNamesRule.ts).
12
+ > This rule is a wrapper around a `graphql-js` validation function. [You can find its source code here](https://github.com/graphql/graphql-js/blob/main/src/validation/rules/UniqueVariableNamesRule.ts).
13
+
14
+ ## Resources
15
+
16
+ - [Rule source](https://github.com/graphql/graphql-js/blob/main/src/validation/rules/UniqueVariableNamesRule.ts)
17
+ - [Test source](https://github.com/graphql/graphql-js/tree/main/src/validation/__tests__/UniqueVariableNamesRule-test.ts)
@@ -9,4 +9,9 @@
9
9
 
10
10
  A GraphQL document is only valid if all value literals are of the type expected at their position.
11
11
 
12
- > This rule is a wrapper around a `graphql-js` validation function. [You can find its source code here](https://github.com/graphql/graphql-js/blob/main/src/validation/rules/ValuesOfCorrectTypeRule.ts).
12
+ > This rule is a wrapper around a `graphql-js` validation function. [You can find its source code here](https://github.com/graphql/graphql-js/blob/main/src/validation/rules/ValuesOfCorrectTypeRule.ts).
13
+
14
+ ## Resources
15
+
16
+ - [Rule source](https://github.com/graphql/graphql-js/blob/main/src/validation/rules/ValueLiteralsOfCorrectTypeRule.ts)
17
+ - [Test source](https://github.com/graphql/graphql-js/tree/main/src/validation/__tests__/ValueLiteralsOfCorrectTypeRule-test.ts)
@@ -9,4 +9,9 @@
9
9
 
10
10
  A GraphQL operation is only valid if all the variables it defines are of input types (scalar, enum, or input object).
11
11
 
12
- > This rule is a wrapper around a `graphql-js` validation function. [You can find its source code here](https://github.com/graphql/graphql-js/blob/main/src/validation/rules/VariablesAreInputTypesRule.ts).
12
+ > This rule is a wrapper around a `graphql-js` validation function. [You can find its source code here](https://github.com/graphql/graphql-js/blob/main/src/validation/rules/VariablesAreInputTypesRule.ts).
13
+
14
+ ## Resources
15
+
16
+ - [Rule source](https://github.com/graphql/graphql-js/blob/main/src/validation/rules/VariablesAreInputTypesRule.ts)
17
+ - [Test source](https://github.com/graphql/graphql-js/tree/main/src/validation/__tests__/VariablesAreInputTypesRule-test.ts)
@@ -9,4 +9,9 @@
9
9
 
10
10
  Variables passed to field arguments conform to type.
11
11
 
12
- > This rule is a wrapper around a `graphql-js` validation function. [You can find its source code here](https://github.com/graphql/graphql-js/blob/main/src/validation/rules/VariablesInAllowedPositionRule.ts).
12
+ > This rule is a wrapper around a `graphql-js` validation function. [You can find its source code here](https://github.com/graphql/graphql-js/blob/main/src/validation/rules/VariablesInAllowedPositionRule.ts).
13
+
14
+ ## Resources
15
+
16
+ - [Rule source](https://github.com/graphql/graphql-js/blob/main/src/validation/rules/VariablesInAllowedPositionRule.ts)
17
+ - [Test source](https://github.com/graphql/graphql-js/tree/main/src/validation/__tests__/VariablesInAllowedPositionRule-test.ts)
package/index.js CHANGED
@@ -656,10 +656,7 @@ const rule = {
656
656
  line: start.line,
657
657
  column: start.column - (isVariableNode ? 2 : 1),
658
658
  },
659
- end: {
660
- line: end.line,
661
- column: end.column,
662
- },
659
+ end,
663
660
  },
664
661
  messageId: ALPHABETIZE,
665
662
  data: isVariableNode
@@ -910,15 +907,16 @@ const rule$2 = {
910
907
  const testKeyword = caseSensitive ? keyword : keyword.toLowerCase();
911
908
  const testName = caseSensitive ? node.name.value : node.name.value.toLowerCase();
912
909
  if (testName.startsWith(testKeyword)) {
910
+ const { start } = node.name.loc;
913
911
  context.report({
914
912
  loc: {
915
913
  start: {
916
- line: node.name.loc.start.line,
917
- column: node.name.loc.start.column - 1,
914
+ line: start.line,
915
+ column: start.column - 1,
918
916
  },
919
917
  end: {
920
- line: node.name.loc.start.line,
921
- column: node.name.loc.start.column + testKeyword.length - 1,
918
+ line: start.line,
919
+ column: start.column - 1 + testKeyword.length,
922
920
  },
923
921
  },
924
922
  data: {
@@ -1023,17 +1021,27 @@ const rule$4 = {
1023
1021
  return {
1024
1022
  'ObjectTypeDefinition, ObjectTypeExtension, InterfaceTypeDefinition, InterfaceTypeExtension'(node) {
1025
1023
  const typeName = node.name.value;
1026
- const lowerTypeName = (typeName || '').toLowerCase();
1024
+ const lowerTypeName = typeName.toLowerCase();
1027
1025
  for (const field of node.fields) {
1028
- const fieldName = field.name.value || '';
1029
- if (fieldName && lowerTypeName && fieldName.toLowerCase().startsWith(lowerTypeName)) {
1026
+ const fieldName = field.name.value;
1027
+ if (fieldName.toLowerCase().startsWith(lowerTypeName)) {
1028
+ const { start } = field.loc;
1030
1029
  context.report({
1031
- node: field.name,
1032
1030
  data: {
1033
1031
  fieldName,
1034
1032
  typeName,
1035
1033
  },
1036
1034
  messageId: AVOID_TYPENAME_PREFIX,
1035
+ loc: {
1036
+ start: {
1037
+ line: start.line,
1038
+ column: start.column - 1,
1039
+ },
1040
+ end: {
1041
+ line: start.line,
1042
+ column: start.column - 1 + lowerTypeName.length,
1043
+ },
1044
+ },
1037
1045
  });
1038
1046
  }
1039
1047
  }
@@ -1736,16 +1744,19 @@ const rule$9 = {
1736
1744
  create(context) {
1737
1745
  return {
1738
1746
  OperationDefinition(node) {
1739
- if (node && (!node.name || node.name.value === '')) {
1747
+ var _a;
1748
+ const isAnonymous = (((_a = node.name) === null || _a === void 0 ? void 0 : _a.value) || '').length === 0;
1749
+ if (isAnonymous) {
1750
+ const { start } = node.loc;
1740
1751
  context.report({
1741
1752
  loc: {
1742
1753
  start: {
1743
- column: node.loc.start.column - 1,
1744
- line: node.loc.start.line,
1754
+ column: start.column - 1,
1755
+ line: start.line,
1745
1756
  },
1746
1757
  end: {
1747
- column: node.loc.start.column + node.operation.length,
1748
- line: node.loc.start.line,
1758
+ column: start.column - 1 + node.operation.length,
1759
+ line: start.line,
1749
1760
  },
1750
1761
  },
1751
1762
  data: {
@@ -2043,11 +2054,23 @@ const rule$d = {
2043
2054
  create(context) {
2044
2055
  return {
2045
2056
  'OperationDefinition, FragmentDefinition'(node) {
2046
- if (node && node.name && node.name.value !== '') {
2047
- const invalidSuffix = (node.type === 'OperationDefinition' ? node.operation : 'fragment').toLowerCase();
2048
- if (node.name.value.toLowerCase().endsWith(invalidSuffix)) {
2057
+ var _a;
2058
+ const name = ((_a = node.name) === null || _a === void 0 ? void 0 : _a.value) || '';
2059
+ if (name.length > 0) {
2060
+ const invalidSuffix = 'operation' in node ? node.operation : 'fragment';
2061
+ if (name.toLowerCase().endsWith(invalidSuffix)) {
2062
+ const { start, end } = node.name.loc;
2049
2063
  context.report({
2050
- node: node.name,
2064
+ loc: {
2065
+ start: {
2066
+ column: start.column - 1 + name.length - invalidSuffix.length,
2067
+ line: start.line,
2068
+ },
2069
+ end: {
2070
+ column: end.column - 1 + name.length,
2071
+ line: end.line,
2072
+ },
2073
+ },
2051
2074
  data: {
2052
2075
  invalidSuffix,
2053
2076
  },
@@ -2499,15 +2522,18 @@ const DESCRIBABLE_NODES = [
2499
2522
  function verifyRule(context, node) {
2500
2523
  if (node) {
2501
2524
  if (!node.description || !node.description.value || node.description.value.trim().length === 0) {
2525
+ const { start, end } = ('name' in node ? node.name : node).loc;
2502
2526
  context.report({
2503
2527
  loc: {
2504
2528
  start: {
2505
- line: node.loc.start.line,
2506
- column: node.loc.start.column - 1,
2529
+ line: start.line,
2530
+ column: start.column - 1,
2507
2531
  },
2508
2532
  end: {
2509
- line: node.loc.end.line,
2510
- column: node.loc.end.column,
2533
+ line: end.line,
2534
+ column:
2535
+ // node.name don't exist on SchemaDefinition
2536
+ 'name' in node ? end.column - 1 + node.name.value.length : end.column,
2511
2537
  },
2512
2538
  },
2513
2539
  messageId: REQUIRE_DESCRIPTION_ERROR,
package/index.mjs CHANGED
@@ -650,10 +650,7 @@ const rule = {
650
650
  line: start.line,
651
651
  column: start.column - (isVariableNode ? 2 : 1),
652
652
  },
653
- end: {
654
- line: end.line,
655
- column: end.column,
656
- },
653
+ end,
657
654
  },
658
655
  messageId: ALPHABETIZE,
659
656
  data: isVariableNode
@@ -904,15 +901,16 @@ const rule$2 = {
904
901
  const testKeyword = caseSensitive ? keyword : keyword.toLowerCase();
905
902
  const testName = caseSensitive ? node.name.value : node.name.value.toLowerCase();
906
903
  if (testName.startsWith(testKeyword)) {
904
+ const { start } = node.name.loc;
907
905
  context.report({
908
906
  loc: {
909
907
  start: {
910
- line: node.name.loc.start.line,
911
- column: node.name.loc.start.column - 1,
908
+ line: start.line,
909
+ column: start.column - 1,
912
910
  },
913
911
  end: {
914
- line: node.name.loc.start.line,
915
- column: node.name.loc.start.column + testKeyword.length - 1,
912
+ line: start.line,
913
+ column: start.column - 1 + testKeyword.length,
916
914
  },
917
915
  },
918
916
  data: {
@@ -1017,17 +1015,27 @@ const rule$4 = {
1017
1015
  return {
1018
1016
  'ObjectTypeDefinition, ObjectTypeExtension, InterfaceTypeDefinition, InterfaceTypeExtension'(node) {
1019
1017
  const typeName = node.name.value;
1020
- const lowerTypeName = (typeName || '').toLowerCase();
1018
+ const lowerTypeName = typeName.toLowerCase();
1021
1019
  for (const field of node.fields) {
1022
- const fieldName = field.name.value || '';
1023
- if (fieldName && lowerTypeName && fieldName.toLowerCase().startsWith(lowerTypeName)) {
1020
+ const fieldName = field.name.value;
1021
+ if (fieldName.toLowerCase().startsWith(lowerTypeName)) {
1022
+ const { start } = field.loc;
1024
1023
  context.report({
1025
- node: field.name,
1026
1024
  data: {
1027
1025
  fieldName,
1028
1026
  typeName,
1029
1027
  },
1030
1028
  messageId: AVOID_TYPENAME_PREFIX,
1029
+ loc: {
1030
+ start: {
1031
+ line: start.line,
1032
+ column: start.column - 1,
1033
+ },
1034
+ end: {
1035
+ line: start.line,
1036
+ column: start.column - 1 + lowerTypeName.length,
1037
+ },
1038
+ },
1031
1039
  });
1032
1040
  }
1033
1041
  }
@@ -1730,16 +1738,19 @@ const rule$9 = {
1730
1738
  create(context) {
1731
1739
  return {
1732
1740
  OperationDefinition(node) {
1733
- if (node && (!node.name || node.name.value === '')) {
1741
+ var _a;
1742
+ const isAnonymous = (((_a = node.name) === null || _a === void 0 ? void 0 : _a.value) || '').length === 0;
1743
+ if (isAnonymous) {
1744
+ const { start } = node.loc;
1734
1745
  context.report({
1735
1746
  loc: {
1736
1747
  start: {
1737
- column: node.loc.start.column - 1,
1738
- line: node.loc.start.line,
1748
+ column: start.column - 1,
1749
+ line: start.line,
1739
1750
  },
1740
1751
  end: {
1741
- column: node.loc.start.column + node.operation.length,
1742
- line: node.loc.start.line,
1752
+ column: start.column - 1 + node.operation.length,
1753
+ line: start.line,
1743
1754
  },
1744
1755
  },
1745
1756
  data: {
@@ -2037,11 +2048,23 @@ const rule$d = {
2037
2048
  create(context) {
2038
2049
  return {
2039
2050
  'OperationDefinition, FragmentDefinition'(node) {
2040
- if (node && node.name && node.name.value !== '') {
2041
- const invalidSuffix = (node.type === 'OperationDefinition' ? node.operation : 'fragment').toLowerCase();
2042
- if (node.name.value.toLowerCase().endsWith(invalidSuffix)) {
2051
+ var _a;
2052
+ const name = ((_a = node.name) === null || _a === void 0 ? void 0 : _a.value) || '';
2053
+ if (name.length > 0) {
2054
+ const invalidSuffix = 'operation' in node ? node.operation : 'fragment';
2055
+ if (name.toLowerCase().endsWith(invalidSuffix)) {
2056
+ const { start, end } = node.name.loc;
2043
2057
  context.report({
2044
- node: node.name,
2058
+ loc: {
2059
+ start: {
2060
+ column: start.column - 1 + name.length - invalidSuffix.length,
2061
+ line: start.line,
2062
+ },
2063
+ end: {
2064
+ column: end.column - 1 + name.length,
2065
+ line: end.line,
2066
+ },
2067
+ },
2045
2068
  data: {
2046
2069
  invalidSuffix,
2047
2070
  },
@@ -2493,15 +2516,18 @@ const DESCRIBABLE_NODES = [
2493
2516
  function verifyRule(context, node) {
2494
2517
  if (node) {
2495
2518
  if (!node.description || !node.description.value || node.description.value.trim().length === 0) {
2519
+ const { start, end } = ('name' in node ? node.name : node).loc;
2496
2520
  context.report({
2497
2521
  loc: {
2498
2522
  start: {
2499
- line: node.loc.start.line,
2500
- column: node.loc.start.column - 1,
2523
+ line: start.line,
2524
+ column: start.column - 1,
2501
2525
  },
2502
2526
  end: {
2503
- line: node.loc.end.line,
2504
- column: node.loc.end.column,
2527
+ line: end.line,
2528
+ column:
2529
+ // node.name don't exist on SchemaDefinition
2530
+ 'name' in node ? end.column - 1 + node.name.value.length : end.column,
2505
2531
  },
2506
2532
  },
2507
2533
  messageId: REQUIRE_DESCRIPTION_ERROR,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@graphql-eslint/eslint-plugin",
3
- "version": "2.4.0-alpha-a96ed5f.0",
3
+ "version": "2.4.0-alpha-a7d7d78.0",
4
4
  "sideEffects": false,
5
5
  "peerDependencies": {
6
6
  "graphql": "^0.8.0 || ^0.9.0 || ^0.10.0 || ^0.11.0 || ^0.12.0 || ^0.13.0 || ^14.0.0 || ^15.0.0"
package/types.d.ts CHANGED
@@ -62,3 +62,4 @@ export declare type GraphQLESLintRule<Options = any[], WithTypeInfo extends bool
62
62
  create(context: GraphQLESLintRuleContext<Options>): GraphQLESLintRuleListener<WithTypeInfo>;
63
63
  meta: Rule.RuleMetaData & RuleDocsInfo<Options>;
64
64
  };
65
+ export declare type ValueOf<T> = T[keyof T];
package/utils.d.ts CHANGED
@@ -31,6 +31,7 @@ export declare enum CaseStyle {
31
31
  upperCase = "UPPER_CASE",
32
32
  kebabCase = "kebab-case"
33
33
  }
34
+ export declare const pascalCase: (str: string) => string;
34
35
  export declare const camelCase: (str: string) => string;
35
36
  export declare const convertCase: (style: CaseStyle, str: string) => string;
36
37
  export {};