@graphql-eslint/eslint-plugin 4.0.0-alpha-20230801163310-8bc4340 → 4.0.0-alpha-20230810160036-304c2c0
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/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
@@ -5,48 +5,42 @@ var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
5
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
6
6
|
var __export = (target, all) => {
|
7
7
|
for (var name in all)
|
8
|
-
__defProp(target, name, { get: all[name], enumerable:
|
9
|
-
}
|
10
|
-
|
11
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: !0 });
|
9
|
+
}, __copyProps = (to, from, except, desc) => {
|
10
|
+
if (from && typeof from == "object" || typeof from == "function")
|
12
11
|
for (let key of __getOwnPropNames(from))
|
13
|
-
|
14
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
15
|
-
}
|
12
|
+
!__hasOwnProp.call(to, key) && key !== except && __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
16
13
|
return to;
|
17
14
|
};
|
18
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value:
|
15
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: !0 }), mod);
|
19
16
|
var require_description_exports = {};
|
20
17
|
__export(require_description_exports, {
|
21
18
|
RULE_ID: () => RULE_ID,
|
22
19
|
rule: () => rule
|
23
20
|
});
|
24
21
|
module.exports = __toCommonJS(require_description_exports);
|
25
|
-
var import_utils = require("@graphql-tools/utils");
|
26
|
-
|
27
|
-
var import_utils2 = require("../utils.js");
|
28
|
-
const RULE_ID = "require-description";
|
29
|
-
const ALLOWED_KINDS = [
|
22
|
+
var import_utils = require("@graphql-tools/utils"), import_graphql = require("graphql"), import_utils2 = require("../utils.js");
|
23
|
+
const RULE_ID = "require-description", ALLOWED_KINDS = [
|
30
24
|
...import_utils2.TYPES_KINDS,
|
31
25
|
import_graphql.Kind.DIRECTIVE_DEFINITION,
|
32
26
|
import_graphql.Kind.FIELD_DEFINITION,
|
33
27
|
import_graphql.Kind.INPUT_VALUE_DEFINITION,
|
34
28
|
import_graphql.Kind.ENUM_VALUE_DEFINITION,
|
35
29
|
import_graphql.Kind.OPERATION_DEFINITION
|
36
|
-
]
|
37
|
-
const schema = {
|
30
|
+
], schema = {
|
38
31
|
type: "array",
|
39
32
|
minItems: 1,
|
40
33
|
maxItems: 1,
|
41
34
|
items: {
|
42
35
|
type: "object",
|
43
|
-
additionalProperties:
|
36
|
+
additionalProperties: !1,
|
44
37
|
minProperties: 1,
|
45
38
|
properties: {
|
46
39
|
types: {
|
47
40
|
type: "boolean",
|
48
41
|
description: `Includes:
|
49
|
-
${import_utils2.TYPES_KINDS.map((kind) => `- \`${kind}\``).join(
|
42
|
+
${import_utils2.TYPES_KINDS.map((kind) => `- \`${kind}\``).join(`
|
43
|
+
`)}`
|
50
44
|
},
|
51
45
|
rootField: {
|
52
46
|
type: "boolean",
|
@@ -55,16 +49,12 @@ ${import_utils2.TYPES_KINDS.map((kind) => `- \`${kind}\``).join("\n")}`
|
|
55
49
|
...Object.fromEntries(
|
56
50
|
[...ALLOWED_KINDS].sort().map((kind) => {
|
57
51
|
let description = `Read more about this kind on [spec.graphql.org](https://spec.graphql.org/October2021/#${kind}).`;
|
58
|
-
|
59
|
-
description += '\n> You must use only comment syntax `#` and not description syntax `"""` or `"`.';
|
60
|
-
}
|
61
|
-
return [kind, { type: "boolean", description }];
|
52
|
+
return kind === import_graphql.Kind.OPERATION_DEFINITION && (description += '\n> You must use only comment syntax `#` and not description syntax `"""` or `"`.'), [kind, { type: "boolean", description }];
|
62
53
|
})
|
63
54
|
)
|
64
55
|
}
|
65
56
|
}
|
66
|
-
}
|
67
|
-
const rule = {
|
57
|
+
}, rule = {
|
68
58
|
meta: {
|
69
59
|
docs: {
|
70
60
|
category: "Schema",
|
@@ -73,7 +63,7 @@ const rule = {
|
|
73
63
|
examples: [
|
74
64
|
{
|
75
65
|
title: "Incorrect",
|
76
|
-
usage: [{ types:
|
66
|
+
usage: [{ types: !0, FieldDefinition: !0 }],
|
77
67
|
code: (
|
78
68
|
/* GraphQL */
|
79
69
|
`
|
@@ -85,7 +75,7 @@ const rule = {
|
|
85
75
|
},
|
86
76
|
{
|
87
77
|
title: "Correct",
|
88
|
-
usage: [{ types:
|
78
|
+
usage: [{ types: !0, FieldDefinition: !0 }],
|
89
79
|
code: (
|
90
80
|
/* GraphQL */
|
91
81
|
`
|
@@ -103,7 +93,7 @@ const rule = {
|
|
103
93
|
},
|
104
94
|
{
|
105
95
|
title: "Correct",
|
106
|
-
usage: [{ OperationDefinition:
|
96
|
+
usage: [{ OperationDefinition: !0 }],
|
107
97
|
code: (
|
108
98
|
/* GraphQL */
|
109
99
|
`
|
@@ -116,7 +106,7 @@ const rule = {
|
|
116
106
|
},
|
117
107
|
{
|
118
108
|
title: "Correct",
|
119
|
-
usage: [{ rootField:
|
109
|
+
usage: [{ rootField: !0 }],
|
120
110
|
code: (
|
121
111
|
/* GraphQL */
|
122
112
|
`
|
@@ -134,12 +124,12 @@ const rule = {
|
|
134
124
|
],
|
135
125
|
configOptions: [
|
136
126
|
{
|
137
|
-
types:
|
138
|
-
[import_graphql.Kind.DIRECTIVE_DEFINITION]:
|
139
|
-
|
127
|
+
types: !0,
|
128
|
+
[import_graphql.Kind.DIRECTIVE_DEFINITION]: !0,
|
129
|
+
rootField: !0
|
140
130
|
}
|
141
131
|
],
|
142
|
-
recommended:
|
132
|
+
recommended: !0
|
143
133
|
},
|
144
134
|
type: "suggestion",
|
145
135
|
messages: {
|
@@ -148,52 +138,36 @@ const rule = {
|
|
148
138
|
schema
|
149
139
|
},
|
150
140
|
create(context) {
|
151
|
-
const { types, rootField, ...restOptions } = context.options[0] || {};
|
152
|
-
const
|
153
|
-
|
154
|
-
if (isEnabled) {
|
155
|
-
kinds.add(kind);
|
156
|
-
} else {
|
157
|
-
kinds.delete(kind);
|
158
|
-
}
|
159
|
-
}
|
141
|
+
const { types, rootField, ...restOptions } = context.options[0] || {}, kinds = new Set(types ? import_utils2.TYPES_KINDS : []);
|
142
|
+
for (const [kind, isEnabled] of Object.entries(restOptions))
|
143
|
+
isEnabled ? kinds.add(kind) : kinds.delete(kind);
|
160
144
|
if (rootField) {
|
161
|
-
const schema2 = (0, import_utils2.requireGraphQLSchemaFromContext)(RULE_ID, context);
|
162
|
-
const rootTypeNames = (0, import_utils.getRootTypeNames)(schema2);
|
145
|
+
const schema2 = (0, import_utils2.requireGraphQLSchemaFromContext)(RULE_ID, context), rootTypeNames = (0, import_utils.getRootTypeNames)(schema2);
|
163
146
|
kinds.add(
|
164
147
|
`:matches(ObjectTypeDefinition, ObjectTypeExtension)[name.value=/^(${[
|
165
148
|
...rootTypeNames
|
166
149
|
].join(",")})$/] > FieldDefinition`
|
167
150
|
);
|
168
151
|
}
|
169
|
-
const selector = [...kinds].join(",");
|
170
152
|
return {
|
171
|
-
[
|
172
|
-
var _a;
|
153
|
+
[[...kinds].join(",")](node) {
|
173
154
|
let description = "";
|
174
155
|
const isOperation = node.kind === import_graphql.Kind.OPERATION_DEFINITION;
|
175
156
|
if (isOperation) {
|
176
|
-
const rawNode = node.rawNode();
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
const linesBefore = line - prev.line;
|
181
|
-
if (!value.startsWith("eslint") && linesBefore === 1) {
|
182
|
-
description = value;
|
183
|
-
}
|
157
|
+
const rawNode = node.rawNode(), { prev, line } = rawNode.loc.startToken;
|
158
|
+
if (prev?.kind === import_graphql.TokenKind.COMMENT) {
|
159
|
+
const value = prev.value.trim(), linesBefore = line - prev.line;
|
160
|
+
!value.startsWith("eslint") && linesBefore === 1 && (description = value);
|
184
161
|
}
|
185
|
-
} else
|
186
|
-
description =
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
|
194
|
-
}
|
195
|
-
});
|
196
|
-
}
|
162
|
+
} else
|
163
|
+
description = node.description?.value.trim() || "";
|
164
|
+
description.length === 0 && context.report({
|
165
|
+
loc: isOperation ? (0, import_utils2.getLocation)(node.loc.start, node.operation) : node.name.loc,
|
166
|
+
messageId: RULE_ID,
|
167
|
+
data: {
|
168
|
+
nodeName: (0, import_utils2.getNodeName)(node)
|
169
|
+
}
|
170
|
+
});
|
197
171
|
}
|
198
172
|
};
|
199
173
|
}
|
@@ -1,11 +1,12 @@
|
|
1
|
-
import {
|
2
|
-
import '@graphql-tools/utils';
|
1
|
+
import { GraphQLESLintRule } from '../types.js';
|
3
2
|
import 'eslint';
|
4
3
|
import 'estree';
|
5
4
|
import 'graphql';
|
6
|
-
import 'graphql-config';
|
7
5
|
import 'json-schema-to-ts';
|
6
|
+
import '../siblings.js';
|
7
|
+
import '@graphql-tools/utils';
|
8
8
|
import '../estree-converter/types.js';
|
9
|
+
import 'graphql-config';
|
9
10
|
|
10
11
|
declare const rule: GraphQLESLintRule;
|
11
12
|
|
@@ -5,33 +5,28 @@ var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
5
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
6
6
|
var __export = (target, all) => {
|
7
7
|
for (var name in all)
|
8
|
-
__defProp(target, name, { get: all[name], enumerable:
|
9
|
-
}
|
10
|
-
|
11
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: !0 });
|
9
|
+
}, __copyProps = (to, from, except, desc) => {
|
10
|
+
if (from && typeof from == "object" || typeof from == "function")
|
12
11
|
for (let key of __getOwnPropNames(from))
|
13
|
-
|
14
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
15
|
-
}
|
12
|
+
!__hasOwnProp.call(to, key) && key !== except && __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
16
13
|
return to;
|
17
14
|
};
|
18
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value:
|
15
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: !0 }), mod);
|
19
16
|
var require_field_of_type_query_in_mutation_result_exports = {};
|
20
17
|
__export(require_field_of_type_query_in_mutation_result_exports, {
|
21
18
|
rule: () => rule
|
22
19
|
});
|
23
20
|
module.exports = __toCommonJS(require_field_of_type_query_in_mutation_result_exports);
|
24
|
-
var import_graphql = require("graphql");
|
25
|
-
|
26
|
-
const RULE_ID = "require-field-of-type-query-in-mutation-result";
|
27
|
-
const rule = {
|
21
|
+
var import_graphql = require("graphql"), import_utils = require("../utils.js");
|
22
|
+
const RULE_ID = "require-field-of-type-query-in-mutation-result", rule = {
|
28
23
|
meta: {
|
29
24
|
type: "suggestion",
|
30
25
|
docs: {
|
31
26
|
category: "Schema",
|
32
27
|
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`.",
|
33
28
|
url: `https://the-guild.dev/graphql/eslint/rules/${RULE_ID}`,
|
34
|
-
requiresSchema:
|
29
|
+
requiresSchema: !0,
|
35
30
|
examples: [
|
36
31
|
{
|
37
32
|
title: "Incorrect",
|
@@ -71,26 +66,16 @@ const rule = {
|
|
71
66
|
schema: []
|
72
67
|
},
|
73
68
|
create(context) {
|
74
|
-
const schema = (0, import_utils.requireGraphQLSchemaFromContext)(RULE_ID, context);
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
return {};
|
79
|
-
}
|
80
|
-
const selector = `:matches(ObjectTypeDefinition, ObjectTypeExtension)[name.value=${mutationType.name}] > FieldDefinition > .gqlType Name`;
|
81
|
-
return {
|
82
|
-
[selector](node) {
|
83
|
-
const typeName = node.value;
|
84
|
-
const graphQLType = schema.getType(typeName);
|
69
|
+
const schema = (0, import_utils.requireGraphQLSchemaFromContext)(RULE_ID, context), mutationType = schema.getMutationType(), queryType = schema.getQueryType();
|
70
|
+
return !mutationType || !queryType ? {} : {
|
71
|
+
[`:matches(ObjectTypeDefinition, ObjectTypeExtension)[name.value=${mutationType.name}] > FieldDefinition > .gqlType Name`](node) {
|
72
|
+
const typeName = node.value, graphQLType = schema.getType(typeName);
|
85
73
|
if ((0, import_graphql.isObjectType)(graphQLType)) {
|
86
74
|
const { fields } = graphQLType.astNode;
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
message: `Mutation result type "${graphQLType.name}" must contain field of type "${queryType.name}"`
|
92
|
-
});
|
93
|
-
}
|
75
|
+
fields?.some((field) => (0, import_utils.getTypeName)(field) === queryType.name) || context.report({
|
76
|
+
node,
|
77
|
+
message: `Mutation result type "${graphQLType.name}" must contain field of type "${queryType.name}"`
|
78
|
+
});
|
94
79
|
}
|
95
80
|
}
|
96
81
|
};
|
@@ -1,11 +1,12 @@
|
|
1
|
-
import {
|
2
|
-
import '@graphql-tools/utils';
|
1
|
+
import { GraphQLESLintRule } from '../types.js';
|
3
2
|
import 'eslint';
|
4
3
|
import 'estree';
|
5
4
|
import 'graphql';
|
6
|
-
import 'graphql-config';
|
7
5
|
import 'json-schema-to-ts';
|
6
|
+
import '../siblings.js';
|
7
|
+
import '@graphql-tools/utils';
|
8
8
|
import '../estree-converter/types.js';
|
9
|
+
import 'graphql-config';
|
9
10
|
|
10
11
|
declare const rule: GraphQLESLintRule;
|
11
12
|
|
@@ -3,18 +3,14 @@ var __create = Object.create;
|
|
3
3
|
var __defProp = Object.defineProperty;
|
4
4
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
5
5
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
6
|
-
var __getProtoOf = Object.getPrototypeOf;
|
7
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
6
|
+
var __getProtoOf = Object.getPrototypeOf, __hasOwnProp = Object.prototype.hasOwnProperty;
|
8
7
|
var __export = (target, all) => {
|
9
8
|
for (var name in all)
|
10
|
-
__defProp(target, name, { get: all[name], enumerable:
|
11
|
-
}
|
12
|
-
|
13
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
9
|
+
__defProp(target, name, { get: all[name], enumerable: !0 });
|
10
|
+
}, __copyProps = (to, from, except, desc) => {
|
11
|
+
if (from && typeof from == "object" || typeof from == "function")
|
14
12
|
for (let key of __getOwnPropNames(from))
|
15
|
-
|
16
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
17
|
-
}
|
13
|
+
!__hasOwnProp.call(to, key) && key !== except && __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
18
14
|
return to;
|
19
15
|
};
|
20
16
|
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
@@ -22,20 +18,16 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
22
18
|
// file that has been converted to a CommonJS file using a Babel-
|
23
19
|
// compatible transform (i.e. "__esModule" has not been set), then set
|
24
20
|
// "default" to the CommonJS "module.exports" for node compatibility.
|
25
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable:
|
21
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: !0 }) : target,
|
26
22
|
mod
|
27
|
-
));
|
28
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
23
|
+
)), __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: !0 }), mod);
|
29
24
|
var require_import_fragment_exports = {};
|
30
25
|
__export(require_import_fragment_exports, {
|
31
26
|
rule: () => rule
|
32
27
|
});
|
33
28
|
module.exports = __toCommonJS(require_import_fragment_exports);
|
34
|
-
var
|
35
|
-
|
36
|
-
const RULE_ID = "require-import-fragment";
|
37
|
-
const SUGGESTION_ID = "add-import-expression";
|
38
|
-
const rule = {
|
29
|
+
var import_node_path = __toESM(require("node:path")), import_utils = require("../utils.js");
|
30
|
+
const RULE_ID = "require-import-fragment", SUGGESTION_ID = "add-import-expression", rule = {
|
39
31
|
meta: {
|
40
32
|
type: "suggestion",
|
41
33
|
docs: {
|
@@ -99,10 +91,9 @@ const rule = {
|
|
99
91
|
)
|
100
92
|
}
|
101
93
|
],
|
102
|
-
requiresSiblings:
|
103
|
-
isDisabledForAllConfig: true
|
94
|
+
requiresSiblings: !0
|
104
95
|
},
|
105
|
-
hasSuggestions:
|
96
|
+
hasSuggestions: !0,
|
106
97
|
messages: {
|
107
98
|
[RULE_ID]: 'Expected "{{fragmentName}}" fragment to be imported.',
|
108
99
|
[SUGGESTION_ID]: 'Add import expression for "{{fragmentName}}".'
|
@@ -110,38 +101,29 @@ const rule = {
|
|
110
101
|
schema: []
|
111
102
|
},
|
112
103
|
create(context) {
|
113
|
-
const comments = context.getSourceCode().getAllComments();
|
114
|
-
const siblings = (0, import_utils.requireSiblingsOperations)(RULE_ID, context);
|
115
|
-
const filePath = context.getFilename();
|
104
|
+
const comments = context.getSourceCode().getAllComments(), siblings = (0, import_utils.requireSiblingsOperations)(RULE_ID, context), filePath = context.filename;
|
116
105
|
return {
|
117
106
|
"FragmentSpread > .name"(node) {
|
118
|
-
|
119
|
-
const fragmentName = node.value;
|
120
|
-
const fragmentsFromSiblings = siblings.getFragment(fragmentName);
|
107
|
+
const fragmentName = node.value, fragmentsFromSiblings = siblings.getFragment(fragmentName);
|
121
108
|
for (const comment of comments) {
|
122
|
-
if (comment.type !== "Line"
|
123
|
-
continue;
|
124
|
-
const isPossibleImported = new RegExp(
|
109
|
+
if (comment.type !== "Line" || !new RegExp(
|
125
110
|
`^\\s*import\\s+(${fragmentName}\\s+from\\s+)?['"]`
|
126
|
-
).test(comment.value)
|
127
|
-
if (!isPossibleImported)
|
111
|
+
).test(comment.value))
|
128
112
|
continue;
|
129
|
-
const extractedImportPath =
|
113
|
+
const extractedImportPath = comment.value.match(/(["'])((?:\1|.)*?)\1/)?.[2];
|
130
114
|
if (!extractedImportPath)
|
131
115
|
continue;
|
132
|
-
const importPath =
|
133
|
-
|
116
|
+
const importPath = import_node_path.default.join(import_node_path.default.dirname(filePath), extractedImportPath);
|
117
|
+
if (fragmentsFromSiblings.some(
|
134
118
|
(source) => source.filePath === importPath
|
135
|
-
)
|
136
|
-
if (hasInSiblings)
|
119
|
+
))
|
137
120
|
return;
|
138
121
|
}
|
139
|
-
|
122
|
+
if (fragmentsFromSiblings.some(
|
140
123
|
(source) => source.filePath === filePath
|
141
|
-
)
|
142
|
-
if (fragmentInSameFile)
|
124
|
+
))
|
143
125
|
return;
|
144
|
-
const suggestedFilePaths = fragmentsFromSiblings.length ? fragmentsFromSiblings.map((o) =>
|
126
|
+
const suggestedFilePaths = fragmentsFromSiblings.length ? fragmentsFromSiblings.map((o) => import_node_path.default.relative(import_node_path.default.dirname(filePath), o.filePath)) : ["CHANGE_ME.graphql"];
|
145
127
|
context.report({
|
146
128
|
node,
|
147
129
|
messageId: RULE_ID,
|
@@ -1,11 +1,12 @@
|
|
1
|
-
import {
|
2
|
-
import '@graphql-tools/utils';
|
1
|
+
import { GraphQLESLintRule } from '../types.js';
|
3
2
|
import 'eslint';
|
4
3
|
import 'estree';
|
5
4
|
import 'graphql';
|
6
|
-
import 'graphql-config';
|
7
5
|
import 'json-schema-to-ts';
|
6
|
+
import '../siblings.js';
|
7
|
+
import '@graphql-tools/utils';
|
8
8
|
import '../estree-converter/types.js';
|
9
|
+
import 'graphql-config';
|
9
10
|
|
10
11
|
declare const rule: GraphQLESLintRule;
|
11
12
|
|
@@ -5,26 +5,21 @@ var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
5
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
6
6
|
var __export = (target, all) => {
|
7
7
|
for (var name in all)
|
8
|
-
__defProp(target, name, { get: all[name], enumerable:
|
9
|
-
}
|
10
|
-
|
11
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: !0 });
|
9
|
+
}, __copyProps = (to, from, except, desc) => {
|
10
|
+
if (from && typeof from == "object" || typeof from == "function")
|
12
11
|
for (let key of __getOwnPropNames(from))
|
13
|
-
|
14
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
15
|
-
}
|
12
|
+
!__hasOwnProp.call(to, key) && key !== except && __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
16
13
|
return to;
|
17
14
|
};
|
18
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value:
|
15
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: !0 }), mod);
|
19
16
|
var require_nullable_fields_with_oneof_exports = {};
|
20
17
|
__export(require_nullable_fields_with_oneof_exports, {
|
21
18
|
rule: () => rule
|
22
19
|
});
|
23
20
|
module.exports = __toCommonJS(require_nullable_fields_with_oneof_exports);
|
24
|
-
var import_graphql = require("graphql");
|
25
|
-
|
26
|
-
const RULE_ID = "require-nullable-fields-with-oneof";
|
27
|
-
const rule = {
|
21
|
+
var import_graphql = require("graphql"), import_utils = require("../utils.js");
|
22
|
+
const RULE_ID = "require-nullable-fields-with-oneof", rule = {
|
28
23
|
meta: {
|
29
24
|
type: "suggestion",
|
30
25
|
docs: {
|
@@ -66,22 +61,16 @@ const rule = {
|
|
66
61
|
create(context) {
|
67
62
|
return {
|
68
63
|
"Directive[name.value=oneOf]"({ parent }) {
|
69
|
-
|
64
|
+
if ([
|
70
65
|
import_graphql.Kind.OBJECT_TYPE_DEFINITION,
|
71
66
|
import_graphql.Kind.INPUT_OBJECT_TYPE_DEFINITION
|
72
|
-
].includes(parent.kind)
|
73
|
-
|
74
|
-
|
75
|
-
}
|
76
|
-
for (const field of parent.fields || []) {
|
77
|
-
if (field.gqlType.kind === import_graphql.Kind.NON_NULL_TYPE) {
|
78
|
-
context.report({
|
67
|
+
].includes(parent.kind))
|
68
|
+
for (const field of parent.fields || [])
|
69
|
+
field.gqlType.kind === import_graphql.Kind.NON_NULL_TYPE && context.report({
|
79
70
|
node: field.name,
|
80
71
|
messageId: RULE_ID,
|
81
72
|
data: { nodeName: (0, import_utils.getNodeName)(field) }
|
82
73
|
});
|
83
|
-
}
|
84
|
-
}
|
85
74
|
}
|
86
75
|
};
|
87
76
|
}
|
@@ -1,11 +1,12 @@
|
|
1
|
-
import {
|
2
|
-
import '@graphql-tools/utils';
|
1
|
+
import { GraphQLESLintRule } from '../types.js';
|
3
2
|
import 'eslint';
|
4
3
|
import 'estree';
|
5
4
|
import 'graphql';
|
6
|
-
import 'graphql-config';
|
7
5
|
import 'json-schema-to-ts';
|
6
|
+
import '../siblings.js';
|
7
|
+
import '@graphql-tools/utils';
|
8
8
|
import '../estree-converter/types.js';
|
9
|
+
import 'graphql-config';
|
9
10
|
|
10
11
|
declare const rule: GraphQLESLintRule;
|
11
12
|
|
@@ -5,34 +5,29 @@ var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
5
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
6
6
|
var __export = (target, all) => {
|
7
7
|
for (var name in all)
|
8
|
-
__defProp(target, name, { get: all[name], enumerable:
|
9
|
-
}
|
10
|
-
|
11
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: !0 });
|
9
|
+
}, __copyProps = (to, from, except, desc) => {
|
10
|
+
if (from && typeof from == "object" || typeof from == "function")
|
12
11
|
for (let key of __getOwnPropNames(from))
|
13
|
-
|
14
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
15
|
-
}
|
12
|
+
!__hasOwnProp.call(to, key) && key !== except && __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
16
13
|
return to;
|
17
14
|
};
|
18
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value:
|
15
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: !0 }), mod);
|
19
16
|
var require_nullable_result_in_root_exports = {};
|
20
17
|
__export(require_nullable_result_in_root_exports, {
|
21
18
|
rule: () => rule
|
22
19
|
});
|
23
20
|
module.exports = __toCommonJS(require_nullable_result_in_root_exports);
|
24
|
-
var import_graphql = require("graphql");
|
25
|
-
|
26
|
-
const RULE_ID = "require-nullable-result-in-root";
|
27
|
-
const rule = {
|
21
|
+
var import_graphql = require("graphql"), import_utils = require("../utils.js");
|
22
|
+
const RULE_ID = "require-nullable-result-in-root", rule = {
|
28
23
|
meta: {
|
29
24
|
type: "suggestion",
|
30
|
-
hasSuggestions:
|
25
|
+
hasSuggestions: !0,
|
31
26
|
docs: {
|
32
27
|
category: "Schema",
|
33
28
|
description: "Require nullable fields in root types.",
|
34
29
|
url: `https://the-guild.dev/graphql/eslint/rules/${RULE_ID}`,
|
35
|
-
requiresSchema:
|
30
|
+
requiresSchema: !0,
|
36
31
|
examples: [
|
37
32
|
{
|
38
33
|
title: "Incorrect",
|
@@ -66,39 +61,34 @@ const rule = {
|
|
66
61
|
schema: []
|
67
62
|
},
|
68
63
|
create(context) {
|
69
|
-
const schema = (0, import_utils.requireGraphQLSchemaFromContext)(RULE_ID, context)
|
70
|
-
|
71
|
-
|
72
|
-
);
|
73
|
-
const sourceCode = context.getSourceCode();
|
64
|
+
const schema = (0, import_utils.requireGraphQLSchemaFromContext)(RULE_ID, context), rootTypeNames = new Set(
|
65
|
+
[schema.getQueryType(), schema.getMutationType()].filter(import_utils.truthy).map((type) => type.name)
|
66
|
+
), sourceCode = context.getSourceCode();
|
74
67
|
return {
|
75
68
|
"ObjectTypeDefinition,ObjectTypeExtension"(node) {
|
76
|
-
if (
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
const text = sourceCode.getText(field.gqlType);
|
96
|
-
return fixer.replaceText(field.gqlType, text.replace("!", ""));
|
69
|
+
if (rootTypeNames.has(node.name.value))
|
70
|
+
for (const field of node.fields || []) {
|
71
|
+
if (field.gqlType.type !== import_graphql.Kind.NON_NULL_TYPE || field.gqlType.gqlType.type !== import_graphql.Kind.NAMED_TYPE)
|
72
|
+
continue;
|
73
|
+
const name = field.gqlType.gqlType.name.value, type = schema.getType(name), resultType = type?.astNode ? (0, import_utils.getNodeName)(type.astNode) : type?.name;
|
74
|
+
context.report({
|
75
|
+
node: field.gqlType,
|
76
|
+
messageId: RULE_ID,
|
77
|
+
data: {
|
78
|
+
resultType: resultType || "",
|
79
|
+
rootType: (0, import_utils.getNodeName)(node)
|
80
|
+
},
|
81
|
+
suggest: [
|
82
|
+
{
|
83
|
+
desc: `Make ${resultType} nullable`,
|
84
|
+
fix(fixer) {
|
85
|
+
const text = sourceCode.getText(field.gqlType);
|
86
|
+
return fixer.replaceText(field.gqlType, text.replace("!", ""));
|
87
|
+
}
|
97
88
|
}
|
98
|
-
|
99
|
-
|
100
|
-
}
|
101
|
-
}
|
89
|
+
]
|
90
|
+
});
|
91
|
+
}
|
102
92
|
}
|
103
93
|
};
|
104
94
|
}
|
@@ -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.js';
|
4
3
|
import 'eslint';
|
5
4
|
import 'estree';
|
6
5
|
import 'graphql';
|
7
|
-
import '
|
6
|
+
import '../siblings.js';
|
7
|
+
import '@graphql-tools/utils';
|
8
8
|
import '../estree-converter/types.js';
|
9
|
+
import 'graphql-config';
|
9
10
|
|
10
11
|
declare const schema: {
|
11
12
|
readonly definitions: {
|