@graphql-eslint/eslint-plugin 3.0.1-alpha-8123ea2.0 → 3.1.0-alpha-27dcb49.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.
@@ -44,7 +44,6 @@ export declare const configs: {
44
44
  '@graphql-eslint/strict-id-in-types': string;
45
45
  '@graphql-eslint/unique-directive-names': string;
46
46
  '@graphql-eslint/unique-directive-names-per-location': string;
47
- '@graphql-eslint/unique-enum-value-names': string;
48
47
  '@graphql-eslint/unique-field-definition-names': string;
49
48
  '@graphql-eslint/unique-operation-types': string;
50
49
  '@graphql-eslint/unique-type-names': string;
@@ -59,10 +58,7 @@ export declare const configs: {
59
58
  arguments: string[];
60
59
  })[];
61
60
  '@graphql-eslint/input-name': string;
62
- '@graphql-eslint/no-root-type': string;
63
61
  '@graphql-eslint/no-scalar-result-type-on-mutation': string;
64
- '@graphql-eslint/no-unused-fields': string;
65
- '@graphql-eslint/possible-type-extension': string;
66
62
  '@graphql-eslint/require-deprecation-date': string;
67
63
  '@graphql-eslint/require-field-of-type-query-in-mutation-result': string;
68
64
  };
@@ -7,10 +7,7 @@ declare const _default: {
7
7
  arguments: string[];
8
8
  })[];
9
9
  '@graphql-eslint/input-name': string;
10
- '@graphql-eslint/no-root-type': string;
11
10
  '@graphql-eslint/no-scalar-result-type-on-mutation': string;
12
- '@graphql-eslint/no-unused-fields': string;
13
- '@graphql-eslint/possible-type-extension': string;
14
11
  '@graphql-eslint/require-deprecation-date': string;
15
12
  '@graphql-eslint/require-field-of-type-query-in-mutation-result': string;
16
13
  };
