@graphql-eslint/eslint-plugin 4.0.0-alpha-20230801163310-8bc4340 → 4.0.0-alpha-20230810160036-304c2c0

Sign up to get free protection for your applications and to get access to all the features.
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
@@ -0,0 +1,198 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: !0 });
9
+ }, __copyProps = (to, from, except, desc) => {
10
+ if (from && typeof from == "object" || typeof from == "function")
11
+ for (let key of __getOwnPropNames(from))
12
+ !__hasOwnProp.call(to, key) && key !== except && __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
13
+ return to;
14
+ };
15
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: !0 }), mod);
16
+ var require_selections_exports = {};
17
+ __export(require_selections_exports, {
18
+ rule: () => rule
19
+ });
20
+ module.exports = __toCommonJS(require_selections_exports);
21
+ var import_utils = require("@graphql-tools/utils"), import_graphql = require("graphql"), import_estree_converter = require("../estree-converter/index.js"), import_utils2 = require("../utils.js");
22
+ const RULE_ID = "require-selections", DEFAULT_ID_FIELD_NAME = "id", schema = {
23
+ definitions: {
24
+ asString: {
25
+ type: "string"
26
+ },
27
+ asArray: import_utils2.ARRAY_DEFAULT_OPTIONS
28
+ },
29
+ type: "array",
30
+ maxItems: 1,
31
+ items: {
32
+ type: "object",
33
+ additionalProperties: !1,
34
+ properties: {
35
+ fieldName: {
36
+ oneOf: [{ $ref: "#/definitions/asString" }, { $ref: "#/definitions/asArray" }],
37
+ default: DEFAULT_ID_FIELD_NAME
38
+ }
39
+ }
40
+ }
41
+ }, rule = {
42
+ meta: {
43
+ type: "suggestion",
44
+ hasSuggestions: !0,
45
+ docs: {
46
+ category: "Operations",
47
+ description: "Enforce selecting specific fields when they are available on the GraphQL type.",
48
+ url: `https://the-guild.dev/graphql/eslint/rules/${RULE_ID}`,
49
+ requiresSchema: !0,
50
+ requiresSiblings: !0,
51
+ examples: [
52
+ {
53
+ title: "Incorrect",
54
+ code: (
55
+ /* GraphQL */
56
+ `
57
+ # In your schema
58
+ type User {
59
+ id: ID!
60
+ name: String!
61
+ }
62
+
63
+ # Query
64
+ query {
65
+ user {
66
+ name
67
+ }
68
+ }
69
+ `
70
+ )
71
+ },
72
+ {
73
+ title: "Correct",
74
+ code: (
75
+ /* GraphQL */
76
+ `
77
+ # In your schema
78
+ type User {
79
+ id: ID!
80
+ name: String!
81
+ }
82
+
83
+ # Query
84
+ query {
85
+ user {
86
+ id
87
+ name
88
+ }
89
+ }
90
+
91
+ # Selecting \`id\` with an alias is also valid
92
+ query {
93
+ user {
94
+ id: name
95
+ }
96
+ }
97
+ `
98
+ )
99
+ }
100
+ ],
101
+ recommended: !0
102
+ },
103
+ messages: {
104
+ [RULE_ID]: `Field{{ pluralSuffix }} {{ fieldName }} must be selected when it's available on a type.
105
+ Include it in your selection set{{ addition }}.`
106
+ },
107
+ schema
108
+ },
109
+ create(context) {
110
+ const schema2 = (0, import_utils2.requireGraphQLSchemaFromContext)(RULE_ID, context), siblings = (0, import_utils2.requireSiblingsOperations)(RULE_ID, context), { fieldName = DEFAULT_ID_FIELD_NAME } = context.options[0] || {}, idNames = (0, import_utils.asArray)(fieldName), selector = "OperationDefinition SelectionSet[parent.kind!=/(^OperationDefinition|InlineFragment)$/]", typeInfo = new import_graphql.TypeInfo(schema2);
111
+ function checkFragments(node) {
112
+ for (const selection of node.selections) {
113
+ if (selection.kind !== import_graphql.Kind.FRAGMENT_SPREAD)
114
+ continue;
115
+ const [foundSpread] = siblings.getFragment(selection.name.value);
116
+ if (!foundSpread)
117
+ continue;
118
+ const checkedFragmentSpreads = /* @__PURE__ */ new Set(), visitor = (0, import_graphql.visitWithTypeInfo)(typeInfo, {
119
+ SelectionSet(node2, key, _parent) {
120
+ const parent = _parent;
121
+ parent.kind === import_graphql.Kind.FRAGMENT_DEFINITION ? checkedFragmentSpreads.add(parent.name.value) : parent.kind !== import_graphql.Kind.INLINE_FRAGMENT && checkSelections(
122
+ node2,
123
+ typeInfo.getType(),
124
+ selection.loc.start,
125
+ parent,
126
+ checkedFragmentSpreads
127
+ );
128
+ }
129
+ });
130
+ (0, import_graphql.visit)(foundSpread.document, visitor);
131
+ }
132
+ }
133
+ function checkSelections(node, type, loc, parent, checkedFragmentSpreads = /* @__PURE__ */ new Set()) {
134
+ const rawType = (0, import_estree_converter.getBaseType)(type);
135
+ if (rawType instanceof import_graphql.GraphQLObjectType || rawType instanceof import_graphql.GraphQLInterfaceType)
136
+ checkFields(rawType);
137
+ else if (rawType instanceof import_graphql.GraphQLUnionType) {
138
+ for (const selection of node.selections)
139
+ if (selection.kind === import_graphql.Kind.INLINE_FRAGMENT) {
140
+ const t = rawType.getTypes().find((t2) => t2.name === selection.typeCondition.name.value);
141
+ t && checkFields(t);
142
+ }
143
+ }
144
+ function checkFields(rawType2) {
145
+ const fields = rawType2.getFields();
146
+ if (!idNames.some((name) => fields[name]))
147
+ return;
148
+ function hasIdField({ selections }) {
149
+ return selections.some((selection) => {
150
+ if (selection.kind === import_graphql.Kind.FIELD)
151
+ return selection.alias && idNames.includes(selection.alias.value) ? !0 : idNames.includes(selection.name.value);
152
+ if (selection.kind === import_graphql.Kind.INLINE_FRAGMENT)
153
+ return hasIdField(selection.selectionSet);
154
+ if (selection.kind === import_graphql.Kind.FRAGMENT_SPREAD) {
155
+ const [foundSpread] = siblings.getFragment(selection.name.value);
156
+ if (foundSpread) {
157
+ const fragmentSpread = foundSpread.document;
158
+ return checkedFragmentSpreads.add(fragmentSpread.name.value), hasIdField(fragmentSpread.selectionSet);
159
+ }
160
+ }
161
+ return !1;
162
+ });
163
+ }
164
+ const hasId = hasIdField(node);
165
+ if (checkFragments(node), hasId)
166
+ return;
167
+ const pluralSuffix = idNames.length > 1 ? "s" : "", fieldName2 = (0, import_utils2.englishJoinWords)(
168
+ idNames.map((name) => `\`${(parent.alias || parent.name).value}.${name}\``)
169
+ ), addition = checkedFragmentSpreads.size === 0 ? "" : ` or add to used fragment${checkedFragmentSpreads.size > 1 ? "s" : ""} ${(0, import_utils2.englishJoinWords)([...checkedFragmentSpreads].map((name) => `\`${name}\``))}`, problem = {
170
+ loc,
171
+ messageId: RULE_ID,
172
+ data: {
173
+ pluralSuffix,
174
+ fieldName: fieldName2,
175
+ addition
176
+ }
177
+ };
178
+ "type" in node && (problem.suggest = idNames.map((idName) => ({
179
+ desc: `Add \`${idName}\` selection`,
180
+ fix: (fixer) => {
181
+ let insertNode = node.selections[0];
182
+ return insertNode = insertNode.kind === import_graphql.Kind.INLINE_FRAGMENT ? insertNode.selectionSet.selections[0] : insertNode, fixer.insertTextBefore(insertNode, `${idName} `);
183
+ }
184
+ }))), context.report(problem);
185
+ }
186
+ }
187
+ return {
188
+ [selector](node) {
189
+ const typeInfo2 = node.typeInfo();
190
+ typeInfo2.gqlType && checkSelections(node, typeInfo2.gqlType, node.loc.start, node.parent);
191
+ }
192
+ };
193
+ }
194
+ };
195
+ // Annotate the CommonJS export names for ESM import in node:
196
+ 0 && (module.exports = {
197
+ rule
198
+ });
@@ -1,11 +1,12 @@
1
- import { f as GraphQLESLintRule } from '../types-8d5f4ae0.js';
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,25 +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: true });
9
- };
10
- var __copyProps = (to, from, except, desc) => {
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
- if (!__hasOwnProp.call(to, key) && key !== except)
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: true }), mod);
15
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: !0 }), mod);
19
16
  var require_type_pattern_with_oneof_exports = {};
