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