@graphql-eslint/eslint-plugin 3.7.0 → 3.7.1-alpha-d9a3c78.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/docs/README.md CHANGED
@@ -44,7 +44,7 @@ Name            &nbs
44
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
45
  [require-deprecation-date](rules/require-deprecation-date.md)|Require deletion date on `@deprecated` directive. Suggest removing deprecated things after deprecated date.|![all][]|🚀
46
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][]|🚀
47
+ [require-description](rules/require-description.md)|Enforce descriptions in type definitions and operations.|![recommended][]|🚀
48
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
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
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][]|🔮
package/docs/parser.md CHANGED
@@ -36,7 +36,7 @@ Here's a list of changes that the parser performs, in order to make the GraphQL
36
36
 
37
37
  **Problem**: GraphQL uses `location` field to store the AST locations, while ESTree also uses it in a different structure.
38
38
 
39
- **Solution**: The parser creates a new `location` field that is compatible with ESTree, and renames the GraphQL `location` to `gqlLocation`.
39
+ **Solution**: The parser creates a new `location` field that is compatible with ESTree.
40
40
 
41
41
  ### Loading GraphQL Schema
42
42
 
@@ -1,5 +1,7 @@
1
1
  # `alphabetize`
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
+
3
5
  - Category: `Schema & Operations`
4
6
  - Rule name: `@graphql-eslint/alphabetize`
5
7
  - Requires GraphQL Schema: `false` [â„šī¸](../../README.md#extended-linting-rules-with-graphql-schema)
@@ -131,7 +131,7 @@ The schema defines the following additional types:
131
131
 
132
132
  ## `asString` (enum)
133
133
 
134
- One of: `camelCase`, `PascalCase`, `snake_case`, `UPPER_CASE`, `kebab-case`
134
+ One of: `camelCase`, `PascalCase`, `snake_case`, `UPPER_CASE`, `kebab-case`, `matchDocumentStyle`
135
135
 
136
136
  ## `asObject` (object)
137
137
 
@@ -146,6 +146,7 @@ This element must be one of the following enum values:
146
146
  - `snake_case`
147
147
  - `UPPER_CASE`
148
148
  - `kebab-case`
149
+ - `matchDocumentStyle`
149
150
 
150
151
  ### `suffix` (string)
151
152
 
@@ -7,7 +7,7 @@
7
7
  - Requires GraphQL Schema: `false` [â„šī¸](../../README.md#extended-linting-rules-with-graphql-schema)
8
8
  - Requires GraphQL Operations: `false` [â„šī¸](../../README.md#extended-linting-rules-with-siblings-operations)
9
9
 
10
- Enforce descriptions in your type definitions.
10
+ Enforce descriptions in type definitions and operations.
11
11
 
12
12
  ## Usage Examples
13
13
 
@@ -37,6 +37,17 @@ type someTypeName {
37
37
  }
38
38
  ```
39
39
 
40
+ ### Correct
41
+
42
+ ```graphql
43
+ # eslint @graphql-eslint/require-description: ['error', { OperationDefinition: true }]
44
+
45
+ # Create a new user
46
+ mutation createUser {
47
+ # ...
48
+ }
49
+ ```
50
+
40
51
  ## Config Schema
41
52
 
42
53
  The schema defines the following properties:
@@ -84,6 +95,12 @@ Read more about this kind on [spec.graphql.org](https://spec.graphql.org/October
84
95
 
85
96
  Read more about this kind on [spec.graphql.org](https://spec.graphql.org/October2021/#ObjectTypeDefinition).
86
97
 
98
+ ### `OperationDefinition` (boolean)
99
+
100
+ Read more about this kind on [spec.graphql.org](https://spec.graphql.org/October2021/#OperationDefinition).
101
+
102
+ > You must use only comment syntax `#` and not description syntax `"""` or `"`.
103
+
87
104
  ### `ScalarTypeDefinition` (boolean)
88
105
 
89
106
  Read more about this kind on [spec.graphql.org](https://spec.graphql.org/October2021/#ScalarTypeDefinition).
@@ -1,4 +1,4 @@
1
- import { ASTNode, Location, TypeInfo, TypeNode, ValueNode } from 'graphql';
1
+ import { ASTNode, TypeInfo, TypeNode, ValueNode } from 'graphql';
2
2
  import { BaseNode } from 'estree';
3
3
  export declare type SafeGraphQLType<T extends ASTNode | ValueNode> = Omit<T extends {
4
4
  readonly type: TypeNode;
@@ -7,7 +7,6 @@ export declare type SafeGraphQLType<T extends ASTNode | ValueNode> = Omit<T exte
7
7
  } : T, 'loc'>;
8
8
  export declare type SingleESTreeNode<T, WithTypeInfo extends boolean> = T extends ASTNode | ValueNode ? SafeGraphQLType<T> & Pick<BaseNode, 'leadingComments' | 'loc' | 'range'> & {
9
9
  type: T['kind'];
10
- gqlLocation: Location;
11
10
  } & (WithTypeInfo extends true ? {
12
11
  typeInfo?: () => {
13
12
  argument?: ReturnType<TypeInfo['getArgument']>;
@@ -1,13 +1,18 @@
1
- import { Location, ValueNode, StringValueNode, ASTNode, GraphQLOutputType, GraphQLNamedType } from 'graphql';
2
- import { SourceLocation, Comment } from 'estree';
3
- import { GraphQLESTreeNode } from './estree-ast';
1
+ import { Location, ValueNode, StringValueNode, ASTNode, GraphQLOutputType, GraphQLNamedType, Token, Source } from 'graphql';
2
+ import type { Comment } from 'estree';
3
+ import type { AST } from 'eslint';
4
+ import type { GraphQLESTreeNode } from './estree-ast';
4
5
  export default function keyValMap<T, V>(list: ReadonlyArray<T>, keyFn: (item: T) => string, valFn: (item: T) => V): Record<string, V>;
5
6
  export declare function valueFromNode(valueNode: GraphQLESTreeNode<ValueNode>, variables?: Record<string, any>): any;
6
7
  export declare function getBaseType(type: GraphQLOutputType): GraphQLNamedType;
7
- export declare function convertRange(gqlLocation: Location): [number, number];
8
+ declare type TokenKindValue = '<SOF>' | '!' | '$' | '&' | '(' | ')' | '...' | ':' | '=' | '@' | '[' | ']' | '{' | '|' | '}' | 'Name' | 'Int' | 'Float' | 'String' | 'BlockString' | 'Comment';
9
+ export declare function convertToken<T extends 'Line' | 'Block' | TokenKindValue>(token: Token, type: T): Omit<AST.Token, 'type'> & {
10
+ type: T;
11
+ };
12
+ export declare function extractTokens(source: Source): AST.Token[];
8
13
  export declare function extractCommentsFromAst(loc: Location): Comment[];
9
- export declare function convertLocation(gqlLocation: Location): SourceLocation;
10
14
  export declare function isNodeWithDescription<T extends ASTNode>(obj: T): obj is T & {
11
15
  readonly description?: StringValueNode;
12
16
  };
13
17
  export declare function convertDescription<T extends ASTNode>(node: T): Comment[];
18
+ export {};