@graphql-eslint/eslint-plugin 4.0.0-alpha.1 → 4.0.0-alpha.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (173) hide show
  1. package/{esm/cache.d.mts → cjs/cache.d.cts} +1 -1
  2. package/cjs/cache.js +1 -1
  3. package/cjs/configs/index.d.cts +14 -0
  4. package/cjs/configs/index.js +13 -2
  5. package/cjs/documents.js +1 -1
  6. package/{esm/estree-converter/converter.d.mts → cjs/estree-converter/converter.d.cts} +1 -1
  7. package/cjs/estree-converter/index.d.cts +8 -0
  8. package/{esm/estree-converter/utils.d.mts → cjs/estree-converter/utils.d.cts} +3 -3
  9. package/{esm/graphql-config.d.mts → cjs/graphql-config.d.cts} +3 -3
  10. package/cjs/graphql-config.js +2 -2
  11. package/{esm/index.d.mts → cjs/index.d.cts} +13 -10
  12. package/cjs/index.js +3 -3
  13. package/cjs/meta.d.cts +4 -0
  14. package/cjs/meta.js +36 -0
  15. package/cjs/package.json +1 -0
  16. package/{esm/parser.d.mts → cjs/parser.d.cts} +11 -4
  17. package/cjs/parser.js +12 -3
  18. package/{esm/processor.d.mts → cjs/processor.d.cts} +4 -0
  19. package/cjs/processor.js +5 -1
  20. package/{esm/rules/alphabetize.d.mts → cjs/rules/alphabetize.d.cts} +3 -3
  21. package/cjs/rules/alphabetize.js +1 -1
  22. package/{esm/rules/description-style.d.mts → cjs/rules/description-style.d.cts} +3 -3
  23. package/{esm/rules/graphql-js-validation.d.mts → cjs/rules/graphql-js-validation.d.cts} +3 -3
  24. package/{esm/rules/index.d.mts → cjs/rules/index.d.cts} +9 -9
  25. package/{esm/rules/input-name.d.mts → cjs/rules/input-name.d.cts} +3 -3
  26. package/{esm/rules/lone-executable-definition.d.mts → cjs/rules/lone-executable-definition.d.cts} +3 -3
  27. package/{esm/rules/match-document-filename.d.mts → cjs/rules/match-document-filename.d.cts} +4 -4
  28. package/cjs/rules/match-document-filename.js +2 -2
  29. package/{esm/rules/naming-convention.d.mts → cjs/rules/naming-convention.d.cts} +3 -3
  30. package/cjs/rules/no-anonymous-operations.d.cts +13 -0
  31. package/{esm/rules/no-deprecated.d.mts → cjs/rules/no-deprecated.d.cts} +3 -3
  32. package/cjs/rules/no-duplicate-fields.d.cts +13 -0
  33. package/{esm/rules/no-hashtag-description.d.mts → cjs/rules/no-hashtag-description.d.cts} +3 -3
  34. package/cjs/rules/no-one-place-fragments.d.cts +13 -0
  35. package/{esm/rules/no-root-type.d.mts → cjs/rules/no-root-type.d.cts} +3 -3
  36. package/cjs/rules/no-scalar-result-type-on-mutation.d.cts +13 -0
  37. package/cjs/rules/no-typename-prefix.d.cts +13 -0
  38. package/cjs/rules/no-unreachable-types.d.cts +13 -0
  39. package/cjs/rules/no-unreachable-types.js +6 -7
  40. package/cjs/rules/no-unused-fields.d.cts +13 -0
  41. package/cjs/rules/no-unused-fields.js +6 -6
  42. package/{esm/rules/relay-arguments.d.mts → cjs/rules/relay-arguments.d.cts} +3 -3
  43. package/{esm/rules/relay-connection-types.d.mts → cjs/rules/relay-connection-types.d.cts} +3 -3
  44. package/{esm/rules/relay-edge-types.d.mts → cjs/rules/relay-edge-types.d.cts} +3 -3
  45. package/cjs/rules/relay-edge-types.js +1 -1
  46. package/cjs/rules/relay-page-info.d.cts +13 -0
  47. package/cjs/rules/relay-page-info.js +1 -1
  48. package/{esm/rules/require-deprecation-date.d.mts → cjs/rules/require-deprecation-date.d.cts} +3 -3
  49. package/cjs/rules/require-deprecation-reason.d.cts +13 -0
  50. package/{esm/rules/require-description.d.mts → cjs/rules/require-description.d.cts} +3 -3
  51. package/cjs/rules/require-field-of-type-query-in-mutation-result.d.cts +13 -0
  52. package/cjs/rules/require-import-fragment.d.cts +13 -0
  53. package/cjs/rules/require-import-fragment.js +1 -1
  54. package/cjs/rules/require-nullable-fields-with-oneof.d.cts +13 -0
  55. package/cjs/rules/require-nullable-result-in-root.d.cts +13 -0
  56. package/{esm/rules/require-selections.d.mts → cjs/rules/require-selections.d.cts} +3 -3
  57. package/cjs/rules/require-selections.js +1 -0
  58. package/cjs/rules/require-type-pattern-with-oneof.d.cts +13 -0
  59. package/{esm/rules/selection-set-depth.d.mts → cjs/rules/selection-set-depth.d.cts} +3 -3
  60. package/cjs/rules/selection-set-depth.js +2 -2
  61. package/{esm/rules/strict-id-in-types.d.mts → cjs/rules/strict-id-in-types.d.cts} +3 -3
  62. package/cjs/rules/unique-enum-value-names.d.cts +13 -0
  63. package/{esm/rules/unique-fragment-name.d.mts → cjs/rules/unique-fragment-name.d.cts} +3 -3
  64. package/cjs/rules/unique-operation-name.d.cts +13 -0
  65. package/{esm/schema.d.mts → cjs/schema.d.cts} +3 -3
  66. package/cjs/schema.js +1 -1
  67. package/{esm/types.d.mts → cjs/types.d.cts} +2 -2
  68. package/{esm/utils.d.mts → cjs/utils.d.cts} +3 -3
  69. package/cjs/utils.js +1 -1
  70. package/{cjs → esm}/cache.d.ts +1 -1
  71. package/esm/configs/index.d.ts +14 -0
  72. package/esm/configs/index.js +12 -1
  73. package/{cjs → esm}/estree-converter/index.d.ts +2 -2
  74. package/{cjs → esm}/estree-converter/utils.d.ts +3 -3
  75. package/esm/graphql-config.js +1 -1
  76. package/{cjs → esm}/index.d.ts +5 -2
  77. package/esm/index.js +2 -3
  78. package/esm/meta.d.ts +4 -0
  79. package/esm/meta.js +7 -0
  80. package/{cjs → esm}/parser.d.ts +8 -1
  81. package/esm/parser.js +10 -1
  82. package/{cjs → esm}/processor.d.ts +4 -0
  83. package/esm/processor.js +5 -0
  84. package/{cjs → esm}/rules/alphabetize.d.ts +1 -1
  85. package/{cjs → esm}/rules/index.d.ts +8 -8
  86. package/esm/rules/match-document-filename.js +2 -2
  87. package/esm/rules/no-unreachable-types.js +6 -6
  88. package/esm/rules/no-unused-fields.js +6 -5
  89. package/esm/rules/relay-edge-types.js +1 -1
  90. package/esm/rules/relay-page-info.js +1 -1
  91. package/esm/rules/require-selections.js +1 -0
  92. package/esm/rules/selection-set-depth.js +1 -1
  93. package/{index.browser.mjs → index.browser.js} +158 -81
  94. package/package.json +7 -6
  95. package/cjs/configs/index.d.ts +0 -174
  96. package/cjs/flat-configs.d.ts +0 -307
  97. package/cjs/flat-configs.js +0 -55
  98. package/esm/configs/index.d.mts +0 -174
  99. package/esm/estree-converter/index.d.mts +0 -8
  100. package/esm/flat-configs.d.mts +0 -307
  101. package/esm/flat-configs.js +0 -36
  102. package/esm/package.json +0 -1
  103. package/esm/rules/no-anonymous-operations.d.mts +0 -13
  104. package/esm/rules/no-duplicate-fields.d.mts +0 -13
  105. package/esm/rules/no-one-place-fragments.d.mts +0 -13
  106. package/esm/rules/no-scalar-result-type-on-mutation.d.mts +0 -13
  107. package/esm/rules/no-typename-prefix.d.mts +0 -13
  108. package/esm/rules/no-unreachable-types.d.mts +0 -13
  109. package/esm/rules/no-unused-fields.d.mts +0 -13
  110. package/esm/rules/relay-page-info.d.mts +0 -13
  111. package/esm/rules/require-deprecation-reason.d.mts +0 -13
  112. package/esm/rules/require-field-of-type-query-in-mutation-result.d.mts +0 -13
  113. package/esm/rules/require-import-fragment.d.mts +0 -13
  114. package/esm/rules/require-nullable-fields-with-oneof.d.mts +0 -13
  115. package/esm/rules/require-nullable-result-in-root.d.mts +0 -13
  116. package/esm/rules/require-type-pattern-with-oneof.d.mts +0 -13
  117. package/esm/rules/unique-enum-value-names.d.mts +0 -13
  118. package/esm/rules/unique-operation-name.d.mts +0 -13
  119. /package/cjs/configs/{operations-all.d.ts → operations-all.d.cts} +0 -0
  120. /package/cjs/configs/{operations-recommended.d.ts → operations-recommended.d.cts} +0 -0
  121. /package/cjs/configs/{schema-all.d.ts → schema-all.d.cts} +0 -0
  122. /package/cjs/configs/{schema-recommended.d.ts → schema-recommended.d.cts} +0 -0
  123. /package/cjs/configs/{schema-relay.d.ts → schema-relay.d.cts} +0 -0
  124. /package/cjs/{documents.d.ts → documents.d.cts} +0 -0
  125. /package/cjs/estree-converter/{types.d.ts → types.d.cts} +0 -0
  126. /package/cjs/{siblings.d.ts → siblings.d.cts} +0 -0
  127. /package/esm/configs/{operations-all.d.mts → operations-all.d.ts} +0 -0
  128. /package/esm/configs/{operations-recommended.d.mts → operations-recommended.d.ts} +0 -0
  129. /package/esm/configs/{schema-all.d.mts → schema-all.d.ts} +0 -0
  130. /package/esm/configs/{schema-recommended.d.mts → schema-recommended.d.ts} +0 -0
  131. /package/esm/configs/{schema-relay.d.mts → schema-relay.d.ts} +0 -0
  132. /package/esm/{documents.d.mts → documents.d.ts} +0 -0
  133. /package/{cjs → esm}/estree-converter/converter.d.ts +0 -0
  134. /package/esm/estree-converter/{types.d.mts → types.d.ts} +0 -0
  135. /package/{cjs → esm}/graphql-config.d.ts +0 -0
  136. /package/{cjs → esm}/rules/description-style.d.ts +0 -0
  137. /package/{cjs → esm}/rules/graphql-js-validation.d.ts +0 -0
  138. /package/{cjs → esm}/rules/input-name.d.ts +0 -0
  139. /package/{cjs → esm}/rules/lone-executable-definition.d.ts +0 -0
  140. /package/{cjs → esm}/rules/match-document-filename.d.ts +0 -0
  141. /package/{cjs → esm}/rules/naming-convention.d.ts +0 -0
  142. /package/{cjs → esm}/rules/no-anonymous-operations.d.ts +0 -0
  143. /package/{cjs → esm}/rules/no-deprecated.d.ts +0 -0
  144. /package/{cjs → esm}/rules/no-duplicate-fields.d.ts +0 -0
  145. /package/{cjs → esm}/rules/no-hashtag-description.d.ts +0 -0
  146. /package/{cjs → esm}/rules/no-one-place-fragments.d.ts +0 -0
  147. /package/{cjs → esm}/rules/no-root-type.d.ts +0 -0
  148. /package/{cjs → esm}/rules/no-scalar-result-type-on-mutation.d.ts +0 -0
  149. /package/{cjs → esm}/rules/no-typename-prefix.d.ts +0 -0
  150. /package/{cjs → esm}/rules/no-unreachable-types.d.ts +0 -0
  151. /package/{cjs → esm}/rules/no-unused-fields.d.ts +0 -0
  152. /package/{cjs → esm}/rules/relay-arguments.d.ts +0 -0
  153. /package/{cjs → esm}/rules/relay-connection-types.d.ts +0 -0
  154. /package/{cjs → esm}/rules/relay-edge-types.d.ts +0 -0
  155. /package/{cjs → esm}/rules/relay-page-info.d.ts +0 -0
  156. /package/{cjs → esm}/rules/require-deprecation-date.d.ts +0 -0
  157. /package/{cjs → esm}/rules/require-deprecation-reason.d.ts +0 -0
  158. /package/{cjs → esm}/rules/require-description.d.ts +0 -0
  159. /package/{cjs → esm}/rules/require-field-of-type-query-in-mutation-result.d.ts +0 -0
  160. /package/{cjs → esm}/rules/require-import-fragment.d.ts +0 -0
  161. /package/{cjs → esm}/rules/require-nullable-fields-with-oneof.d.ts +0 -0
  162. /package/{cjs → esm}/rules/require-nullable-result-in-root.d.ts +0 -0
  163. /package/{cjs → esm}/rules/require-selections.d.ts +0 -0
  164. /package/{cjs → esm}/rules/require-type-pattern-with-oneof.d.ts +0 -0
  165. /package/{cjs → esm}/rules/selection-set-depth.d.ts +0 -0
  166. /package/{cjs → esm}/rules/strict-id-in-types.d.ts +0 -0
  167. /package/{cjs → esm}/rules/unique-enum-value-names.d.ts +0 -0
  168. /package/{cjs → esm}/rules/unique-fragment-name.d.ts +0 -0
  169. /package/{cjs → esm}/rules/unique-operation-name.d.ts +0 -0
  170. /package/{cjs → esm}/schema.d.ts +0 -0
  171. /package/esm/{siblings.d.mts → siblings.d.ts} +0 -0
  172. /package/{cjs → esm}/types.d.ts +0 -0
  173. /package/{cjs → esm}/utils.d.ts +0 -0
