@graphql-eslint/eslint-plugin 3.20.0 → 3.20.1-alpha-20230713065115-b9bc635

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 (91) hide show
  1. package/cjs/configs/operations-all.js +1 -23
  2. package/cjs/configs/operations-recommended.js +1 -23
  3. package/cjs/configs/relay.js +1 -23
  4. package/cjs/configs/schema-all.js +1 -23
  5. package/cjs/configs/schema-recommended.js +1 -23
  6. package/cjs/documents.js +2 -1
  7. package/cjs/estree-converter/utils.js +1 -1
  8. package/cjs/parser.js +4 -3
  9. package/cjs/processor.js +1 -1
  10. package/cjs/rules/alphabetize.js +12 -9
  11. package/cjs/rules/graphql-js-validation.js +13 -8
  12. package/cjs/rules/lone-executable-definition.js +5 -3
  13. package/cjs/rules/match-document-filename.js +2 -1
  14. package/cjs/rules/naming-convention.js +2 -2
  15. package/cjs/rules/no-case-insensitive-enum-values-duplicates.js +2 -1
  16. package/cjs/rules/no-deprecated.js +4 -2
  17. package/cjs/rules/no-one-place-fragments.js +1 -1
  18. package/cjs/rules/no-unreachable-types.js +2 -2
  19. package/cjs/rules/no-unused-fields.js +4 -2
  20. package/cjs/rules/relay-arguments.js +2 -1
  21. package/cjs/rules/relay-connection-types.js +8 -2
  22. package/cjs/rules/relay-edge-types.js +7 -4
  23. package/cjs/rules/relay-page-info.js +2 -1
  24. package/cjs/rules/require-deprecation-date.js +3 -2
  25. package/cjs/rules/require-deprecation-reason.js +2 -1
  26. package/cjs/rules/require-description.js +3 -2
  27. package/cjs/rules/require-field-of-type-query-in-mutation-result.js +1 -1
  28. package/cjs/rules/require-import-fragment.js +2 -1
  29. package/cjs/rules/require-nullable-result-in-root.js +1 -1
  30. package/cjs/rules/require-type-pattern-with-oneof.js +2 -1
  31. package/cjs/rules/strict-id-in-types.js +4 -3
  32. package/cjs/rules/unique-fragment-name.js +2 -1
  33. package/cjs/siblings.js +8 -3
  34. package/cjs/utils.js +2 -1
  35. package/esm/cache.js +1 -0
  36. package/esm/chunk-BMTV3EA2.js +8 -0
  37. package/esm/configs/index.js +1 -0
  38. package/esm/configs/operations-all.js +32 -27
  39. package/esm/configs/operations-recommended.js +57 -52
  40. package/esm/configs/relay.js +17 -12
  41. package/esm/configs/schema-all.js +26 -21
  42. package/esm/configs/schema-recommended.js +53 -48
  43. package/esm/documents.js +3 -1
  44. package/esm/estree-converter/converter.js +1 -0
  45. package/esm/estree-converter/utils.js +2 -1
  46. package/esm/flat-configs.js +1 -0
  47. package/esm/graphql-config.js +1 -0
  48. package/esm/index.js +1 -0
  49. package/esm/parser.js +5 -3
  50. package/esm/processor.js +2 -1
  51. package/esm/rules/alphabetize.js +13 -9
  52. package/esm/rules/description-style.js +1 -0
  53. package/esm/rules/graphql-js-validation.js +14 -8
  54. package/esm/rules/index.js +1 -0
  55. package/esm/rules/input-name.js +1 -0
  56. package/esm/rules/lone-executable-definition.js +6 -3
  57. package/esm/rules/match-document-filename.js +3 -1
  58. package/esm/rules/naming-convention.js +3 -2
  59. package/esm/rules/no-anonymous-operations.js +1 -0
  60. package/esm/rules/no-case-insensitive-enum-values-duplicates.js +3 -1
  61. package/esm/rules/no-deprecated.js +5 -2
  62. package/esm/rules/no-duplicate-fields.js +1 -0
  63. package/esm/rules/no-hashtag-description.js +1 -0
  64. package/esm/rules/no-one-place-fragments.js +2 -1
  65. package/esm/rules/no-root-type.js +1 -0
  66. package/esm/rules/no-scalar-result-type-on-mutation.js +1 -0
  67. package/esm/rules/no-typename-prefix.js +1 -0
  68. package/esm/rules/no-unreachable-types.js +3 -2
  69. package/esm/rules/no-unused-fields.js +5 -2
  70. package/esm/rules/relay-arguments.js +3 -1
  71. package/esm/rules/relay-connection-types.js +9 -2
  72. package/esm/rules/relay-edge-types.js +8 -4
  73. package/esm/rules/relay-page-info.js +3 -1
  74. package/esm/rules/require-deprecation-date.js +4 -2
  75. package/esm/rules/require-deprecation-reason.js +3 -1
  76. package/esm/rules/require-description.js +4 -2
  77. package/esm/rules/require-field-of-type-query-in-mutation-result.js +2 -1
  78. package/esm/rules/require-id-when-available.js +1 -0
  79. package/esm/rules/require-import-fragment.js +3 -1
  80. package/esm/rules/require-nullable-fields-with-oneof.js +1 -0
  81. package/esm/rules/require-nullable-result-in-root.js +2 -1
  82. package/esm/rules/require-type-pattern-with-oneof.js +3 -1
  83. package/esm/rules/selection-set-depth.js +1 -0
  84. package/esm/rules/strict-id-in-types.js +5 -3
  85. package/esm/rules/unique-fragment-name.js +3 -1
  86. package/esm/rules/unique-operation-name.js +1 -0
  87. package/esm/schema.js +1 -0
  88. package/esm/siblings.js +9 -3
  89. package/esm/testkit.js +1 -0
  90. package/esm/utils.js +3 -1
  91. package/package.json +1 -4