20
17
  __export(require_type_pattern_with_oneof_exports, {
21
18
  rule: () => rule
22
19
  });
23
20
  module.exports = __toCommonJS(require_type_pattern_with_oneof_exports);
24
21
  var import_utils = require("../utils.js");
25
- const RULE_ID = "require-type-pattern-with-oneof";
26
- const rule = {
22
+ const RULE_ID = "require-type-pattern-with-oneof", rule = {
27
23
  meta: {
28
24
  type: "suggestion",
29
25
  docs: {
@@ -67,20 +63,16 @@ const rule = {
67
63
  "Directive[name.value=oneOf][parent.kind=ObjectTypeDefinition]"({
68
64
  parent
69
65
  }) {
70
- var _a;
71
66
  const requiredFields = ["error", "ok"];
72
- for (const fieldName of requiredFields) {
73
- if (!((_a = parent.fields) == null ? void 0 : _a.some((field) => field.name.value === fieldName))) {
74
- context.report({
75
- node: parent.name,
76
- messageId: RULE_ID,
77
- data: {
78
- nodeName: (0, import_utils.displayNodeName)(parent),
79
- fieldName
80
- }
81
- });
82
- }
83
- }
67
+ for (const fieldName of requiredFields)
68
+ parent.fields?.some((field) => field.name.value === fieldName) || context.report({
69
+ node: parent.name,
70
+ messageId: RULE_ID,
71
+ data: {
72
+ nodeName: (0, import_utils.displayNodeName)(parent),
73
+ fieldName
74
+ }
75
+ });
84
76
  }
85
77
  };
86
78
  }
@@ -1,11 +1,12 @@
1
1
  import { FromSchema } from 'json-schema-to-ts';
2
- import { f as GraphQLESLintRule } from '../types-8d5f4ae0.js';
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 'graphql-config';
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";
@@ -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: true });
11
- };
12
- var __copyProps = (to, from, except, desc) => {
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
- if (!__hasOwnProp.call(to, key) && key !== except)
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,26 +18,22 @@ 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: true }) : target,
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 selection_set_depth_exports = {};
30
25
  __export(selection_set_depth_exports, {
31
26
  rule: () => rule
32
27
  });
