@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.
Files changed (222) hide show
  1. package/README.md +2 -0
  2. package/cjs/cache.js +10 -19
  3. package/cjs/configs/index.d.ts +42 -16
  4. package/cjs/configs/index.js +10 -19
  5. package/cjs/configs/operations-all.d.ts +4 -3
  6. package/cjs/configs/operations-all.js +5 -4
  7. package/cjs/configs/operations-recommended.d.ts +3 -1
  8. package/cjs/configs/operations-recommended.js +3 -1
  9. package/cjs/configs/schema-all.d.ts +6 -1
  10. package/cjs/configs/schema-all.js +5 -2
  11. package/cjs/configs/schema-recommended.d.ts +19 -1
  12. package/cjs/configs/schema-recommended.js +22 -2
  13. package/cjs/documents.js +17 -32
  14. package/cjs/estree-converter/converter.js +14 -27
  15. package/cjs/estree-converter/index.js +4 -7
  16. package/cjs/estree-converter/types.js +3 -5
  17. package/cjs/estree-converter/utils.d.ts +2 -3
  18. package/cjs/estree-converter/utils.js +15 -45
  19. package/cjs/flat-configs.d.ts +59 -12
  20. package/cjs/flat-configs.js +9 -14
  21. package/cjs/graphql-config.d.ts +4 -3
  22. package/cjs/graphql-config.js +23 -44
  23. package/cjs/index.d.ts +10 -4
  24. package/cjs/index.js +8 -16
  25. package/cjs/parser.d.ts +4 -3
  26. package/cjs/parser.js +38 -45
  27. package/cjs/processor.d.ts +5 -1
  28. package/cjs/processor.js +25 -57
  29. package/cjs/rules/alphabetize.d.ts +6 -16
  30. package/cjs/rules/alphabetize.js +60 -132
  31. package/cjs/rules/description-style.d.ts +4 -3
  32. package/cjs/rules/description-style.js +11 -18
  33. package/cjs/rules/graphql-js-validation.d.ts +4 -3
  34. package/cjs/rules/graphql-js-validation.js +151 -225
  35. package/cjs/rules/index.d.ts +15 -13
  36. package/cjs/rules/index.js +8 -45
  37. package/cjs/rules/input-name.d.ts +4 -3
  38. package/cjs/rules/input-name.js +43 -59
  39. package/cjs/rules/lone-executable-definition.d.ts +6 -5
  40. package/cjs/rules/lone-executable-definition.js +14 -28
  41. package/cjs/rules/match-document-filename.d.ts +4 -3
  42. package/cjs/rules/match-document-filename.js +39 -70
  43. package/cjs/rules/naming-convention.d.ts +4 -3
  44. package/cjs/rules/naming-convention.js +56 -74
  45. package/cjs/rules/no-anonymous-operations.d.ts +4 -3
  46. package/cjs/rules/no-anonymous-operations.js +11 -18
  47. package/cjs/rules/no-deprecated.d.ts +4 -3
  48. package/cjs/rules/no-deprecated.js +15 -29
  49. package/cjs/rules/no-duplicate-fields.d.ts +4 -3
  50. package/cjs/rules/no-duplicate-fields.js +13 -23
  51. package/cjs/rules/no-hashtag-description.d.ts +4 -3
  52. package/cjs/rules/no-hashtag-description.js +16 -29
  53. package/cjs/rules/no-one-place-fragments.d.ts +4 -3
  54. package/cjs/rules/no-one-place-fragments.js +17 -29
  55. package/cjs/rules/no-root-type.d.ts +4 -3
  56. package/cjs/rules/no-root-type.js +15 -25
  57. package/cjs/rules/no-scalar-result-type-on-mutation.d.ts +4 -3
  58. package/cjs/rules/no-scalar-result-type-on-mutation.js +18 -30
  59. package/cjs/rules/no-typename-prefix.d.ts +4 -3
  60. package/cjs/rules/no-typename-prefix.js +26 -33
  61. package/cjs/rules/no-unreachable-types.d.ts +4 -3
  62. package/cjs/rules/no-unreachable-types.js +25 -47
  63. package/cjs/rules/no-unused-fields.d.ts +4 -3
  64. package/cjs/rules/no-unused-fields.js +24 -49
  65. package/cjs/rules/relay-arguments.d.ts +4 -3
  66. package/cjs/rules/relay-arguments.js +20 -43
  67. package/cjs/rules/relay-connection-types.d.ts +4 -3
  68. package/cjs/rules/relay-connection-types.js +14 -45
  69. package/cjs/rules/relay-edge-types.d.ts +4 -3
  70. package/cjs/rules/relay-edge-types.js +48 -99
  71. package/cjs/rules/relay-page-info.d.ts +4 -3
  72. package/cjs/rules/relay-page-info.js +21 -44
  73. package/cjs/rules/require-deprecation-date.d.ts +4 -3
  74. package/cjs/rules/require-deprecation-date.js +15 -31
  75. package/cjs/rules/require-deprecation-reason.d.ts +4 -3
  76. package/cjs/rules/require-deprecation-reason.js +12 -20
  77. package/cjs/rules/require-description.d.ts +4 -3
  78. package/cjs/rules/require-description.js +39 -65
  79. package/cjs/rules/require-field-of-type-query-in-mutation-result.d.ts +4 -3
  80. package/cjs/rules/require-field-of-type-query-in-mutation-result.js +16 -31
  81. package/cjs/rules/require-import-fragment.d.ts +4 -3
  82. package/cjs/rules/require-import-fragment.js +22 -40
  83. package/cjs/rules/require-nullable-fields-with-oneof.d.ts +4 -3
  84. package/cjs/rules/require-nullable-fields-with-oneof.js +11 -22
  85. package/cjs/rules/require-nullable-result-in-root.d.ts +4 -3
  86. package/cjs/rules/require-nullable-result-in-root.js +34 -44
  87. package/cjs/rules/{require-id-when-available.d.ts → require-selections.d.ts} +4 -3
  88. package/cjs/rules/require-selections.js +198 -0
  89. package/cjs/rules/require-type-pattern-with-oneof.d.ts +4 -3
  90. package/cjs/rules/require-type-pattern-with-oneof.js +15 -23
  91. package/cjs/rules/selection-set-depth.d.ts +4 -3
  92. package/cjs/rules/selection-set-depth.js +18 -34
  93. package/cjs/rules/strict-id-in-types.d.ts +4 -3
  94. package/cjs/rules/strict-id-in-types.js +25 -43
  95. package/cjs/rules/{no-case-insensitive-enum-values-duplicates.d.ts → unique-enum-value-names.d.ts} +4 -3
  96. package/cjs/rules/{no-case-insensitive-enum-values-duplicates.js → unique-enum-value-names.js} +16 -21
  97. package/cjs/rules/unique-fragment-name.d.ts +3 -2
  98. package/cjs/rules/unique-fragment-name.js +24 -36
  99. package/cjs/rules/unique-operation-name.d.ts +4 -3
  100. package/cjs/rules/unique-operation-name.js +10 -12
  101. package/cjs/schema.d.ts +4 -3
  102. package/cjs/schema.js +14 -27
  103. package/cjs/siblings.d.ts +24 -8
  104. package/cjs/siblings.js +42 -82
  105. package/cjs/types.d.ts +74 -7
  106. package/cjs/types.js +3 -5
  107. package/cjs/utils.d.ts +3 -2
  108. package/cjs/utils.js +27 -44
  109. package/esm/cache.js +4 -8
  110. package/esm/{chunk-BMTV3EA2.js → chunk-U3TKCM4X.js} +1 -1
  111. package/esm/configs/index.d.mts +42 -16
  112. package/esm/configs/index.js +4 -4
  113. package/esm/configs/operations-all.d.mts +4 -3
  114. package/esm/configs/operations-all.js +6 -5
  115. package/esm/configs/operations-recommended.d.mts +3 -1
  116. package/esm/configs/operations-recommended.js +4 -2
  117. package/esm/configs/schema-all.d.mts +6 -1
  118. package/esm/configs/schema-all.js +6 -3
  119. package/esm/configs/schema-recommended.d.mts +19 -1
  120. package/esm/configs/schema-recommended.js +23 -3
  121. package/esm/configs/{relay.js → schema-relay.js} +4 -4
  122. package/esm/documents.js +10 -17
  123. package/esm/estree-converter/converter.js +9 -18
  124. package/esm/estree-converter/utils.d.mts +2 -3
  125. package/esm/estree-converter/utils.js +11 -38
  126. package/esm/flat-configs.d.mts +59 -12
  127. package/esm/flat-configs.js +4 -5
  128. package/esm/graphql-config.d.mts +4 -3
  129. package/esm/graphql-config.js +18 -34
  130. package/esm/index.d.mts +10 -4
  131. package/esm/index.js +1 -1
  132. package/esm/parser.d.mts +4 -3
  133. package/esm/parser.js +33 -27
  134. package/esm/processor.d.mts +5 -1
  135. package/esm/processor.js +21 -46
  136. package/esm/rules/alphabetize.d.mts +6 -16
  137. package/esm/rules/alphabetize.js +53 -118
  138. package/esm/rules/description-style.d.mts +4 -3
  139. package/esm/rules/description-style.js +7 -11
  140. package/esm/rules/graphql-js-validation.d.mts +4 -3
  141. package/esm/rules/graphql-js-validation.js +178 -218
  142. package/esm/rules/index.d.mts +15 -13
  143. package/esm/rules/index.js +5 -5
  144. package/esm/rules/input-name.d.mts +4 -3
  145. package/esm/rules/input-name.js +39 -52
  146. package/esm/rules/lone-executable-definition.d.mts +6 -5
  147. package/esm/rules/lone-executable-definition.js +10 -20
  148. package/esm/rules/match-document-filename.d.mts +4 -3
  149. package/esm/rules/match-document-filename.js +35 -61
  150. package/esm/rules/naming-convention.d.mts +4 -3
  151. package/esm/rules/naming-convention.js +51 -65
  152. package/esm/rules/no-anonymous-operations.d.mts +4 -3
  153. package/esm/rules/no-anonymous-operations.js +6 -9
  154. package/esm/rules/no-deprecated.d.mts +4 -3
  155. package/esm/rules/no-deprecated.js +10 -20
  156. package/esm/rules/no-duplicate-fields.d.mts +4 -3
  157. package/esm/rules/no-duplicate-fields.js +9 -16
  158. package/esm/rules/no-hashtag-description.d.mts +4 -3
  159. package/esm/rules/no-hashtag-description.js +11 -20
  160. package/esm/rules/no-one-place-fragments.d.mts +4 -3
  161. package/esm/rules/no-one-place-fragments.js +12 -19
  162. package/esm/rules/no-root-type.d.mts +4 -3
  163. package/esm/rules/no-root-type.js +11 -18
  164. package/esm/rules/no-scalar-result-type-on-mutation.d.mts +4 -3
  165. package/esm/rules/no-scalar-result-type-on-mutation.js +13 -21
  166. package/esm/rules/no-typename-prefix.d.mts +4 -3
  167. package/esm/rules/no-typename-prefix.js +22 -26
  168. package/esm/rules/no-unreachable-types.d.mts +4 -3
  169. package/esm/rules/no-unreachable-types.js +18 -33
  170. package/esm/rules/no-unused-fields.d.mts +4 -3
  171. package/esm/rules/no-unused-fields.js +19 -40
  172. package/esm/rules/relay-arguments.d.mts +4 -3
  173. package/esm/rules/relay-arguments.js +15 -34
  174. package/esm/rules/relay-connection-types.d.mts +4 -3
  175. package/esm/rules/relay-connection-types.js +10 -38
  176. package/esm/rules/relay-edge-types.d.mts +4 -3
  177. package/esm/rules/relay-edge-types.js +43 -89
  178. package/esm/rules/relay-page-info.d.mts +4 -3
  179. package/esm/rules/relay-page-info.js +16 -34
  180. package/esm/rules/require-deprecation-date.d.mts +4 -3
  181. package/esm/rules/require-deprecation-date.js +10 -22
  182. package/esm/rules/require-deprecation-reason.d.mts +4 -3
  183. package/esm/rules/require-deprecation-reason.js +7 -11
  184. package/esm/rules/require-description.d.mts +4 -3
  185. package/esm/rules/require-description.js +34 -55
  186. package/esm/rules/require-field-of-type-query-in-mutation-result.d.mts +4 -3
  187. package/esm/rules/require-field-of-type-query-in-mutation-result.js +11 -22
  188. package/esm/rules/require-import-fragment.d.mts +4 -3
  189. package/esm/rules/require-import-fragment.js +14 -26
  190. package/esm/rules/require-nullable-fields-with-oneof.d.mts +4 -3
  191. package/esm/rules/require-nullable-fields-with-oneof.js +6 -13
  192. package/esm/rules/require-nullable-result-in-root.d.mts +4 -3
  193. package/esm/rules/require-nullable-result-in-root.js +29 -35
  194. package/esm/rules/{require-id-when-available.d.mts → require-selections.d.mts} +4 -3
  195. package/esm/rules/{require-id-when-available.js → require-selections.js} +43 -80
  196. package/esm/rules/require-type-pattern-with-oneof.d.mts +4 -3
  197. package/esm/rules/require-type-pattern-with-oneof.js +11 -16
  198. package/esm/rules/selection-set-depth.d.mts +4 -3
  199. package/esm/rules/selection-set-depth.js +11 -20
  200. package/esm/rules/strict-id-in-types.d.mts +4 -3
  201. package/esm/rules/strict-id-in-types.js +20 -34
  202. package/esm/rules/{no-case-insensitive-enum-values-duplicates.d.mts → unique-enum-value-names.d.mts} +4 -3
  203. package/esm/rules/{no-case-insensitive-enum-values-duplicates.js → unique-enum-value-names.js} +8 -9
  204. package/esm/rules/unique-fragment-name.d.mts +3 -2
  205. package/esm/rules/unique-fragment-name.js +20 -27
  206. package/esm/rules/unique-operation-name.d.mts +4 -3
  207. package/esm/rules/unique-operation-name.js +6 -5
  208. package/esm/schema.d.mts +4 -3
  209. package/esm/schema.js +7 -12
  210. package/esm/siblings.d.mts +24 -8
  211. package/esm/siblings.js +37 -73
  212. package/esm/types.d.mts +74 -7
  213. package/esm/utils.d.mts +3 -2
  214. package/esm/utils.js +20 -31
  215. package/index.browser.mjs +5323 -0
  216. package/package.json +8 -13
  217. package/cjs/rules/require-id-when-available.js +0 -241
  218. package/cjs/types-8d5f4ae0.d.ts +0 -107
  219. package/esm/types-ace77d86.d.ts +0 -107
  220. /package/cjs/configs/{relay.d.ts → schema-relay.d.ts} +0 -0
  221. /package/cjs/configs/{relay.js → schema-relay.js} +0 -0
  222. /package/esm/configs/{relay.d.mts → schema-relay.d.mts} +0 -0
