@graphql-eslint/eslint-plugin 2.4.0-alpha-60dfe26.0 → 3.0.0-alpha-5388f29.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.4.0-alpha-60dfe26.0",
3
+ "version": "3.0.0-alpha-5388f29.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"
@@ -1,3 +1,3 @@
1
1
  import { GraphQLESLintRule } from '../types';
2
- declare const rule: GraphQLESLintRule<[], false>;
2
+ declare const rule: GraphQLESLintRule;
3
3
  export default rule;
package/rules/index.d.ts CHANGED
@@ -6,7 +6,7 @@ export declare const rules: {
6
6
  variables?: "OperationDefinition"[];
7
7
  arguments?: ("Field" | "Directive" | "FieldDefinition" | "DirectiveDefinition")[];
8
8
  }], false>;
9
- 'avoid-duplicate-fields': import("..").GraphQLESLintRule<[], false>;
9
+ 'avoid-duplicate-fields': import("..").GraphQLESLintRule<any[], false>;
10
10
  'avoid-operation-name-prefix': import("..").GraphQLESLintRule<import("./avoid-operation-name-prefix").AvoidOperationNamePrefixConfig, false>;
11
11
  'avoid-scalar-result-type-on-mutation': import("..").GraphQLESLintRule<any[], false>;
12
12
  'avoid-typename-prefix': import("..").GraphQLESLintRule<any[], false>;
@@ -39,20 +39,122 @@ 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>;
@@ -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;
package/testkit.d.ts CHANGED
@@ -6,6 +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
10
  options?: Options;
10
11
  parserOptions?: ParserOptions;
11
12
  };
@@ -13,8 +14,11 @@ export declare type GraphQLInvalidTestCase<T> = GraphQLValidTestCase<T> & {
13
14
  errors: number | Array<RuleTester.TestCaseError | string>;
14
15
  output?: string | null;
15
16
  };
16
- declare const GraphQLRuleTester_base: any;
17
- export declare class GraphQLRuleTester extends GraphQLRuleTester_base {
17
+ export declare class GraphQLRuleTester extends RuleTester {
18
+ config: {
19
+ parser: string;
20
+ parserOptions: ParserOptions;
21
+ };
18
22
  constructor(parserOptions?: ParserOptions);
19
23
  fromMockFile(path: string): string;
20
24
  runGraphQLTests<Config>(name: string, rule: GraphQLESLintRule, tests: {
@@ -22,4 +26,3 @@ export declare class GraphQLRuleTester extends GraphQLRuleTester_base {
22
26
  invalid: GraphQLInvalidTestCase<Config>[];
23
27
  }): void;
24
28
  }
25
- export {};
package/types.d.ts CHANGED
@@ -56,6 +56,7 @@ export declare type RuleDocsInfo<T> = Rule.RuleMetaData & {
56
56
  usage?: T;
57
57
  }[];
58
58
  optionsForConfig?: T;
59
+ graphQLJSRuleName?: string;
59
60
  };
60
61
  };
61
62
  export declare type GraphQLESLintRule<Options = any[], WithTypeInfo extends boolean = false> = {
package/utils.d.ts CHANGED
@@ -1,10 +1,9 @@
1
- import { GraphQLSchema, ObjectTypeDefinitionNode, ObjectTypeExtensionNode } from 'graphql';
1
+ import { GraphQLSchema } 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: ("ScalarTypeDefinition" | "ObjectTypeDefinition" | "InterfaceTypeDefinition" | "UnionTypeDefinition" | "EnumTypeDefinition" | "InputObjectTypeDefinition")[];
27
23
  export declare enum CaseStyle {
28
24
  camelCase = "camelCase",
29
25
  pascalCase = "PascalCase",
@@ -31,7 +27,9 @@ export declare enum CaseStyle {
31
27
  upperCase = "UPPER_CASE",
32
28
  kebabCase = "kebab-case"
33
29
  }
34
- export declare const pascalCase: (str: string) => string;
35
30
  export declare const camelCase: (str: string) => string;
36
31
  export declare const convertCase: (style: CaseStyle, str: string) => string;
37
- export {};
32
+ export declare function getLocation(loc: Partial<AST.SourceLocation>, fieldName?: string, offset?: {
33
+ offsetStart?: number;
34
+ offsetEnd?: number;
35
+ }): AST.SourceLocation;