@@ -237,10 +237,23 @@ var require_schema_relay = __commonJS({
237
237
  });
238
238
 
239
239
  // src/parser.ts
240
- import debugFactory from "debug";
240
+ import debugFactory2 from "debug";
241
241
  import { buildSchema, GraphQLError } from "graphql";
242
242
  import { parseGraphQLSDL } from "@graphql-tools/utils";
243
243
 
244
+ // src/cache.ts
245
+ import debugFactory from "debug";
246
+ var log = debugFactory("graphql-eslint:ModuleCache"), ModuleCache = class {
247
+ map = /* @__PURE__ */ new Map();
248
+ set(cacheKey, result) {
249
+ }
250
+ get(cacheKey, settings = {
251
+ lifetime: 10
252
+ /* seconds */
253
+ }) {
254
+ }
255
+ };
256
+
244
257
  // src/estree-converter/converter.ts
245
258
  import {
246
259
  Kind,
@@ -374,6 +387,84 @@ function convertToESTree(node, schema15) {
374
387
  );
375
388
  }
376
389
 
390
+ // package.json
391
+ var package_default = {
392
+ name: "@graphql-eslint/eslint-plugin",
393
+ version: "4.0.0-alpha.3",
394
+ type: "module",
395
+ description: "GraphQL plugin for ESLint",
396
+ repository: "https://github.com/B2o5T/graphql-eslint",
397
+ author: "Dotan Simha <dotansimha@gmail.com>",
398
+ license: "MIT",
399
+ engines: {
400
+ node: ">=18"
401
+ },
402
+ main: "dist/cjs/index.js",
403
+ exports: {
404
+ "./package.json": "./package.json",
405
+ ".": {
406
+ require: {
407
+ types: "./dist/cjs/index.d.ts",
408
+ default: "./dist/cjs/index.js"
409
+ },
410
+ import: {
411
+ types: "./dist/esm/index.d.ts",
412
+ default: "./dist/esm/index.js"
413
+ },
414
+ default: {
415
+ types: "./dist/esm/index.d.ts",
416
+ default: "./dist/esm/index.js"
417
+ }
418
+ }
419
+ },
420
+ types: "dist/esm/index.d.ts",
421
+ keywords: [
422
+ "eslint",
423
+ "eslintplugin",
424
+ "eslint-plugin",
425
+ "graphql"
426
+ ],
427
+ scripts: {
428
+ build: "tsup",
429
+ test: "vitest",
430
+ typecheck: "tsc --noEmit"
431
+ },
432
+ peerDependencies: {
433
+ eslint: ">=8.44.0",
434
+ graphql: "^16"
435
+ },
436
+ dependencies: {
437
+ "@graphql-tools/code-file-loader": "^8.0.0",
438
+ "@graphql-tools/graphql-tag-pluck": "8.3.2-alpha-20240803110708-298aeb8bb2ca4ef649bf09fc42f82fc88c6d5e13",
439
+ "@graphql-tools/utils": "^10.0.0",
440
+ debug: "^4.3.4",
441
+ "fast-glob": "^3.2.12",
442
+ "graphql-config": "^5.1.0",
443
+ "graphql-depth-limit": "^1.1.0",
444
+ "lodash.lowercase": "^4.3.0"
445
+ },
446
+ devDependencies: {
447
+ "@theguild/eslint-rule-tester": "workspace:*",
448
+ "@types/debug": "4.1.12",
449
+ "@types/eslint": "9.6.0",
450
+ "@types/estree": "1.0.5",
451
+ "@types/graphql-depth-limit": "1.1.6",
452
+ "@types/json-schema": "7.0.15",
453
+ "@types/lodash.lowercase": "4.3.9",
454
+ graphql: "16.9.0",
455
+ "json-schema-to-ts": "2.12.0",
456
+ "vite-tsconfig-paths": "^4.3.2"
457
+ },
458
+ publishConfig: {
459
+ directory: "dist",
460
+ access: "public"
461
+ },
462
+ sideEffects: !1
463
+ };
464
+
465
+ // src/meta.ts
466
+ var { name, version } = package_default;
467
+
377
468
  // src/siblings.ts