@@ -1,12 +1,6 @@
1
- import "../chunk-BMTV3EA2.js";
1
+ import "../chunk-U3TKCM4X.js";
2
2
  import { Kind } from "graphql";
3
- const MUST_BE_OBJECT_TYPE = "MUST_BE_OBJECT_TYPE";
4
- const MUST_CONTAIN_FIELD_EDGES = "MUST_CONTAIN_FIELD_EDGES";
5
- const MUST_CONTAIN_FIELD_PAGE_INFO = "MUST_CONTAIN_FIELD_PAGE_INFO";
6
- const MUST_HAVE_CONNECTION_SUFFIX = "MUST_HAVE_CONNECTION_SUFFIX";
7
- const EDGES_FIELD_MUST_RETURN_LIST_TYPE = "EDGES_FIELD_MUST_RETURN_LIST_TYPE";
8
- const PAGE_INFO_FIELD_MUST_RETURN_NON_NULL_TYPE = "PAGE_INFO_FIELD_MUST_RETURN_NON_NULL_TYPE";
9
- const NON_OBJECT_TYPES = [
3
+ const MUST_BE_OBJECT_TYPE = "MUST_BE_OBJECT_TYPE", MUST_CONTAIN_FIELD_EDGES = "MUST_CONTAIN_FIELD_EDGES", MUST_CONTAIN_FIELD_PAGE_INFO = "MUST_CONTAIN_FIELD_PAGE_INFO", MUST_HAVE_CONNECTION_SUFFIX = "MUST_HAVE_CONNECTION_SUFFIX", EDGES_FIELD_MUST_RETURN_LIST_TYPE = "EDGES_FIELD_MUST_RETURN_LIST_TYPE", PAGE_INFO_FIELD_MUST_RETURN_NON_NULL_TYPE = "PAGE_INFO_FIELD_MUST_RETURN_NON_NULL_TYPE", NON_OBJECT_TYPES = [
10
4
  Kind.SCALAR_TYPE_DEFINITION,
11
5
  Kind.UNION_TYPE_DEFINITION,
12
6
  Kind.UNION_TYPE_EXTENSION,
@@ -16,17 +10,7 @@ const NON_OBJECT_TYPES = [
16
10
  Kind.ENUM_TYPE_EXTENSION,
17
11
  Kind.INTERFACE_TYPE_DEFINITION,
18
12
  Kind.INTERFACE_TYPE_EXTENSION
19
- ];
20
- const notConnectionTypesSelector = `:matches(${NON_OBJECT_TYPES})[name.value=/Connection$/] > .name`;
21
- const hasEdgesField = (node) => {
22
- var _a;
23
- return (_a = node.fields) == null ? void 0 : _a.some((field) => field.name.value === "edges");
24
- };
25
- const hasPageInfoField = (node) => {
26
- var _a;
27
- return (_a = node.fields) == null ? void 0 : _a.some((field) => field.name.value === "pageInfo");
28
- };
29
- const rule = {
13
+ ], notConnectionTypesSelector = `:matches(${NON_OBJECT_TYPES})[name.value=/Connection$/] > .name`, hasEdgesField = (node) => node.fields?.some((field) => field.name.value === "edges"), hasPageInfoField = (node) => node.fields?.some((field) => field.name.value === "pageInfo"), rule = {
30
14
  meta: {
31
15
  type: "problem",
32
16
  docs: {
@@ -38,9 +22,10 @@ const rule = {
38
22
  "- Connection type must be an Object type",
39
23
  "- Connection type must contain a field `edges` that return a list type that wraps an edge type",
40
24
  "- Connection type must contain a field `pageInfo` that return a non-null `PageInfo` Object type"
41
- ].join("\n"),
25
+ ].join(`
26
+ `),
42
27
  url: "https://the-guild.dev/graphql/eslint/rules/relay-connection-types",
43
- isDisabledForAllConfig: true,
28
+ isDisabledForAllConfig: !0,
44
29
  examples: [
45
30
  {
46
31
  title: "Incorrect",
@@ -85,29 +70,16 @@ const rule = {
85
70
  context.report({ node, messageId: MUST_BE_OBJECT_TYPE });
86
71
  },
87
72
  ":matches(ObjectTypeDefinition, ObjectTypeExtension)[name.value!=/Connection$/]"(node) {
88
- if (hasEdgesField(node) && hasPageInfoField(node)) {
89
- context.report({ node: node.name, messageId: MUST_HAVE_CONNECTION_SUFFIX });
90
- }
73
+ hasEdgesField(node) && hasPageInfoField(node) && context.report({ node: node.name, messageId: MUST_HAVE_CONNECTION_SUFFIX });
91
74
  },
92
75
  ":matches(ObjectTypeDefinition, ObjectTypeExtension)[name.value=/Connection$/]"(node) {
93
- if (!hasEdgesField(node)) {
94
- context.report({ node: node.name, messageId: MUST_CONTAIN_FIELD_EDGES });
95
- }
96
- if (!hasPageInfoField(node)) {
97
- context.report({ node: node.name, messageId: MUST_CONTAIN_FIELD_PAGE_INFO });
98
- }
76
+ hasEdgesField(node) || context.report({ node: node.name, messageId: MUST_CONTAIN_FIELD_EDGES }), hasPageInfoField(node) || context.report({ node: node.name, messageId: MUST_CONTAIN_FIELD_PAGE_INFO });
99
77
  },
100
78
  ":matches(ObjectTypeDefinition, ObjectTypeExtension)[name.value=/Connection$/] > FieldDefinition[name.value=edges] > .gqlType"(node) {
101
- const isListType = node.kind === Kind.LIST_TYPE || node.kind === Kind.NON_NULL_TYPE && node.gqlType.kind === Kind.LIST_TYPE;
102
- if (!isListType) {
103
- context.report({ node, messageId: EDGES_FIELD_MUST_RETURN_LIST_TYPE });
104
- }
79
+ node.kind === Kind.LIST_TYPE || node.kind === Kind.NON_NULL_TYPE && node.gqlType.kind === Kind.LIST_TYPE || context.report({ node, messageId: EDGES_FIELD_MUST_RETURN_LIST_TYPE });
105
80
  },
106
81
  ":matches(ObjectTypeDefinition, ObjectTypeExtension)[name.value=/Connection$/] > FieldDefinition[name.value=pageInfo] > .gqlType"(node) {
107
- const isNonNullPageInfoType = node.kind === Kind.NON_NULL_TYPE && node.gqlType.kind === Kind.NAMED_TYPE && node.gqlType.name.value === "PageInfo";
108
- if (!isNonNullPageInfoType) {
109
- context.report({ node, messageId: PAGE_INFO_FIELD_MUST_RETURN_NON_NULL_TYPE });
110
- }
82
+ node.kind === Kind.NON_NULL_TYPE && node.gqlType.kind === Kind.NAMED_TYPE && node.gqlType.name.value === "PageInfo" || context.report({ node, messageId: PAGE_INFO_FIELD_MUST_RETURN_NON_NULL_TYPE });
111
83
  }
112
84
  };
113
85
  }
@@ -1,11 +1,12 @@
1
1
  import { FromSchema } from 'json-schema-to-ts';
2
- import { f as GraphQLESLintRule } from '../types-ace77d86.js';
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 'graphql-config';
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";
@@ -1,4 +1,4 @@
1
- import "../chunk-BMTV3EA2.js";
1
+ import "../chunk-U3TKCM4X.js";
2
2
  import { getDocumentNodeFromSchema } from "@graphql-tools/utils";
3
3
  import {
4
4
  isObjectType,
@@ -7,67 +7,50 @@ import {
7
7
  visit
8
8
  } from "graphql";
9
9
  import { getTypeName, requireGraphQLSchemaFromContext } from "../utils.js";
10
- const RULE_ID = "relay-edge-types";
11
- const MESSAGE_MUST_BE_OBJECT_TYPE = "MESSAGE_MUST_BE_OBJECT_TYPE";
12
- const MESSAGE_MISSING_EDGE_SUFFIX = "MESSAGE_MISSING_EDGE_SUFFIX";
13
- const MESSAGE_LIST_TYPE_ONLY_EDGE_TYPE = "MESSAGE_LIST_TYPE_ONLY_EDGE_TYPE";
14
- const MESSAGE_SHOULD_IMPLEMENTS_NODE = "MESSAGE_SHOULD_IMPLEMENTS_NODE";
10
+ 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";
15
11
  let edgeTypesCache;
16
12
  function getEdgeTypes(schema2) {
17
- if (edgeTypesCache) {
13
+ if (edgeTypesCache)
18
14
  return edgeTypesCache;
19
- }
20
- const edgeTypes = /* @__PURE__ */ new Set();
21
- const visitor = {
15
+ const edgeTypes = /* @__PURE__ */ new Set(), visitor = {
22
16
  ObjectTypeDefinition(node) {
23
- var _a;
24
- const typeName = node.name.value;
25
- const hasConnectionSuffix = typeName.endsWith("Connection");
26
- if (!hasConnectionSuffix) {
17
+ if (!node.name.value.endsWith("Connection"))
27
18
  return;
28
- }
29
- const edges = (_a = node.fields) == null ? void 0 : _a.find((field) => field.name.value === "edges");
19
+ const edges = node.fields?.find((field) => field.name.value === "edges");
30
20
  if (edges) {
31
- const edgesTypeName = getTypeName(edges);
32
- const edgesType = schema2.getType(edgesTypeName);
33
- if (isObjectType(edgesType)) {
34
- edgeTypes.add(edgesTypeName);
35
- }
21
+ const edgesTypeName = getTypeName(edges), edgesType = schema2.getType(edgesTypeName);
22
+ isObjectType(edgesType) && edgeTypes.add(edgesTypeName);
36
23
  }
37
24
  }
38
- };
39
- const astNode = getDocumentNodeFromSchema(schema2);
40
- visit(astNode, visitor);
41
- edgeTypesCache = edgeTypes;
42
- return edgeTypesCache;
25
+ }, astNode = getDocumentNodeFromSchema(schema2);
26
+ return visit(astNode, visitor), edgeTypesCache = edgeTypes, edgeTypesCache;
43
27
  }
44
28
  const schema = {
45
29
  type: "array",
46
30
  maxItems: 1,
47
31
  items: {
48
32
  type: "object",
49
- additionalProperties: false,
33
+ additionalProperties: !1,
50
34
  minProperties: 1,
51
35
  properties: {
52
36
  withEdgeSuffix: {
53
37
  type: "boolean",
54
- default: true,
38
+ default: !0,
55
39
  description: 'Edge type name must end in "Edge".'
56
40
  },
57
41
  shouldImplementNode: {
58
42
  type: "boolean",
59
- default: true,
43
+ default: !0,
60
44
  description: "Edge type's field `node` must implement `Node` interface."
61
45
  },
62
46
  listTypeCanWrapOnlyEdgeType: {
63
47
  type: "boolean",
64
- default: true,
48
+ default: !0,
65
49
  description: "A list type should only wrap an edge type."
66
50
  }
67
51
  }
68
52
  }
69
- };
70
- const rule = {
53
+ }, rule = {
71
54
  meta: {
72
55
  type: "problem",
73
56
  docs: {
@@ -82,10 +65,11 @@ const rule = {
82
65
  '- Edge type name must end in "Edge" _(optional)_',
83
66
  "- Edge type's field `node` must implement `Node` interface _(optional)_",
84
67
  "- A list type should only wrap an edge type _(optional)_"
85
- ].join("\n"),
68
+ ].join(`
69
+ `),
86
70
  url: `https://the-guild.dev/graphql/eslint/rules/${RULE_ID}`,
87
- isDisabledForAllConfig: true,
88
- requiresSchema: true,
71
+ isDisabledForAllConfig: !0,
72
+ requiresSchema: !0,
89
73
  examples: [
90
74
  {
91
75
  title: "Correct",
@@ -110,42 +94,28 @@ const rule = {
110
94
  schema
111
95
  },
112
96
  create(context) {
113
- const schema2 = requireGraphQLSchemaFromContext(RULE_ID, context);
114
- const edgeTypes = getEdgeTypes(schema2);
115
- const options = {
116
- withEdgeSuffix: true,
117
- shouldImplementNode: true,
118
- listTypeCanWrapOnlyEdgeType: true,
97
+ const schema2 = requireGraphQLSchemaFromContext(RULE_ID, context), edgeTypes = getEdgeTypes(schema2), options = {
98
+ withEdgeSuffix: !0,
99
+ shouldImplementNode: !0,
100
+ listTypeCanWrapOnlyEdgeType: !0,
119
101
  ...context.options[0]
120
- };
121
- const isNamedOrNonNullNamed = (node) => node.kind === Kind.NAMED_TYPE || node.kind === Kind.NON_NULL_TYPE && node.gqlType.kind === Kind.NAMED_TYPE;
122
- const checkNodeField = (node) => {
123
- var _a, _b;
124
- const nodeField = (_a = node.fields) == null ? void 0 : _a.find((field) => field.name.value === "node");
125
- const message = "return either a Scalar, Enum, Object, Interface, Union, or a non-null wrapper around one of those types.";
126
- if (!nodeField) {
102
+ }, isNamedOrNonNullNamed = (node) => node.kind === Kind.NAMED_TYPE || node.kind === Kind.NON_NULL_TYPE && node.gqlType.kind === Kind.NAMED_TYPE, checkNodeField = (node) => {
103
+ 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.";
104
+ if (!nodeField)
127
105
  context.report({
128
106
  node: node.name,
129
107
  message: `Edge type must contain a field \`node\` that ${message}`
130
108
  });
131
- } else if (!isNamedOrNonNullNamed(nodeField.gqlType)) {
109
+ else if (!isNamedOrNonNullNamed(nodeField.gqlType))
132
110
  context.report({ node: nodeField.name, message: `Field \`node\` must ${message}` });
133
- } else if (options.shouldImplementNode) {
134
- const nodeReturnTypeName = getTypeName(nodeField.gqlType.rawNode());
135
- const type = schema2.getType(nodeReturnTypeName);
136
- if (!isObjectType(type)) {
111
+ else if (options.shouldImplementNode) {
112
+ const nodeReturnTypeName = getTypeName(nodeField.gqlType.rawNode()), type = schema2.getType(nodeReturnTypeName);
113
+ if (!isObjectType(type))
137
114
  return;
138
- }
139
- const implementsNode = (_b = type.astNode.interfaces) == null ? void 0 : _b.some((n) => n.name.value === "Node");
140
- if (!implementsNode) {
141
- context.report({ node: node.name, messageId: MESSAGE_SHOULD_IMPLEMENTS_NODE });
142
- }
115
+ type.astNode.interfaces?.some((n) => n.name.value === "Node") || context.report({ node: node.name, messageId: MESSAGE_SHOULD_IMPLEMENTS_NODE });
143
116
  }
144
- };
145
- const checkCursorField = (node) => {
146
- var _a;
147
- const cursorField = (_a = node.fields) == null ? void 0 : _a.find((field) => field.name.value === "cursor");
148
- const message = "return either a String, Scalar, or a non-null wrapper wrapper around one of those types.";
117
+ }, checkCursorField = (node) => {
118
+ 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.";
149
119
  if (!cursorField) {
150
120
  context.report({
151
121
  node: node.name,
@@ -154,39 +124,23 @@ const rule = {
154
124
  return;
155
125
  }
156
126
  const typeName = getTypeName(cursorField.rawNode());
157
- if (!isNamedOrNonNullNamed(cursorField.gqlType) || typeName !== "String" && !isScalarType(schema2.getType(typeName))) {
158
- context.report({ node: cursorField.name, message: `Field \`cursor\` must ${message}` });
159
- }
160
- };
161
- const listeners = {
127
+ (!isNamedOrNonNullNamed(cursorField.gqlType) || typeName !== "String" && !isScalarType(schema2.getType(typeName))) && context.report({ node: cursorField.name, message: `Field \`cursor\` must ${message}` });
128
+ }, listeners = {
162
129
  ":matches(ObjectTypeDefinition, ObjectTypeExtension)[name.value=/Connection$/] > FieldDefinition[name.value=edges] > .gqlType Name"(node) {
163
130
  const type = schema2.getType(node.value);
164
- if (!isObjectType(type)) {
165
- context.report({ node, messageId: MESSAGE_MUST_BE_OBJECT_TYPE });
166
- }
131
+ isObjectType(type) || context.report({ node, messageId: MESSAGE_MUST_BE_OBJECT_TYPE });
167
132
  },
168
133
  ":matches(ObjectTypeDefinition, ObjectTypeExtension)"(node) {
169
134
  const typeName = node.name.value;
170
- if (edgeTypes.has(typeName)) {
171
- checkNodeField(node);
172
- checkCursorField(node);
173
- if (options.withEdgeSuffix && !typeName.endsWith("Edge")) {
174
- context.report({ node: node.name, messageId: MESSAGE_MISSING_EDGE_SUFFIX });
175
- }
176
- }
135
+ edgeTypes.has(typeName) && (checkNodeField(node), checkCursorField(node), options.withEdgeSuffix && !typeName.endsWith("Edge") && context.report({ node: node.name, messageId: MESSAGE_MISSING_EDGE_SUFFIX }));
177
136
  }
178
137
  };
179
- if (options.listTypeCanWrapOnlyEdgeType) {
180
- listeners["FieldDefinition > .gqlType"] = (node) => {
181
- if (node.kind === Kind.LIST_TYPE || node.kind === Kind.NON_NULL_TYPE && node.gqlType.kind === Kind.LIST_TYPE) {
182
- const typeName = getTypeName(node.rawNode());
183
- if (!edgeTypes.has(typeName)) {
184
- context.report({ node, messageId: MESSAGE_LIST_TYPE_ONLY_EDGE_TYPE });
185
- }
186
- }
187
- };
188
- }
189
- return listeners;
138
+ return options.listTypeCanWrapOnlyEdgeType && (listeners["FieldDefinition > .gqlType"] = (node) => {
139
+ if (node.kind === Kind.LIST_TYPE || node.kind === Kind.NON_NULL_TYPE && node.gqlType.kind === Kind.LIST_TYPE) {
140
+ const typeName = getTypeName(node.rawNode());
141
+ edgeTypes.has(typeName) || context.report({ node, messageId: MESSAGE_LIST_TYPE_ONLY_EDGE_TYPE });
142
+ }
143
+ }), listeners;
190
144
  }
191
145
  };
192
146
  export {
@@ -1,11 +1,12 @@
1
- import { f as GraphQLESLintRule } from '../types-ace77d86.js';
2
- import '@graphql-tools/utils';
1
+ import { GraphQLESLintRule } from '../types.mjs';
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.mjs';
7
+ import '@graphql-tools/utils';
8
8
  import '../estree-converter/types.mjs';
9
+ import 'graphql-config';
9
10
 
10
11
  declare const rule: GraphQLESLintRule;
11
12
 
@@ -1,12 +1,9 @@
1
- import "../chunk-BMTV3EA2.js";
1
+ import "../chunk-U3TKCM4X.js";
2
2
  import { isScalarType, Kind } from "graphql";
3
3
  import { REPORT_ON_FIRST_CHARACTER, requireGraphQLSchemaFromContext } from "../utils.js";
4
4
  import { NON_OBJECT_TYPES } from "./relay-connection-types.js";
5
- const RULE_ID = "relay-page-info";
6
- const MESSAGE_MUST_EXIST = "MESSAGE_MUST_EXIST";
7
- const MESSAGE_MUST_BE_OBJECT_TYPE = "MESSAGE_MUST_BE_OBJECT_TYPE";
8
- const notPageInfoTypesSelector = `:matches(${NON_OBJECT_TYPES})[name.value=PageInfo] > .name`;
9
- let hasPageInfoChecked = false;
5
+ const RULE_ID = "relay-page-info", MESSAGE_MUST_EXIST = "MESSAGE_MUST_EXIST", MESSAGE_MUST_BE_OBJECT_TYPE = "MESSAGE_MUST_BE_OBJECT_TYPE", notPageInfoTypesSelector = `:matches(${NON_OBJECT_TYPES})[name.value=PageInfo] > .name`;
6
+ let hasPageInfoChecked = !1;
10
7
  const rule = {
11
8
  meta: {
12
9
  type: "problem",
@@ -18,7 +15,8 @@ const rule = {
18
15
  "- `PageInfo` must be an Object type",
19
16
  "- `PageInfo` must contain fields `hasPreviousPage` and `hasNextPage`, that return non-null Boolean",
20
17
  "- `PageInfo` must contain fields `startCursor` and `endCursor`, that return either String or Scalar, which can be null if there are no results"
21
- ].join("\n"),
18
+ ].join(`
19
+ `),
22
20
  url: `https://the-guild.dev/graphql/eslint/rules/${RULE_ID}`,
23
21
  examples: [
24
22
  {
@@ -36,8 +34,8 @@ const rule = {
36
34
  )
37
35
  }
38
36
  ],
39
- isDisabledForAllConfig: true,
40
- requiresSchema: true
37
+ isDisabledForAllConfig: !0,
38
+ requiresSchema: !0
41
39
  },
42
40
  messages: {
43
41
  [MESSAGE_MUST_EXIST]: "The server must provide a `PageInfo` object.",
@@ -47,35 +45,22 @@ const rule = {
47
45
  },
48
46
  create(context) {
49
47
  const schema = requireGraphQLSchemaFromContext(RULE_ID, context);
50
- if (!hasPageInfoChecked) {
51
- const pageInfoType = schema.getType("PageInfo");
52
- if (!pageInfoType) {
53
- context.report({
54
- loc: REPORT_ON_FIRST_CHARACTER,
55
- messageId: MESSAGE_MUST_EXIST
56
- });
57
- }
58
- hasPageInfoChecked = true;
59
- }
60
- return {
48
+ return hasPageInfoChecked || (schema.getType("PageInfo") || context.report({
49
+ loc: REPORT_ON_FIRST_CHARACTER,
50
+ messageId: MESSAGE_MUST_EXIST
51
+ }), hasPageInfoChecked = !0), {
61
52
  [notPageInfoTypesSelector](node) {
62
53
  context.report({ node, messageId: MESSAGE_MUST_BE_OBJECT_TYPE });
63
54
  },
64
55
  "ObjectTypeDefinition[name.value=PageInfo]"(node) {
65
- var _a;
66
56
  const fieldMap = Object.fromEntries(
67
- ((_a = node.fields) == null ? void 0 : _a.map((field) => [field.name.value, field])) || []
68
- );
69
- const checkField = (fieldName, typeName) => {
57
+ node.fields?.map((field) => [field.name.value, field]) || []
58
+ ), checkField = (fieldName, typeName) => {
70
59
  const field = fieldMap[fieldName];
71
- let isAllowedType = false;
60
+ let isAllowedType = !1;
72
61
  if (field) {
73
62
  const type = field.gqlType;
74
- if (typeName === "Boolean") {
75
- isAllowedType = type.kind === Kind.NON_NULL_TYPE && type.gqlType.kind === Kind.NAMED_TYPE && type.gqlType.name.value === "Boolean";
76
- } else if (type.kind === Kind.NAMED_TYPE) {
77
- isAllowedType = type.name.value === "String" || isScalarType(schema.getType(type.name.value));
78
- }
63
+ typeName === "Boolean" ? isAllowedType = type.kind === Kind.NON_NULL_TYPE && type.gqlType.kind === Kind.NAMED_TYPE && type.gqlType.name.value === "Boolean" : type.kind === Kind.NAMED_TYPE && (isAllowedType = type.name.value === "String" || isScalarType(schema.getType(type.name.value)));
79
64
  }
80
65
  if (!isAllowedType) {
81
66
  const returnType = typeName === "Boolean" ? "non-null Boolean" : "either String or Scalar, which can be null if there are no results";
@@ -85,10 +70,7 @@ const rule = {
85
70
  });
86
71
  }
87
72
  };
88
- checkField("hasPreviousPage", "Boolean");
89
- checkField("hasNextPage", "Boolean");
90
- checkField("startCursor", "String");
91
- checkField("endCursor", "String");
73
+ checkField("hasPreviousPage", "Boolean"), checkField("hasNextPage", "Boolean"), checkField("startCursor", "String"), checkField("endCursor", "String");
92
74
  }
93
75
  };
94
76
  }
@@ -1,11 +1,12 @@
1
1
  import { FromSchema } from 'json-schema-to-ts';
2
- import { f as GraphQLESLintRule } from '../types-ace77d86.js';
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 'graphql-config';
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";
@@ -1,28 +1,22 @@
1
- import "../chunk-BMTV3EA2.js";
1
+ import "../chunk-U3TKCM4X.js";
2
2
  import { valueFromNode } from "../estree-converter/index.js";
3
3
  import { getNodeName } from "../utils.js";
4
- const DATE_REGEX = /^\d{2}\/\d{2}\/\d{4}$/;
5
- const MESSAGE_REQUIRE_DATE = "MESSAGE_REQUIRE_DATE";
6
- const MESSAGE_INVALID_FORMAT = "MESSAGE_INVALID_FORMAT";
7
- const MESSAGE_INVALID_DATE = "MESSAGE_INVALID_DATE";
8
- const MESSAGE_CAN_BE_REMOVED = "MESSAGE_CAN_BE_REMOVED";
9
- const schema = {
4
+ 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 = {
10
5
  type: "array",
11
6
  maxItems: 1,
12
7
  items: {
13
8
  type: "object",
14
- additionalProperties: false,
9
+ additionalProperties: !1,
15
10
  properties: {
16
11
  argumentName: {
17
12
  type: "string"
18
13
  }
19
14
  }
20
15
  }
21
- };
22
- const rule = {
16
+ }, rule = {
23
17
  meta: {
24
18
  type: "suggestion",
25
- hasSuggestions: true,
19
+ hasSuggestions: !0,
26
20
  docs: {
27
21
  category: "Schema",
28
22
  description: "Require deletion date on `@deprecated` directive. Suggest removing deprecated things after deprecated date.",
@@ -78,9 +72,7 @@ const rule = {
78
72
  create(context) {
79
73
  return {
80
74
  "Directive[name.value=deprecated]"(node) {
81
- var _a, _b;
82
- const argName = ((_a = context.options[0]) == null ? void 0 : _a.argumentName) || "deletionDate";
83
- const deletionDateNode = (_b = node.arguments) == null ? void 0 : _b.find((arg) => arg.name.value === argName);
75
+ const argName = context.options[0]?.argumentName || "deletionDate", deletionDateNode = node.arguments?.find((arg) => arg.name.value === argName);
84
76
  if (!deletionDateNode) {
85
77
  context.report({
86
78
  node: node.name,
@@ -92,8 +84,7 @@ const rule = {
92
84
  return;
93
85
  }
94
86
  const deletionDate = valueFromNode(deletionDateNode.value);
95
- const isValidDate = DATE_REGEX.test(deletionDate);
96
- if (!isValidDate) {
87
+ if (!DATE_REGEX.test(deletionDate)) {
97
88
  context.report({
98
89
  node: deletionDateNode.value,
99
90
  messageId: MESSAGE_INVALID_FORMAT,
@@ -102,8 +93,7 @@ const rule = {
102
93
  return;
103
94
  }
104
95
  let [day, month, year] = deletionDate.split("/");
105
- day = day.padStart(2, "0");
106
- month = month.padStart(2, "0");
96
+ day = day.padStart(2, "0"), month = month.padStart(2, "0");
107
97
  const deletionDateInMS = Date.parse(`${year}-${month}-${day}`);
108
98
  if (Number.isNaN(deletionDateInMS)) {
109
99
  context.report({
@@ -116,10 +106,8 @@ const rule = {
116
106
  });
117
107
  return;
118
108
  }
119
- const canRemove = Date.now() > deletionDateInMS;
120
- if (canRemove) {
121
- const { parent } = node;
122
- const nodeName = parent.name.value;
109
+ if (Date.now() > deletionDateInMS) {
110
+ const { parent } = node, nodeName = parent.name.value;
123
111
  context.report({
124
112
  node: parent.name,
125
113
  messageId: MESSAGE_CAN_BE_REMOVED,
@@ -1,11 +1,12 @@
1
- import { f as GraphQLESLintRule } from '../types-ace77d86.js';
2
- import '@graphql-tools/utils';
1
+ import { GraphQLESLintRule } from '../types.mjs';
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.mjs';
7
+ import '@graphql-tools/utils';
8
8
  import '../estree-converter/types.mjs';
9
+ import 'graphql-config';
9
10
 
10
11
  declare const rule: GraphQLESLintRule;
11
12
 
@@ -1,4 +1,4 @@
1
- import "../chunk-BMTV3EA2.js";
1
+ import "../chunk-U3TKCM4X.js";
2
2
  import { valueFromNode } from "../estree-converter/index.js";
3
3
  import { getNodeName } from "../utils.js";
4
4
  const rule = {
@@ -7,7 +7,7 @@ const rule = {
7
7
  description: "Require all deprecation directives to specify a reason.",
8
8
  category: "Schema",
9
9
  url: "https://the-guild.dev/graphql/eslint/rules/require-deprecation-reason",
10
- recommended: true,
10
+ recommended: !0,
11
11
  examples: [
12
12
  {
13
13
  title: "Incorrect",
@@ -50,17 +50,13 @@ const rule = {
50
50
  create(context) {
51
51
  return {
52
52
  "Directive[name.value=deprecated]"(node) {
53
- var _a;
54
- const reasonArgument = (_a = node.arguments) == null ? void 0 : _a.find(
53
+ const reasonArgument = node.arguments?.find(
55
54
  (arg) => arg.name.value === "reason"
56
55
  );
57
- const value = reasonArgument && String(valueFromNode(reasonArgument.value)).trim();
58
- if (!value) {
59
- context.report({
60
- node: node.name,
61
- message: `Deprecation reason is required for ${getNodeName(node.parent)}.`
62
- });
63
- }
56
+ reasonArgument && String(valueFromNode(reasonArgument.value)).trim() || context.report({
57
+ node: node.name,
58
+ message: `Deprecation reason is required for ${getNodeName(node.parent)}.`
59
+ });
64
60
  }
65
61
  };
66
62
  }
@@ -1,11 +1,12 @@
1
1
  import { Kind } from 'graphql';
2
- import { f as GraphQLESLintRule } from '../types-ace77d86.js';
3
- import '@graphql-tools/utils';
2
+ import { GraphQLESLintRule } from '../types.mjs';
4
3
  import 'eslint';
5
4
  import 'estree';
6
- import 'graphql-config';
7
5
  import 'json-schema-to-ts';
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 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];