33
28
  module.exports = __toCommonJS(selection_set_depth_exports);
34
- var import_graphql = require("graphql");
35
- var import_graphql_depth_limit = __toESM(require("graphql-depth-limit"));
36
- var import_utils = require("../utils.js");
37
- const RULE_ID = "selection-set-depth";
38
- const schema = {
29
+ var import_graphql = require("graphql"), import_graphql_depth_limit = __toESM(require("graphql-depth-limit")), import_utils = require("../utils.js");
30
+ const RULE_ID = "selection-set-depth", schema = {
39
31
  type: "array",
40
32
  minItems: 1,
41
33
  maxItems: 1,
42
34
  items: {
43
35
  type: "object",
44
- additionalProperties: false,
36
+ additionalProperties: !1,
45
37
  required: ["maxDepth"],
46
38
  properties: {
47
39
  maxDepth: {
@@ -50,16 +42,15 @@ const schema = {
50
42
  ignore: import_utils.ARRAY_DEFAULT_OPTIONS
51
43
  }
52
44
  }
53
- };
54
- const rule = {
45
+ }, rule = {
55
46
  meta: {
56
47
  type: "suggestion",
57
- hasSuggestions: true,
48
+ hasSuggestions: !0,
58
49
  docs: {
59
50
  category: "Operations",
60
51
  description: "Limit the complexity of the GraphQL operations solely by their depth. Based on [graphql-depth-limit](https://npmjs.com/package/graphql-depth-limit).",
61
52
  url: `https://the-guild.dev/graphql/eslint/rules/${RULE_ID}`,
62
- requiresSiblings: true,
53
+ requiresSiblings: !0,
63
54
  examples: [
64
55
  {
65
56
  title: "Incorrect",
@@ -101,7 +92,7 @@ const rule = {
101
92
  `
102
93
  }
103
94
  ],
104
- recommended: true,
95
+ recommended: !0,
105
96
  configOptions: [{ maxDepth: 7 }]
106
97
  },
107
98
  schema
@@ -115,23 +106,18 @@ const rule = {
115
106
  `Rule "${RULE_ID}" works best with siblings operations loaded. For more info: https://bit.ly/graphql-eslint-operations`
116
107
  );
117
108
  }
118
- const { maxDepth, ignore = [] } = context.options[0];
119
- const checkFn = (0, import_graphql_depth_limit.default)(maxDepth, { ignore });
109
+ const { maxDepth, ignore = [] } = context.options[0], checkFn = (0, import_graphql_depth_limit.default)(maxDepth, { ignore });
120
110
  return {
121
111
  "OperationDefinition, FragmentDefinition"(node) {
122
112
  try {
123
- const rawNode = node.rawNode();
124
- const fragmentsInUse = siblings ? siblings.getFragmentsInUse(rawNode) : [];
125
- const document = {
113
+ const rawNode = node.rawNode(), fragmentsInUse = siblings ? siblings.getFragmentsInUse(rawNode) : [], document = {
126
114
  kind: import_graphql.Kind.DOCUMENT,
127
115
  definitions: [rawNode, ...fragmentsInUse]
128
116
  };
129
117
  checkFn({
130
118
  getDocument: () => document,
131
119
  reportError(error) {
132
- const { line, column } = error.locations[0];
133
- const ancestors = context.getAncestors();
134
- const token = ancestors[0].tokens.find(
120
+ const { line, column } = error.locations[0], token = context.getAncestors()[0].tokens.find(
135
121
  (token2) => token2.loc.start.line === line && token2.loc.start.column === column - 1
136
122
  );
137
123
  context.report({
@@ -146,9 +132,7 @@ const rule = {
146
132
  {
147
133
  desc: "Remove selections",
148
134
  fix(fixer) {
149
- const sourceCode = context.getSourceCode();
150
- const foundNode = sourceCode.getNodeByRangeIndex(token.range[0]);
151
- const parentNode = foundNode.parent.parent;
135
+ const foundNode = context.getSourceCode().getNodeByRangeIndex(token.range[0]), parentNode = foundNode.parent.parent;
152
136
  return fixer.remove(
153
137
  foundNode.kind === "Name" ? parentNode.parent : parentNode
154
138
  );
@@ -1,11 +1,12 @@
1
1
  import { FromSchema } from 'json-schema-to-ts';
2
- import { f as GraphQLESLintRule } from '../types-8d5f4ae0.js';
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 'graphql-config';
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,31 +5,26 @@ 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: true });
9
- };
10
- var __copyProps = (to, from, except, desc) => {
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
- if (!__hasOwnProp.call(to, key) && key !== except)
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: true }), mod);
15
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: !0 }), mod);
19
16
  var strict_id_in_types_exports = {};
20
17
  __export(strict_id_in_types_exports, {
21
18
  rule: () => rule
22
19
  });
23
20
  module.exports = __toCommonJS(strict_id_in_types_exports);
24
- var import_graphql = require("graphql");
25
- var import_utils = require("../utils.js");
26
- const RULE_ID = "strict-id-in-types";
27
- const schema = {
21
+ var import_graphql = require("graphql"), import_utils = require("../utils.js");
22
+ const RULE_ID = "strict-id-in-types", schema = {
28
23
  type: "array",
29
24
  maxItems: 1,
30
25
  items: {
31
26
  type: "object",
32
- additionalProperties: false,
27
+ additionalProperties: !1,
33
28
  properties: {
34
29
  acceptedIdNames: {
35
30
  ...import_utils.ARRAY_DEFAULT_OPTIONS,
@@ -41,7 +36,7 @@ const schema = {
41
36
  },
42
37
  exceptions: {
43
38
  type: "object",
44
- additionalProperties: false,
39
+ additionalProperties: !1,
45
40
  properties: {
46
41
  types: {
47
42
  ...import_utils.ARRAY_DEFAULT_OPTIONS,
@@ -55,16 +50,15 @@ const schema = {
55
50
  }
56
51
  }
57
52
  }
58
- };
59
- const rule = {
53
+ }, rule = {
60
54
  meta: {
61
55
  type: "suggestion",
62
56
  docs: {
63
57
  description: "Requires output types to have one unique identifier unless they do not have a logical one. Exceptions can be used to ignore output types that do not have unique identifiers.",
64
58
  category: "Schema",
65
- recommended: true,
59
+ recommended: !0,
66
60
  url: `https://the-guild.dev/graphql/eslint/rules/${RULE_ID}`,
67
- requiresSchema: true,
61
+ requiresSchema: !0,
68
62
  examples: [
69
63
  {
70
64
  title: "Incorrect",
@@ -141,34 +135,22 @@ const rule = {
141
135
  acceptedIdTypes: ["ID"],
142
136
  exceptions: {},
143
137
  ...context.options[0]
144
- };
145
- const schema2 = (0, import_utils.requireGraphQLSchemaFromContext)(RULE_ID, context);
146
- const rootTypeNames = [
147
- schema2.getQueryType(),
148
- schema2.getMutationType(),
149
- schema2.getSubscriptionType()
150
- ].filter(import_utils.truthy).map((type) => type.name);
151
- const selector = `ObjectTypeDefinition[name.value!=/^(${rootTypeNames.join("|")})$/]`;
138
+ }, schema2 = (0, import_utils.requireGraphQLSchemaFromContext)(RULE_ID, context);
152
139
  return {
153
- [selector](node) {
154
- var _a, _b, _c;
140
+ [`ObjectTypeDefinition[name.value!=/^(${[
141
+ schema2.getQueryType(),
142
+ schema2.getMutationType(),
143
+ schema2.getSubscriptionType()
144
+ ].filter(import_utils.truthy).map((type) => type.name).join("|")})$/]`](node) {
155
145
  const typeName = node.name.value;
156
- const shouldIgnoreNode = ((_a = options.exceptions.types) == null ? void 0 : _a.includes(typeName)) || ((_b = options.exceptions.suffixes) == null ? void 0 : _b.some((suffix) => typeName.endsWith(suffix)));
157
- if (shouldIgnoreNode) {
146
+ if (options.exceptions.types?.includes(typeName) || options.exceptions.suffixes?.some((suffix) => typeName.endsWith(suffix)))
158
147
  return;
159
- }
160
- const validIds = (_c = node.fields) == null ? void 0 : _c.filter((field) => {
161
- const fieldNode = field.rawNode();
162
- const isValidIdName = options.acceptedIdNames.includes(fieldNode.name.value);
163
- let isValidIdType = false;
164
- if (fieldNode.type.kind === import_graphql.Kind.NON_NULL_TYPE && fieldNode.type.type.kind === import_graphql.Kind.NAMED_TYPE) {
165
- isValidIdType = options.acceptedIdTypes.includes(fieldNode.type.type.name.value);
166
- }
167
- return isValidIdName && isValidIdType;
168
- });
169
- if ((validIds == null ? void 0 : validIds.length) !== 1) {
170
- const pluralNamesSuffix = options.acceptedIdNames.length > 1 ? "s" : "";
171
- const pluralTypesSuffix = options.acceptedIdTypes.length > 1 ? "s" : "";
148
+ if (node.fields?.filter((field) => {
149
+ const fieldNode = field.rawNode(), isValidIdName = options.acceptedIdNames.includes(fieldNode.name.value);
150
+ let isValidIdType = !1;
151
+ return fieldNode.type.kind === import_graphql.Kind.NON_NULL_TYPE && fieldNode.type.type.kind === import_graphql.Kind.NAMED_TYPE && (isValidIdType = options.acceptedIdTypes.includes(fieldNode.type.type.name.value)), isValidIdName && isValidIdType;
152
+ })?.length !== 1) {
153
+ const pluralNamesSuffix = options.acceptedIdNames.length > 1 ? "s" : "", pluralTypesSuffix = options.acceptedIdTypes.length > 1 ? "s" : "";
172
154
  context.report({
173
155
  node: node.name,
174
156
  message: `${(0, import_utils.displayNodeName)(node)} must have exactly one non-nullable unique identifier.
@@ -1,11 +1,12 @@
1
- import { f as GraphQLESLintRule } from '../types-8d5f4ae0.js';
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,30 @@ 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: true });
9
- };
10
- var __copyProps = (to, from, except, desc) => {
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
- if (!__hasOwnProp.call(to, key) && key !== except)
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: true }), mod);
19
- var no_case_insensitive_enum_values_duplicates_exports = {};
20
- __export(no_case_insensitive_enum_values_duplicates_exports, {
15
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: !0 }), mod);
16
+ var unique_enum_value_names_exports = {};
17
+ __export(unique_enum_value_names_exports, {
21
18
  rule: () => rule
22
19
  });
23
- module.exports = __toCommonJS(no_case_insensitive_enum_values_duplicates_exports);
24
- var import_graphql = require("graphql");
25
- var import_utils = require("../utils.js");
20
+ module.exports = __toCommonJS(unique_enum_value_names_exports);
21
+ var import_graphql = require("graphql"), import_utils = require("../utils.js");
26
22
  const rule = {
27
23
  meta: {
28
24
  type: "suggestion",
29
- hasSuggestions: true,
25
+ hasSuggestions: !0,
30
26
  docs: {
31
- url: "https://the-guild.dev/graphql/eslint/rules/no-case-insensitive-enum-values-duplicates",
27
+ url: "https://the-guild.dev/graphql/eslint/rules/unique-enum-value-names",
32
28
  category: "Schema",
33
- recommended: true,
34
- description: "Disallow case-insensitive enum values duplicates.",
29
+ recommended: !0,
30
+ description: `A GraphQL enum type is only valid if all its values are uniquely named.
31
+ > This rule disallows case-insensitive enum values duplicates too.`,
35
32
  examples: [
36
33
  {
37
34
  title: "Incorrect",
@@ -64,11 +61,9 @@ const rule = {
64
61
  schema: []
65
62
  },
66
63
  create(context) {
67
- const selector = [import_graphql.Kind.ENUM_TYPE_DEFINITION, import_graphql.Kind.ENUM_TYPE_EXTENSION].join(",");
68
64
  return {
69
- [selector](node) {
70
- var _a;
71
- const duplicates = (_a = node.values) == null ? void 0 : _a.filter(
65
+ [[import_graphql.Kind.ENUM_TYPE_DEFINITION, import_graphql.Kind.ENUM_TYPE_EXTENSION].join(",")](node) {
66
+ const duplicates = node.values?.filter(
72
67
  (item, index, array) => array.findIndex((v) => v.name.value.toLowerCase() === item.name.value.toLowerCase()) !== index
73
68
  );
74
69
  for (const duplicate of duplicates || []) {
@@ -1,11 +1,12 @@
1
1
  import { ExecutableDefinitionNode } from 'graphql';
2
2
  import { GraphQLESTreeNode } from '../estree-converter/types.js';
3
- import { c as GraphQLESLintRuleContext, f as GraphQLESLintRule } from '../types-8d5f4ae0.js';
3
+ import { GraphQLESLintRuleContext, GraphQLESLintRule } from '../types.js';
4
4
  import 'eslint';
5
5
  import 'estree';
6
+ import 'json-schema-to-ts';
7
+ import '../siblings.js';
6
8
  import '@graphql-tools/utils';
7
9
  import 'graphql-config';
8
- import 'json-schema-to-ts';
9
10
 
10
11
  declare const checkNode: (context: GraphQLESLintRuleContext, node: GraphQLESTreeNode<ExecutableDefinitionNode>, ruleId: string) => void;
11
12
  declare const rule: GraphQLESLintRule;