378
469
  import {
379
470
  Kind as Kind3,
@@ -550,7 +641,7 @@ function getSiblings(documents) {
550
641
  cachedOperations = result;
551
642
  }
552
643
  return cachedOperations;
553
- }, getFragment = (name) => getFragments().filter((f) => f.document.name.value === name), collectFragments = (selectable, recursive, collected = /* @__PURE__ */ new Map()) => (visit2(selectable, {
644
+ }, getFragment = (name2) => getFragments().filter((f) => f.document.name.value === name2), collectFragments = (selectable, recursive, collected = /* @__PURE__ */ new Map()) => (visit2(selectable, {
554
645
  FragmentSpread(spread) {
555
646
  let fragmentName = spread.name.value, [fragment] = getFragment(fragmentName);
556
647
  if (!fragment) {
@@ -567,7 +658,7 @@ function getSiblings(documents) {
567
658
  getFragments,
568
659
  getFragmentByType: (typeName) => getFragments().filter((f) => f.document.typeCondition.name.value === typeName),
569
660
  getFragmentsInUse: (selectable, recursive = !0) => Array.from(collectFragments(selectable, recursive).values()),
570
- getOperation: (name) => getOperations().filter((o) => o.document.name?.value === name),
661
+ getOperation: (name2) => getOperations().filter((o) => o.document.name?.value === name2),
571
662
  getOperations,
572
663
  getOperationByType: (type) => getOperations().filter((o) => o.document.operation === type)
573
664
  };
@@ -575,7 +666,7 @@ function getSiblings(documents) {
575
666
  }
576
667
 
577
668
  // src/parser.ts
578
- var debug = debugFactory("graphql-eslint:parser");
669
+ var debug = debugFactory2("graphql-eslint:parser");
579
670
  debug("cwd %o", CWD);
580
671
  var LEGACY_PARSER_OPTIONS_KEYS = [
581
672
  "schema",
@@ -640,6 +731,13 @@ function parseForESLint(code, options) {
640
731
  throw error;
641
732
  }
642
733
  }
734
+ var parser = {
735
+ parseForESLint,
736
+ meta: {
737
+ name: "@graphql-eslint/parser",
738
+ version
739
+ }
740
+ };
643
741
 
644
742
  // src/rules/alphabetize.ts
645
743
  import {
@@ -1078,10 +1176,10 @@ function validateDocument({
1078
1176
  loc,
1079
1177
  message: error.message,
1080
1178
  suggest: hasDidYouMeanSuggestions ? matches.map((match) => {
1081
- let { name } = match.groups;
1179
+ let { name: name2 } = match.groups;
1082
1180
  return {
1083
- desc: `Rename to \`${name}\``,
1084
- fix: (fixer) => fixer.replaceText(token, name)
1181
+ desc: `Rename to \`${name2}\``,
1182
+ fix: (fixer) => fixer.replaceText(token, name2)
1085
1183
  };
1086
1184
  }) : []
1087
1185
  });
@@ -1105,7 +1203,7 @@ var getFragmentDefsAndFragmentSpreads = (node) => {
1105
1203
  }), { fragmentDefs, fragmentSpreads };
1106
1204
  }, getMissingFragments = (node) => {
1107
1205
  let { fragmentDefs, fragmentSpreads } = getFragmentDefsAndFragmentSpreads(node);
1108
- return [...fragmentSpreads].filter((name) => !fragmentDefs.has(name));
1206
+ return [...fragmentSpreads].filter((name2) => !fragmentDefs.has(name2));
1109
1207
  }, handleMissingFragments = ({ ruleId, context, node }) => {
1110
1208
  let missingFragments = getMissingFragments(node);
1111
1209
  if (missingFragments.length > 0) {
@@ -1742,10 +1840,10 @@ Using the same name for all input parameters will make your schemas easier to co
1742
1840
  return currentNode;
1743
1841
  })(node);
1744
1842
  if (shouldCheckType(inputValueNode.parent.parent)) {
1745
- let mutationName = `${inputValueNode.parent.name.value}Input`, name = node.name.value;
1746
- (options.caseSensitiveInputType && node.name.value !== mutationName || name.toLowerCase() !== mutationName.toLowerCase()) && context.report({
1843
+ let mutationName = `${inputValueNode.parent.name.value}Input`, name2 = node.name.value;
1844
+ (options.caseSensitiveInputType && node.name.value !== mutationName || name2.toLowerCase() !== mutationName.toLowerCase()) && context.report({
1747
1845
  node: node.name,
1748
- message: `Input type \`${name}\` name should be \`${mutationName}\`.`,
1846
+ message: `Input type \`${name2}\` name should be \`${mutationName}\`.`,
1749
1847
  suggest: [
1750
1848
  {
1751
1849
  desc: `Rename to \`${mutationName}\``,
@@ -1828,11 +1926,11 @@ var RULE_ID2 = "lone-executable-definition", definitionTypes = ["fragment", ...O
1828
1926
  },
1829
1927
  "Document:exit"() {
1830
1928
  for (let { node, type } of definitions.slice(1)) {
1831
- let name = pascalCase(type), definitionName = node.name?.value;
1832
- definitionName && (name += ` "${definitionName}"`), context.report({
1929
+ let name2 = pascalCase(type), definitionName = node.name?.value;
1930
+ definitionName && (name2 += ` "${definitionName}"`), context.report({
1833
1931
  loc: node.name?.loc || getLocation(node.loc.start, type),
1834
1932
  messageId: RULE_ID2,
1835
- data: { name }
1933
+ data: { name: name2 }
1836
1934
  });
1837
1935
  }
1838
1936
  }
@@ -2399,51 +2497,51 @@ ${TYPES_KINDS.map((kind) => `- \`${kind}\``).join(`
2399
2497
  report(node, `${nodeType} "${nodeName}" should ${errorMessage}`, suggestedNames);
2400
2498
  }
2401
2499
  function getError() {
2402
- let name = nodeName.replace(/(^_+)|(_+$)/g, "");
2403
- if (ignorePattern && new RegExp(ignorePattern, "u").test(name))
2500
+ let name2 = nodeName.replace(/(^_+)|(_+$)/g, "");
2501
+ if (ignorePattern && new RegExp(ignorePattern, "u").test(name2))
2404
2502
  return;
2405
- if (prefix && !name.startsWith(prefix))
2503
+ if (prefix && !name2.startsWith(prefix))
2406
2504
  return {
2407
2505
  errorMessage: `have "${prefix}" prefix`,
2408
- renameToNames: [prefix + name]
2506
+ renameToNames: [prefix + name2]
2409
2507
  };
2410
- if (suffix && !name.endsWith(suffix))
2508
+ if (suffix && !name2.endsWith(suffix))
2411
2509
  return {
2412
2510
  errorMessage: `have "${suffix}" suffix`,
2413
- renameToNames: [name + suffix]
2511
+ renameToNames: [name2 + suffix]
2414
2512
  };
2415
- let forbiddenPrefix = forbiddenPrefixes?.find((prefix2) => name.startsWith(prefix2));
2513
+ let forbiddenPrefix = forbiddenPrefixes?.find((prefix2) => name2.startsWith(prefix2));
2416
2514
  if (forbiddenPrefix)
2417
2515
  return {
2418
2516
  errorMessage: `not have "${forbiddenPrefix}" prefix`,
2419
- renameToNames: [name.replace(new RegExp(`^${forbiddenPrefix}`), "")]
2517
+ renameToNames: [name2.replace(new RegExp(`^${forbiddenPrefix}`), "")]
2420
2518
  };
2421
- let forbiddenSuffix = forbiddenSuffixes?.find((suffix2) => name.endsWith(suffix2));
2519
+ let forbiddenSuffix = forbiddenSuffixes?.find((suffix2) => name2.endsWith(suffix2));
2422
2520
  if (forbiddenSuffix)
2423
2521
  return {
2424
2522
  errorMessage: `not have "${forbiddenSuffix}" suffix`,
2425
- renameToNames: [name.replace(new RegExp(`${forbiddenSuffix}$`), "")]
2523
+ renameToNames: [name2.replace(new RegExp(`${forbiddenSuffix}$`), "")]
2426
2524
  };
2427
- if (requiredPrefixes && !requiredPrefixes.some((requiredPrefix) => name.startsWith(requiredPrefix)))
2525
+ if (requiredPrefixes && !requiredPrefixes.some((requiredPrefix) => name2.startsWith(requiredPrefix)))
2428
2526
  return {
2429
2527
  errorMessage: `have one of the following prefixes: ${englishJoinWords(
2430
2528
  requiredPrefixes
2431
2529
  )}`,
2432
- renameToNames: style ? requiredPrefixes.map((prefix2) => convertCase(style, `${prefix2} ${name}`)) : requiredPrefixes.map((prefix2) => `${prefix2}${name}`)
2530
+ renameToNames: style ? requiredPrefixes.map((prefix2) => convertCase(style, `${prefix2} ${name2}`)) : requiredPrefixes.map((prefix2) => `${prefix2}${name2}`)
2433
2531
  };
2434
- if (requiredSuffixes && !requiredSuffixes.some((requiredSuffix) => name.endsWith(requiredSuffix)))
2532
+ if (requiredSuffixes && !requiredSuffixes.some((requiredSuffix) => name2.endsWith(requiredSuffix)))
2435
2533
  return {
2436
2534
  errorMessage: `have one of the following suffixes: ${englishJoinWords(
2437
2535
  requiredSuffixes
2438
2536
  )}`,
2439
- renameToNames: style ? requiredSuffixes.map((suffix2) => convertCase(style, `${name} ${suffix2}`)) : requiredSuffixes.map((suffix2) => `${name}${suffix2}`)
2537
+ renameToNames: style ? requiredSuffixes.map((suffix2) => convertCase(style, `${name2} ${suffix2}`)) : requiredSuffixes.map((suffix2) => `${name2}${suffix2}`)
2440
2538
  };
2441
2539
  if (!style)
2442
2540
  return;
2443
- if (!StyleToRegex[style].test(name))
2541
+ if (!StyleToRegex[style].test(name2))
2444
2542
  return {
2445
2543
  errorMessage: `be in ${style} format`,
2446
- renameToNames: [convertCase(style, name)]
2544
+ renameToNames: [convertCase(style, name2)]
2447
2545
  };
2448
2546
  }
2449
2547
  }, checkUnderscore = (isLeading) => (node) => {
@@ -2930,8 +3028,8 @@ var RULE_ID7 = "no-one-place-fragments", rule11 = {
2930
3028
  for (let { document, filePath } of allDocuments) {
2931
3029
  let relativeFilePath = relative(CWD, filePath);
2932
3030
  visit4(document, {
2933
- FragmentSpread({ name }) {
2934
- let spreadName = name.value;
3031
+ FragmentSpread({ name: name2 }) {
3032
+ let spreadName = name2.value;
2935
3033
  usedFragmentsMap[spreadName] ||= [], usedFragmentsMap[spreadName].push(relativeFilePath);
2936
3034
  }
2937
3035
  });
@@ -3186,7 +3284,7 @@ var RULE_ID9 = "no-unreachable-types", KINDS = [
3186
3284
  Kind13.UNION_TYPE_EXTENSION,
3187
3285
  Kind13.ENUM_TYPE_DEFINITION,
3188
3286
  Kind13.ENUM_TYPE_EXTENSION
3189
- ], reachableTypesCache, RequestDirectiveLocations = /* @__PURE__ */ new Set([
3287
+ ], reachableTypesCache = new ModuleCache(), RequestDirectiveLocations = /* @__PURE__ */ new Set([
3190
3288
  DirectiveLocation.QUERY,
3191
3289
  DirectiveLocation.MUTATION,
3192
3290
  DirectiveLocation.SUBSCRIPTION,
@@ -3197,8 +3295,9 @@ var RULE_ID9 = "no-unreachable-types", KINDS = [
3197
3295
  DirectiveLocation.VARIABLE_DEFINITION
3198
3296
  ]);
3199
3297
  function getReachableTypes(schema15) {
3200
- if (reachableTypesCache)
3201
- return reachableTypesCache;
3298
+ let cachedValue = reachableTypesCache.get(schema15);
3299
+ if (cachedValue)
3300
+ return cachedValue;
3202
3301
  let reachableTypes = /* @__PURE__ */ new Set(), collect = (node) => {
3203
3302
  let typeName = getTypeName(node);
3204
3303
  if (reachableTypes.has(typeName))
@@ -3235,7 +3334,7 @@ function getReachableTypes(schema15) {
3235
3334
  argTypeName && reachableTypes.add(argTypeName);
3236
3335
  }
3237
3336
  }
3238
- return reachableTypesCache = reachableTypes, reachableTypesCache;
3337
+ return reachableTypesCache.set(schema15, reachableTypes), reachableTypes;
3239
3338
  }
3240
3339
  var rule15 = {
3241
3340
  meta: {
@@ -3316,10 +3415,11 @@ var rule15 = {
3316
3415
 
3317
3416
  // src/rules/no-unused-fields.ts
3318
3417
  import { TypeInfo as TypeInfo2, visit as visit6, visitWithTypeInfo as visitWithTypeInfo2 } from "graphql";
3319
- var RULE_ID10 = "no-unused-fields", usedFieldsCache;
3418
+ var RULE_ID10 = "no-unused-fields", usedFieldsCache = new ModuleCache();
3320
3419
  function getUsedFields(schema15, operations) {
3321
- if (usedFieldsCache)
3322
- return usedFieldsCache;
3420
+ let cachedValue = usedFieldsCache.get(schema15);
3421
+ if (cachedValue)
3422
+ return cachedValue;
3323
3423
  let usedFields = /* @__PURE__ */ Object.create(null), typeInfo = new TypeInfo2(schema15), visitor = visitWithTypeInfo2(typeInfo, {
3324
3424
  Field(node) {
3325
3425
  if (!typeInfo.getFieldDef())
@@ -3330,7 +3430,7 @@ function getUsedFields(schema15, operations) {
3330
3430
  }), allDocuments = [...operations.getOperations(), ...operations.getFragments()];
3331
3431
  for (let { document } of allDocuments)
3332
3432
  visit6(document, visitor);
3333
- return usedFieldsCache = usedFields, usedFieldsCache;
3433
+ return usedFieldsCache.set(schema15, usedFields), usedFields;
3334
3434
  }
3335
3435
  var rule16 = {
3336
3436
  meta: {
@@ -4463,7 +4563,7 @@ var RULE_ID18 = "require-nullable-result-in-root", rule27 = {
4463
4563
  for (let field of node.fields || []) {
4464
4564
  if (field.gqlType.type !== Kind20.NON_NULL_TYPE || field.gqlType.gqlType.type !== Kind20.NAMED_TYPE)
4465
4565
  continue;
4466
- let name = field.gqlType.gqlType.name.value, type = schema15.getType(name), resultType = type?.astNode ? getNodeName(type.astNode) : type?.name;
4566
+ let name2 = field.gqlType.gqlType.name.value, type = schema15.getType(name2), resultType = type?.astNode ? getNodeName(type.astNode) : type?.name;
4467
4567
  context.report({
4468
4568
  node: field.gqlType,
4469
4569
  messageId: RULE_ID18,
@@ -4520,6 +4620,7 @@ var RULE_ID19 = "require-selections", DEFAULT_ID_FIELD_NAME = "id", schema12 = {
4520
4620
  }, rule28 = {
4521
4621
  meta: {
4522
4622
  type: "suggestion",
4623
+ // eslint-disable-next-line eslint-plugin/require-meta-has-suggestions -- false positive since we assign `problem.suggest` conditionally
4523
4624
  hasSuggestions: !0,
4524
4625
  docs: {
4525
4626
  category: "Operations",
@@ -4622,7 +4723,7 @@ Include it in your selection set{{ addition }}.`
4622
4723
  }
4623
4724
  function checkFields(rawType2) {
4624
4725
  let fields = rawType2.getFields();
4625
- if (!idNames.some((name) => fields[name]))
4726
+ if (!idNames.some((name2) => fields[name2]))
4626
4727
  return;
4627
4728
  function hasIdField({ selections }) {
4628
4729
  return selections.some((selection) => {
@@ -4644,8 +4745,8 @@ Include it in your selection set{{ addition }}.`
4644
4745
  if (checkFragments(node), hasId)
4645
4746
  return;
4646
4747
  let pluralSuffix = idNames.length > 1 ? "s" : "", fieldName2 = englishJoinWords(
4647
- idNames.map((name) => `\`${(parent.alias || parent.name).value}.${name}\``)
4648
- ), addition = checkedFragmentSpreads.size === 0 ? "" : ` or add to used fragment${checkedFragmentSpreads.size > 1 ? "s" : ""} ${englishJoinWords([...checkedFragmentSpreads].map((name) => `\`${name}\``))}`, problem = {
4748
+ idNames.map((name2) => `\`${(parent.alias || parent.name).value}.${name2}\``)
4749
+ ), addition = checkedFragmentSpreads.size === 0 ? "" : ` or add to used fragment${checkedFragmentSpreads.size > 1 ? "s" : ""} ${englishJoinWords([...checkedFragmentSpreads].map((name2) => `\`${name2}\``))}`, problem = {
4649
4750
  loc,
4650
4751
  messageId: RULE_ID19,
4651
4752
  data: {
@@ -4825,7 +4926,7 @@ var RULE_ID21 = "selection-set-depth", schema13 = {
4825
4926
  checkFn({
4826
4927
  getDocument: () => document,
4827
4928
  reportError(error) {
4828
- let { line, column } = error.locations[0], token = context.getAncestors()[0].tokens.find(
4929
+ let { line, column } = error.locations[0], token = context.sourceCode.getAncestors(node)[0].tokens.find(
4829
4930
  (token2) => token2.loc.start.line === line && token2.loc.start.column === column - 1
4830
4931
  );
4831
4932
  context.report({
@@ -5269,50 +5370,26 @@ var rules = {
5269
5370
  };
5270
5371
 
5271
5372
  // src/configs/index.ts
5272
- var import_operations_all = __toESM(require_operations_all()), import_operations_recommended = __toESM(require_operations_recommended()), import_schema_all = __toESM(require_schema_all()), import_schema_recommended = __toESM(require_schema_recommended()), import_schema_relay = __toESM(require_schema_relay()), configs = {
5373
+ var import_operations_all = __toESM(require_operations_all(), 1), import_operations_recommended = __toESM(require_operations_recommended(), 1), import_schema_all = __toESM(require_schema_all(), 1), import_schema_recommended = __toESM(require_schema_recommended(), 1), import_schema_relay = __toESM(require_schema_relay(), 1), configs = {
5273
5374
  "schema-recommended": import_schema_recommended.default,
5274
5375
  "schema-all": import_schema_all.default,
5275
5376
  "schema-relay": import_schema_relay.default,
5276
5377
  "operations-recommended": import_operations_recommended.default,
5277
- "operations-all": import_operations_all.default
5278
- };
5279
-
5280
- // src/flat-configs.ts
5281
- var languageOptions = {
5282
- parser: { parseForESLint }
5283
- }, flatConfigs = {
5284
- "operations-all": {
5285
- languageOptions,
5286
- rules: {
5287
- ...configs["operations-recommended"].rules,
5288
- ...configs["operations-all"].rules
5289
- }
5290
- },
5291
- "operations-recommended": {
5292
- languageOptions,
5293
- rules: configs["operations-recommended"].rules
5378
+ "operations-all": import_operations_all.default,
5379
+ "flat/schema-recommended": import_schema_recommended.default.rules,
5380
+ "flat/schema-all": {
5381
+ ...import_schema_recommended.default.rules,
5382
+ ...import_schema_all.default.rules
5294
5383
  },
5295
- "schema-relay": {
5296
- languageOptions,
5297
- rules: configs["schema-relay"].rules
5298
- },
5299
- "schema-all": {
5300
- languageOptions,
5301
- rules: {
5302
- ...configs["schema-recommended"].rules,
5303
- ...configs["schema-all"].rules
5304
- }
5305
- },
5306
- "schema-recommended": {
5307
- languageOptions,
5308
- rules: configs["schema-recommended"].rules
5384
+ "flat/schema-relay": import_schema_relay.default.rules,
5385
+ "flat/operations-recommended": import_operations_recommended.default.rules,
5386
+ "flat/operations-all": {
5387
+ ...import_operations_recommended.default.rules,
5388
+ ...import_operations_all.default.rules
5309
5389
  }
5310
5390
  };
5311
5391
  export {
5312
5392
  configs,
5313
- flatConfigs,
5314
- parseForESLint,
5315
- requireGraphQLSchemaFromContext,
5316
- requireSiblingsOperations,
5393
+ parser,
5317
5394
  rules
5318
5395
  };
package/package.json CHANGED
@@ -1,6 +1,7 @@
1
1
  {
2
2
  "name": "@graphql-eslint/eslint-plugin",
3
- "version": "4.0.0-alpha.1",
3
+ "version": "4.0.0-alpha.3",
4
+ "type": "module",
4
5
  "description": "GraphQL plugin for ESLint",
5
6
  "repository": "https://github.com/B2o5T/graphql-eslint",
6
7
  "author": "Dotan Simha <dotansimha@gmail.com>",
@@ -12,21 +13,21 @@
12
13
  "exports": {
13
14
  "./package.json": "./package.json",
14
15
  ".": {
15
- "browser": "./index.browser.mjs",
16
16
  "require": {
17
17
  "types": "./cjs/index.d.ts",
18
18
  "default": "./cjs/index.js"
19
19
  },
20
20
  "import": {
21
- "types": "./esm/index.d.mts",
21
+ "types": "./esm/index.d.ts",
22
22
  "default": "./esm/index.js"
23
23
  },
24
24
  "default": {
25
- "types": "./esm/index.d.mts",
25
+ "types": "./esm/index.d.ts",
26
26
  "default": "./esm/index.js"
27
27
  }
28
28
  }
29
29
  },
30
+ "types": "esm/index.d.ts",
30
31
  "keywords": [
31
32
  "eslint",
32
33
  "eslintplugin",
@@ -39,11 +40,11 @@
39
40
  },
40
41
  "dependencies": {
41
42
  "@graphql-tools/code-file-loader": "^8.0.0",
42
- "@graphql-tools/graphql-tag-pluck": "^8.0.0",
43
+ "@graphql-tools/graphql-tag-pluck": "8.3.2-alpha-20240803110708-298aeb8bb2ca4ef649bf09fc42f82fc88c6d5e13",
43
44
  "@graphql-tools/utils": "^10.0.0",
44
45
  "debug": "^4.3.4",
45
46
  "fast-glob": "^3.2.12",
46
- "graphql-config": "^5.0.0",
47
+ "graphql-config": "^5.1.0",
47
48
  "graphql-depth-limit": "^1.1.0",
48
49
  "lodash.lowercase": "^4.3.0"
49
50
  },
@@ -1,174 +0,0 @@
1
- declare const configs: {
2
- 'schema-recommended': {
3
- parser: string;
4
- plugins: string[];
5
- rules: {
6
- '@graphql-eslint/description-style': string;
7
- '@graphql-eslint/known-argument-names': string;
8
- '@graphql-eslint/known-directives': string;
9
- '@graphql-eslint/known-type-names': string;
10
- '@graphql-eslint/lone-schema-definition': string;
11
- '@graphql-eslint/naming-convention': (string | {
12
- types: string;
13
- FieldDefinition: string;
14
- InputValueDefinition: string;
15
- Argument: string;
16
- DirectiveDefinition: string;
17
- EnumValueDefinition: string;
18
- 'FieldDefinition[parent.name.value=Query]': {
19
- forbiddenPrefixes: string[];
20
- forbiddenSuffixes: string[];
21
- };
22
- 'FieldDefinition[parent.name.value=Mutation]': {
23
- forbiddenPrefixes: string[];
24
- forbiddenSuffixes: string[];
25
- };
26
- 'FieldDefinition[parent.name.value=Subscription]': {
27
- forbiddenPrefixes: string[];
28
- forbiddenSuffixes: string[];
29
- };
30
- 'EnumTypeDefinition,EnumTypeExtension': {
31
- forbiddenPrefixes: string[];
32
- forbiddenSuffixes: string[];
33
- };
34
- 'InterfaceTypeDefinition,InterfaceTypeExtension': {
35
- forbiddenPrefixes: string[];
36
- forbiddenSuffixes: string[];
37
- };
38
- 'UnionTypeDefinition,UnionTypeExtension': {
39
- forbiddenPrefixes: string[];
40
- forbiddenSuffixes: string[];
41
- };
42
- 'ObjectTypeDefinition,ObjectTypeExtension': {
43
- forbiddenPrefixes: string[];
44
- forbiddenSuffixes: string[];
45
- };
46
- })[];
47
- '@graphql-eslint/no-hashtag-description': string;
48
- '@graphql-eslint/no-typename-prefix': string;
49
- '@graphql-eslint/no-unreachable-types': string;
50
- '@graphql-eslint/possible-type-extension': string;
51
- '@graphql-eslint/provided-required-arguments': string;
52
- '@graphql-eslint/require-deprecation-reason': string;
53
- '@graphql-eslint/require-description': (string | {
54
- types: boolean;
55
- DirectiveDefinition: boolean;
56
- rootField: boolean;
57
- })[];
58
- '@graphql-eslint/strict-id-in-types': string;
59
- '@graphql-eslint/unique-directive-names': string;
60
- '@graphql-eslint/unique-directive-names-per-location': string;
61
- '@graphql-eslint/unique-enum-value-names': string;
62
- '@graphql-eslint/unique-field-definition-names': string;
63
- '@graphql-eslint/unique-operation-types': string;
64
- '@graphql-eslint/unique-type-names': string;
65
- };
66
- };
67
- 'schema-all': {
68
- extends: string;
69
- rules: {
70
- '@graphql-eslint/alphabetize': (string | {
71
- definitions: boolean;
72
- fields: string[];
73
- values: boolean;
74
- arguments: string[];
75
- groups: string[];
76
- })[];
77
- '@graphql-eslint/input-name': string;
78
- '@graphql-eslint/no-root-type': (string | {
79
- disallow: string[];
80
- })[];
81
- '@graphql-eslint/no-scalar-result-type-on-mutation': string;
82
- '@graphql-eslint/require-deprecation-date': string;
83
- '@graphql-eslint/require-field-of-type-query-in-mutation-result': string;
84
- '@graphql-eslint/require-nullable-fields-with-oneof': string;
85
- '@graphql-eslint/require-nullable-result-in-root': string;
86
- '@graphql-eslint/require-type-pattern-with-oneof': string;
87
- };
88
- };
89
- 'schema-relay': {
90
- parser: string;
91
- plugins: string[];
92
- rules: {
93
- '@graphql-eslint/relay-arguments': string;
94
- '@graphql-eslint/relay-connection-types': string;
95
- '@graphql-eslint/relay-edge-types': string;
96
- '@graphql-eslint/relay-page-info': string;
97
- };
98
- };
99
- 'operations-recommended': {
100
- parser: string;
101
- plugins: string[];
102
- rules: {
103
- '@graphql-eslint/executable-definitions': string;
104
- '@graphql-eslint/fields-on-correct-type': string;
105
- '@graphql-eslint/fragments-on-composite-type': string;
106
- '@graphql-eslint/known-argument-names': string;
107
- '@graphql-eslint/known-directives': string;
108
- '@graphql-eslint/known-fragment-names': string;
109
- '@graphql-eslint/known-type-names': string;
110
- '@graphql-eslint/lone-anonymous-operation': string;
111
- '@graphql-eslint/naming-convention': (string | {
112
- VariableDefinition: string;
113
- OperationDefinition: {
114
- style: string;
115
- forbiddenPrefixes: string[];
116
- forbiddenSuffixes: string[];
117
- };
118
- FragmentDefinition: {
119
- style: string;
120
- forbiddenPrefixes: string[];
121
- forbiddenSuffixes: string[];
122
- };
123
- })[];
124
- '@graphql-eslint/no-anonymous-operations': string;
125
- '@graphql-eslint/no-deprecated': string;
126
- '@graphql-eslint/no-duplicate-fields': string;
127
- '@graphql-eslint/no-fragment-cycles': string;
128
- '@graphql-eslint/no-undefined-variables': string;
129
- '@graphql-eslint/no-unused-fragments': string;
130
- '@graphql-eslint/no-unused-variables': string;
131
- '@graphql-eslint/one-field-subscriptions': string;
132
- '@graphql-eslint/overlapping-fields-can-be-merged': string;
133
- '@graphql-eslint/possible-fragment-spread': string;
134
- '@graphql-eslint/provided-required-arguments': string;
135
- '@graphql-eslint/require-selections': string;
136
- '@graphql-eslint/scalar-leafs': string;
137
- '@graphql-eslint/selection-set-depth': (string | {
138
- maxDepth: number;
139
- })[];
140
- '@graphql-eslint/unique-argument-names': string;
141
- '@graphql-eslint/unique-directive-names-per-location': string;
142
- '@graphql-eslint/unique-fragment-name': string;
143
- '@graphql-eslint/unique-input-field-names': string;
144
- '@graphql-eslint/unique-operation-name': string;
145
- '@graphql-eslint/unique-variable-names': string;
146
- '@graphql-eslint/value-literals-of-correct-type': string;
147
- '@graphql-eslint/variables-are-input-types': string;
148
- '@graphql-eslint/variables-in-allowed-position': string;
149
- };
150
- };
151
- 'operations-all': {
152
- extends: string;
153
- rules: {
154
- '@graphql-eslint/alphabetize': (string | {
155
- definitions: boolean;
156
- selections: string[];
157
- variables: boolean;
158
- arguments: string[];
159
- groups: string[];
160
- })[];
161
- '@graphql-eslint/lone-executable-definition': string;
162
- '@graphql-eslint/match-document-filename': (string | {
163
- query: string;
164
- mutation: string;
165
- subscription: string;
166
- fragment: string;
167
- })[];
168
- '@graphql-eslint/no-one-place-fragments': string;
169
- '@graphql-eslint/require-import-fragment': string;
170
- };
171
- };
172
- };
173
-
174
- export { configs };