@@ -1,3 +1,4 @@
1
+ import "../chunk-BMTV3EA2.js";
1
2
  import {
2
3
  Kind
3
4
  } from "graphql";
@@ -206,6 +207,7 @@ const rule = {
206
207
  schema
207
208
  },
208
209
  create(context) {
210
+ var _a, _b, _c, _d, _e;
209
211
  const sourceCode = context.getSourceCode();
210
212
  function isNodeAndCommentOnSameLine(node, comment) {
211
213
  return node.loc.end.line === comment.loc.start.line;
@@ -241,19 +243,20 @@ const rule = {
241
243
  return [from.range[0], to.range[1]];
242
244
  }
243
245
  function checkNodes(nodes = []) {
246
+ var _a2, _b2, _c2, _d2;
244
247
  for (let i = 1; i < nodes.length; i += 1) {
245
248
  const currNode = nodes[i];
246
- const currName = "alias" in currNode && currNode.alias?.value || "name" in currNode && currNode.name?.value;
249
+ const currName = "alias" in currNode && ((_a2 = currNode.alias) == null ? void 0 : _a2.value) || "name" in currNode && ((_b2 = currNode.name) == null ? void 0 : _b2.value);
247
250
  if (!currName) {
248
251
  continue;
249
252
  }
250
253
  const prevNode = nodes[i - 1];
251
- const prevName = "alias" in prevNode && prevNode.alias?.value || "name" in prevNode && prevNode.name?.value;
254
+ const prevName = "alias" in prevNode && ((_c2 = prevNode.alias) == null ? void 0 : _c2.value) || "name" in prevNode && ((_d2 = prevNode.name) == null ? void 0 : _d2.value);
252
255
  if (prevName) {
253
256
  const compareResult = prevName.localeCompare(currName);
254
257
  const { groups } = opts;
255
258
  let shouldSortByGroup = false;
256
- if (groups?.length) {
259
+ if (groups == null ? void 0 : groups.length) {
257
260
  if (!groups.includes("*")) {
258
261
  throw new Error("`groups` option should contain `*` string.");
259
262
  }
@@ -300,7 +303,7 @@ const rule = {
300
303
  }
301
304
  }
302
305
  const opts = context.options[0];
303
- const fields = new Set(opts.fields ?? []);
306
+ const fields = new Set((_a = opts.fields) != null ? _a : []);
304
307
  const listeners = {};
305
308
  const kinds = [
306
309
  fields.has(Kind.OBJECT_TYPE_DEFINITION) && [
@@ -317,10 +320,10 @@ const rule = {
317
320
  ]
318
321
  ].filter(truthy).flat();
319
322
  const fieldsSelector = kinds.join(",");
320
- const hasEnumValues = opts.values?.[0] === Kind.ENUM_TYPE_DEFINITION;
321
- const selectionsSelector = opts.selections?.join(",");
322
- const hasVariables = opts.variables?.[0] === Kind.OPERATION_DEFINITION;
323
- const argumentsSelector = opts.arguments?.join(",");
323
+ const hasEnumValues = ((_b = opts.values) == null ? void 0 : _b[0]) === Kind.ENUM_TYPE_DEFINITION;
324
+ const selectionsSelector = (_c = opts.selections) == null ? void 0 : _c.join(",");
325
+ const hasVariables = ((_d = opts.variables) == null ? void 0 : _d[0]) === Kind.OPERATION_DEFINITION;
326
+ const argumentsSelector = (_e = opts.arguments) == null ? void 0 : _e.join(",");
324
327
  if (fieldsSelector) {
325
328
  listeners[fieldsSelector] = (node) => {
326
329
  checkNodes(node.fields);
@@ -339,7 +342,8 @@ const rule = {
339
342
  }
340
343
  if (hasVariables) {
341
344
  listeners.OperationDefinition = (node) => {
342
- checkNodes(node.variableDefinitions?.map((varDef) => varDef.variable));
345
+ var _a2;
346
+ checkNodes((_a2 = node.variableDefinitions) == null ? void 0 : _a2.map((varDef) => varDef.variable));
343
347
  };
344
348
  }
345
349
  if (argumentsSelector) {
@@ -1,3 +1,4 @@
1
+ import "../chunk-BMTV3EA2.js";
1
2
  import { getNodeName } from "../utils.js";
2
3
  const schema = {
3
4
  type: "array",
@@ -1,5 +1,6 @@
1
1
  import { createRequire } from 'module';
2
2
  const require = createRequire(import.meta.url);
3
+ import "../chunk-BMTV3EA2.js";
3
4
  import {
4
5
  Kind,
5
6
  validate,
@@ -20,6 +21,7 @@ function validateDocument({
20
21
  rule,
21
22
  hasDidYouMeanSuggestions
22
23
  }) {
24
+ var _a;
23
25
  if (documentNode.definitions.length === 0) {
24
26
  return;
25
27
  }
@@ -40,7 +42,7 @@ function validateDocument({
40
42
  loc = // if cursor on `@` symbol than use next node
41
43
  token.type === "@" ? sourceCode.getNodeByRangeIndex(token.range[1] + 1).loc : token.loc;
42
44
  }
43
- const didYouMeanContent = error.message.match(/Did you mean (?<content>.*)\?$/)?.groups.content;
45
+ const didYouMeanContent = (_a = error.message.match(/Did you mean (?<content>.*)\?$/)) == null ? void 0 : _a.groups.content;
44
46
  const matches = didYouMeanContent ? [...didYouMeanContent.matchAll(/"(?<name>[^"]*)"/g)] : [];
45
47
  context.report({
46
48
  loc,
@@ -215,12 +217,15 @@ const GRAPHQL_JS_VALIDATIONS = Object.assign(
215
217
  if (ignoreClientDirectives.length === 0) {
216
218
  return documentNode;
217
219
  }
218
- const filterDirectives = (node) => ({
219
- ...node,
220
- directives: node.directives?.filter(
221
- (directive) => !ignoreClientDirectives.includes(directive.name.value)
222
- )
223
- });
220
+ const filterDirectives = (node) => {
221
+ var _a;
222
+ return {
223
+ ...node,
224
+ directives: (_a = node.directives) == null ? void 0 : _a.filter(
225
+ (directive) => !ignoreClientDirectives.includes(directive.name.value)
226
+ )
227
+ };
228
+ };
224
229
  return visit(documentNode, {
225
230
  Field: filterDirectives,
226
231
  OperationDefinition: filterDirectives
@@ -396,7 +401,8 @@ const GRAPHQL_JS_VALIDATIONS = Object.assign(
396
401
  ...siblings.getOperations(),
397
402
  ...siblings.getFragments()
398
403
  ].reduce((map, { filePath, document }) => {
399
- map[filePath] ??= [];
404
+ var _a;
405
+ (_a = map[filePath]) != null ? _a : map[filePath] = [];
400
406
  map[filePath].push(document);
401
407
  return map;
402
408
  }, /* @__PURE__ */ Object.create(null));
@@ -1,3 +1,4 @@
1
+ import "../chunk-BMTV3EA2.js";
1
2
  import { GRAPHQL_JS_VALIDATIONS } from "./graphql-js-validation.js";
2
3
  import { rule as alphabetize } from "./alphabetize.js";
3
4
  import { rule as descriptionStyle } from "./description-style.js";
@@ -1,3 +1,4 @@
1
+ import "../chunk-BMTV3EA2.js";
1
2
  import {
2
3
  Kind
3
4
  } from "graphql";
@@ -1,3 +1,4 @@
1
+ import "../chunk-BMTV3EA2.js";
1
2
  import { ARRAY_DEFAULT_OPTIONS, getLocation, pascalCase } from "../utils.js";
2
3
  const RULE_ID = "lone-executable-definition";
3
4
  const definitionTypes = ["fragment", "query", "mutation", "subscription"];
@@ -62,7 +63,8 @@ const rule = {
62
63
  schema
63
64
  },
64
65
  create(context) {
65
- const ignore = new Set(context.options[0]?.ignore || []);
66
+ var _a;
67
+ const ignore = new Set(((_a = context.options[0]) == null ? void 0 : _a.ignore) || []);
66
68
  const definitions = [];
67
69
  return {
68
70
  ":matches(OperationDefinition, FragmentDefinition)"(node) {
@@ -72,14 +74,15 @@ const rule = {
72
74
  }
73
75
  },
74
76
  "Document:exit"() {
77
+ var _a2, _b;
75
78
  for (const { node, type } of definitions.slice(1)) {
76
79
  let name = pascalCase(type);
77
- const definitionName = node.name?.value;
80
+ const definitionName = (_a2 = node.name) == null ? void 0 : _a2.value;
78
81
  if (definitionName) {
79
82
  name += ` "${definitionName}"`;
80
83
  }
81
84
  context.report({
82
- loc: node.name?.loc || getLocation(node.loc.start, type),
85
+ loc: ((_b = node.name) == null ? void 0 : _b.loc) || getLocation(node.loc.start, type),
83
86
  messageId: RULE_ID,
84
87
  data: { name }
85
88
  });
@@ -1,3 +1,4 @@
1
+ import "../chunk-BMTV3EA2.js";
1
2
  import { basename, extname } from "path";
2
3
  import { Kind } from "graphql";
3
4
  import {
@@ -201,6 +202,7 @@ const rule = {
201
202
  const filename = basename(filePath, fileExtension);
202
203
  return {
203
204
  Document(documentNode) {
205
+ var _a;
204
206
  if (options.fileExtension && options.fileExtension !== fileExtension) {
205
207
  context.report({
206
208
  loc: REPORT_ON_FIRST_CHARACTER,
@@ -221,7 +223,7 @@ const rule = {
221
223
  if (!node) {
222
224
  return;
223
225
  }
224
- const docName = node.name?.value;
226
+ const docName = (_a = node.name) == null ? void 0 : _a.value;
225
227
  if (!docName) {
226
228
  return;
227
229
  }
@@ -1,3 +1,4 @@
1
+ import "../chunk-BMTV3EA2.js";
1
2
  import { Kind } from "graphql";
2
3
  import {
3
4
  ARRAY_DEFAULT_OPTIONS,
@@ -347,14 +348,14 @@ const rule = {
347
348
  renameToNames: [name + suffix]
348
349
  };
349
350
  }
350
- const forbiddenPrefix = forbiddenPrefixes?.find((prefix2) => name.startsWith(prefix2));
351
+ const forbiddenPrefix = forbiddenPrefixes == null ? void 0 : forbiddenPrefixes.find((prefix2) => name.startsWith(prefix2));
351
352
  if (forbiddenPrefix) {
352
353
  return {
353
354
  errorMessage: `not have "${forbiddenPrefix}" prefix`,
354
355
  renameToNames: [name.replace(new RegExp(`^${forbiddenPrefix}`), "")]
355
356
  };
356
357
  }
357
- const forbiddenSuffix = forbiddenSuffixes?.find((suffix2) => name.endsWith(suffix2));
358
+ const forbiddenSuffix = forbiddenSuffixes == null ? void 0 : forbiddenSuffixes.find((suffix2) => name.endsWith(suffix2));
358
359
  if (forbiddenSuffix) {
359
360
  return {
360
361
  errorMessage: `not have "${forbiddenSuffix}" suffix`,
@@ -1,3 +1,4 @@
1
+ import "../chunk-BMTV3EA2.js";
1
2
  import { Kind } from "graphql";
2
3
  import { getLocation } from "../utils.js";
3
4
  const RULE_ID = "no-anonymous-operations";
@@ -1,3 +1,4 @@
1
+ import "../chunk-BMTV3EA2.js";
1
2
  import { Kind } from "graphql";
2
3
  import { getNodeName } from "../utils.js";
3
4
  const rule = {
@@ -44,7 +45,8 @@ const rule = {
44
45
  const selector = [Kind.ENUM_TYPE_DEFINITION, Kind.ENUM_TYPE_EXTENSION].join(",");
45
46
  return {
46
47
  [selector](node) {
47
- const duplicates = node.values?.filter(
48
+ var _a;
49
+ const duplicates = (_a = node.values) == null ? void 0 : _a.filter(
48
50
  (item, index, array) => array.findIndex((v) => v.name.value.toLowerCase() === item.name.value.toLowerCase()) !== index
49
51
  );
50
52
  for (const duplicate of duplicates || []) {
@@ -1,3 +1,4 @@
1
+ import "../chunk-BMTV3EA2.js";
1
2
  import { Kind } from "graphql";
2
3
  import { requireGraphQLSchemaFromContext } from "../utils.js";
3
4
  const RULE_ID = "no-deprecated";
@@ -110,15 +111,17 @@ const rule = {
110
111
  }
111
112
  return {
112
113
  EnumValue(node) {
114
+ var _a;
113
115
  const typeInfo = node.typeInfo();
114
- const reason = typeInfo.enumValue?.deprecationReason;
116
+ const reason = (_a = typeInfo.enumValue) == null ? void 0 : _a.deprecationReason;
115
117
  if (reason) {
116
118
  report(node, reason);
117
119
  }
118
120
  },
119
121
  Field(node) {
122
+ var _a;
120
123
  const typeInfo = node.typeInfo();
121
- const reason = typeInfo.fieldDef?.deprecationReason;
124
+ const reason = (_a = typeInfo.fieldDef) == null ? void 0 : _a.deprecationReason;
122
125
  if (reason) {
123
126
  report(node, reason);
124
127
  }
@@ -1,3 +1,4 @@
1
+ import "../chunk-BMTV3EA2.js";
1
2
  import { Kind } from "graphql";
2
3
  const RULE_ID = "no-duplicate-fields";
3
4
  const rule = {
@@ -1,3 +1,4 @@
1
+ import "../chunk-BMTV3EA2.js";
1
2
  import { TokenKind } from "graphql";
2
3
  import { getNodeName } from "../utils.js";
3
4
  const RULE_ID = "HASHTAG_COMMENT";
@@ -1,3 +1,4 @@
1
+ import "../chunk-BMTV3EA2.js";
1
2
  import { relative } from "path";
2
3
  import { visit } from "graphql";
3
4
  import { CWD, requireSiblingsOperations } from "../utils.js";
@@ -64,7 +65,7 @@ const rule = {
64
65
  visit(document, {
65
66
  FragmentSpread({ name }) {
66
67
  const spreadName = name.value;
67
- usedFragmentsMap[spreadName] ||= [];
68
+ usedFragmentsMap[spreadName] || (usedFragmentsMap[spreadName] = []);
68
69
  usedFragmentsMap[spreadName].push(relativeFilePath);
69
70
  }
70
71
  });
@@ -1,3 +1,4 @@
1
+ import "../chunk-BMTV3EA2.js";
1
2
  import { ARRAY_DEFAULT_OPTIONS, requireGraphQLSchemaFromContext, truthy } from "../utils.js";
2
3
  const schema = {
3
4
  type: "array",
@@ -1,3 +1,4 @@
1
+ import "../chunk-BMTV3EA2.js";
1
2
  import { isScalarType, Kind } from "graphql";
2
3
  import { getNodeName, requireGraphQLSchemaFromContext } from "../utils.js";
3
4
  const RULE_ID = "no-scalar-result-type-on-mutation";
@@ -1,3 +1,4 @@
1
+ import "../chunk-BMTV3EA2.js";
1
2
  const NO_TYPENAME_PREFIX = "NO_TYPENAME_PREFIX";
2
3
  const rule = {
3
4
  meta: {
@@ -1,3 +1,4 @@
1
+ import "../chunk-BMTV3EA2.js";
1
2
  import {
2
3
  DirectiveLocation,
3
4
  isInterfaceType,
@@ -50,7 +51,7 @@ function getReachableTypes(schema) {
50
51
  for (const { astNode } of [...objects, ...interfaces]) {
51
52
  visit(astNode, visitor);
52
53
  }
53
- } else if (type?.astNode) {
54
+ } else if (type == null ? void 0 : type.astNode) {
54
55
  visit(type.astNode, visitor);
55
56
  }
56
57
  };
@@ -70,7 +71,7 @@ function getReachableTypes(schema) {
70
71
  schema.getMutationType(),
71
72
  schema.getSubscriptionType()
72
73
  ]) {
73
- if (type?.astNode) {
74
+ if (type == null ? void 0 : type.astNode) {
74
75
  visit(type.astNode, visitor);
75
76
  }
76
77
  }
@@ -1,3 +1,4 @@
1
+ import "../chunk-BMTV3EA2.js";
1
2
  import { TypeInfo, visit, visitWithTypeInfo } from "graphql";
2
3
  import { requireGraphQLSchemaFromContext, requireSiblingsOperations } from "../utils.js";
3
4
  const RULE_ID = "no-unused-fields";
@@ -10,13 +11,14 @@ function getUsedFields(schema, operations) {
10
11
  const typeInfo = new TypeInfo(schema);
11
12
  const visitor = visitWithTypeInfo(typeInfo, {
12
13
  Field(node) {
14
+ var _a;
13
15
  const fieldDef = typeInfo.getFieldDef();
14
16
  if (!fieldDef) {
15
17
  return false;
16
18
  }
17
19
  const parentTypeName = typeInfo.getParentType().name;
18
20
  const fieldName = node.name.value;
19
- usedFields[parentTypeName] ??= /* @__PURE__ */ new Set();
21
+ (_a = usedFields[parentTypeName]) != null ? _a : usedFields[parentTypeName] = /* @__PURE__ */ new Set();
20
22
  usedFields[parentTypeName].add(fieldName);
21
23
  }
22
24
  });
@@ -99,9 +101,10 @@ const rule = {
99
101
  const usedFields = getUsedFields(schema, siblingsOperations);
100
102
  return {
101
103
  FieldDefinition(node) {
104
+ var _a;
102
105
  const fieldName = node.name.value;
103
106
  const parentTypeName = node.parent.name.value;
104
- const isUsed = usedFields[parentTypeName]?.has(fieldName);
107
+ const isUsed = (_a = usedFields[parentTypeName]) == null ? void 0 : _a.has(fieldName);
105
108
  if (isUsed) {
106
109
  return;
107
110
  }
@@ -1,3 +1,4 @@
1
+ import "../chunk-BMTV3EA2.js";
1
2
  import { isScalarType, Kind } from "graphql";
2
3
  import { requireGraphQLSchemaFromContext } from "../utils.js";
3
4
  const RULE_ID = "relay-arguments";
@@ -75,12 +76,13 @@ const rule = {
75
76
  const { includeBoth = true } = context.options[0] || {};
76
77
  return {
77
78
  "FieldDefinition > .gqlType Name[value=/Connection$/]"(node) {
79
+ var _a;
78
80
  let fieldNode = node.parent;
79
81
  while (fieldNode.kind !== Kind.FIELD_DEFINITION) {
80
82
  fieldNode = fieldNode.parent;
81
83
  }
82
84
  const args = Object.fromEntries(
83
- fieldNode.arguments?.map((argument) => [argument.name.value, argument]) || []
85
+ ((_a = fieldNode.arguments) == null ? void 0 : _a.map((argument) => [argument.name.value, argument])) || []
84
86
  );
85
87
  const hasForwardPagination = !!(args.first && args.after);
86
88
  const hasBackwardPagination = !!(args.last && args.before);
@@ -1,3 +1,4 @@
1
+ import "../chunk-BMTV3EA2.js";
1
2
  import { Kind } from "graphql";
2
3
  const MUST_BE_OBJECT_TYPE = "MUST_BE_OBJECT_TYPE";
3
4
  const MUST_CONTAIN_FIELD_EDGES = "MUST_CONTAIN_FIELD_EDGES";
@@ -17,8 +18,14 @@ const NON_OBJECT_TYPES = [
17
18
  Kind.INTERFACE_TYPE_EXTENSION
18
19
  ];
19
20
  const notConnectionTypesSelector = `:matches(${NON_OBJECT_TYPES})[name.value=/Connection$/] > .name`;
20
- const hasEdgesField = (node) => node.fields?.some((field) => field.name.value === "edges");
21
- const hasPageInfoField = (node) => node.fields?.some((field) => field.name.value === "pageInfo");
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
+ };
22
29
  const rule = {
23
30
  meta: {
24
31
  type: "problem",
@@ -1,3 +1,4 @@
1
+ import "../chunk-BMTV3EA2.js";
1
2
  import { getDocumentNodeFromSchema } from "@graphql-tools/utils";
2
3
  import {
3
4
  isObjectType,
@@ -19,12 +20,13 @@ function getEdgeTypes(schema2) {
19
20
  const edgeTypes = /* @__PURE__ */ new Set();
20
21
  const visitor = {
21
22
  ObjectTypeDefinition(node) {
23
+ var _a;
22
24
  const typeName = node.name.value;
23
25
  const hasConnectionSuffix = typeName.endsWith("Connection");
24
26
  if (!hasConnectionSuffix) {
25
27
  return;
26
28
  }
27
- const edges = node.fields?.find((field) => field.name.value === "edges");
29
+ const edges = (_a = node.fields) == null ? void 0 : _a.find((field) => field.name.value === "edges");
28
30
  if (edges) {
29
31
  const edgesTypeName = getTypeName(edges);
30
32
  const edgesType = schema2.getType(edgesTypeName);
@@ -118,7 +120,8 @@ const rule = {
118
120
  };
119
121
  const isNamedOrNonNullNamed = (node) => node.kind === Kind.NAMED_TYPE || node.kind === Kind.NON_NULL_TYPE && node.gqlType.kind === Kind.NAMED_TYPE;
120
122
  const checkNodeField = (node) => {
121
- const nodeField = node.fields?.find((field) => field.name.value === "node");
123
+ var _a, _b;
124
+ const nodeField = (_a = node.fields) == null ? void 0 : _a.find((field) => field.name.value === "node");
122
125
  const message = "return either a Scalar, Enum, Object, Interface, Union, or a non-null wrapper around one of those types.";
123
126
  if (!nodeField) {
124
127
  context.report({
@@ -133,14 +136,15 @@ const rule = {
133
136
  if (!isObjectType(type)) {
134
137
  return;
135
138
  }
136
- const implementsNode = type.astNode.interfaces?.some((n) => n.name.value === "Node");
139
+ const implementsNode = (_b = type.astNode.interfaces) == null ? void 0 : _b.some((n) => n.name.value === "Node");
137
140
  if (!implementsNode) {
138
141
  context.report({ node: node.name, messageId: MESSAGE_SHOULD_IMPLEMENTS_NODE });
139
142
  }
140
143
  }
141
144
  };
142
145
  const checkCursorField = (node) => {
143
- const cursorField = node.fields?.find((field) => field.name.value === "cursor");
146
+ var _a;
147
+ const cursorField = (_a = node.fields) == null ? void 0 : _a.find((field) => field.name.value === "cursor");
144
148
  const message = "return either a String, Scalar, or a non-null wrapper wrapper around one of those types.";
145
149
  if (!cursorField) {
146
150
  context.report({
@@ -1,3 +1,4 @@
1
+ import "../chunk-BMTV3EA2.js";
1
2
  import { isScalarType, Kind } from "graphql";
2
3
  import { REPORT_ON_FIRST_CHARACTER, requireGraphQLSchemaFromContext } from "../utils.js";
3
4
  import { NON_OBJECT_TYPES } from "./relay-connection-types.js";
@@ -61,8 +62,9 @@ const rule = {
61
62
  context.report({ node, messageId: MESSAGE_MUST_BE_OBJECT_TYPE });
62
63
  },
63
64
  "ObjectTypeDefinition[name.value=PageInfo]"(node) {
65
+ var _a;
64
66
  const fieldMap = Object.fromEntries(
65
- node.fields?.map((field) => [field.name.value, field]) || []
67
+ ((_a = node.fields) == null ? void 0 : _a.map((field) => [field.name.value, field])) || []
66
68
  );
67
69
  const checkField = (fieldName, typeName) => {
68
70
  const field = fieldMap[fieldName];
@@ -1,3 +1,4 @@
1
+ import "../chunk-BMTV3EA2.js";
1
2
  import { valueFromNode } from "../estree-converter/index.js";
2
3
  import { getNodeName } from "../utils.js";
3
4
  const DATE_REGEX = /^\d{2}\/\d{2}\/\d{4}$/;
@@ -77,8 +78,9 @@ const rule = {
77
78
  create(context) {
78
79
  return {
79
80
  "Directive[name.value=deprecated]"(node) {
80
- const argName = context.options[0]?.argumentName || "deletionDate";
81
- const deletionDateNode = node.arguments?.find((arg) => arg.name.value === argName);
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);
82
84
  if (!deletionDateNode) {
83
85
  context.report({
84
86
  node: node.name,
@@ -1,3 +1,4 @@
1
+ import "../chunk-BMTV3EA2.js";
1
2
  import { valueFromNode } from "../estree-converter/index.js";
2
3
  import { getNodeName } from "../utils.js";
3
4
  const rule = {
@@ -49,7 +50,8 @@ const rule = {
49
50
  create(context) {
50
51
  return {
51
52
  "Directive[name.value=deprecated]"(node) {
52
- const reasonArgument = node.arguments?.find(
53
+ var _a;
54
+ const reasonArgument = (_a = node.arguments) == null ? void 0 : _a.find(
53
55
  (arg) => arg.name.value === "reason"
54
56
  );
55
57
  const value = reasonArgument && String(valueFromNode(reasonArgument.value)).trim();
@@ -1,3 +1,4 @@
1
+ import "../chunk-BMTV3EA2.js";
1
2
  import { getRootTypeNames } from "@graphql-tools/utils";
2
3
  import { Kind, TokenKind } from "graphql";
3
4
  import {
@@ -150,12 +151,13 @@ const rule = {
150
151
  const selector = [...kinds].join(",");
151
152
  return {
152
153
  [selector](node) {
154
+ var _a;
153
155
  let description = "";
154
156
  const isOperation = node.kind === Kind.OPERATION_DEFINITION;
155
157
  if (isOperation) {
156
158
  const rawNode = node.rawNode();
157
159
  const { prev, line } = rawNode.loc.startToken;
158
- if (prev?.kind === TokenKind.COMMENT) {
160
+ if ((prev == null ? void 0 : prev.kind) === TokenKind.COMMENT) {
159
161
  const value = prev.value.trim();
160
162
  const linesBefore = line - prev.line;
161
163
  if (!value.startsWith("eslint") && linesBefore === 1) {
@@ -163,7 +165,7 @@ const rule = {
163
165
  }
164
166
  }
165
167
  } else {
166
- description = node.description?.value.trim() || "";
168
+ description = ((_a = node.description) == null ? void 0 : _a.value.trim()) || "";
167
169
  }
168
170
  if (description.length === 0) {
169
171
  context.report({
@@ -1,3 +1,4 @@
1
+ import "../chunk-BMTV3EA2.js";
1
2
  import { isObjectType } from "graphql";
2
3
  import { getTypeName, requireGraphQLSchemaFromContext } from "../utils.js";
3
4
  const RULE_ID = "require-field-of-type-query-in-mutation-result";
@@ -61,7 +62,7 @@ const rule = {
61
62
  const graphQLType = schema.getType(typeName);
62
63
  if (isObjectType(graphQLType)) {
63
64
  const { fields } = graphQLType.astNode;
64
- const hasQueryType = fields?.some((field) => getTypeName(field) === queryType.name);
65
+ const hasQueryType = fields == null ? void 0 : fields.some((field) => getTypeName(field) === queryType.name);
65
66
  if (!hasQueryType) {
66
67
  context.report({
67
68
  node,
@@ -1,3 +1,4 @@
1
+ import "../chunk-BMTV3EA2.js";
1
2
  import { asArray } from "@graphql-tools/utils";
2
3
  import {
3
4
  GraphQLInterfaceType,
@@ -1,3 +1,4 @@
1
+ import "../chunk-BMTV3EA2.js";
1
2
  import path from "path";
2
3
  import { requireSiblingsOperations } from "../utils.js";
3
4
  const RULE_ID = "require-import-fragment";
@@ -82,6 +83,7 @@ const rule = {
82
83
  const filePath = context.getFilename();
83
84
  return {
84
85
  "FragmentSpread > .name"(node) {
86
+ var _a;
85
87
  const fragmentName = node.value;
86
88
  const fragmentsFromSiblings = siblings.getFragment(fragmentName);
87
89
  for (const comment of comments) {
@@ -92,7 +94,7 @@ const rule = {
92
94
  ).test(comment.value);
93
95
  if (!isPossibleImported)
94
96
  continue;
95
- const extractedImportPath = comment.value.match(/(["'])((?:\1|.)*?)\1/)?.[2];
97
+ const extractedImportPath = (_a = comment.value.match(/(["'])((?:\1|.)*?)\1/)) == null ? void 0 : _a[2];
96
98
  if (!extractedImportPath)
97
99
  continue;
98
100
  const importPath = path.join(path.dirname(filePath), extractedImportPath);
@@ -1,3 +1,4 @@
1
+ import "../chunk-BMTV3EA2.js";
1
2
  import { Kind } from "graphql";
2
3
  import { getNodeName } from "../utils.js";
3
4
  const RULE_ID = "require-nullable-fields-with-oneof";
@@ -1,3 +1,4 @@
1
+ import "../chunk-BMTV3EA2.js";
1
2
  import { Kind } from "graphql";
2
3
  import { getNodeName, requireGraphQLSchemaFromContext, truthy } from "../utils.js";
3
4
  const RULE_ID = "require-nullable-result-in-root";
@@ -57,7 +58,7 @@ const rule = {
57
58
  continue;
58
59
  const name = field.gqlType.gqlType.name.value;
59
60
  const type = schema.getType(name);
60
- const resultType = type?.astNode ? getNodeName(type.astNode) : type?.name;
61
+ const resultType = (type == null ? void 0 : type.astNode) ? getNodeName(type.astNode) : type == null ? void 0 : type.name;
61
62
  context.report({
62
63
  node: field.gqlType,
63
64
  messageId: RULE_ID,
@@ -1,3 +1,4 @@
1
+ import "../chunk-BMTV3EA2.js";
1
2
  import { displayNodeName } from "../utils.js";
2
3
  const RULE_ID = "require-type-pattern-with-oneof";
3
4
  const rule = {
@@ -44,9 +45,10 @@ const rule = {
44
45
  "Directive[name.value=oneOf][parent.kind=ObjectTypeDefinition]"({
45
46
  parent
46
47
  }) {
48
+ var _a;
47
49
  const requiredFields = ["error", "ok"];
48
50
  for (const fieldName of requiredFields) {
49
- if (!parent.fields?.some((field) => field.name.value === fieldName)) {
51
+ if (!((_a = parent.fields) == null ? void 0 : _a.some((field) => field.name.value === fieldName))) {
50
52
  context.report({
51
53
  node: parent.name,
52
54
  messageId: RULE_ID,
@@ -1,3 +1,4 @@
1
+ import "../chunk-BMTV3EA2.js";
1
2
  import { Kind } from "graphql";
2
3
  import depthLimit from "graphql-depth-limit";
3
4
  import { ARRAY_DEFAULT_OPTIONS, logger, requireSiblingsOperations } from "../utils.js";