@graphql-eslint/eslint-plugin 4.0.0-alpha-20230801163310-8bc4340 → 4.0.0-alpha-20230810155929-e89edf7
Sign up to get free protection for your applications and to get access to all the features.
- package/README.md +2 -0
- package/cjs/cache.js +10 -19
- package/cjs/configs/index.d.ts +42 -16
- package/cjs/configs/index.js +10 -19
- package/cjs/configs/operations-all.d.ts +4 -3
- package/cjs/configs/operations-all.js +5 -4
- package/cjs/configs/operations-recommended.d.ts +3 -1
- package/cjs/configs/operations-recommended.js +3 -1
- package/cjs/configs/schema-all.d.ts +6 -1
- package/cjs/configs/schema-all.js +5 -2
- package/cjs/configs/schema-recommended.d.ts +19 -1
- package/cjs/configs/schema-recommended.js +22 -2
- package/cjs/documents.js +17 -32
- package/cjs/estree-converter/converter.js +14 -27
- package/cjs/estree-converter/index.js +4 -7
- package/cjs/estree-converter/types.js +3 -5
- package/cjs/estree-converter/utils.d.ts +2 -3
- package/cjs/estree-converter/utils.js +15 -45
- package/cjs/flat-configs.d.ts +59 -12
- package/cjs/flat-configs.js +9 -14
- package/cjs/graphql-config.d.ts +4 -3
- package/cjs/graphql-config.js +23 -44
- package/cjs/index.d.ts +10 -4
- package/cjs/index.js +8 -16
- package/cjs/parser.d.ts +4 -3
- package/cjs/parser.js +38 -45
- package/cjs/processor.d.ts +5 -1
- package/cjs/processor.js +25 -57
- package/cjs/rules/alphabetize.d.ts +6 -16
- package/cjs/rules/alphabetize.js +60 -132
- package/cjs/rules/description-style.d.ts +4 -3
- package/cjs/rules/description-style.js +11 -18
- package/cjs/rules/graphql-js-validation.d.ts +4 -3
- package/cjs/rules/graphql-js-validation.js +151 -225
- package/cjs/rules/index.d.ts +15 -13
- package/cjs/rules/index.js +8 -45
- package/cjs/rules/input-name.d.ts +4 -3
- package/cjs/rules/input-name.js +43 -59
- package/cjs/rules/lone-executable-definition.d.ts +6 -5
- package/cjs/rules/lone-executable-definition.js +14 -28
- package/cjs/rules/match-document-filename.d.ts +4 -3
- package/cjs/rules/match-document-filename.js +39 -70
- package/cjs/rules/naming-convention.d.ts +4 -3
- package/cjs/rules/naming-convention.js +56 -74
- package/cjs/rules/no-anonymous-operations.d.ts +4 -3
- package/cjs/rules/no-anonymous-operations.js +11 -18
- package/cjs/rules/no-deprecated.d.ts +4 -3
- package/cjs/rules/no-deprecated.js +15 -29
- package/cjs/rules/no-duplicate-fields.d.ts +4 -3
- package/cjs/rules/no-duplicate-fields.js +13 -23
- package/cjs/rules/no-hashtag-description.d.ts +4 -3
- package/cjs/rules/no-hashtag-description.js +16 -29
- package/cjs/rules/no-one-place-fragments.d.ts +4 -3
- package/cjs/rules/no-one-place-fragments.js +17 -29
- package/cjs/rules/no-root-type.d.ts +4 -3
- package/cjs/rules/no-root-type.js +15 -25
- package/cjs/rules/no-scalar-result-type-on-mutation.d.ts +4 -3
- package/cjs/rules/no-scalar-result-type-on-mutation.js +18 -30
- package/cjs/rules/no-typename-prefix.d.ts +4 -3
- package/cjs/rules/no-typename-prefix.js +26 -33
- package/cjs/rules/no-unreachable-types.d.ts +4 -3
- package/cjs/rules/no-unreachable-types.js +25 -47
- package/cjs/rules/no-unused-fields.d.ts +4 -3
- package/cjs/rules/no-unused-fields.js +24 -49
- package/cjs/rules/relay-arguments.d.ts +4 -3
- package/cjs/rules/relay-arguments.js +20 -43
- package/cjs/rules/relay-connection-types.d.ts +4 -3
- package/cjs/rules/relay-connection-types.js +14 -45
- package/cjs/rules/relay-edge-types.d.ts +4 -3
- package/cjs/rules/relay-edge-types.js +48 -99
- package/cjs/rules/relay-page-info.d.ts +4 -3
- package/cjs/rules/relay-page-info.js +21 -44
- package/cjs/rules/require-deprecation-date.d.ts +4 -3
- package/cjs/rules/require-deprecation-date.js +15 -31
- package/cjs/rules/require-deprecation-reason.d.ts +4 -3
- package/cjs/rules/require-deprecation-reason.js +12 -20
- package/cjs/rules/require-description.d.ts +4 -3
- package/cjs/rules/require-description.js +39 -65
- package/cjs/rules/require-field-of-type-query-in-mutation-result.d.ts +4 -3
- package/cjs/rules/require-field-of-type-query-in-mutation-result.js +16 -31
- package/cjs/rules/require-import-fragment.d.ts +4 -3
- package/cjs/rules/require-import-fragment.js +22 -40
- package/cjs/rules/require-nullable-fields-with-oneof.d.ts +4 -3
- package/cjs/rules/require-nullable-fields-with-oneof.js +11 -22
- package/cjs/rules/require-nullable-result-in-root.d.ts +4 -3
- package/cjs/rules/require-nullable-result-in-root.js +34 -44
- package/cjs/rules/{require-id-when-available.d.ts → require-selections.d.ts} +4 -3
- package/cjs/rules/require-selections.js +198 -0
- package/cjs/rules/require-type-pattern-with-oneof.d.ts +4 -3
- package/cjs/rules/require-type-pattern-with-oneof.js +15 -23
- package/cjs/rules/selection-set-depth.d.ts +4 -3
- package/cjs/rules/selection-set-depth.js +18 -34
- package/cjs/rules/strict-id-in-types.d.ts +4 -3
- package/cjs/rules/strict-id-in-types.js +25 -43
- package/cjs/rules/{no-case-insensitive-enum-values-duplicates.d.ts → unique-enum-value-names.d.ts} +4 -3
- package/cjs/rules/{no-case-insensitive-enum-values-duplicates.js → unique-enum-value-names.js} +16 -21
- package/cjs/rules/unique-fragment-name.d.ts +3 -2
- package/cjs/rules/unique-fragment-name.js +24 -36
- package/cjs/rules/unique-operation-name.d.ts +4 -3
- package/cjs/rules/unique-operation-name.js +10 -12
- package/cjs/schema.d.ts +4 -3
- package/cjs/schema.js +14 -27
- package/cjs/siblings.d.ts +24 -8
- package/cjs/siblings.js +42 -82
- package/cjs/types.d.ts +74 -7
- package/cjs/types.js +3 -5
- package/cjs/utils.d.ts +3 -2
- package/cjs/utils.js +27 -44
- package/esm/cache.js +4 -8
- package/esm/{chunk-BMTV3EA2.js → chunk-U3TKCM4X.js} +1 -1
- package/esm/configs/index.d.mts +42 -16
- package/esm/configs/index.js +4 -4
- package/esm/configs/operations-all.d.mts +4 -3
- package/esm/configs/operations-all.js +6 -5
- package/esm/configs/operations-recommended.d.mts +3 -1
- package/esm/configs/operations-recommended.js +4 -2
- package/esm/configs/schema-all.d.mts +6 -1
- package/esm/configs/schema-all.js +6 -3
- package/esm/configs/schema-recommended.d.mts +19 -1
- package/esm/configs/schema-recommended.js +23 -3
- package/esm/configs/{relay.js → schema-relay.js} +4 -4
- package/esm/documents.js +10 -17
- package/esm/estree-converter/converter.js +9 -18
- package/esm/estree-converter/utils.d.mts +2 -3
- package/esm/estree-converter/utils.js +11 -38
- package/esm/flat-configs.d.mts +59 -12
- package/esm/flat-configs.js +4 -5
- package/esm/graphql-config.d.mts +4 -3
- package/esm/graphql-config.js +18 -34
- package/esm/index.d.mts +10 -4
- package/esm/index.js +1 -1
- package/esm/parser.d.mts +4 -3
- package/esm/parser.js +33 -27
- package/esm/processor.d.mts +5 -1
- package/esm/processor.js +21 -46
- package/esm/rules/alphabetize.d.mts +6 -16
- package/esm/rules/alphabetize.js +53 -118
- package/esm/rules/description-style.d.mts +4 -3
- package/esm/rules/description-style.js +7 -11
- package/esm/rules/graphql-js-validation.d.mts +4 -3
- package/esm/rules/graphql-js-validation.js +178 -218
- package/esm/rules/index.d.mts +15 -13
- package/esm/rules/index.js +5 -5
- package/esm/rules/input-name.d.mts +4 -3
- package/esm/rules/input-name.js +39 -52
- package/esm/rules/lone-executable-definition.d.mts +6 -5
- package/esm/rules/lone-executable-definition.js +10 -20
- package/esm/rules/match-document-filename.d.mts +4 -3
- package/esm/rules/match-document-filename.js +35 -61
- package/esm/rules/naming-convention.d.mts +4 -3
- package/esm/rules/naming-convention.js +51 -65
- package/esm/rules/no-anonymous-operations.d.mts +4 -3
- package/esm/rules/no-anonymous-operations.js +6 -9
- package/esm/rules/no-deprecated.d.mts +4 -3
- package/esm/rules/no-deprecated.js +10 -20
- package/esm/rules/no-duplicate-fields.d.mts +4 -3
- package/esm/rules/no-duplicate-fields.js +9 -16
- package/esm/rules/no-hashtag-description.d.mts +4 -3
- package/esm/rules/no-hashtag-description.js +11 -20
- package/esm/rules/no-one-place-fragments.d.mts +4 -3
- package/esm/rules/no-one-place-fragments.js +12 -19
- package/esm/rules/no-root-type.d.mts +4 -3
- package/esm/rules/no-root-type.js +11 -18
- package/esm/rules/no-scalar-result-type-on-mutation.d.mts +4 -3
- package/esm/rules/no-scalar-result-type-on-mutation.js +13 -21
- package/esm/rules/no-typename-prefix.d.mts +4 -3
- package/esm/rules/no-typename-prefix.js +22 -26
- package/esm/rules/no-unreachable-types.d.mts +4 -3
- package/esm/rules/no-unreachable-types.js +18 -33
- package/esm/rules/no-unused-fields.d.mts +4 -3
- package/esm/rules/no-unused-fields.js +19 -40
- package/esm/rules/relay-arguments.d.mts +4 -3
- package/esm/rules/relay-arguments.js +15 -34
- package/esm/rules/relay-connection-types.d.mts +4 -3
- package/esm/rules/relay-connection-types.js +10 -38
- package/esm/rules/relay-edge-types.d.mts +4 -3
- package/esm/rules/relay-edge-types.js +43 -89
- package/esm/rules/relay-page-info.d.mts +4 -3
- package/esm/rules/relay-page-info.js +16 -34
- package/esm/rules/require-deprecation-date.d.mts +4 -3
- package/esm/rules/require-deprecation-date.js +10 -22
- package/esm/rules/require-deprecation-reason.d.mts +4 -3
- package/esm/rules/require-deprecation-reason.js +7 -11
- package/esm/rules/require-description.d.mts +4 -3
- package/esm/rules/require-description.js +34 -55
- package/esm/rules/require-field-of-type-query-in-mutation-result.d.mts +4 -3
- package/esm/rules/require-field-of-type-query-in-mutation-result.js +11 -22
- package/esm/rules/require-import-fragment.d.mts +4 -3
- package/esm/rules/require-import-fragment.js +14 -26
- package/esm/rules/require-nullable-fields-with-oneof.d.mts +4 -3
- package/esm/rules/require-nullable-fields-with-oneof.js +6 -13
- package/esm/rules/require-nullable-result-in-root.d.mts +4 -3
- package/esm/rules/require-nullable-result-in-root.js +29 -35
- package/esm/rules/{require-id-when-available.d.mts → require-selections.d.mts} +4 -3
- package/esm/rules/{require-id-when-available.js → require-selections.js} +43 -80
- package/esm/rules/require-type-pattern-with-oneof.d.mts +4 -3
- package/esm/rules/require-type-pattern-with-oneof.js +11 -16
- package/esm/rules/selection-set-depth.d.mts +4 -3
- package/esm/rules/selection-set-depth.js +11 -20
- package/esm/rules/strict-id-in-types.d.mts +4 -3
- package/esm/rules/strict-id-in-types.js +20 -34
- package/esm/rules/{no-case-insensitive-enum-values-duplicates.d.mts → unique-enum-value-names.d.mts} +4 -3
- package/esm/rules/{no-case-insensitive-enum-values-duplicates.js → unique-enum-value-names.js} +8 -9
- package/esm/rules/unique-fragment-name.d.mts +3 -2
- package/esm/rules/unique-fragment-name.js +20 -27
- package/esm/rules/unique-operation-name.d.mts +4 -3
- package/esm/rules/unique-operation-name.js +6 -5
- package/esm/schema.d.mts +4 -3
- package/esm/schema.js +7 -12
- package/esm/siblings.d.mts +24 -8
- package/esm/siblings.js +37 -73
- package/esm/types.d.mts +74 -7
- package/esm/utils.d.mts +3 -2
- package/esm/utils.js +20 -31
- package/index.browser.mjs +5323 -0
- package/package.json +8 -13
- package/cjs/rules/require-id-when-available.js +0 -241
- package/cjs/types-8d5f4ae0.d.ts +0 -107
- package/esm/types-ace77d86.d.ts +0 -107
- /package/cjs/configs/{relay.d.ts → schema-relay.d.ts} +0 -0
- /package/cjs/configs/{relay.js → schema-relay.js} +0 -0
- /package/esm/configs/{relay.d.mts → schema-relay.d.mts} +0 -0
package/esm/rules/index.d.mts
CHANGED
@@ -1,23 +1,25 @@
|
|
1
1
|
import { RuleOptions } from './require-description.mjs';
|
2
2
|
import { CaseStyle } from '../utils.mjs';
|
3
|
-
import
|
3
|
+
import * as graphql_language_ast_js from 'graphql/language/ast.js';
|
4
|
+
import { GraphQLESLintRule } from '../types.mjs';
|
4
5
|
import * as json_schema_to_ts_lib_types_type_utils_writable_js from 'json-schema-to-ts/lib/types/type-utils/writable.js';
|
5
6
|
import 'graphql';
|
6
7
|
import 'eslint';
|
7
8
|
import 'estree';
|
8
|
-
import '../
|
9
|
+
import '../siblings.mjs';
|
9
10
|
import '@graphql-tools/utils';
|
10
|
-
import '
|
11
|
+
import '../estree-converter/types.mjs';
|
11
12
|
import 'json-schema-to-ts';
|
13
|
+
import 'graphql-config';
|
12
14
|
|
13
15
|
declare const rules: {
|
14
16
|
alphabetize: GraphQLESLintRule<{
|
15
17
|
definitions?: boolean | undefined;
|
16
18
|
selections?: json_schema_to_ts_lib_types_type_utils_writable_js.DeepWritable<"OperationDefinition" | "FragmentDefinition">[] | undefined;
|
17
19
|
arguments?: json_schema_to_ts_lib_types_type_utils_writable_js.DeepWritable<"Field" | "Directive" | "FieldDefinition" | "DirectiveDefinition">[] | undefined;
|
18
|
-
values?:
|
20
|
+
values?: boolean | undefined;
|
19
21
|
fields?: json_schema_to_ts_lib_types_type_utils_writable_js.DeepWritable<"ObjectTypeDefinition" | "InterfaceTypeDefinition" | "InputObjectTypeDefinition">[] | undefined;
|
20
|
-
variables?:
|
22
|
+
variables?: boolean | undefined;
|
21
23
|
groups?: string[] | undefined;
|
22
24
|
}[]>;
|
23
25
|
'description-style': GraphQLESLintRule<{
|
@@ -30,7 +32,7 @@ declare const rules: {
|
|
30
32
|
checkMutations?: boolean | undefined;
|
31
33
|
}[]>;
|
32
34
|
'lone-executable-definition': GraphQLESLintRule<{
|
33
|
-
ignore?: ("fragment" |
|
35
|
+
ignore?: ("fragment" | json_schema_to_ts_lib_types_type_utils_writable_js.DeepWritable<graphql_language_ast_js.OperationTypeNode>)[] | undefined;
|
34
36
|
}[]>;
|
35
37
|
'match-document-filename': GraphQLESLintRule<{
|
36
38
|
fragment?: json_schema_to_ts_lib_types_type_utils_writable_js.DeepWritable<CaseStyle | "matchDocumentStyle"> | {
|
@@ -38,17 +40,17 @@ declare const rules: {
|
|
38
40
|
suffix?: string | undefined;
|
39
41
|
prefix?: string | undefined;
|
40
42
|
} | undefined;
|
41
|
-
|
43
|
+
mutation?: json_schema_to_ts_lib_types_type_utils_writable_js.DeepWritable<CaseStyle | "matchDocumentStyle"> | {
|
42
44
|
style?: json_schema_to_ts_lib_types_type_utils_writable_js.DeepWritable<CaseStyle | "matchDocumentStyle"> | undefined;
|
43
45
|
suffix?: string | undefined;
|
44
46
|
prefix?: string | undefined;
|
45
47
|
} | undefined;
|
46
|
-
|
48
|
+
subscription?: json_schema_to_ts_lib_types_type_utils_writable_js.DeepWritable<CaseStyle | "matchDocumentStyle"> | {
|
47
49
|
style?: json_schema_to_ts_lib_types_type_utils_writable_js.DeepWritable<CaseStyle | "matchDocumentStyle"> | undefined;
|
48
50
|
suffix?: string | undefined;
|
49
51
|
prefix?: string | undefined;
|
50
52
|
} | undefined;
|
51
|
-
|
53
|
+
query?: json_schema_to_ts_lib_types_type_utils_writable_js.DeepWritable<CaseStyle | "matchDocumentStyle"> | {
|
52
54
|
style?: json_schema_to_ts_lib_types_type_utils_writable_js.DeepWritable<CaseStyle | "matchDocumentStyle"> | undefined;
|
53
55
|
suffix?: string | undefined;
|
54
56
|
prefix?: string | undefined;
|
@@ -71,7 +73,6 @@ declare const rules: {
|
|
71
73
|
allowTrailingUnderscore?: boolean | undefined;
|
72
74
|
}[]>;
|
73
75
|
'no-anonymous-operations': GraphQLESLintRule;
|
74
|
-
'no-case-insensitive-enum-values-duplicates': GraphQLESLintRule;
|
75
76
|
'no-deprecated': GraphQLESLintRule<[], true>;
|
76
77
|
'no-duplicate-fields': GraphQLESLintRule;
|
77
78
|
'no-hashtag-description': GraphQLESLintRule;
|
@@ -99,12 +100,12 @@ declare const rules: {
|
|
99
100
|
'require-deprecation-reason': GraphQLESLintRule;
|
100
101
|
'require-description': GraphQLESLintRule<RuleOptions>;
|
101
102
|
'require-field-of-type-query-in-mutation-result': GraphQLESLintRule;
|
102
|
-
'require-id-when-available': GraphQLESLintRule<{
|
103
|
-
fieldName?: string | string[] | undefined;
|
104
|
-
}[], true>;
|
105
103
|
'require-import-fragment': GraphQLESLintRule;
|
106
104
|
'require-nullable-fields-with-oneof': GraphQLESLintRule;
|
107
105
|
'require-nullable-result-in-root': GraphQLESLintRule;
|
106
|
+
'require-selections': GraphQLESLintRule<{
|
107
|
+
fieldName?: string | string[] | undefined;
|
108
|
+
}[], true>;
|
108
109
|
'require-type-pattern-with-oneof': GraphQLESLintRule;
|
109
110
|
'selection-set-depth': GraphQLESLintRule<{
|
110
111
|
ignore?: string[] | undefined;
|
@@ -118,6 +119,7 @@ declare const rules: {
|
|
118
119
|
suffixes?: string[] | undefined;
|
119
120
|
} | undefined;
|
120
121
|
}[]>;
|
122
|
+
'unique-enum-value-names': GraphQLESLintRule;
|
121
123
|
'unique-fragment-name': GraphQLESLintRule;
|
122
124
|
'unique-operation-name': GraphQLESLintRule;
|
123
125
|
};
|
package/esm/rules/index.js
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
import "../chunk-
|
1
|
+
import "../chunk-U3TKCM4X.js";
|
2
2
|
import { GRAPHQL_JS_VALIDATIONS } from "./graphql-js-validation.js";
|
3
3
|
import { rule as alphabetize } from "./alphabetize.js";
|
4
4
|
import { rule as descriptionStyle } from "./description-style.js";
|
@@ -7,7 +7,6 @@ import { rule as loneExecutableDefinition } from "./lone-executable-definition.j
|
|
7
7
|
import { rule as matchDocumentFilename } from "./match-document-filename.js";
|
8
8
|
import { rule as namingConvention } from "./naming-convention.js";
|
9
9
|
import { rule as noAnonymousOperations } from "./no-anonymous-operations.js";
|
10
|
-
import { rule as noCaseInsensitiveEnumValuesDuplicates } from "./no-case-insensitive-enum-values-duplicates.js";
|
11
10
|
import { rule as noDeprecated } from "./no-deprecated.js";
|
12
11
|
import { rule as noDuplicateFields } from "./no-duplicate-fields.js";
|
13
12
|
import { rule as noHashtagDescription } from "./no-hashtag-description.js";
|
@@ -25,13 +24,14 @@ import { rule as requireDeprecationDate } from "./require-deprecation-date.js";
|
|
25
24
|
import { rule as requireDeprecationReason } from "./require-deprecation-reason.js";
|
26
25
|
import { rule as requireDescription } from "./require-description.js";
|
27
26
|
import { rule as requireFieldOfTypeQueryInMutationResult } from "./require-field-of-type-query-in-mutation-result.js";
|
28
|
-
import { rule as requireIdWhenAvailable } from "./require-id-when-available.js";
|
29
27
|
import { rule as requireImportFragment } from "./require-import-fragment.js";
|
30
28
|
import { rule as requireNullableFieldsWithOneof } from "./require-nullable-fields-with-oneof.js";
|
31
29
|
import { rule as requireNullableResultInRoot } from "./require-nullable-result-in-root.js";
|
30
|
+
import { rule as requireSelections } from "./require-selections.js";
|
32
31
|
import { rule as requireTypePatternWithOneof } from "./require-type-pattern-with-oneof.js";
|
33
32
|
import { rule as selectionSetDepth } from "./selection-set-depth.js";
|
34
33
|
import { rule as strictIdInTypes } from "./strict-id-in-types.js";
|
34
|
+
import { rule as uniqueEnumValueNames } from "./unique-enum-value-names.js";
|
35
35
|
import { rule as uniqueFragmentName } from "./unique-fragment-name.js";
|
36
36
|
import { rule as uniqueOperationName } from "./unique-operation-name.js";
|
37
37
|
const rules = {
|
@@ -43,7 +43,6 @@ const rules = {
|
|
43
43
|
"match-document-filename": matchDocumentFilename,
|
44
44
|
"naming-convention": namingConvention,
|
45
45
|
"no-anonymous-operations": noAnonymousOperations,
|
46
|
-
"no-case-insensitive-enum-values-duplicates": noCaseInsensitiveEnumValuesDuplicates,
|
47
46
|
"no-deprecated": noDeprecated,
|
48
47
|
"no-duplicate-fields": noDuplicateFields,
|
49
48
|
"no-hashtag-description": noHashtagDescription,
|
@@ -61,13 +60,14 @@ const rules = {
|
|
61
60
|
"require-deprecation-reason": requireDeprecationReason,
|
62
61
|
"require-description": requireDescription,
|
63
62
|
"require-field-of-type-query-in-mutation-result": requireFieldOfTypeQueryInMutationResult,
|
64
|
-
"require-id-when-available": requireIdWhenAvailable,
|
65
63
|
"require-import-fragment": requireImportFragment,
|
66
64
|
"require-nullable-fields-with-oneof": requireNullableFieldsWithOneof,
|
67
65
|
"require-nullable-result-in-root": requireNullableResultInRoot,
|
66
|
+
"require-selections": requireSelections,
|
68
67
|
"require-type-pattern-with-oneof": requireTypePatternWithOneof,
|
69
68
|
"selection-set-depth": selectionSetDepth,
|
70
69
|
"strict-id-in-types": strictIdInTypes,
|
70
|
+
"unique-enum-value-names": uniqueEnumValueNames,
|
71
71
|
"unique-fragment-name": uniqueFragmentName,
|
72
72
|
"unique-operation-name": uniqueOperationName
|
73
73
|
};
|
@@ -1,11 +1,12 @@
|
|
1
1
|
import { FromSchema } from 'json-schema-to-ts';
|
2
|
-
import {
|
3
|
-
import '@graphql-tools/utils';
|
2
|
+
import { GraphQLESLintRule } from '../types.mjs';
|
4
3
|
import 'eslint';
|
5
4
|
import 'estree';
|
6
5
|
import 'graphql';
|
7
|
-
import '
|
6
|
+
import '../siblings.mjs';
|
7
|
+
import '@graphql-tools/utils';
|
8
8
|
import '../estree-converter/types.mjs';
|
9
|
+
import 'graphql-config';
|
9
10
|
|
10
11
|
declare const schema: {
|
11
12
|
readonly type: "array";
|
package/esm/rules/input-name.js
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
import "../chunk-
|
1
|
+
import "../chunk-U3TKCM4X.js";
|
2
2
|
import {
|
3
3
|
Kind
|
4
4
|
} from "graphql";
|
@@ -7,49 +7,46 @@ const schema = {
|
|
7
7
|
maxItems: 1,
|
8
8
|
items: {
|
9
9
|
type: "object",
|
10
|
-
additionalProperties:
|
10
|
+
additionalProperties: !1,
|
11
11
|
properties: {
|
12
12
|
checkInputType: {
|
13
13
|
type: "boolean",
|
14
|
-
default:
|
14
|
+
default: !1,
|
15
15
|
description: "Check that the input type name follows the convention \\<mutationName>Input"
|
16
16
|
},
|
17
17
|
caseSensitiveInputType: {
|
18
18
|
type: "boolean",
|
19
|
-
default:
|
19
|
+
default: !0,
|
20
20
|
description: "Allow for case discrepancies in the input type name"
|
21
21
|
},
|
22
22
|
checkQueries: {
|
23
23
|
type: "boolean",
|
24
|
-
default:
|
24
|
+
default: !1,
|
25
25
|
description: "Apply the rule to Queries"
|
26
26
|
},
|
27
27
|
checkMutations: {
|
28
28
|
type: "boolean",
|
29
|
-
default:
|
29
|
+
default: !0,
|
30
30
|
description: "Apply the rule to Mutations"
|
31
31
|
}
|
32
32
|
}
|
33
33
|
}
|
34
|
-
}
|
35
|
-
const isObjectType = (node) => (
|
34
|
+
}, isObjectType = (node) => (
|
36
35
|
// TODO: remove `as any` when drop support of graphql@15
|
37
36
|
[Kind.OBJECT_TYPE_DEFINITION, Kind.OBJECT_TYPE_EXTENSION].includes(node.type)
|
38
|
-
)
|
39
|
-
const isQueryType = (node) => isObjectType(node) && node.name.value === "Query";
|
40
|
-
const isMutationType = (node) => isObjectType(node) && node.name.value === "Mutation";
|
41
|
-
const rule = {
|
37
|
+
), isQueryType = (node) => isObjectType(node) && node.name.value === "Query", isMutationType = (node) => isObjectType(node) && node.name.value === "Mutation", rule = {
|
42
38
|
meta: {
|
43
39
|
type: "suggestion",
|
44
|
-
hasSuggestions:
|
40
|
+
hasSuggestions: !0,
|
45
41
|
docs: {
|
46
|
-
description:
|
42
|
+
description: `Require mutation argument to be always called "input" and input type to be called Mutation name + "Input".
|
43
|
+
Using the same name for all input parameters will make your schemas easier to consume and more predictable. Using the same name as mutation for InputType will make it easier to find mutations that InputType belongs to.`,
|
47
44
|
category: "Schema",
|
48
45
|
url: "https://the-guild.dev/graphql/eslint/rules/input-name",
|
49
46
|
examples: [
|
50
47
|
{
|
51
48
|
title: "Incorrect",
|
52
|
-
usage: [{ checkInputType:
|
49
|
+
usage: [{ checkInputType: !0 }],
|
53
50
|
code: (
|
54
51
|
/* GraphQL */
|
55
52
|
`
|
@@ -61,7 +58,7 @@ const rule = {
|
|
61
58
|
},
|
62
59
|
{
|
63
60
|
title: "Correct (with `checkInputType`)",
|
64
|
-
usage: [{ checkInputType:
|
61
|
+
usage: [{ checkInputType: !0 }],
|
65
62
|
code: (
|
66
63
|
/* GraphQL */
|
67
64
|
`
|
@@ -73,7 +70,7 @@ const rule = {
|
|
73
70
|
},
|
74
71
|
{
|
75
72
|
title: "Correct (without `checkInputType`)",
|
76
|
-
usage: [{ checkInputType:
|
73
|
+
usage: [{ checkInputType: !1 }],
|
77
74
|
code: (
|
78
75
|
/* GraphQL */
|
79
76
|
`
|
@@ -89,13 +86,11 @@ const rule = {
|
|
89
86
|
},
|
90
87
|
create(context) {
|
91
88
|
const options = {
|
92
|
-
checkInputType:
|
93
|
-
caseSensitiveInputType:
|
94
|
-
checkMutations:
|
89
|
+
checkInputType: !1,
|
90
|
+
caseSensitiveInputType: !0,
|
91
|
+
checkMutations: !0,
|
95
92
|
...context.options[0]
|
96
|
-
}
|
97
|
-
const shouldCheckType = (node) => options.checkMutations && isMutationType(node) || options.checkQueries && isQueryType(node) || false;
|
98
|
-
const listeners = {
|
93
|
+
}, shouldCheckType = (node) => options.checkMutations && isMutationType(node) || options.checkQueries && isQueryType(node) || !1, listeners = {
|
99
94
|
"FieldDefinition > InputValueDefinition[name.value!=input] > Name"(node) {
|
100
95
|
const fieldDef = node.parent.parent;
|
101
96
|
if (shouldCheckType(fieldDef.parent)) {
|
@@ -113,35 +108,27 @@ const rule = {
|
|
113
108
|
}
|
114
109
|
}
|
115
110
|
};
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
};
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
}
|
138
|
-
]
|
139
|
-
});
|
140
|
-
}
|
141
|
-
}
|
142
|
-
};
|
143
|
-
}
|
144
|
-
return listeners;
|
111
|
+
return options.checkInputType && (listeners["FieldDefinition > InputValueDefinition NamedType"] = (node) => {
|
112
|
+
const inputValueNode = ((item) => {
|
113
|
+
let currentNode = item;
|
114
|
+
for (; currentNode.type !== Kind.INPUT_VALUE_DEFINITION; )
|
115
|
+
currentNode = currentNode.parent;
|
116
|
+
return currentNode;
|
117
|
+
})(node);
|
118
|
+
if (shouldCheckType(inputValueNode.parent.parent)) {
|
119
|
+
const mutationName = `${inputValueNode.parent.name.value}Input`, name = node.name.value;
|
120
|
+
(options.caseSensitiveInputType && node.name.value !== mutationName || name.toLowerCase() !== mutationName.toLowerCase()) && context.report({
|
121
|
+
node: node.name,
|
122
|
+
message: `Input type \`${name}\` name should be \`${mutationName}\`.`,
|
123
|
+
suggest: [
|
124
|
+
{
|
125
|
+
desc: `Rename to \`${mutationName}\``,
|
126
|
+
fix: (fixer) => fixer.replaceText(node, mutationName)
|
127
|
+
}
|
128
|
+
]
|
129
|
+
});
|
130
|
+
}
|
131
|
+
}), listeners;
|
145
132
|
}
|
146
133
|
};
|
147
134
|
export {
|
@@ -1,11 +1,12 @@
|
|
1
|
+
import { OperationTypeNode } from 'graphql';
|
1
2
|
import { FromSchema } from 'json-schema-to-ts';
|
2
|
-
import {
|
3
|
-
import '@graphql-tools/utils';
|
3
|
+
import { GraphQLESLintRule } from '../types.mjs';
|
4
4
|
import 'eslint';
|
5
5
|
import 'estree';
|
6
|
-
import '
|
7
|
-
import 'graphql-
|
6
|
+
import '../siblings.mjs';
|
7
|
+
import '@graphql-tools/utils';
|
8
8
|
import '../estree-converter/types.mjs';
|
9
|
+
import 'graphql-config';
|
9
10
|
|
10
11
|
declare const schema: {
|
11
12
|
readonly type: "array";
|
@@ -18,7 +19,7 @@ declare const schema: {
|
|
18
19
|
readonly ignore: {
|
19
20
|
readonly maxItems: 3;
|
20
21
|
readonly items: {
|
21
|
-
readonly enum: readonly ["fragment",
|
22
|
+
readonly enum: readonly ["fragment", ...OperationTypeNode[]];
|
22
23
|
};
|
23
24
|
readonly description: "Allow certain definitions to be placed alongside others.";
|
24
25
|
readonly type: "array";
|
@@ -1,14 +1,13 @@
|
|
1
|
-
import "../chunk-
|
1
|
+
import "../chunk-U3TKCM4X.js";
|
2
|
+
import { OperationTypeNode } from "graphql";
|
2
3
|
import { ARRAY_DEFAULT_OPTIONS, getLocation, pascalCase } from "../utils.js";
|
3
|
-
const RULE_ID = "lone-executable-definition"
|
4
|
-
const definitionTypes = ["fragment", "query", "mutation", "subscription"];
|
5
|
-
const schema = {
|
4
|
+
const RULE_ID = "lone-executable-definition", definitionTypes = ["fragment", ...Object.values(OperationTypeNode)], schema = {
|
6
5
|
type: "array",
|
7
6
|
maxItems: 1,
|
8
7
|
items: {
|
9
8
|
type: "object",
|
10
9
|
minProperties: 1,
|
11
|
-
additionalProperties:
|
10
|
+
additionalProperties: !1,
|
12
11
|
properties: {
|
13
12
|
ignore: {
|
14
13
|
...ARRAY_DEFAULT_OPTIONS,
|
@@ -21,8 +20,7 @@ const schema = {
|
|
21
20
|
}
|
22
21
|
}
|
23
22
|
}
|
24
|
-
}
|
25
|
-
const rule = {
|
23
|
+
}, rule = {
|
26
24
|
meta: {
|
27
25
|
type: "suggestion",
|
28
26
|
docs: {
|
@@ -63,26 +61,18 @@ const rule = {
|
|
63
61
|
schema
|
64
62
|
},
|
65
63
|
create(context) {
|
66
|
-
|
67
|
-
const ignore = new Set(((_a = context.options[0]) == null ? void 0 : _a.ignore) || []);
|
68
|
-
const definitions = [];
|
64
|
+
const ignore = new Set(context.options[0]?.ignore || []), definitions = [];
|
69
65
|
return {
|
70
66
|
":matches(OperationDefinition, FragmentDefinition)"(node) {
|
71
67
|
const type = "operation" in node ? node.operation : "fragment";
|
72
|
-
|
73
|
-
definitions.push({ type, node });
|
74
|
-
}
|
68
|
+
ignore.has(type) || definitions.push({ type, node });
|
75
69
|
},
|
76
70
|
"Document:exit"() {
|
77
|
-
var _a2, _b;
|
78
71
|
for (const { node, type } of definitions.slice(1)) {
|
79
72
|
let name = pascalCase(type);
|
80
|
-
const definitionName =
|
81
|
-
|
82
|
-
name
|
83
|
-
}
|
84
|
-
context.report({
|
85
|
-
loc: ((_b = node.name) == null ? void 0 : _b.loc) || getLocation(node.loc.start, type),
|
73
|
+
const definitionName = node.name?.value;
|
74
|
+
definitionName && (name += ` "${definitionName}"`), context.report({
|
75
|
+
loc: node.name?.loc || getLocation(node.loc.start, type),
|
86
76
|
messageId: RULE_ID,
|
87
77
|
data: { name }
|
88
78
|
});
|
@@ -1,12 +1,13 @@
|
|
1
1
|
import { FromSchema } from 'json-schema-to-ts';
|
2
|
-
import {
|
2
|
+
import { GraphQLESLintRule } from '../types.mjs';
|
3
3
|
import { CaseStyle as CaseStyle$1 } from '../utils.mjs';
|
4
|
-
import '@graphql-tools/utils';
|
5
4
|
import 'eslint';
|
6
5
|
import 'estree';
|
7
6
|
import 'graphql';
|
8
|
-
import '
|
7
|
+
import '../siblings.mjs';
|
8
|
+
import '@graphql-tools/utils';
|
9
9
|
import '../estree-converter/types.mjs';
|
10
|
+
import 'graphql-config';
|
10
11
|
|
11
12
|
type CaseStyle = CaseStyle$1 | 'matchDocumentStyle';
|
12
13
|
declare const schema: {
|
@@ -1,25 +1,21 @@
|
|
1
|
-
import "../chunk-
|
2
|
-
import { basename, extname } from "path";
|
1
|
+
import "../chunk-U3TKCM4X.js";
|
2
|
+
import { basename, extname } from "node:path";
|
3
3
|
import { Kind } from "graphql";
|
4
4
|
import {
|
5
5
|
convertCase,
|
6
6
|
REPORT_ON_FIRST_CHARACTER,
|
7
7
|
VIRTUAL_DOCUMENT_REGEX
|
8
8
|
} from "../utils.js";
|
9
|
-
const MATCH_EXTENSION = "MATCH_EXTENSION"
|
10
|
-
const MATCH_STYLE = "MATCH_STYLE";
|
11
|
-
const CASE_STYLES = [
|
9
|
+
const MATCH_EXTENSION = "MATCH_EXTENSION", MATCH_STYLE = "MATCH_STYLE", CASE_STYLES = [
|
12
10
|
"camelCase",
|
13
11
|
"PascalCase",
|
14
12
|
"snake_case",
|
15
13
|
"UPPER_CASE",
|
16
14
|
"kebab-case",
|
17
15
|
"matchDocumentStyle"
|
18
|
-
]
|
19
|
-
const schemaOption = {
|
16
|
+
], schemaOption = {
|
20
17
|
oneOf: [{ $ref: "#/definitions/asString" }, { $ref: "#/definitions/asObject" }]
|
21
|
-
}
|
22
|
-
const schema = {
|
18
|
+
}, schema = {
|
23
19
|
definitions: {
|
24
20
|
asString: {
|
25
21
|
enum: CASE_STYLES,
|
@@ -27,7 +23,7 @@ const schema = {
|
|
27
23
|
},
|
28
24
|
asObject: {
|
29
25
|
type: "object",
|
30
|
-
additionalProperties:
|
26
|
+
additionalProperties: !1,
|
31
27
|
minProperties: 1,
|
32
28
|
properties: {
|
33
29
|
style: { enum: CASE_STYLES },
|
@@ -41,7 +37,7 @@ const schema = {
|
|
41
37
|
maxItems: 1,
|
42
38
|
items: {
|
43
39
|
type: "object",
|
44
|
-
additionalProperties:
|
40
|
+
additionalProperties: !1,
|
45
41
|
minProperties: 1,
|
46
42
|
properties: {
|
47
43
|
fileExtension: { enum: [".gql", ".graphql"] },
|
@@ -51,8 +47,7 @@ const schema = {
|
|
51
47
|
fragment: schemaOption
|
52
48
|
}
|
53
49
|
}
|
54
|
-
}
|
55
|
-
const rule = {
|
50
|
+
}, rule = {
|
56
51
|
meta: {
|
57
52
|
type: "suggestion",
|
58
53
|
docs: {
|
@@ -192,68 +187,47 @@ const rule = {
|
|
192
187
|
create(context) {
|
193
188
|
const options = context.options[0] || {
|
194
189
|
fileExtension: null
|
195
|
-
};
|
196
|
-
|
197
|
-
const isVirtualFile = VIRTUAL_DOCUMENT_REGEX.test(filePath);
|
198
|
-
if (isVirtualFile) {
|
190
|
+
}, filePath = context.filename;
|
191
|
+
if (VIRTUAL_DOCUMENT_REGEX.test(filePath))
|
199
192
|
return {};
|
200
|
-
|
201
|
-
const fileExtension = extname(filePath);
|
202
|
-
const filename = basename(filePath, fileExtension);
|
193
|
+
const fileExtension = extname(filePath), filename = basename(filePath, fileExtension);
|
203
194
|
return {
|
204
195
|
Document(documentNode) {
|
205
|
-
|
206
|
-
|
207
|
-
|
208
|
-
|
209
|
-
|
210
|
-
|
211
|
-
|
212
|
-
|
213
|
-
}
|
214
|
-
});
|
215
|
-
}
|
196
|
+
options.fileExtension && options.fileExtension !== fileExtension && context.report({
|
197
|
+
loc: REPORT_ON_FIRST_CHARACTER,
|
198
|
+
messageId: MATCH_EXTENSION,
|
199
|
+
data: {
|
200
|
+
fileExtension,
|
201
|
+
expectedFileExtension: options.fileExtension
|
202
|
+
}
|
203
|
+
});
|
216
204
|
const firstOperation = documentNode.definitions.find(
|
217
205
|
(n) => n.kind === Kind.OPERATION_DEFINITION
|
218
|
-
)
|
219
|
-
const firstFragment = documentNode.definitions.find(
|
206
|
+
), firstFragment = documentNode.definitions.find(
|
220
207
|
(n) => n.kind === Kind.FRAGMENT_DEFINITION
|
221
|
-
);
|
222
|
-
|
223
|
-
if (!node) {
|
208
|
+
), node = firstOperation || firstFragment;
|
209
|
+
if (!node)
|
224
210
|
return;
|
225
|
-
|
226
|
-
|
227
|
-
if (!docName) {
|
211
|
+
const docName = node.name?.value;
|
212
|
+
if (!docName)
|
228
213
|
return;
|
229
|
-
}
|
230
214
|
const docType = "operation" in node ? node.operation : "fragment";
|
231
215
|
let option = options[docType];
|
232
|
-
if (!option)
|
216
|
+
if (!option)
|
233
217
|
return;
|
234
|
-
}
|
235
|
-
if (typeof option === "string") {
|
236
|
-
option = { style: option };
|
237
|
-
}
|
218
|
+
typeof option == "string" && (option = { style: option });
|
238
219
|
const expectedExtension = options.fileExtension || fileExtension;
|
239
220
|
let expectedFilename = option.prefix || "";
|
240
|
-
|
241
|
-
expectedFilename += option.style === "matchDocumentStyle" ? docName : convertCase(option.style, docName);
|
242
|
-
} else {
|
243
|
-
expectedFilename += filename;
|
244
|
-
}
|
245
|
-
expectedFilename += (option.suffix || "") + expectedExtension;
|
221
|
+
option.style ? expectedFilename += option.style === "matchDocumentStyle" ? docName : convertCase(option.style, docName) : expectedFilename += filename, expectedFilename += (option.suffix || "") + expectedExtension;
|
246
222
|
const filenameWithExtension = filename + expectedExtension;
|
247
|
-
|
248
|
-
|
249
|
-
|
250
|
-
|
251
|
-
|
252
|
-
|
253
|
-
|
254
|
-
|
255
|
-
});
|
256
|
-
}
|
223
|
+
expectedFilename !== filenameWithExtension && context.report({
|
224
|
+
loc: REPORT_ON_FIRST_CHARACTER,
|
225
|
+
messageId: MATCH_STYLE,
|
226
|
+
data: {
|
227
|
+
expectedFilename,
|
228
|
+
filename: filenameWithExtension
|
229
|
+
}
|
230
|
+
});
|
257
231
|
}
|
258
232
|
};
|
259
233
|
}
|
@@ -1,11 +1,12 @@
|
|
1
1
|
import { FromSchema } from 'json-schema-to-ts';
|
2
|
-
import {
|
3
|
-
import '@graphql-tools/utils';
|
2
|
+
import { GraphQLESLintRule } from '../types.mjs';
|
4
3
|
import 'eslint';
|
5
4
|
import 'estree';
|
6
5
|
import 'graphql';
|
7
|
-
import '
|
6
|
+
import '../siblings.mjs';
|
7
|
+
import '@graphql-tools/utils';
|
8
8
|
import '../estree-converter/types.mjs';
|
9
|
+
import 'graphql-config';
|
9
10
|
|
10
11
|
type AllowedStyle = 'camelCase' | 'PascalCase' | 'snake_case' | 'UPPER_CASE';
|
11
12
|
declare const schema: {
|