@graphql-eslint/eslint-plugin 2.5.0-alpha-14532ce.0 → 3.0.0-alpha-069461d.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@graphql-eslint/eslint-plugin",
3
- "version": "2.5.0-alpha-14532ce.0",
3
+ "version": "3.0.0-alpha-069461d.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"
@@ -1,10 +1,9 @@
1
- import { Kind } from 'graphql';
2
1
  import { GraphQLESLintRule } from '../types';
3
- declare const fieldsEnum: Kind[];
4
- declare const valuesEnum: Kind[];
5
- declare const selectionsEnum: Kind[];
6
- declare const variablesEnum: Kind[];
7
- declare const argumentsEnum: Kind[];
2
+ declare const fieldsEnum: ('ObjectTypeDefinition' | 'InterfaceTypeDefinition' | 'InputObjectTypeDefinition')[];
3
+ declare const valuesEnum: ['EnumTypeDefinition'];
4
+ declare const selectionsEnum: ('OperationDefinition' | 'FragmentDefinition')[];
5
+ declare const variablesEnum: ['OperationDefinition'];
6
+ declare const argumentsEnum: ('FieldDefinition' | 'Field' | 'DirectiveDefinition' | 'Directive')[];
8
7
  declare type AlphabetizeConfig = [
9
8
  {
10
9
  fields?: typeof fieldsEnum;
package/rules/index.d.ts CHANGED
@@ -1,10 +1,10 @@
1
1
  export declare const rules: {
2
2
  alphabetize: import("..").GraphQLESLintRule<[{
3
- fields?: import("graphql").Kind[];
4
- values?: import("graphql").Kind[];
5
- selections?: import("graphql").Kind[];
6
- variables?: import("graphql").Kind[];
7
- arguments?: import("graphql").Kind[];
3
+ fields?: ("ObjectTypeDefinition" | "InterfaceTypeDefinition" | "InputObjectTypeDefinition")[];
4
+ values?: ["EnumTypeDefinition"];
5
+ selections?: ("OperationDefinition" | "FragmentDefinition")[];
6
+ variables?: ["OperationDefinition"];
7
+ arguments?: ("Field" | "Directive" | "FieldDefinition" | "DirectiveDefinition")[];
8
8
  }], false>;
9
9
  'avoid-duplicate-fields': import("..").GraphQLESLintRule<any[], false>;
10
10
  'avoid-operation-name-prefix': import("..").GraphQLESLintRule<import("./avoid-operation-name-prefix").AvoidOperationNamePrefixConfig, false>;
@@ -39,26 +39,131 @@ export declare const rules: {
39
39
  };
40
40
  }], false>;
41
41
  'naming-convention': import("..").GraphQLESLintRule<[{
42
- leadingUnderscore?: "allow" | "forbid";
43
- trailingUnderscore?: "allow" | "forbid";
44
- QueryDefinition?: "camelCase" | "PascalCase" | "snake_case" | "UPPER_CASE" | import("./naming-convention").PropertySchema;
45
- FieldDefinition?: "camelCase" | "PascalCase" | "snake_case" | "UPPER_CASE" | import("./naming-convention").PropertySchema;
46
- EnumValueDefinition?: "camelCase" | "PascalCase" | "snake_case" | "UPPER_CASE" | import("./naming-convention").PropertySchema;
47
- InputValueDefinition?: "camelCase" | "PascalCase" | "snake_case" | "UPPER_CASE" | import("./naming-convention").PropertySchema;
48
- ObjectTypeDefinition?: "camelCase" | "PascalCase" | "snake_case" | "UPPER_CASE" | import("./naming-convention").PropertySchema;
49
- InterfaceTypeDefinition?: "camelCase" | "PascalCase" | "snake_case" | "UPPER_CASE" | import("./naming-convention").PropertySchema;
50
- EnumTypeDefinition?: "camelCase" | "PascalCase" | "snake_case" | "UPPER_CASE" | import("./naming-convention").PropertySchema;
51
- UnionTypeDefinition?: "camelCase" | "PascalCase" | "snake_case" | "UPPER_CASE" | import("./naming-convention").PropertySchema;
52
- ScalarTypeDefinition?: "camelCase" | "PascalCase" | "snake_case" | "UPPER_CASE" | import("./naming-convention").PropertySchema;
53
- OperationDefinition?: "camelCase" | "PascalCase" | "snake_case" | "UPPER_CASE" | import("./naming-convention").PropertySchema;
54
- FragmentDefinition?: "camelCase" | "PascalCase" | "snake_case" | "UPPER_CASE" | import("./naming-convention").PropertySchema;
55
- InputObjectTypeDefinition?: "camelCase" | "PascalCase" | "snake_case" | "UPPER_CASE" | import("./naming-convention").PropertySchema;
42
+ allowLeadingUnderscore?: boolean;
43
+ allowTrailingUnderscore?: boolean;
44
+ types?: ("PascalCase" | "camelCase" | "UPPER_CASE" | "snake_case") | {
45
+ style?: "PascalCase" | "camelCase" | "UPPER_CASE" | "snake_case";
46
+ suffix?: string;
47
+ prefix?: string;
48
+ forbiddenPrefixes?: string[];
49
+ forbiddenSuffixes?: string[];
50
+ };
51
+ fields?: ("PascalCase" | "camelCase" | "UPPER_CASE" | "snake_case") | {
52
+ style?: "PascalCase" | "camelCase" | "UPPER_CASE" | "snake_case";
53
+ suffix?: string;
54
+ prefix?: string;
55
+ forbiddenPrefixes?: string[];
56
+ forbiddenSuffixes?: string[];
57
+ };
58
+ overrides?: {
59
+ [x: `OperationDefinition${string}`]: ("PascalCase" | "camelCase" | "UPPER_CASE" | "snake_case") | {
60
+ style?: "PascalCase" | "camelCase" | "UPPER_CASE" | "snake_case";
61
+ suffix?: string;
62
+ prefix?: string;
63
+ forbiddenPrefixes?: string[];
64
+ forbiddenSuffixes?: string[];
65
+ };
66
+ [x: `VariableDefinition${string}`]: ("PascalCase" | "camelCase" | "UPPER_CASE" | "snake_case") | {
67
+ style?: "PascalCase" | "camelCase" | "UPPER_CASE" | "snake_case";
68
+ suffix?: string;
69
+ prefix?: string;
70
+ forbiddenPrefixes?: string[];
71
+ forbiddenSuffixes?: string[];
72
+ };
73
+ [x: `Argument${string}`]: ("PascalCase" | "camelCase" | "UPPER_CASE" | "snake_case") | {
74
+ style?: "PascalCase" | "camelCase" | "UPPER_CASE" | "snake_case";
75
+ suffix?: string;
76
+ prefix?: string;
77
+ forbiddenPrefixes?: string[];
78
+ forbiddenSuffixes?: string[];
79
+ };
80
+ [x: `FragmentDefinition${string}`]: ("PascalCase" | "camelCase" | "UPPER_CASE" | "snake_case") | {
81
+ style?: "PascalCase" | "camelCase" | "UPPER_CASE" | "snake_case";
82
+ suffix?: string;
83
+ prefix?: string;
84
+ forbiddenPrefixes?: string[];
85
+ forbiddenSuffixes?: string[];
86
+ };
87
+ [x: `ScalarTypeDefinition${string}`]: ("PascalCase" | "camelCase" | "UPPER_CASE" | "snake_case") | {
88
+ style?: "PascalCase" | "camelCase" | "UPPER_CASE" | "snake_case";
89
+ suffix?: string;
90
+ prefix?: string;
91
+ forbiddenPrefixes?: string[];
92
+ forbiddenSuffixes?: string[];
93
+ };
94
+ [x: `ObjectTypeDefinition${string}`]: ("PascalCase" | "camelCase" | "UPPER_CASE" | "snake_case") | {
95
+ style?: "PascalCase" | "camelCase" | "UPPER_CASE" | "snake_case";
96
+ suffix?: string;
97
+ prefix?: string;
98
+ forbiddenPrefixes?: string[];
99
+ forbiddenSuffixes?: string[];
100
+ };
101
+ [x: `FieldDefinition${string}`]: ("PascalCase" | "camelCase" | "UPPER_CASE" | "snake_case") | {
102
+ style?: "PascalCase" | "camelCase" | "UPPER_CASE" | "snake_case";
103
+ suffix?: string;
104
+ prefix?: string;
105
+ forbiddenPrefixes?: string[];
106
+ forbiddenSuffixes?: string[];
107
+ };
108
+ [x: `InputValueDefinition${string}`]: ("PascalCase" | "camelCase" | "UPPER_CASE" | "snake_case") | {
109
+ style?: "PascalCase" | "camelCase" | "UPPER_CASE" | "snake_case";
110
+ suffix?: string;
111
+ prefix?: string;
112
+ forbiddenPrefixes?: string[];
113
+ forbiddenSuffixes?: string[];
114
+ };
115
+ [x: `InterfaceTypeDefinition${string}`]: ("PascalCase" | "camelCase" | "UPPER_CASE" | "snake_case") | {
116
+ style?: "PascalCase" | "camelCase" | "UPPER_CASE" | "snake_case";
117
+ suffix?: string;
118
+ prefix?: string;
119
+ forbiddenPrefixes?: string[];
120
+ forbiddenSuffixes?: string[];
121
+ };
122
+ [x: `UnionTypeDefinition${string}`]: ("PascalCase" | "camelCase" | "UPPER_CASE" | "snake_case") | {
123
+ style?: "PascalCase" | "camelCase" | "UPPER_CASE" | "snake_case";
124
+ suffix?: string;
125
+ prefix?: string;
126
+ forbiddenPrefixes?: string[];
127
+ forbiddenSuffixes?: string[];
128
+ };
129
+ [x: `EnumTypeDefinition${string}`]: ("PascalCase" | "camelCase" | "UPPER_CASE" | "snake_case") | {
130
+ style?: "PascalCase" | "camelCase" | "UPPER_CASE" | "snake_case";
131
+ suffix?: string;
132
+ prefix?: string;
133
+ forbiddenPrefixes?: string[];
134
+ forbiddenSuffixes?: string[];
135
+ };
136
+ [x: `EnumValueDefinition${string}`]: ("PascalCase" | "camelCase" | "UPPER_CASE" | "snake_case") | {
137
+ style?: "PascalCase" | "camelCase" | "UPPER_CASE" | "snake_case";
138
+ suffix?: string;
139
+ prefix?: string;
140
+ forbiddenPrefixes?: string[];
141
+ forbiddenSuffixes?: string[];
142
+ };
143
+ [x: `InputObjectTypeDefinition${string}`]: ("PascalCase" | "camelCase" | "UPPER_CASE" | "snake_case") | {
144
+ style?: "PascalCase" | "camelCase" | "UPPER_CASE" | "snake_case";
145
+ suffix?: string;
146
+ prefix?: string;
147
+ forbiddenPrefixes?: string[];
148
+ forbiddenSuffixes?: string[];
149
+ };
150
+ [x: `DirectiveDefinition${string}`]: ("PascalCase" | "camelCase" | "UPPER_CASE" | "snake_case") | {
151
+ style?: "PascalCase" | "camelCase" | "UPPER_CASE" | "snake_case";
152
+ suffix?: string;
153
+ prefix?: string;
154
+ forbiddenPrefixes?: string[];
155
+ forbiddenSuffixes?: string[];
156
+ };
157
+ };
56
158
  }], false>;
57
159
  'no-anonymous-operations': import("..").GraphQLESLintRule<any[], false>;
58
160
  'no-case-insensitive-enum-values-duplicates': import("..").GraphQLESLintRule<any[], false>;
59
161
  'no-deprecated': import("..").GraphQLESLintRule<[], true>;
60
162
  'no-hashtag-description': import("..").GraphQLESLintRule<any[], false>;
61
163
  'no-operation-name-suffix': import("..").GraphQLESLintRule<any[], false>;
164
+ 'no-root-type': import("..").GraphQLESLintRule<[{
165
+ disallow: ("query" | "mutation" | "subscription")[];
166
+ }], false>;
62
167
  'no-unreachable-types': import("..").GraphQLESLintRule<any[], false>;
63
168
  'no-unused-fields': import("..").GraphQLESLintRule<any[], false>;
64
169
  'require-deprecation-date': import("..").GraphQLESLintRule<[{
@@ -1,31 +1,38 @@
1
- import { Kind } from 'graphql';
2
1
  import { GraphQLESLintRule } from '../types';
3
- declare const acceptedStyles: ['camelCase', 'PascalCase', 'snake_case', 'UPPER_CASE'];
4
- declare type ValidNaming = typeof acceptedStyles[number];
5
- export interface PropertySchema {
6
- style?: ValidNaming;
2
+ declare const KindToDisplayName: {
3
+ ObjectTypeDefinition: string;
4
+ InterfaceTypeDefinition: string;
5
+ EnumTypeDefinition: string;
6
+ ScalarTypeDefinition: string;
7
+ InputObjectTypeDefinition: string;
8
+ UnionTypeDefinition: string;
9
+ FieldDefinition: string;
10
+ InputValueDefinition: string;
11
+ VariableDefinition: string;
12
+ Argument: string;
13
+ DirectiveDefinition: string;
14
+ EnumValueDefinition: string;
15
+ OperationDefinition: string;
16
+ FragmentDefinition: string;
17
+ };
18
+ declare type AllowedKind = keyof typeof KindToDisplayName;
19
+ declare type AllowedStyle = 'camelCase' | 'PascalCase' | 'snake_case' | 'UPPER_CASE';
20
+ declare type PropertySchema = {
21
+ style?: AllowedStyle;
7
22
  suffix?: string;
8
23
  prefix?: string;
9
24
  forbiddenPrefixes?: string[];
10
25
  forbiddenSuffixes?: string[];
11
- }
12
- declare type NamingConventionRuleConfig = [
13
- {
14
- leadingUnderscore?: 'allow' | 'forbid';
15
- trailingUnderscore?: 'allow' | 'forbid';
16
- QueryDefinition?: ValidNaming | PropertySchema;
17
- [Kind.FIELD_DEFINITION]?: ValidNaming | PropertySchema;
18
- [Kind.ENUM_VALUE_DEFINITION]?: ValidNaming | PropertySchema;
19
- [Kind.INPUT_VALUE_DEFINITION]?: ValidNaming | PropertySchema;
20
- [Kind.OBJECT_TYPE_DEFINITION]?: ValidNaming | PropertySchema;
21
- [Kind.INTERFACE_TYPE_DEFINITION]?: ValidNaming | PropertySchema;
22
- [Kind.ENUM_TYPE_DEFINITION]?: ValidNaming | PropertySchema;
23
- [Kind.UNION_TYPE_DEFINITION]?: ValidNaming | PropertySchema;
24
- [Kind.SCALAR_TYPE_DEFINITION]?: ValidNaming | PropertySchema;
25
- [Kind.OPERATION_DEFINITION]?: ValidNaming | PropertySchema;
26
- [Kind.FRAGMENT_DEFINITION]?: ValidNaming | PropertySchema;
27
- [Kind.INPUT_OBJECT_TYPE_DEFINITION]?: ValidNaming | PropertySchema;
28
- }
29
- ];
30
- declare const rule: GraphQLESLintRule<NamingConventionRuleConfig>;
26
+ };
27
+ declare type Options = AllowedStyle | PropertySchema;
28
+ declare type NamingConventionRuleConfig = {
29
+ allowLeadingUnderscore?: boolean;
30
+ allowTrailingUnderscore?: boolean;
31
+ types?: Options;
32
+ fields?: Options;
33
+ overrides?: {
34
+ [key in `${AllowedKind}${string}`]?: Options;
35
+ };
36
+ };
37
+ declare const rule: GraphQLESLintRule<[NamingConventionRuleConfig]>;
31
38
  export default rule;
@@ -0,0 +1,7 @@
1
+ import { GraphQLESLintRule } from '../types';
2
+ declare const ROOT_TYPES: ('query' | 'mutation' | 'subscription')[];
3
+ declare type NoRootTypeConfig = {
4
+ disallow: typeof ROOT_TYPES;
5
+ };
6
+ declare const rule: GraphQLESLintRule<[NoRootTypeConfig]>;
7
+ export default rule;
package/testkit.d.ts CHANGED
@@ -6,7 +6,7 @@ export declare type GraphQLESLintRuleListener<WithTypeInfo extends boolean = fal
6
6
  [K in keyof ASTKindToNode]?: (node: GraphQLESTreeNode<ASTKindToNode[K], WithTypeInfo>) => void;
7
7
  } & Record<string, any>;
8
8
  export declare type GraphQLValidTestCase<Options> = Omit<RuleTester.ValidTestCase, 'options' | 'parserOptions'> & {
9
- name: string;
9
+ name?: string;
10
10
  options?: Options;
11
11
  parserOptions?: ParserOptions;
12
12
  };
package/utils.d.ts CHANGED
@@ -1,10 +1,9 @@
1
- import { GraphQLSchema, Source, ObjectTypeDefinitionNode, ObjectTypeExtensionNode } from 'graphql';
1
+ import { GraphQLSchema, Source, Kind } from 'graphql';
2
2
  import { AST } from 'eslint';
3
3
  import { Source as LoaderSource } from '@graphql-tools/utils';
4
4
  import { GraphQLESLintRuleContext } from './types';
5
5
  import { SiblingOperations } from './sibling-operations';
6
6
  import { UsedFields, ReachableTypes } from './graphql-ast';
7
- import { GraphQLESTreeNode } from './estree-parser';
8
7
  export declare function requireSiblingsOperations(ruleName: string, context: GraphQLESLintRuleContext): SiblingOperations | never;
9
8
  export declare function requireGraphQLSchemaFromContext(ruleName: string, context: GraphQLESLintRuleContext): GraphQLSchema | never;
10
9
  export declare function requireReachableTypesFromContext(ruleName: string, context: GraphQLESLintRuleContext): ReachableTypes | never;
@@ -20,10 +19,7 @@ export declare const normalizePath: (path: string) => string;
20
19
  export declare const getOnDiskFilepath: (filepath: string) => string;
21
20
  export declare const getTypeName: (node: any) => any;
22
21
  export declare const loaderCache: Record<string, LoaderSource[]>;
23
- declare type ObjectTypeNode = GraphQLESTreeNode<ObjectTypeDefinitionNode | ObjectTypeExtensionNode>;
24
- export declare const isQueryType: (node: ObjectTypeNode) => boolean;
25
- export declare const isMutationType: (node: ObjectTypeNode) => boolean;
26
- export declare const isSubscriptionType: (node: ObjectTypeNode) => boolean;
22
+ export declare const TYPES_KINDS: Kind[];
27
23
  export declare enum CaseStyle {
28
24
  camelCase = "camelCase",
29
25
  pascalCase = "PascalCase",
@@ -37,4 +33,3 @@ export declare function getLocation(loc: Partial<AST.SourceLocation>, fieldName?
37
33
  offsetStart?: number;
38
34
  offsetEnd?: number;
39
35
  }): AST.SourceLocation;
40
- export {};