@@ -39,7 +39,6 @@ declare const _default: {
39
39
  '@graphql-eslint/strict-id-in-types': string;
40
40
  '@graphql-eslint/unique-directive-names': string;
41
41
  '@graphql-eslint/unique-directive-names-per-location': string;
42
- '@graphql-eslint/unique-enum-value-names': string;
43
42
  '@graphql-eslint/unique-field-definition-names': string;
44
43
  '@graphql-eslint/unique-operation-types': string;
45
44
  '@graphql-eslint/unique-type-names': string;
package/docs/README.md CHANGED
@@ -4,66 +4,66 @@ Each rule has emojis denoting:
4
4
 
5
5
  - 🚀 `graphql-eslint` rule
6
6
  - 🔮 `graphql-js` rule
7
- - 🔧 if some problems reported by the rule are automatically fixable by the `--fix` [command line](https://eslint.org/docs/user-guide/command-line-interface#fixing-problems) option
8
- - ✅ if it belongs to the `recommended` configuration
9
7
 
10
8
  <!-- 🚨 IMPORTANT! Do not manually modify this table. Run: `yarn generate:docs` -->
11
9
  <!-- prettier-ignore-start -->
12
- Name&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;|Description|🚀&nbsp;/&nbsp;🔮|🔧|✅
13
- -|-|:-:|-|-
14
- [alphabetize](rules/alphabetize.md)|Enforce arrange in alphabetical order for type fields, enum values, input object fields, operation selections and more.|🚀||
15
- [description-style](rules/description-style.md)|Require all comments to follow the same style (either block or inline).|🚀||✅
16
- [executable-definitions](rules/executable-definitions.md)|A GraphQL document is only valid for execution if all definitions are either operation or fragment definitions.|🔮||✅
17
- [fields-on-correct-type](rules/fields-on-correct-type.md)|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`.|🔮||✅
18
- [fragments-on-composite-type](rules/fragments-on-composite-type.md)|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.|🔮||✅
19
- [input-name](rules/input-name.md)|Require mutation argument to be always called "input" and input type to be called Mutation name + "Input".|🚀||
20
- [known-argument-names](rules/known-argument-names.md)|A GraphQL field is only valid if all supplied arguments are defined by that field.|🔮||✅
21
- [known-directives](rules/known-directives.md)|A GraphQL document is only valid if all `@directives` are known by the schema and legally positioned.|🔮||✅
22
- [known-fragment-names](rules/known-fragment-names.md)|A GraphQL document is only valid if all `...Fragment` fragment spreads refer to fragments defined in the same document.|🔮||✅
23
- [known-type-names](rules/known-type-names.md)|A GraphQL document is only valid if referenced types (specifically variable definitions and fragment conditions) are defined by the type schema.|🔮||✅
24
- [lone-anonymous-operation](rules/lone-anonymous-operation.md)|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.|🔮||✅
25
- [lone-schema-definition](rules/lone-schema-definition.md)|A GraphQL document is only valid if it contains only one schema definition.|🔮||✅
26
- [match-document-filename](rules/match-document-filename.md)|This rule allows you to enforce that the file name should match the operation name.|🚀||
27
- [naming-convention](rules/naming-convention.md)|Require names to follow specified conventions.|🚀||✅
28
- [no-anonymous-operations](rules/no-anonymous-operations.md)|Require name for your GraphQL operations. This is useful since most GraphQL client libraries are using the operation name for caching purposes.|🚀||✅
29
- [no-case-insensitive-enum-values-duplicates](rules/no-case-insensitive-enum-values-duplicates.md)|Disallow case-insensitive enum values duplicates.|🚀|🔧|✅
30
- [no-deprecated](rules/no-deprecated.md)|Enforce that deprecated fields or enum values are not in use by operations.|🚀||✅
31
- [no-duplicate-fields](rules/no-duplicate-fields.md)|Checks for duplicate fields in selection set, variables in operation definition, or in arguments set of a field.|🚀||✅
32
- [no-fragment-cycles](rules/no-fragment-cycles.md)|A GraphQL fragment is only valid when it does not have cycles in fragments usage.|🔮||✅
33
- [no-hashtag-description](rules/no-hashtag-description.md)|Requires to use `"""` or `"` for adding a GraphQL description instead of `#`.|🚀||✅
34
- [no-root-type](rules/no-root-type.md)|Disallow using root types `mutation` and/or `subscription`.|🚀||
35
- [no-scalar-result-type-on-mutation](rules/no-scalar-result-type-on-mutation.md)|Avoid scalar result type on mutation type to make sure to return a valid state.|🚀||
36
- [no-typename-prefix](rules/no-typename-prefix.md)|Enforces users to avoid using the type name in a field name while defining your schema.|🚀||✅
37
- [no-undefined-variables](rules/no-undefined-variables.md)|A GraphQL operation is only valid if all variables encountered, both directly and via fragment spreads, are defined by that operation.|🔮||✅
38
- [no-unreachable-types](rules/no-unreachable-types.md)|Requires all types to be reachable at some level by root level fields.|🚀|🔧|✅
39
- [no-unused-fields](rules/no-unused-fields.md)|Requires all fields to be used at some level by siblings operations.|🚀|🔧|
40
- [no-unused-fragments](rules/no-unused-fragments.md)|A GraphQL document is only valid if all fragment definitions are spread within operations, or spread within other fragments spread within operations.|🔮||✅
41
- [no-unused-variables](rules/no-unused-variables.md)|A GraphQL operation is only valid if all variables defined by an operation are used, either directly or within a spread fragment.|🔮||✅
42
- [one-field-subscriptions](rules/one-field-subscriptions.md)|A GraphQL subscription is valid only if it contains a single root field.|🔮||✅
43
- [overlapping-fields-can-be-merged](rules/overlapping-fields-can-be-merged.md)|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.|🔮||✅
44
- [possible-fragment-spread](rules/possible-fragment-spread.md)|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.|🔮||✅
45
- [possible-type-extension](rules/possible-type-extension.md)|A type extension is only valid if the type is defined and has the same kind.|🔮||
46
- [provided-required-arguments](rules/provided-required-arguments.md)|A field or directive is only valid if all required (non-null without a default value) field arguments have been provided.|🔮||✅
47
- [require-deprecation-date](rules/require-deprecation-date.md)|Require deletion date on `@deprecated` directive. Suggest removing deprecated things after deprecated date.|🚀||
48
- [require-deprecation-reason](rules/require-deprecation-reason.md)|Require all deprecation directives to specify a reason.|🚀||✅
49
- [require-description](rules/require-description.md)|Enforce descriptions in your type definitions.|🚀||✅
50
- [require-field-of-type-query-in-mutation-result](rules/require-field-of-type-query-in-mutation-result.md)|Allow the client in one round-trip not only to call mutation but also to get a wagon of data to update their application.|🚀||
51
- [require-id-when-available](rules/require-id-when-available.md)|Enforce selecting specific fields when they are available on the GraphQL type.|🚀||✅
52
- [scalar-leafs](rules/scalar-leafs.md)|A GraphQL document is valid only if all leaf fields (fields without sub selections) are of scalar or enum types.|🔮||✅
53
- [selection-set-depth](rules/selection-set-depth.md)|Limit the complexity of the GraphQL operations solely by their depth. Based on [graphql-depth-limit](https://github.com/stems/graphql-depth-limit).|🚀||✅
54
- [strict-id-in-types](rules/strict-id-in-types.md)|Requires output types to have one unique identifier unless they do not have a logical one. Exceptions can be used to ignore output types that do not have unique identifiers.|🚀||✅
55
- [unique-argument-names](rules/unique-argument-names.md)|A GraphQL field or directive is only valid if all supplied arguments are uniquely named.|🔮||✅
56
- [unique-directive-names](rules/unique-directive-names.md)|A GraphQL document is only valid if all defined directives have unique names.|🔮||✅
57
- [unique-directive-names-per-location](rules/unique-directive-names-per-location.md)|A GraphQL document is only valid if all non-repeatable directives at a given location are uniquely named.|🔮||✅
58
- [unique-enum-value-names](rules/unique-enum-value-names.md)|A GraphQL enum type is only valid if all its values are uniquely named.|🔮||✅
59
- [unique-field-definition-names](rules/unique-field-definition-names.md)|A GraphQL complex type is only valid if all its fields are uniquely named.|🔮||✅
60
- [unique-fragment-name](rules/unique-fragment-name.md)|Enforce unique fragment names across your project.|🚀||
61
- [unique-input-field-names](rules/unique-input-field-names.md)|A GraphQL input object value is only valid if all supplied fields are uniquely named.|🔮||✅
62
- [unique-operation-name](rules/unique-operation-name.md)|Enforce unique operation names across your project.|🚀||
63
- [unique-operation-types](rules/unique-operation-types.md)|A GraphQL document is only valid if it has only one type per operation.|🔮||✅
64
- [unique-type-names](rules/unique-type-names.md)|A GraphQL document is only valid if all defined types have unique names.|🔮||✅
65
- [unique-variable-names](rules/unique-variable-names.md)|A GraphQL operation is only valid if all its variables are uniquely named.|🔮||✅
66
- [value-literals-of-correct-type](rules/value-literals-of-correct-type.md)|A GraphQL document is only valid if all value literals are of the type expected at their position.|🔮||✅
67
- [variables-are-input-types](rules/variables-are-input-types.md)|A GraphQL operation is only valid if all the variables it defines are of input types (scalar, enum, or input object).|🔮||✅
68
- [variables-in-allowed-position](rules/variables-in-allowed-position.md)|Variables passed to field arguments conform to type.|🔮||✅
10
+ Name&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;|Description|&nbsp;&nbsp;&nbsp;&nbsp;Config&nbsp;&nbsp;&nbsp;&nbsp;|🚀&nbsp;/&nbsp;🔮
11
+ -|-|:-:|:-:
12
+ [alphabetize](rules/alphabetize.md)|Enforce arrange in alphabetical order for type fields, enum values, input object fields, operation selections and more.|![all][]|🚀
13
+ [description-style](rules/description-style.md)|Require all comments to follow the same style (either block or inline).|![recommended][]|🚀
14
+ [executable-definitions](rules/executable-definitions.md)|A GraphQL document is only valid for execution if all definitions are either operation or fragment definitions.|![recommended][]|🔮
15
+ [fields-on-correct-type](rules/fields-on-correct-type.md)|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`.|![recommended][]|🔮
16
+ [fragments-on-composite-type](rules/fragments-on-composite-type.md)|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.|![recommended][]|🔮
17
+ [input-name](rules/input-name.md)|Require mutation argument to be always called "input" and input type to be called Mutation name + "Input".|![all][]|🚀
18
+ [known-argument-names](rules/known-argument-names.md)|A GraphQL field is only valid if all supplied arguments are defined by that field.|![recommended][]|🔮
19
+ [known-directives](rules/known-directives.md)|A GraphQL document is only valid if all `@directives` are known by the schema and legally positioned.|![recommended][]|🔮
20
+ [known-fragment-names](rules/known-fragment-names.md)|A GraphQL document is only valid if all `...Fragment` fragment spreads refer to fragments defined in the same document.|![recommended][]|🔮
21
+ [known-type-names](rules/known-type-names.md)|A GraphQL document is only valid if referenced types (specifically variable definitions and fragment conditions) are defined by the type schema.|![recommended][]|🔮
22
+ [lone-anonymous-operation](rules/lone-anonymous-operation.md)|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.|![recommended][]|🔮
23
+ [lone-schema-definition](rules/lone-schema-definition.md)|A GraphQL document is only valid if it contains only one schema definition.|![recommended][]|🔮
24
+ [match-document-filename](rules/match-document-filename.md)|This rule allows you to enforce that the file name should match the operation name.|![all][]|🚀
25
+ [naming-convention](rules/naming-convention.md)|Require names to follow specified conventions.|![recommended][]|🚀
26
+ [no-anonymous-operations](rules/no-anonymous-operations.md)|Require name for your GraphQL operations. This is useful since most GraphQL client libraries are using the operation name for caching purposes.|![recommended][]|🚀
27
+ [no-case-insensitive-enum-values-duplicates](rules/no-case-insensitive-enum-values-duplicates.md)|Disallow case-insensitive enum values duplicates.|![recommended][]|🚀
28
+ [no-deprecated](rules/no-deprecated.md)|Enforce that deprecated fields or enum values are not in use by operations.|![recommended][]|🚀
29
+ [no-duplicate-fields](rules/no-duplicate-fields.md)|Checks for duplicate fields in selection set, variables in operation definition, or in arguments set of a field.|![recommended][]|🚀
30
+ [no-fragment-cycles](rules/no-fragment-cycles.md)|A GraphQL fragment is only valid when it does not have cycles in fragments usage.|![recommended][]|🔮
31
+ [no-hashtag-description](rules/no-hashtag-description.md)|Requires to use `"""` or `"` for adding a GraphQL description instead of `#`.|![recommended][]|🚀
32
+ [no-root-type](rules/no-root-type.md)|Disallow using root types `mutation` and/or `subscription`.||🚀
33
+ [no-scalar-result-type-on-mutation](rules/no-scalar-result-type-on-mutation.md)|Avoid scalar result type on mutation type to make sure to return a valid state.|![all][]|🚀
34
+ [no-typename-prefix](rules/no-typename-prefix.md)|Enforces users to avoid using the type name in a field name while defining your schema.|![recommended][]|🚀
35
+ [no-undefined-variables](rules/no-undefined-variables.md)|A GraphQL operation is only valid if all variables encountered, both directly and via fragment spreads, are defined by that operation.|![recommended][]|🔮
36
+ [no-unreachable-types](rules/no-unreachable-types.md)|Requires all types to be reachable at some level by root level fields.|![recommended][]|🚀
37
+ [no-unused-fields](rules/no-unused-fields.md)|Requires all fields to be used at some level by siblings operations.||🚀
38
+ [no-unused-fragments](rules/no-unused-fragments.md)|A GraphQL document is only valid if all fragment definitions are spread within operations, or spread within other fragments spread within operations.|![recommended][]|🔮
39
+ [no-unused-variables](rules/no-unused-variables.md)|A GraphQL operation is only valid if all variables defined by an operation are used, either directly or within a spread fragment.|![recommended][]|🔮
40
+ [one-field-subscriptions](rules/one-field-subscriptions.md)|A GraphQL subscription is valid only if it contains a single root field.|![recommended][]|🔮
41
+ [overlapping-fields-can-be-merged](rules/overlapping-fields-can-be-merged.md)|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.|![recommended][]|🔮
42
+ [possible-fragment-spread](rules/possible-fragment-spread.md)|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.|![recommended][]|🔮
43
+ [possible-type-extension](rules/possible-type-extension.md)|A type extension is only valid if the type is defined and has the same kind.||🔮
44
+ [provided-required-arguments](rules/provided-required-arguments.md)|A field or directive is only valid if all required (non-null without a default value) field arguments have been provided.|![recommended][]|🔮
45
+ [require-deprecation-date](rules/require-deprecation-date.md)|Require deletion date on `@deprecated` directive. Suggest removing deprecated things after deprecated date.|![all][]|🚀
46
+ [require-deprecation-reason](rules/require-deprecation-reason.md)|Require all deprecation directives to specify a reason.|![recommended][]|🚀
47
+ [require-description](rules/require-description.md)|Enforce descriptions in your type definitions.|![recommended][]|🚀
48
+ [require-field-of-type-query-in-mutation-result](rules/require-field-of-type-query-in-mutation-result.md)|Allow the client in one round-trip not only to call mutation but also to get a wagon of data to update their application.|![all][]|🚀
49
+ [require-id-when-available](rules/require-id-when-available.md)|Enforce selecting specific fields when they are available on the GraphQL type.|![recommended][]|🚀
50
+ [scalar-leafs](rules/scalar-leafs.md)|A GraphQL document is valid only if all leaf fields (fields without sub selections) are of scalar or enum types.|![recommended][]|🔮
51
+ [selection-set-depth](rules/selection-set-depth.md)|Limit the complexity of the GraphQL operations solely by their depth. Based on [graphql-depth-limit](https://github.com/stems/graphql-depth-limit).|![recommended][]|🚀
52
+ [strict-id-in-types](rules/strict-id-in-types.md)|Requires output types to have one unique identifier unless they do not have a logical one. Exceptions can be used to ignore output types that do not have unique identifiers.|![recommended][]|🚀
53
+ [unique-argument-names](rules/unique-argument-names.md)|A GraphQL field or directive is only valid if all supplied arguments are uniquely named.|![recommended][]|🔮
54
+ [unique-directive-names](rules/unique-directive-names.md)|A GraphQL document is only valid if all defined directives have unique names.|![recommended][]|🔮
55
+ [unique-directive-names-per-location](rules/unique-directive-names-per-location.md)|A GraphQL document is only valid if all non-repeatable directives at a given location are uniquely named.|![recommended][]|🔮
56
+ [unique-enum-value-names](rules/unique-enum-value-names.md)|A GraphQL enum type is only valid if all its values are uniquely named.||🔮
57
+ [unique-field-definition-names](rules/unique-field-definition-names.md)|A GraphQL complex type is only valid if all its fields are uniquely named.|![recommended][]|🔮
58
+ [unique-fragment-name](rules/unique-fragment-name.md)|Enforce unique fragment names across your project.|![all][]|🚀
59
+ [unique-input-field-names](rules/unique-input-field-names.md)|A GraphQL input object value is only valid if all supplied fields are uniquely named.|![recommended][]|🔮
60
+ [unique-operation-name](rules/unique-operation-name.md)|Enforce unique operation names across your project.|![all][]|🚀
61
+ [unique-operation-types](rules/unique-operation-types.md)|A GraphQL document is only valid if it has only one type per operation.|![recommended][]|🔮
62
+ [unique-type-names](rules/unique-type-names.md)|A GraphQL document is only valid if all defined types have unique names.|![recommended][]|🔮
63
+ [unique-variable-names](rules/unique-variable-names.md)|A GraphQL operation is only valid if all its variables are uniquely named.|![recommended][]|🔮
64
+ [value-literals-of-correct-type](rules/value-literals-of-correct-type.md)|A GraphQL document is only valid if all value literals are of the type expected at their position.|![recommended][]|🔮
65
+ [variables-are-input-types](rules/variables-are-input-types.md)|A GraphQL operation is only valid if all the variables it defines are of input types (scalar, enum, or input object).|![recommended][]|🔮
66
+ [variables-in-allowed-position](rules/variables-in-allowed-position.md)|Variables passed to field arguments conform to type.|![recommended][]|🔮
69
67
  <!-- prettier-ignore-end -->
68
+ [recommended]: https://img.shields.io/badge/-recommended-green.svg
69
+ [all]: https://img.shields.io/badge/-all-blue.svg
@@ -2,8 +2,6 @@
2
2
 
3
3
  ✅ The `"extends": "plugin:@graphql-eslint/schema-recommended"` property in a configuration file enables this rule.
4
4
 
5
- 🔧 The `--fix` option on the [command line](https://eslint.org/docs/user-guide/command-line-interface#--fix) can automatically fix some of the problems reported by this rule.
6
-
7
5
  - Category: `Schema`
8
6
  - Rule name: `@graphql-eslint/no-case-insensitive-enum-values-duplicates`
9
7
  - Requires GraphQL Schema: `false` [ℹ️](../../README.md#extended-linting-rules-with-graphql-schema)
@@ -40,3 +38,4 @@ enum MyEnum {
40
38
  ## Resources
41
39
 
42
40
  - [Rule source](../../packages/plugin/src/rules/no-case-insensitive-enum-values-duplicates.ts)
41
+ - [Test source](../../packages/plugin/tests/no-case-insensitive-enum-values-duplicates.spec.ts)
@@ -2,8 +2,6 @@
2
2
 
3
3
  ✅ The `"extends": "plugin:@graphql-eslint/schema-recommended"` property in a configuration file enables this rule.
4
4
 
5
- 🔧 The `--fix` option on the [command line](https://eslint.org/docs/user-guide/command-line-interface#--fix) can automatically fix some of the problems reported by this rule.
6
-
7
5
  - Category: `Schema`
8
6
  - Rule name: `@graphql-eslint/no-unreachable-types`
9
7
  - Requires GraphQL Schema: `true` [ℹ️](../../README.md#extended-linting-rules-with-graphql-schema)
@@ -1,7 +1,5 @@
1
1
  # `no-unused-fields`
2
2
 
3
- 🔧 The `--fix` option on the [command line](https://eslint.org/docs/user-guide/command-line-interface#--fix) can automatically fix some of the problems reported by this rule.
4
-
5
3
  - Category: `Schema`
6
4
  - Rule name: `@graphql-eslint/no-unused-fields`
7
5
  - Requires GraphQL Schema: `true` [ℹ️](../../README.md#extended-linting-rules-with-graphql-schema)
@@ -1,7 +1,5 @@
1
1
  # `unique-enum-value-names`
2
2
 
3
- ✅ The `"extends": "plugin:@graphql-eslint/schema-recommended"` property in a configuration file enables this rule.
4
-
5
3
  - Category: `Schema`
6
4
  - Rule name: `@graphql-eslint/unique-enum-value-names`
7
5
  - Requires GraphQL Schema: `false` [ℹ️](../../README.md#extended-linting-rules-with-graphql-schema)
package/index.js CHANGED
@@ -67,7 +67,6 @@ const schemaRecommendedConfig = {
67
67
  '@graphql-eslint/strict-id-in-types': 'error',
68
68
  '@graphql-eslint/unique-directive-names': 'error',
69
69
  '@graphql-eslint/unique-directive-names-per-location': 'error',
70
- '@graphql-eslint/unique-enum-value-names': 'error',
71
70
  '@graphql-eslint/unique-field-definition-names': 'error',
72
71
  '@graphql-eslint/unique-operation-types': 'error',
73
72
  '@graphql-eslint/unique-type-names': 'error',
@@ -89,10 +88,7 @@ const schemaAllConfig = {
89
88
  },
90
89
  ],
91
90
  '@graphql-eslint/input-name': 'error',
92
- '@graphql-eslint/no-root-type': 'off',
93
91
  '@graphql-eslint/no-scalar-result-type-on-mutation': 'error',
94
- '@graphql-eslint/no-unused-fields': 'off',
95
- '@graphql-eslint/possible-type-extension': 'off',
96
92
  '@graphql-eslint/require-deprecation-date': 'error',
97
93
  '@graphql-eslint/require-field-of-type-query-in-mutation-result': 'error',
98
94
  },
@@ -589,6 +585,7 @@ const GRAPHQL_JS_VALIDATIONS = Object.assign({}, validationToRule('executable-de
589
585
  category: 'Schema',
590
586
  description: `A GraphQL enum type is only valid if all its values are uniquely named.`,
591
587
  requiresSchema: false,
588
+ recommended: false,
592
589
  }), validationToRule('unique-field-definition-names', 'UniqueFieldDefinitionNames', {
593
590
  category: 'Schema',
594
591
  description: `A GraphQL complex type is only valid if all its fields are uniquely named.`,
@@ -1575,12 +1572,11 @@ const rule$5 = {
1575
1572
  },
1576
1573
  };
1577
1574
 
1578
- const ERROR_MESSAGE_ID = 'NO_CASE_INSENSITIVE_ENUM_VALUES_DUPLICATES';
1579
1575
  const rule$6 = {
1580
1576
  meta: {
1581
1577
  type: 'suggestion',
1582
1578
  docs: {
1583
- url: 'https://github.com/dotansimha/graphql-eslint/blob/master/docs/rules/no-case-insensitive-enum-values-duplicates.md',
1579
+ url: `https://github.com/dotansimha/graphql-eslint/blob/master/docs/rules/no-case-insensitive-enum-values-duplicates.md`,
1584
1580
  category: 'Schema',
1585
1581
  recommended: true,
1586
1582
  description: 'Disallow case-insensitive enum values duplicates.',
@@ -1607,23 +1603,18 @@ const rule$6 = {
1607
1603
  },
1608
1604
  ],
1609
1605
  },
1610
- fixable: 'code',
1611
- messages: {
1612
- [ERROR_MESSAGE_ID]: `Case-insensitive enum values duplicates are not allowed! Found: "{{ found }}"`,
1613
- },
1614
1606
  schema: [],
1615
1607
  },
1616
1608
  create(context) {
1609
+ const selector = [graphql.Kind.ENUM_TYPE_DEFINITION, graphql.Kind.ENUM_TYPE_EXTENSION].join(',');
1617
1610
  return {
1618
- EnumTypeDefinition(node) {
1619
- const foundDuplicates = node.values.filter((item, index) => node.values.findIndex(v => v.name.value.toLowerCase() === item.name.value.toLowerCase()) !== index);
1620
- for (const dup of foundDuplicates) {
1611
+ [selector](node) {
1612
+ const duplicates = node.values.filter((item, index, array) => array.findIndex(v => v.name.value.toLowerCase() === item.name.value.toLowerCase()) !== index);
1613
+ for (const duplicate of duplicates) {
1614
+ const enumName = duplicate.name.value;
1621
1615
  context.report({
1622
- node: dup.name,
1623
- data: {
1624
- found: dup.name.value,
1625
- },
1626
- messageId: ERROR_MESSAGE_ID,
1616
+ loc: getLocation(duplicate.loc, enumName),
1617
+ message: `Case-insensitive enum values duplicates are not allowed! Found: "${enumName}"`,
1627
1618
  });
1628
1619
  }
1629
1620
  },
@@ -2115,7 +2106,22 @@ const rule$c = {
2115
2106
  };
2116
2107
 
2117
2108
  const UNREACHABLE_TYPE = 'UNREACHABLE_TYPE';
2118
- const RULE_NAME = 'no-unreachable-types';
2109
+ const RULE_ID = 'no-unreachable-types';
2110
+ const KINDS = [
2111
+ graphql.Kind.DIRECTIVE_DEFINITION,
2112
+ graphql.Kind.OBJECT_TYPE_DEFINITION,
2113
+ graphql.Kind.OBJECT_TYPE_EXTENSION,
2114
+ graphql.Kind.INTERFACE_TYPE_DEFINITION,
2115
+ graphql.Kind.INTERFACE_TYPE_EXTENSION,
2116
+ graphql.Kind.SCALAR_TYPE_DEFINITION,
2117
+ graphql.Kind.SCALAR_TYPE_EXTENSION,
2118
+ graphql.Kind.INPUT_OBJECT_TYPE_DEFINITION,
2119
+ graphql.Kind.INPUT_OBJECT_TYPE_EXTENSION,
2120
+ graphql.Kind.UNION_TYPE_DEFINITION,
2121
+ graphql.Kind.UNION_TYPE_EXTENSION,
2122
+ graphql.Kind.ENUM_TYPE_DEFINITION,
2123
+ graphql.Kind.ENUM_TYPE_EXTENSION,
2124
+ ];
2119
2125
  const rule$d = {
2120
2126
  meta: {
2121
2127
  messages: {
@@ -2124,7 +2130,7 @@ const rule$d = {
2124
2130
  docs: {
2125
2131
  description: `Requires all types to be reachable at some level by root level fields.`,
2126
2132
  category: 'Schema',
2127
- url: `https://github.com/dotansimha/graphql-eslint/blob/master/docs/rules/${RULE_NAME}.md`,
2133
+ url: `https://github.com/dotansimha/graphql-eslint/blob/master/docs/rules/${RULE_ID}.md`,
2128
2134
  requiresSchema: true,
2129
2135
  examples: [
2130
2136
  {
@@ -2156,43 +2162,36 @@ const rule$d = {
2156
2162
  ],
2157
2163
  recommended: true,
2158
2164
  },
2159
- fixable: 'code',
2160
2165
  type: 'suggestion',
2161
2166
  schema: [],
2167
+ hasSuggestions: true,
2162
2168
  },
2163
2169
  create(context) {
2164
- const reachableTypes = requireReachableTypesFromContext(RULE_NAME, context);
2165
- function ensureReachability(node) {
2166
- const typeName = node.name.value;
2167
- if (!reachableTypes.has(typeName)) {
2168
- context.report({
2169
- loc: getLocation(node.name.loc, typeName, { offsetStart: node.kind === graphql.Kind.DIRECTIVE_DEFINITION ? 2 : 1 }),
2170
- messageId: UNREACHABLE_TYPE,
2171
- data: { typeName },
2172
- fix: fixer => fixer.remove(node),
2173
- });
2174
- }
2175
- }
2170
+ const reachableTypes = requireReachableTypesFromContext(RULE_ID, context);
2171
+ const selector = KINDS.join(',');
2176
2172
  return {
2177
- DirectiveDefinition: ensureReachability,
2178
- ObjectTypeDefinition: ensureReachability,
2179
- ObjectTypeExtension: ensureReachability,
2180
- InterfaceTypeDefinition: ensureReachability,
2181
- InterfaceTypeExtension: ensureReachability,
2182
- ScalarTypeDefinition: ensureReachability,
2183
- ScalarTypeExtension: ensureReachability,
2184
- InputObjectTypeDefinition: ensureReachability,
2185
- InputObjectTypeExtension: ensureReachability,
2186
- UnionTypeDefinition: ensureReachability,
2187
- UnionTypeExtension: ensureReachability,
2188
- EnumTypeDefinition: ensureReachability,
2189
- EnumTypeExtension: ensureReachability,
2173
+ [selector](node) {
2174
+ const typeName = node.name.value;
2175
+ if (!reachableTypes.has(typeName)) {
2176
+ context.report({
2177
+ loc: getLocation(node.name.loc, typeName, { offsetStart: node.kind === graphql.Kind.DIRECTIVE_DEFINITION ? 2 : 1 }),
2178
+ messageId: UNREACHABLE_TYPE,
2179
+ data: { typeName },
2180
+ suggest: [
2181
+ {
2182
+ desc: `Remove ${typeName}`,
2183
+ fix: fixer => fixer.remove(node),
2184
+ },
2185
+ ],
2186
+ });
2187
+ }
2188
+ },
2190
2189
  };
2191
2190
  },
2192
2191
  };
2193
2192
 
2194
2193
  const UNUSED_FIELD = 'UNUSED_FIELD';
2195
- const RULE_NAME$1 = 'no-unused-fields';
2194
+ const RULE_ID$1 = 'no-unused-fields';
2196
2195
  const rule$e = {
2197
2196
  meta: {
2198
2197
  messages: {
@@ -2201,7 +2200,7 @@ const rule$e = {
2201
2200
  docs: {
2202
2201
  description: `Requires all fields to be used at some level by siblings operations.`,
2203
2202
  category: 'Schema',
2204
- url: `https://github.com/dotansimha/graphql-eslint/blob/master/docs/rules/${RULE_NAME$1}.md`,
2203
+ url: `https://github.com/dotansimha/graphql-eslint/blob/master/docs/rules/${RULE_ID$1}.md`,
2205
2204
  requiresSiblings: true,
2206
2205
  requiresSchema: true,
2207
2206
  examples: [
@@ -2248,12 +2247,12 @@ const rule$e = {
2248
2247
  },
2249
2248
  ],
2250
2249
  },
2251
- fixable: 'code',
2252
2250
  type: 'suggestion',
2253
2251
  schema: [],
2252
+ hasSuggestions: true,
2254
2253
  },
2255
2254
  create(context) {
2256
- const usedFields = requireUsedFieldsFromContext(RULE_NAME$1, context);
2255
+ const usedFields = requireUsedFieldsFromContext(RULE_ID$1, context);
2257
2256
  return {
2258
2257
  FieldDefinition(node) {
2259
2258
  var _a;
@@ -2267,22 +2266,18 @@ const rule$e = {
2267
2266
  loc: getLocation(node.loc, fieldName),
2268
2267
  messageId: UNUSED_FIELD,
2269
2268
  data: { fieldName },
2270
- fix(fixer) {
2271
- const sourceCode = context.getSourceCode();
2272
- const tokenBefore = sourceCode.getTokenBefore(node);
2273
- const tokenAfter = sourceCode.getTokenAfter(node);
2274
- const isEmptyType = tokenBefore.type === '{' && tokenAfter.type === '}';
2275
- if (isEmptyType) {
2276
- // Remove type
2277
- const { parent } = node;
2278
- const parentBeforeToken = sourceCode.getTokenBefore(parent);
2279
- return parentBeforeToken
2280
- ? fixer.removeRange([parentBeforeToken.range[1], parent.range[1]])
2281
- : fixer.remove(parent);
2282
- }
2283
- // Remove whitespace before token
2284
- return fixer.removeRange([tokenBefore.range[1], node.range[1]]);
2285
- },
2269
+ suggest: [
2270
+ {
2271
+ desc: `Remove "${fieldName}" field`,
2272
+ fix(fixer) {
2273
+ const sourceCode = context.getSourceCode();
2274
+ const tokenBefore = sourceCode.getTokenBefore(node);
2275
+ const tokenAfter = sourceCode.getTokenAfter(node);
2276
+ const isEmptyType = tokenBefore.type === '{' && tokenAfter.type === '}';
2277
+ return isEmptyType ? fixer.remove(node.parent) : fixer.remove(node);
2278
+ },
2279
+ },
2280
+ ],
2286
2281
  });
2287
2282
  },
2288
2283
  };
@@ -2645,14 +2640,14 @@ const rule$h = {
2645
2640
  },
2646
2641
  };
2647
2642
 
2648
- const RULE_NAME$2 = 'require-field-of-type-query-in-mutation-result';
2643
+ const RULE_NAME = 'require-field-of-type-query-in-mutation-result';
2649
2644
  const rule$i = {
2650
2645
  meta: {
2651
2646
  type: 'suggestion',
2652
2647
  docs: {
2653
2648
  category: 'Schema',
2654
2649
  description: 'Allow the client in one round-trip not only to call mutation but also to get a wagon of data to update their application.\n> Currently, no errors are reported for result type `union`, `interface` and `scalar`.',
2655
- url: `https://github.com/dotansimha/graphql-eslint/blob/master/docs/rules/${RULE_NAME$2}.md`,
2650
+ url: `https://github.com/dotansimha/graphql-eslint/blob/master/docs/rules/${RULE_NAME}.md`,
2656
2651
  requiresSchema: true,
2657
2652
  examples: [
2658
2653
  {
@@ -2687,7 +2682,7 @@ const rule$i = {
2687
2682
  schema: [],
2688
2683
  },
2689
2684
  create(context) {
2690
- const schema = requireGraphQLSchemaFromContext(RULE_NAME$2, context);
2685
+ const schema = requireGraphQLSchemaFromContext(RULE_NAME, context);
2691
2686
  const mutationType = schema.getMutationType();
2692
2687
  const queryType = schema.getQueryType();
2693
2688
  if (!mutationType || !queryType) {
@@ -2695,13 +2690,11 @@ const rule$i = {
2695
2690
  }
2696
2691
  const selector = [
2697
2692
  `:matches(${graphql.Kind.OBJECT_TYPE_DEFINITION}, ${graphql.Kind.OBJECT_TYPE_EXTENSION})[name.value=${mutationType.name}]`,
2698
- '>',
2699
- graphql.Kind.FIELD_DEFINITION,
2700
- graphql.Kind.NAMED_TYPE,
2693
+ `> ${graphql.Kind.FIELD_DEFINITION} > .gqlType ${graphql.Kind.NAME}`,
2701
2694
  ].join(' ');
2702
2695
  return {
2703
2696
  [selector](node) {
2704
- const typeName = node.name.value;
2697
+ const typeName = node.value;
2705
2698
  const graphQLType = schema.getType(typeName);
2706
2699
  if (graphql.isObjectType(graphQLType)) {
2707
2700
  const { fields } = graphQLType.astNode;
@@ -2709,7 +2702,7 @@ const rule$i = {
2709
2702
  if (!hasQueryType) {
2710
2703
  context.report({
2711
2704
  loc: getLocation(node.loc, typeName),
2712
- message: `Mutation result type "${graphQLType.name}" must contain field of type "${queryType.name}".`,
2705
+ message: `Mutation result type "${graphQLType.name}" must contain field of type "${queryType.name}"`,
2713
2706
  });
2714
2707
  }
2715
2708
  }
@@ -3232,7 +3225,7 @@ const rule$l = {
3232
3225
  },
3233
3226
  };
3234
3227
 
3235
- const RULE_NAME$3 = 'unique-fragment-name';
3228
+ const RULE_NAME$1 = 'unique-fragment-name';
3236
3229
  const UNIQUE_FRAGMENT_NAME = 'UNIQUE_FRAGMENT_NAME';
3237
3230
  const checkNode = (context, node, ruleName, messageId) => {
3238
3231
  const documentName = node.name.value;
@@ -3264,7 +3257,7 @@ const rule$m = {
3264
3257
  docs: {
3265
3258
  category: 'Operations',
3266
3259
  description: `Enforce unique fragment names across your project.`,
3267
- url: `https://github.com/dotansimha/graphql-eslint/blob/master/docs/rules/${RULE_NAME$3}.md`,
3260
+ url: `https://github.com/dotansimha/graphql-eslint/blob/master/docs/rules/${RULE_NAME$1}.md`,
3268
3261
  requiresSiblings: true,
3269
3262
  examples: [
3270
3263
  {
@@ -3309,13 +3302,13 @@ const rule$m = {
3309
3302
  create(context) {
3310
3303
  return {
3311
3304
  FragmentDefinition(node) {
3312
- checkNode(context, node, RULE_NAME$3, UNIQUE_FRAGMENT_NAME);
3305
+ checkNode(context, node, RULE_NAME$1, UNIQUE_FRAGMENT_NAME);
3313
3306
  },
3314
3307
  };
3315
3308
  },
3316
3309
  };
3317
3310
 
3318
- const RULE_NAME$4 = 'unique-operation-name';
3311
+ const RULE_NAME$2 = 'unique-operation-name';
3319
3312
  const UNIQUE_OPERATION_NAME = 'UNIQUE_OPERATION_NAME';
3320
3313
  const rule$n = {
3321
3314
  meta: {
@@ -3323,7 +3316,7 @@ const rule$n = {
3323
3316
  docs: {
3324
3317
  category: 'Operations',
3325
3318
  description: `Enforce unique operation names across your project.`,
3326
- url: `https://github.com/dotansimha/graphql-eslint/blob/master/docs/rules/${RULE_NAME$4}.md`,
3319
+ url: `https://github.com/dotansimha/graphql-eslint/blob/master/docs/rules/${RULE_NAME$2}.md`,
3327
3320
  requiresSiblings: true,
3328
3321
  examples: [
3329
3322
  {
@@ -3372,7 +3365,7 @@ const rule$n = {
3372
3365
  create(context) {
3373
3366
  return {
3374
3367
  'OperationDefinition[name!=undefined]'(node) {
3375
- checkNode(context, node, RULE_NAME$4, UNIQUE_OPERATION_NAME);
3368
+ checkNode(context, node, RULE_NAME$2, UNIQUE_OPERATION_NAME);
3376
3369
  },
3377
3370
  };
3378
3371
  },
package/index.mjs CHANGED
@@ -61,7 +61,6 @@ const schemaRecommendedConfig = {
61
61
  '@graphql-eslint/strict-id-in-types': 'error',
62
62
  '@graphql-eslint/unique-directive-names': 'error',
63
63
  '@graphql-eslint/unique-directive-names-per-location': 'error',
64
- '@graphql-eslint/unique-enum-value-names': 'error',
65
64
  '@graphql-eslint/unique-field-definition-names': 'error',
66
65
  '@graphql-eslint/unique-operation-types': 'error',
67
66
  '@graphql-eslint/unique-type-names': 'error',
@@ -83,10 +82,7 @@ const schemaAllConfig = {
83
82
  },
84
83
  ],
85
84
  '@graphql-eslint/input-name': 'error',
86
- '@graphql-eslint/no-root-type': 'off',
87
85
  '@graphql-eslint/no-scalar-result-type-on-mutation': 'error',
88
- '@graphql-eslint/no-unused-fields': 'off',
89
- '@graphql-eslint/possible-type-extension': 'off',
90
86
  '@graphql-eslint/require-deprecation-date': 'error',
91
87
  '@graphql-eslint/require-field-of-type-query-in-mutation-result': 'error',
92
88
  },
@@ -583,6 +579,7 @@ const GRAPHQL_JS_VALIDATIONS = Object.assign({}, validationToRule('executable-de
583
579
  category: 'Schema',
584
580
  description: `A GraphQL enum type is only valid if all its values are uniquely named.`,
585
581
  requiresSchema: false,
582
+ recommended: false,
586
583
  }), validationToRule('unique-field-definition-names', 'UniqueFieldDefinitionNames', {
587
584
  category: 'Schema',
588
585
  description: `A GraphQL complex type is only valid if all its fields are uniquely named.`,
@@ -1569,12 +1566,11 @@ const rule$5 = {
1569
1566
  },
1570
1567
  };
1571
1568
 
1572
- const ERROR_MESSAGE_ID = 'NO_CASE_INSENSITIVE_ENUM_VALUES_DUPLICATES';
1573
1569
  const rule$6 = {
1574
1570
  meta: {
1575
1571
  type: 'suggestion',
1576
1572
  docs: {
1577
- url: 'https://github.com/dotansimha/graphql-eslint/blob/master/docs/rules/no-case-insensitive-enum-values-duplicates.md',
1573
+ url: `https://github.com/dotansimha/graphql-eslint/blob/master/docs/rules/no-case-insensitive-enum-values-duplicates.md`,
1578
1574
  category: 'Schema',
1579
1575
  recommended: true,
1580
1576
  description: 'Disallow case-insensitive enum values duplicates.',
@@ -1601,23 +1597,18 @@ const rule$6 = {
1601
1597
  },
1602
1598
  ],
1603
1599
  },
1604
- fixable: 'code',
1605
- messages: {
1606
- [ERROR_MESSAGE_ID]: `Case-insensitive enum values duplicates are not allowed! Found: "{{ found }}"`,
1607
- },
1608
1600
  schema: [],
1609
1601
  },
1610
1602
  create(context) {
1603
+ const selector = [Kind.ENUM_TYPE_DEFINITION, Kind.ENUM_TYPE_EXTENSION].join(',');
1611
1604
  return {
1612
- EnumTypeDefinition(node) {
1613
- const foundDuplicates = node.values.filter((item, index) => node.values.findIndex(v => v.name.value.toLowerCase() === item.name.value.toLowerCase()) !== index);
1614
- for (const dup of foundDuplicates) {
1605
+ [selector](node) {
1606
+ const duplicates = node.values.filter((item, index, array) => array.findIndex(v => v.name.value.toLowerCase() === item.name.value.toLowerCase()) !== index);
1607
+ for (const duplicate of duplicates) {
1608
+ const enumName = duplicate.name.value;
1615
1609
  context.report({
1616
- node: dup.name,
1617
- data: {
1618
- found: dup.name.value,
1619
- },
1620
- messageId: ERROR_MESSAGE_ID,
1610
+ loc: getLocation(duplicate.loc, enumName),
1611
+ message: `Case-insensitive enum values duplicates are not allowed! Found: "${enumName}"`,
1621
1612
  });
1622
1613
  }
1623
1614
  },
@@ -2109,7 +2100,22 @@ const rule$c = {
2109
2100
  };
2110
2101
 
2111
2102
  const UNREACHABLE_TYPE = 'UNREACHABLE_TYPE';
2112
- const RULE_NAME = 'no-unreachable-types';
2103
+ const RULE_ID = 'no-unreachable-types';
2104
+ const KINDS = [
2105
+ Kind.DIRECTIVE_DEFINITION,
2106
+ Kind.OBJECT_TYPE_DEFINITION,
2107
+ Kind.OBJECT_TYPE_EXTENSION,
2108
+ Kind.INTERFACE_TYPE_DEFINITION,
2109
+ Kind.INTERFACE_TYPE_EXTENSION,
2110
+ Kind.SCALAR_TYPE_DEFINITION,
2111
+ Kind.SCALAR_TYPE_EXTENSION,
2112
+ Kind.INPUT_OBJECT_TYPE_DEFINITION,
2113
+ Kind.INPUT_OBJECT_TYPE_EXTENSION,
2114
+ Kind.UNION_TYPE_DEFINITION,
2115
+ Kind.UNION_TYPE_EXTENSION,
2116
+ Kind.ENUM_TYPE_DEFINITION,
2117
+ Kind.ENUM_TYPE_EXTENSION,
2118
+ ];
2113
2119
  const rule$d = {
2114
2120
  meta: {
2115
2121
  messages: {
@@ -2118,7 +2124,7 @@ const rule$d = {
2118
2124
  docs: {
2119
2125
  description: `Requires all types to be reachable at some level by root level fields.`,
2120
2126
  category: 'Schema',
2121
- url: `https://github.com/dotansimha/graphql-eslint/blob/master/docs/rules/${RULE_NAME}.md`,
2127
+ url: `https://github.com/dotansimha/graphql-eslint/blob/master/docs/rules/${RULE_ID}.md`,
2122
2128
  requiresSchema: true,
2123
2129
  examples: [
2124
2130
  {
@@ -2150,43 +2156,36 @@ const rule$d = {
2150
2156
  ],
2151
2157
  recommended: true,
2152
2158
  },
2153
- fixable: 'code',
2154
2159
  type: 'suggestion',
2155
2160
  schema: [],
2161
+ hasSuggestions: true,
2156
2162
  },
2157
2163
  create(context) {
2158
- const reachableTypes = requireReachableTypesFromContext(RULE_NAME, context);
2159
- function ensureReachability(node) {
2160
- const typeName = node.name.value;
2161
- if (!reachableTypes.has(typeName)) {
2162
- context.report({
2163
- loc: getLocation(node.name.loc, typeName, { offsetStart: node.kind === Kind.DIRECTIVE_DEFINITION ? 2 : 1 }),
2164
- messageId: UNREACHABLE_TYPE,
2165
- data: { typeName },
2166
- fix: fixer => fixer.remove(node),
2167
- });
2168
- }
2169
- }
2164
+ const reachableTypes = requireReachableTypesFromContext(RULE_ID, context);
2165
+ const selector = KINDS.join(',');
2170
2166
  return {
2171
- DirectiveDefinition: ensureReachability,
2172
- ObjectTypeDefinition: ensureReachability,
2173
- ObjectTypeExtension: ensureReachability,
2174
- InterfaceTypeDefinition: ensureReachability,
2175
- InterfaceTypeExtension: ensureReachability,
2176
- ScalarTypeDefinition: ensureReachability,
2177
- ScalarTypeExtension: ensureReachability,
2178
- InputObjectTypeDefinition: ensureReachability,
2179
- InputObjectTypeExtension: ensureReachability,
2180
- UnionTypeDefinition: ensureReachability,
2181
- UnionTypeExtension: ensureReachability,
2182
- EnumTypeDefinition: ensureReachability,
2183
- EnumTypeExtension: ensureReachability,
2167
+ [selector](node) {
2168
+ const typeName = node.name.value;
2169
+ if (!reachableTypes.has(typeName)) {
2170
+ context.report({
2171
+ loc: getLocation(node.name.loc, typeName, { offsetStart: node.kind === Kind.DIRECTIVE_DEFINITION ? 2 : 1 }),
2172
+ messageId: UNREACHABLE_TYPE,
2173
+ data: { typeName },
2174
+ suggest: [
2175
+ {
2176
+ desc: `Remove ${typeName}`,
2177
+ fix: fixer => fixer.remove(node),
2178
+ },
2179
+ ],
2180
+ });
2181
+ }
2182
+ },
2184
2183
  };
2185
2184
  },
2186
2185
  };
2187
2186
 
2188
2187
  const UNUSED_FIELD = 'UNUSED_FIELD';
2189
- const RULE_NAME$1 = 'no-unused-fields';
2188
+ const RULE_ID$1 = 'no-unused-fields';
2190
2189
  const rule$e = {
2191
2190
  meta: {
2192
2191
  messages: {
@@ -2195,7 +2194,7 @@ const rule$e = {
2195
2194
  docs: {
2196
2195
  description: `Requires all fields to be used at some level by siblings operations.`,
2197
2196
  category: 'Schema',
2198
- url: `https://github.com/dotansimha/graphql-eslint/blob/master/docs/rules/${RULE_NAME$1}.md`,
2197
+ url: `https://github.com/dotansimha/graphql-eslint/blob/master/docs/rules/${RULE_ID$1}.md`,
2199
2198
  requiresSiblings: true,
2200
2199
  requiresSchema: true,
2201
2200
  examples: [
@@ -2242,12 +2241,12 @@ const rule$e = {
2242
2241
  },
2243
2242
  ],
2244
2243
  },
2245
- fixable: 'code',
2246
2244
  type: 'suggestion',
2247
2245
  schema: [],
2246
+ hasSuggestions: true,
2248
2247
  },
2249
2248
  create(context) {
2250
- const usedFields = requireUsedFieldsFromContext(RULE_NAME$1, context);
2249
+ const usedFields = requireUsedFieldsFromContext(RULE_ID$1, context);
2251
2250
  return {
2252
2251
  FieldDefinition(node) {
2253
2252
  var _a;
@@ -2261,22 +2260,18 @@ const rule$e = {
2261
2260
  loc: getLocation(node.loc, fieldName),
2262
2261
  messageId: UNUSED_FIELD,
2263
2262
  data: { fieldName },
2264
- fix(fixer) {
2265
- const sourceCode = context.getSourceCode();
2266
- const tokenBefore = sourceCode.getTokenBefore(node);
2267
- const tokenAfter = sourceCode.getTokenAfter(node);
2268
- const isEmptyType = tokenBefore.type === '{' && tokenAfter.type === '}';
2269
- if (isEmptyType) {
2270
- // Remove type
2271
- const { parent } = node;
2272
- const parentBeforeToken = sourceCode.getTokenBefore(parent);
2273
- return parentBeforeToken
2274
- ? fixer.removeRange([parentBeforeToken.range[1], parent.range[1]])
2275
- : fixer.remove(parent);
2276
- }
2277
- // Remove whitespace before token
2278
- return fixer.removeRange([tokenBefore.range[1], node.range[1]]);
2279
- },
2263
+ suggest: [
2264
+ {
2265
+ desc: `Remove "${fieldName}" field`,
2266
+ fix(fixer) {
2267
+ const sourceCode = context.getSourceCode();
2268
+ const tokenBefore = sourceCode.getTokenBefore(node);
2269
+ const tokenAfter = sourceCode.getTokenAfter(node);
2270
+ const isEmptyType = tokenBefore.type === '{' && tokenAfter.type === '}';
2271
+ return isEmptyType ? fixer.remove(node.parent) : fixer.remove(node);
2272
+ },
2273
+ },
2274
+ ],
2280
2275
  });
2281
2276
  },
2282
2277
  };
@@ -2639,14 +2634,14 @@ const rule$h = {
2639
2634
  },
2640
2635
  };
2641
2636
 
2642
- const RULE_NAME$2 = 'require-field-of-type-query-in-mutation-result';
2637
+ const RULE_NAME = 'require-field-of-type-query-in-mutation-result';
2643
2638
  const rule$i = {
2644
2639
  meta: {
2645
2640
  type: 'suggestion',
2646
2641
  docs: {
2647
2642
  category: 'Schema',
2648
2643
  description: 'Allow the client in one round-trip not only to call mutation but also to get a wagon of data to update their application.\n> Currently, no errors are reported for result type `union`, `interface` and `scalar`.',
2649
- url: `https://github.com/dotansimha/graphql-eslint/blob/master/docs/rules/${RULE_NAME$2}.md`,
2644
+ url: `https://github.com/dotansimha/graphql-eslint/blob/master/docs/rules/${RULE_NAME}.md`,
2650
2645
  requiresSchema: true,
2651
2646
  examples: [
2652
2647
  {
@@ -2681,7 +2676,7 @@ const rule$i = {
2681
2676
  schema: [],
2682
2677
  },
2683
2678
  create(context) {
2684
- const schema = requireGraphQLSchemaFromContext(RULE_NAME$2, context);
2679
+ const schema = requireGraphQLSchemaFromContext(RULE_NAME, context);
2685
2680
  const mutationType = schema.getMutationType();
2686
2681
  const queryType = schema.getQueryType();
2687
2682
  if (!mutationType || !queryType) {
@@ -2689,13 +2684,11 @@ const rule$i = {
2689
2684
  }
2690
2685
  const selector = [
2691
2686
  `:matches(${Kind.OBJECT_TYPE_DEFINITION}, ${Kind.OBJECT_TYPE_EXTENSION})[name.value=${mutationType.name}]`,
2692
- '>',
2693
- Kind.FIELD_DEFINITION,
2694
- Kind.NAMED_TYPE,
2687
+ `> ${Kind.FIELD_DEFINITION} > .gqlType ${Kind.NAME}`,
2695
2688
  ].join(' ');
2696
2689
  return {
2697
2690
  [selector](node) {
2698
- const typeName = node.name.value;
2691
+ const typeName = node.value;
2699
2692
  const graphQLType = schema.getType(typeName);
2700
2693
  if (isObjectType$1(graphQLType)) {
2701
2694
  const { fields } = graphQLType.astNode;
@@ -2703,7 +2696,7 @@ const rule$i = {
2703
2696
  if (!hasQueryType) {
2704
2697
  context.report({
2705
2698
  loc: getLocation(node.loc, typeName),
2706
- message: `Mutation result type "${graphQLType.name}" must contain field of type "${queryType.name}".`,
2699
+ message: `Mutation result type "${graphQLType.name}" must contain field of type "${queryType.name}"`,
2707
2700
  });
2708
2701
  }
2709
2702
  }
@@ -3226,7 +3219,7 @@ const rule$l = {
3226
3219
  },
3227
3220
  };
3228
3221
 
3229
- const RULE_NAME$3 = 'unique-fragment-name';
3222
+ const RULE_NAME$1 = 'unique-fragment-name';
3230
3223
  const UNIQUE_FRAGMENT_NAME = 'UNIQUE_FRAGMENT_NAME';
3231
3224
  const checkNode = (context, node, ruleName, messageId) => {
3232
3225
  const documentName = node.name.value;
@@ -3258,7 +3251,7 @@ const rule$m = {
3258
3251
  docs: {
3259
3252
  category: 'Operations',
3260
3253
  description: `Enforce unique fragment names across your project.`,
3261
- url: `https://github.com/dotansimha/graphql-eslint/blob/master/docs/rules/${RULE_NAME$3}.md`,
3254
+ url: `https://github.com/dotansimha/graphql-eslint/blob/master/docs/rules/${RULE_NAME$1}.md`,
3262
3255
  requiresSiblings: true,
3263
3256
  examples: [
3264
3257
  {
@@ -3303,13 +3296,13 @@ const rule$m = {
3303
3296
  create(context) {
3304
3297
  return {
3305
3298
  FragmentDefinition(node) {
3306
- checkNode(context, node, RULE_NAME$3, UNIQUE_FRAGMENT_NAME);
3299
+ checkNode(context, node, RULE_NAME$1, UNIQUE_FRAGMENT_NAME);
3307
3300
  },
3308
3301
  };
3309
3302
  },
3310
3303
  };
3311
3304
 
3312
- const RULE_NAME$4 = 'unique-operation-name';
3305
+ const RULE_NAME$2 = 'unique-operation-name';
3313
3306
  const UNIQUE_OPERATION_NAME = 'UNIQUE_OPERATION_NAME';
3314
3307
  const rule$n = {
3315
3308
  meta: {
@@ -3317,7 +3310,7 @@ const rule$n = {
3317
3310
  docs: {
3318
3311
  category: 'Operations',
3319
3312
  description: `Enforce unique operation names across your project.`,
3320
- url: `https://github.com/dotansimha/graphql-eslint/blob/master/docs/rules/${RULE_NAME$4}.md`,
3313
+ url: `https://github.com/dotansimha/graphql-eslint/blob/master/docs/rules/${RULE_NAME$2}.md`,
3321
3314
  requiresSiblings: true,
3322
3315
  examples: [
3323
3316
  {
@@ -3366,7 +3359,7 @@ const rule$n = {
3366
3359
  create(context) {
3367
3360
  return {
3368
3361
  'OperationDefinition[name!=undefined]'(node) {
3369
- checkNode(context, node, RULE_NAME$4, UNIQUE_OPERATION_NAME);
3362
+ checkNode(context, node, RULE_NAME$2, UNIQUE_OPERATION_NAME);
3370
3363
  },
3371
3364
  };
3372
3365
  },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@graphql-eslint/eslint-plugin",
3
- "version": "3.0.1-alpha-8123ea2.0",
3
+ "version": "3.1.0-alpha-27dcb49.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 || ^16.0.0"
@@ -8,7 +8,7 @@
8
8
  "dependencies": {
9
9
  "@babel/code-frame": "7.16.0",
10
10
  "@graphql-tools/code-file-loader": "7.2.2",
11
- "@graphql-tools/graphql-tag-pluck": "7.1.3",
11
+ "@graphql-tools/graphql-tag-pluck": "7.1.4",
12
12
  "@graphql-tools/import": "6.6.1",
13
13
  "@graphql-tools/utils": "8.5.3",
14
14
  "graphql-config": "4.1.0",