@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
@@ -5,86 +5,64 @@ 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 relay_edge_types_exports = {};
|
20
17
|
__export(relay_edge_types_exports, {
|
21
18
|
rule: () => rule
|
22
19
|
});
|
23
20
|
module.exports = __toCommonJS(relay_edge_types_exports);
|
24
|
-
var import_utils = require("@graphql-tools/utils");
|
25
|
-
|
26
|
-
var import_utils2 = require("../utils.js");
|
27
|
-
const RULE_ID = "relay-edge-types";
|
28
|
-
const MESSAGE_MUST_BE_OBJECT_TYPE = "MESSAGE_MUST_BE_OBJECT_TYPE";
|
29
|
-
const MESSAGE_MISSING_EDGE_SUFFIX = "MESSAGE_MISSING_EDGE_SUFFIX";
|
30
|
-
const MESSAGE_LIST_TYPE_ONLY_EDGE_TYPE = "MESSAGE_LIST_TYPE_ONLY_EDGE_TYPE";
|
31
|
-
const MESSAGE_SHOULD_IMPLEMENTS_NODE = "MESSAGE_SHOULD_IMPLEMENTS_NODE";
|
21
|
+
var import_utils = require("@graphql-tools/utils"), import_graphql = require("graphql"), import_utils2 = require("../utils.js");
|
22
|
+
const RULE_ID = "relay-edge-types", MESSAGE_MUST_BE_OBJECT_TYPE = "MESSAGE_MUST_BE_OBJECT_TYPE", MESSAGE_MISSING_EDGE_SUFFIX = "MESSAGE_MISSING_EDGE_SUFFIX", MESSAGE_LIST_TYPE_ONLY_EDGE_TYPE = "MESSAGE_LIST_TYPE_ONLY_EDGE_TYPE", MESSAGE_SHOULD_IMPLEMENTS_NODE = "MESSAGE_SHOULD_IMPLEMENTS_NODE";
|
32
23
|
let edgeTypesCache;
|
33
24
|
function getEdgeTypes(schema2) {
|
34
|
-
if (edgeTypesCache)
|
25
|
+
if (edgeTypesCache)
|
35
26
|
return edgeTypesCache;
|
36
|
-
|
37
|
-
const edgeTypes = /* @__PURE__ */ new Set();
|
38
|
-
const visitor = {
|
27
|
+
const edgeTypes = /* @__PURE__ */ new Set(), visitor = {
|
39
28
|
ObjectTypeDefinition(node) {
|
40
|
-
|
41
|
-
const typeName = node.name.value;
|
42
|
-
const hasConnectionSuffix = typeName.endsWith("Connection");
|
43
|
-
if (!hasConnectionSuffix) {
|
29
|
+
if (!node.name.value.endsWith("Connection"))
|
44
30
|
return;
|
45
|
-
|
46
|
-
const edges = (_a = node.fields) == null ? void 0 : _a.find((field) => field.name.value === "edges");
|
31
|
+
const edges = node.fields?.find((field) => field.name.value === "edges");
|
47
32
|
if (edges) {
|
48
|
-
const edgesTypeName = (0, import_utils2.getTypeName)(edges);
|
49
|
-
|
50
|
-
if ((0, import_graphql.isObjectType)(edgesType)) {
|
51
|
-
edgeTypes.add(edgesTypeName);
|
52
|
-
}
|
33
|
+
const edgesTypeName = (0, import_utils2.getTypeName)(edges), edgesType = schema2.getType(edgesTypeName);
|
34
|
+
(0, import_graphql.isObjectType)(edgesType) && edgeTypes.add(edgesTypeName);
|
53
35
|
}
|
54
36
|
}
|
55
|
-
};
|
56
|
-
|
57
|
-
(0, import_graphql.visit)(astNode, visitor);
|
58
|
-
edgeTypesCache = edgeTypes;
|
59
|
-
return edgeTypesCache;
|
37
|
+
}, astNode = (0, import_utils.getDocumentNodeFromSchema)(schema2);
|
38
|
+
return (0, import_graphql.visit)(astNode, visitor), edgeTypesCache = edgeTypes, edgeTypesCache;
|
60
39
|
}
|
61
40
|
const schema = {
|
62
41
|
type: "array",
|
63
42
|
maxItems: 1,
|
64
43
|
items: {
|
65
44
|
type: "object",
|
66
|
-
additionalProperties:
|
45
|
+
additionalProperties: !1,
|
67
46
|
minProperties: 1,
|
68
47
|
properties: {
|
69
48
|
withEdgeSuffix: {
|
70
49
|
type: "boolean",
|
71
|
-
default:
|
50
|
+
default: !0,
|
72
51
|
description: 'Edge type name must end in "Edge".'
|
73
52
|
},
|
74
53
|
shouldImplementNode: {
|
75
54
|
type: "boolean",
|
76
|
-
default:
|
55
|
+
default: !0,
|
77
56
|
description: "Edge type's field `node` must implement `Node` interface."
|
78
57
|
},
|
79
58
|
listTypeCanWrapOnlyEdgeType: {
|
80
59
|
type: "boolean",
|
81
|
-
default:
|
60
|
+
default: !0,
|
82
61
|
description: "A list type should only wrap an edge type."
|
83
62
|
}
|
84
63
|
}
|
85
64
|
}
|
86
|
-
}
|
87
|
-
const rule = {
|
65
|
+
}, rule = {
|
88
66
|
meta: {
|
89
67
|
type: "problem",
|
90
68
|
docs: {
|
@@ -99,10 +77,11 @@ const rule = {
|
|
99
77
|
'- Edge type name must end in "Edge" _(optional)_',
|
100
78
|
"- Edge type's field `node` must implement `Node` interface _(optional)_",
|
101
79
|
"- A list type should only wrap an edge type _(optional)_"
|
102
|
-
].join(
|
80
|
+
].join(`
|
81
|
+
`),
|
103
82
|
url: `https://the-guild.dev/graphql/eslint/rules/${RULE_ID}`,
|
104
|
-
isDisabledForAllConfig:
|
105
|
-
requiresSchema:
|
83
|
+
isDisabledForAllConfig: !0,
|
84
|
+
requiresSchema: !0,
|
106
85
|
examples: [
|
107
86
|
{
|
108
87
|
title: "Correct",
|
@@ -127,42 +106,28 @@ const rule = {
|
|
127
106
|
schema
|
128
107
|
},
|
129
108
|
create(context) {
|
130
|
-
const schema2 = (0, import_utils2.requireGraphQLSchemaFromContext)(RULE_ID, context)
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
shouldImplementNode: true,
|
135
|
-
listTypeCanWrapOnlyEdgeType: true,
|
109
|
+
const schema2 = (0, import_utils2.requireGraphQLSchemaFromContext)(RULE_ID, context), edgeTypes = getEdgeTypes(schema2), options = {
|
110
|
+
withEdgeSuffix: !0,
|
111
|
+
shouldImplementNode: !0,
|
112
|
+
listTypeCanWrapOnlyEdgeType: !0,
|
136
113
|
...context.options[0]
|
137
|
-
}
|
138
|
-
|
139
|
-
|
140
|
-
var _a, _b;
|
141
|
-
const nodeField = (_a = node.fields) == null ? void 0 : _a.find((field) => field.name.value === "node");
|
142
|
-
const message = "return either a Scalar, Enum, Object, Interface, Union, or a non-null wrapper around one of those types.";
|
143
|
-
if (!nodeField) {
|
114
|
+
}, isNamedOrNonNullNamed = (node) => node.kind === import_graphql.Kind.NAMED_TYPE || node.kind === import_graphql.Kind.NON_NULL_TYPE && node.gqlType.kind === import_graphql.Kind.NAMED_TYPE, checkNodeField = (node) => {
|
115
|
+
const nodeField = node.fields?.find((field) => field.name.value === "node"), message = "return either a Scalar, Enum, Object, Interface, Union, or a non-null wrapper around one of those types.";
|
116
|
+
if (!nodeField)
|
144
117
|
context.report({
|
145
118
|
node: node.name,
|
146
119
|
message: `Edge type must contain a field \`node\` that ${message}`
|
147
120
|
});
|
148
|
-
|
121
|
+
else if (!isNamedOrNonNullNamed(nodeField.gqlType))
|
149
122
|
context.report({ node: nodeField.name, message: `Field \`node\` must ${message}` });
|
150
|
-
|
151
|
-
const nodeReturnTypeName = (0, import_utils2.getTypeName)(nodeField.gqlType.rawNode());
|
152
|
-
|
153
|
-
if (!(0, import_graphql.isObjectType)(type)) {
|
123
|
+
else if (options.shouldImplementNode) {
|
124
|
+
const nodeReturnTypeName = (0, import_utils2.getTypeName)(nodeField.gqlType.rawNode()), type = schema2.getType(nodeReturnTypeName);
|
125
|
+
if (!(0, import_graphql.isObjectType)(type))
|
154
126
|
return;
|
155
|
-
}
|
156
|
-
const implementsNode = (_b = type.astNode.interfaces) == null ? void 0 : _b.some((n) => n.name.value === "Node");
|
157
|
-
if (!implementsNode) {
|
158
|
-
context.report({ node: node.name, messageId: MESSAGE_SHOULD_IMPLEMENTS_NODE });
|
159
|
-
}
|
127
|
+
type.astNode.interfaces?.some((n) => n.name.value === "Node") || context.report({ node: node.name, messageId: MESSAGE_SHOULD_IMPLEMENTS_NODE });
|
160
128
|
}
|
161
|
-
}
|
162
|
-
|
163
|
-
var _a;
|
164
|
-
const cursorField = (_a = node.fields) == null ? void 0 : _a.find((field) => field.name.value === "cursor");
|
165
|
-
const message = "return either a String, Scalar, or a non-null wrapper wrapper around one of those types.";
|
129
|
+
}, checkCursorField = (node) => {
|
130
|
+
const cursorField = node.fields?.find((field) => field.name.value === "cursor"), message = "return either a String, Scalar, or a non-null wrapper wrapper around one of those types.";
|
166
131
|
if (!cursorField) {
|
167
132
|
context.report({
|
168
133
|
node: node.name,
|
@@ -171,39 +136,23 @@ const rule = {
|
|
171
136
|
return;
|
172
137
|
}
|
173
138
|
const typeName = (0, import_utils2.getTypeName)(cursorField.rawNode());
|
174
|
-
|
175
|
-
|
176
|
-
}
|
177
|
-
};
|
178
|
-
const listeners = {
|
139
|
+
(!isNamedOrNonNullNamed(cursorField.gqlType) || typeName !== "String" && !(0, import_graphql.isScalarType)(schema2.getType(typeName))) && context.report({ node: cursorField.name, message: `Field \`cursor\` must ${message}` });
|
140
|
+
}, listeners = {
|
179
141
|
":matches(ObjectTypeDefinition, ObjectTypeExtension)[name.value=/Connection$/] > FieldDefinition[name.value=edges] > .gqlType Name"(node) {
|
180
142
|
const type = schema2.getType(node.value);
|
181
|
-
|
182
|
-
context.report({ node, messageId: MESSAGE_MUST_BE_OBJECT_TYPE });
|
183
|
-
}
|
143
|
+
(0, import_graphql.isObjectType)(type) || context.report({ node, messageId: MESSAGE_MUST_BE_OBJECT_TYPE });
|
184
144
|
},
|
185
145
|
":matches(ObjectTypeDefinition, ObjectTypeExtension)"(node) {
|
186
146
|
const typeName = node.name.value;
|
187
|
-
|
188
|
-
checkNodeField(node);
|
189
|
-
checkCursorField(node);
|
190
|
-
if (options.withEdgeSuffix && !typeName.endsWith("Edge")) {
|
191
|
-
context.report({ node: node.name, messageId: MESSAGE_MISSING_EDGE_SUFFIX });
|
192
|
-
}
|
193
|
-
}
|
147
|
+
edgeTypes.has(typeName) && (checkNodeField(node), checkCursorField(node), options.withEdgeSuffix && !typeName.endsWith("Edge") && context.report({ node: node.name, messageId: MESSAGE_MISSING_EDGE_SUFFIX }));
|
194
148
|
}
|
195
149
|
};
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
|
200
|
-
|
201
|
-
|
202
|
-
}
|
203
|
-
}
|
204
|
-
};
|
205
|
-
}
|
206
|
-
return listeners;
|
150
|
+
return options.listTypeCanWrapOnlyEdgeType && (listeners["FieldDefinition > .gqlType"] = (node) => {
|
151
|
+
if (node.kind === import_graphql.Kind.LIST_TYPE || node.kind === import_graphql.Kind.NON_NULL_TYPE && node.gqlType.kind === import_graphql.Kind.LIST_TYPE) {
|
152
|
+
const typeName = (0, import_utils2.getTypeName)(node.rawNode());
|
153
|
+
edgeTypes.has(typeName) || context.report({ node, messageId: MESSAGE_LIST_TYPE_ONLY_EDGE_TYPE });
|
154
|
+
}
|
155
|
+
}), listeners;
|
207
156
|
}
|
208
157
|
};
|
209
158
|
// Annotate the CommonJS export names for ESM import in node:
|
@@ -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,30 +5,22 @@ 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 relay_page_info_exports = {};
|
20
17
|
__export(relay_page_info_exports, {
|
21
18
|
rule: () => rule
|
22
19
|
});
|
23
20
|
module.exports = __toCommonJS(relay_page_info_exports);
|
24
|
-
var import_graphql = require("graphql");
|
25
|
-
|
26
|
-
|
27
|
-
const RULE_ID = "relay-page-info";
|
28
|
-
const MESSAGE_MUST_EXIST = "MESSAGE_MUST_EXIST";
|
29
|
-
const MESSAGE_MUST_BE_OBJECT_TYPE = "MESSAGE_MUST_BE_OBJECT_TYPE";
|
30
|
-
const notPageInfoTypesSelector = `:matches(${import_relay_connection_types.NON_OBJECT_TYPES})[name.value=PageInfo] > .name`;
|
31
|
-
let hasPageInfoChecked = false;
|
21
|
+
var import_graphql = require("graphql"), import_utils = require("../utils.js"), import_relay_connection_types = require("./relay-connection-types.js");
|
22
|
+
const RULE_ID = "relay-page-info", MESSAGE_MUST_EXIST = "MESSAGE_MUST_EXIST", MESSAGE_MUST_BE_OBJECT_TYPE = "MESSAGE_MUST_BE_OBJECT_TYPE", notPageInfoTypesSelector = `:matches(${import_relay_connection_types.NON_OBJECT_TYPES})[name.value=PageInfo] > .name`;
|
23
|
+
let hasPageInfoChecked = !1;
|
32
24
|
const rule = {
|
33
25
|
meta: {
|
34
26
|
type: "problem",
|
@@ -40,7 +32,8 @@ const rule = {
|
|
40
32
|
"- `PageInfo` must be an Object type",
|
41
33
|
"- `PageInfo` must contain fields `hasPreviousPage` and `hasNextPage`, that return non-null Boolean",
|
42
34
|
"- `PageInfo` must contain fields `startCursor` and `endCursor`, that return either String or Scalar, which can be null if there are no results"
|
43
|
-
].join(
|
35
|
+
].join(`
|
36
|
+
`),
|
44
37
|
url: `https://the-guild.dev/graphql/eslint/rules/${RULE_ID}`,
|
45
38
|
examples: [
|
46
39
|
{
|
@@ -58,8 +51,8 @@ const rule = {
|
|
58
51
|
)
|
59
52
|
}
|
60
53
|
],
|
61
|
-
isDisabledForAllConfig:
|
62
|
-
requiresSchema:
|
54
|
+
isDisabledForAllConfig: !0,
|
55
|
+
requiresSchema: !0
|
63
56
|
},
|
64
57
|
messages: {
|
65
58
|
[MESSAGE_MUST_EXIST]: "The server must provide a `PageInfo` object.",
|
@@ -69,35 +62,22 @@ const rule = {
|
|
69
62
|
},
|
70
63
|
create(context) {
|
71
64
|
const schema = (0, import_utils.requireGraphQLSchemaFromContext)(RULE_ID, context);
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
loc: import_utils.REPORT_ON_FIRST_CHARACTER,
|
77
|
-
messageId: MESSAGE_MUST_EXIST
|
78
|
-
});
|
79
|
-
}
|
80
|
-
hasPageInfoChecked = true;
|
81
|
-
}
|
82
|
-
return {
|
65
|
+
return hasPageInfoChecked || (schema.getType("PageInfo") || context.report({
|
66
|
+
loc: import_utils.REPORT_ON_FIRST_CHARACTER,
|
67
|
+
messageId: MESSAGE_MUST_EXIST
|
68
|
+
}), hasPageInfoChecked = !0), {
|
83
69
|
[notPageInfoTypesSelector](node) {
|
84
70
|
context.report({ node, messageId: MESSAGE_MUST_BE_OBJECT_TYPE });
|
85
71
|
},
|
86
72
|
"ObjectTypeDefinition[name.value=PageInfo]"(node) {
|
87
|
-
var _a;
|
88
73
|
const fieldMap = Object.fromEntries(
|
89
|
-
|
90
|
-
)
|
91
|
-
const checkField = (fieldName, typeName) => {
|
74
|
+
node.fields?.map((field) => [field.name.value, field]) || []
|
75
|
+
), checkField = (fieldName, typeName) => {
|
92
76
|
const field = fieldMap[fieldName];
|
93
|
-
let isAllowedType =
|
77
|
+
let isAllowedType = !1;
|
94
78
|
if (field) {
|
95
79
|
const type = field.gqlType;
|
96
|
-
|
97
|
-
isAllowedType = type.kind === import_graphql.Kind.NON_NULL_TYPE && type.gqlType.kind === import_graphql.Kind.NAMED_TYPE && type.gqlType.name.value === "Boolean";
|
98
|
-
} else if (type.kind === import_graphql.Kind.NAMED_TYPE) {
|
99
|
-
isAllowedType = type.name.value === "String" || (0, import_graphql.isScalarType)(schema.getType(type.name.value));
|
100
|
-
}
|
80
|
+
typeName === "Boolean" ? isAllowedType = type.kind === import_graphql.Kind.NON_NULL_TYPE && type.gqlType.kind === import_graphql.Kind.NAMED_TYPE && type.gqlType.name.value === "Boolean" : type.kind === import_graphql.Kind.NAMED_TYPE && (isAllowedType = type.name.value === "String" || (0, import_graphql.isScalarType)(schema.getType(type.name.value)));
|
101
81
|
}
|
102
82
|
if (!isAllowedType) {
|
103
83
|
const returnType = typeName === "Boolean" ? "non-null Boolean" : "either String or Scalar, which can be null if there are no results";
|
@@ -107,10 +87,7 @@ const rule = {
|
|
107
87
|
});
|
108
88
|
}
|
109
89
|
};
|
110
|
-
checkField("hasPreviousPage", "Boolean");
|
111
|
-
checkField("hasNextPage", "Boolean");
|
112
|
-
checkField("startCursor", "String");
|
113
|
-
checkField("endCursor", "String");
|
90
|
+
checkField("hasPreviousPage", "Boolean"), checkField("hasNextPage", "Boolean"), checkField("startCursor", "String"), checkField("endCursor", "String");
|
114
91
|
}
|
115
92
|
};
|
116
93
|
}
|
@@ -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 type: "array";
|
@@ -5,46 +5,36 @@ 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_deprecation_date_exports = {};
|
20
17
|
__export(require_deprecation_date_exports, {
|
21
18
|
rule: () => rule
|
22
19
|
});
|
23
20
|
module.exports = __toCommonJS(require_deprecation_date_exports);
|
24
|
-
var import_estree_converter = require("../estree-converter/index.js");
|
25
|
-
|
26
|
-
const DATE_REGEX = /^\d{2}\/\d{2}\/\d{4}$/;
|
27
|
-
const MESSAGE_REQUIRE_DATE = "MESSAGE_REQUIRE_DATE";
|
28
|
-
const MESSAGE_INVALID_FORMAT = "MESSAGE_INVALID_FORMAT";
|
29
|
-
const MESSAGE_INVALID_DATE = "MESSAGE_INVALID_DATE";
|
30
|
-
const MESSAGE_CAN_BE_REMOVED = "MESSAGE_CAN_BE_REMOVED";
|
31
|
-
const schema = {
|
21
|
+
var import_estree_converter = require("../estree-converter/index.js"), import_utils = require("../utils.js");
|
22
|
+
const DATE_REGEX = /^\d{2}\/\d{2}\/\d{4}$/, MESSAGE_REQUIRE_DATE = "MESSAGE_REQUIRE_DATE", MESSAGE_INVALID_FORMAT = "MESSAGE_INVALID_FORMAT", MESSAGE_INVALID_DATE = "MESSAGE_INVALID_DATE", MESSAGE_CAN_BE_REMOVED = "MESSAGE_CAN_BE_REMOVED", schema = {
|
32
23
|
type: "array",
|
33
24
|
maxItems: 1,
|
34
25
|
items: {
|
35
26
|
type: "object",
|
36
|
-
additionalProperties:
|
27
|
+
additionalProperties: !1,
|
37
28
|
properties: {
|
38
29
|
argumentName: {
|
39
30
|
type: "string"
|
40
31
|
}
|
41
32
|
}
|
42
33
|
}
|
43
|
-
}
|
44
|
-
const rule = {
|
34
|
+
}, rule = {
|
45
35
|
meta: {
|
46
36
|
type: "suggestion",
|
47
|
-
hasSuggestions:
|
37
|
+
hasSuggestions: !0,
|
48
38
|
docs: {
|
49
39
|
category: "Schema",
|
50
40
|
description: "Require deletion date on `@deprecated` directive. Suggest removing deprecated things after deprecated date.",
|
@@ -100,9 +90,7 @@ const rule = {
|
|
100
90
|
create(context) {
|
101
91
|
return {
|
102
92
|
"Directive[name.value=deprecated]"(node) {
|
103
|
-
|
104
|
-
const argName = ((_a = context.options[0]) == null ? void 0 : _a.argumentName) || "deletionDate";
|
105
|
-
const deletionDateNode = (_b = node.arguments) == null ? void 0 : _b.find((arg) => arg.name.value === argName);
|
93
|
+
const argName = context.options[0]?.argumentName || "deletionDate", deletionDateNode = node.arguments?.find((arg) => arg.name.value === argName);
|
106
94
|
if (!deletionDateNode) {
|
107
95
|
context.report({
|
108
96
|
node: node.name,
|
@@ -114,8 +102,7 @@ const rule = {
|
|
114
102
|
return;
|
115
103
|
}
|
116
104
|
const deletionDate = (0, import_estree_converter.valueFromNode)(deletionDateNode.value);
|
117
|
-
|
118
|
-
if (!isValidDate) {
|
105
|
+
if (!DATE_REGEX.test(deletionDate)) {
|
119
106
|
context.report({
|
120
107
|
node: deletionDateNode.value,
|
121
108
|
messageId: MESSAGE_INVALID_FORMAT,
|
@@ -124,8 +111,7 @@ const rule = {
|
|
124
111
|
return;
|
125
112
|
}
|
126
113
|
let [day, month, year] = deletionDate.split("/");
|
127
|
-
day = day.padStart(2, "0");
|
128
|
-
month = month.padStart(2, "0");
|
114
|
+
day = day.padStart(2, "0"), month = month.padStart(2, "0");
|
129
115
|
const deletionDateInMS = Date.parse(`${year}-${month}-${day}`);
|
130
116
|
if (Number.isNaN(deletionDateInMS)) {
|
131
117
|
context.report({
|
@@ -138,10 +124,8 @@ const rule = {
|
|
138
124
|
});
|
139
125
|
return;
|
140
126
|
}
|
141
|
-
|
142
|
-
|
143
|
-
const { parent } = node;
|
144
|
-
const nodeName = parent.name.value;
|
127
|
+
if (Date.now() > deletionDateInMS) {
|
128
|
+
const { parent } = node, nodeName = parent.name.value;
|
145
129
|
context.report({
|
146
130
|
node: parent.name,
|
147
131
|
messageId: MESSAGE_CAN_BE_REMOVED,
|
@@ -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,31 +5,27 @@ 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_deprecation_reason_exports = {};
|
20
17
|
__export(require_deprecation_reason_exports, {
|
21
18
|
rule: () => rule
|
22
19
|
});
|
23
20
|
module.exports = __toCommonJS(require_deprecation_reason_exports);
|
24
|
-
var import_estree_converter = require("../estree-converter/index.js");
|
25
|
-
var import_utils = require("../utils.js");
|
21
|
+
var import_estree_converter = require("../estree-converter/index.js"), import_utils = require("../utils.js");
|
26
22
|
const rule = {
|
27
23
|
meta: {
|
28
24
|
docs: {
|
29
25
|
description: "Require all deprecation directives to specify a reason.",
|
30
26
|
category: "Schema",
|
31
27
|
url: "https://the-guild.dev/graphql/eslint/rules/require-deprecation-reason",
|
32
|
-
recommended:
|
28
|
+
recommended: !0,
|
33
29
|
examples: [
|
34
30
|
{
|
35
31
|
title: "Incorrect",
|
@@ -72,17 +68,13 @@ const rule = {
|
|
72
68
|
create(context) {
|
73
69
|
return {
|
74
70
|
"Directive[name.value=deprecated]"(node) {
|
75
|
-
|
76
|
-
const reasonArgument = (_a = node.arguments) == null ? void 0 : _a.find(
|
71
|
+
const reasonArgument = node.arguments?.find(
|
77
72
|
(arg) => arg.name.value === "reason"
|
78
73
|
);
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
message: `Deprecation reason is required for ${(0, import_utils.getNodeName)(node.parent)}.`
|
84
|
-
});
|
85
|
-
}
|
74
|
+
reasonArgument && String((0, import_estree_converter.valueFromNode)(reasonArgument.value)).trim() || context.report({
|
75
|
+
node: node.name,
|
76
|
+
message: `Deprecation reason is required for ${(0, import_utils.getNodeName)(node.parent)}.`
|
77
|
+
});
|
86
78
|
}
|
87
79
|
};
|
88
80
|
}
|
@@ -1,11 +1,12 @@
|
|
1
1
|
import { Kind } from 'graphql';
|
2
|
-
import {
|
3
|
-
import '@graphql-tools/utils';
|
2
|
+
import { GraphQLESLintRule } from '../types.js';
|
4
3
|
import 'eslint';
|
5
4
|
import 'estree';
|
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_ID = "require-description";
|
11
12
|
declare const ALLOWED_KINDS: readonly [Kind.OBJECT_TYPE_DEFINITION, Kind.INTERFACE_TYPE_DEFINITION, Kind.ENUM_TYPE_DEFINITION, Kind.SCALAR_TYPE_DEFINITION, Kind.INPUT_OBJECT_TYPE_DEFINITION, Kind.UNION_TYPE_DEFINITION, Kind.DIRECTIVE_DEFINITION, Kind.FIELD_DEFINITION, Kind.INPUT_VALUE_DEFINITION, Kind.ENUM_VALUE_DEFINITION, Kind.OPERATION_DEFINITION];
|