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

Sign up to get free protection for your applications and to get access to all the features.
Files changed (222) hide show
  1. package/README.md +2 -0
  2. package/cjs/cache.js +10 -19
  3. package/cjs/configs/index.d.ts +42 -16
  4. package/cjs/configs/index.js +10 -19
  5. package/cjs/configs/operations-all.d.ts +4 -3
  6. package/cjs/configs/operations-all.js +5 -4
  7. package/cjs/configs/operations-recommended.d.ts +3 -1
  8. package/cjs/configs/operations-recommended.js +3 -1
  9. package/cjs/configs/schema-all.d.ts +6 -1
  10. package/cjs/configs/schema-all.js +5 -2
  11. package/cjs/configs/schema-recommended.d.ts +19 -1
  12. package/cjs/configs/schema-recommended.js +22 -2
  13. package/cjs/documents.js +17 -32
  14. package/cjs/estree-converter/converter.js +14 -27
  15. package/cjs/estree-converter/index.js +4 -7
  16. package/cjs/estree-converter/types.js +3 -5
  17. package/cjs/estree-converter/utils.d.ts +2 -3
  18. package/cjs/estree-converter/utils.js +15 -45
  19. package/cjs/flat-configs.d.ts +59 -12
  20. package/cjs/flat-configs.js +9 -14
  21. package/cjs/graphql-config.d.ts +4 -3
  22. package/cjs/graphql-config.js +23 -44
  23. package/cjs/index.d.ts +10 -4
  24. package/cjs/index.js +8 -16
  25. package/cjs/parser.d.ts +4 -3
  26. package/cjs/parser.js +38 -45
  27. package/cjs/processor.d.ts +5 -1
  28. package/cjs/processor.js +25 -57
  29. package/cjs/rules/alphabetize.d.ts +6 -16
  30. package/cjs/rules/alphabetize.js +60 -132
  31. package/cjs/rules/description-style.d.ts +4 -3
  32. package/cjs/rules/description-style.js +11 -18
  33. package/cjs/rules/graphql-js-validation.d.ts +4 -3
  34. package/cjs/rules/graphql-js-validation.js +151 -225
  35. package/cjs/rules/index.d.ts +15 -13
  36. package/cjs/rules/index.js +8 -45
  37. package/cjs/rules/input-name.d.ts +4 -3
  38. package/cjs/rules/input-name.js +43 -59
  39. package/cjs/rules/lone-executable-definition.d.ts +6 -5
  40. package/cjs/rules/lone-executable-definition.js +14 -28
  41. package/cjs/rules/match-document-filename.d.ts +4 -3
  42. package/cjs/rules/match-document-filename.js +39 -70
  43. package/cjs/rules/naming-convention.d.ts +4 -3
  44. package/cjs/rules/naming-convention.js +56 -74
  45. package/cjs/rules/no-anonymous-operations.d.ts +4 -3
  46. package/cjs/rules/no-anonymous-operations.js +11 -18
  47. package/cjs/rules/no-deprecated.d.ts +4 -3
  48. package/cjs/rules/no-deprecated.js +15 -29
  49. package/cjs/rules/no-duplicate-fields.d.ts +4 -3
  50. package/cjs/rules/no-duplicate-fields.js +13 -23
  51. package/cjs/rules/no-hashtag-description.d.ts +4 -3
  52. package/cjs/rules/no-hashtag-description.js +16 -29
  53. package/cjs/rules/no-one-place-fragments.d.ts +4 -3
  54. package/cjs/rules/no-one-place-fragments.js +17 -29
  55. package/cjs/rules/no-root-type.d.ts +4 -3
  56. package/cjs/rules/no-root-type.js +15 -25
  57. package/cjs/rules/no-scalar-result-type-on-mutation.d.ts +4 -3
  58. package/cjs/rules/no-scalar-result-type-on-mutation.js +18 -30
  59. package/cjs/rules/no-typename-prefix.d.ts +4 -3
  60. package/cjs/rules/no-typename-prefix.js +26 -33
  61. package/cjs/rules/no-unreachable-types.d.ts +4 -3
  62. package/cjs/rules/no-unreachable-types.js +25 -47
  63. package/cjs/rules/no-unused-fields.d.ts +4 -3
  64. package/cjs/rules/no-unused-fields.js +24 -49
  65. package/cjs/rules/relay-arguments.d.ts +4 -3
  66. package/cjs/rules/relay-arguments.js +20 -43
  67. package/cjs/rules/relay-connection-types.d.ts +4 -3
  68. package/cjs/rules/relay-connection-types.js +14 -45
  69. package/cjs/rules/relay-edge-types.d.ts +4 -3
  70. package/cjs/rules/relay-edge-types.js +48 -99
  71. package/cjs/rules/relay-page-info.d.ts +4 -3
  72. package/cjs/rules/relay-page-info.js +21 -44
  73. package/cjs/rules/require-deprecation-date.d.ts +4 -3
  74. package/cjs/rules/require-deprecation-date.js +15 -31
  75. package/cjs/rules/require-deprecation-reason.d.ts +4 -3
  76. package/cjs/rules/require-deprecation-reason.js +12 -20
  77. package/cjs/rules/require-description.d.ts +4 -3
  78. package/cjs/rules/require-description.js +39 -65
  79. package/cjs/rules/require-field-of-type-query-in-mutation-result.d.ts +4 -3
  80. package/cjs/rules/require-field-of-type-query-in-mutation-result.js +16 -31
  81. package/cjs/rules/require-import-fragment.d.ts +4 -3
  82. package/cjs/rules/require-import-fragment.js +22 -40
  83. package/cjs/rules/require-nullable-fields-with-oneof.d.ts +4 -3
  84. package/cjs/rules/require-nullable-fields-with-oneof.js +11 -22
  85. package/cjs/rules/require-nullable-result-in-root.d.ts +4 -3
  86. package/cjs/rules/require-nullable-result-in-root.js +34 -44
  87. package/cjs/rules/{require-id-when-available.d.ts → require-selections.d.ts} +4 -3
  88. package/cjs/rules/require-selections.js +198 -0
  89. package/cjs/rules/require-type-pattern-with-oneof.d.ts +4 -3
  90. package/cjs/rules/require-type-pattern-with-oneof.js +15 -23
  91. package/cjs/rules/selection-set-depth.d.ts +4 -3
  92. package/cjs/rules/selection-set-depth.js +18 -34
  93. package/cjs/rules/strict-id-in-types.d.ts +4 -3
  94. package/cjs/rules/strict-id-in-types.js +25 -43
  95. package/cjs/rules/{no-case-insensitive-enum-values-duplicates.d.ts → unique-enum-value-names.d.ts} +4 -3
  96. package/cjs/rules/{no-case-insensitive-enum-values-duplicates.js → unique-enum-value-names.js} +16 -21
  97. package/cjs/rules/unique-fragment-name.d.ts +3 -2
  98. package/cjs/rules/unique-fragment-name.js +24 -36
  99. package/cjs/rules/unique-operation-name.d.ts +4 -3
  100. package/cjs/rules/unique-operation-name.js +10 -12
  101. package/cjs/schema.d.ts +4 -3
  102. package/cjs/schema.js +14 -27
  103. package/cjs/siblings.d.ts +24 -8
  104. package/cjs/siblings.js +42 -82
  105. package/cjs/types.d.ts +74 -7
  106. package/cjs/types.js +3 -5
  107. package/cjs/utils.d.ts +3 -2
  108. package/cjs/utils.js +27 -44
  109. package/esm/cache.js +4 -8
  110. package/esm/{chunk-BMTV3EA2.js → chunk-U3TKCM4X.js} +1 -1
  111. package/esm/configs/index.d.mts +42 -16
  112. package/esm/configs/index.js +4 -4
  113. package/esm/configs/operations-all.d.mts +4 -3
  114. package/esm/configs/operations-all.js +6 -5
  115. package/esm/configs/operations-recommended.d.mts +3 -1
  116. package/esm/configs/operations-recommended.js +4 -2
  117. package/esm/configs/schema-all.d.mts +6 -1
  118. package/esm/configs/schema-all.js +6 -3
  119. package/esm/configs/schema-recommended.d.mts +19 -1
  120. package/esm/configs/schema-recommended.js +23 -3
  121. package/esm/configs/{relay.js → schema-relay.js} +4 -4
  122. package/esm/documents.js +10 -17
  123. package/esm/estree-converter/converter.js +9 -18
  124. package/esm/estree-converter/utils.d.mts +2 -3
  125. package/esm/estree-converter/utils.js +11 -38
  126. package/esm/flat-configs.d.mts +59 -12
  127. package/esm/flat-configs.js +4 -5
  128. package/esm/graphql-config.d.mts +4 -3
  129. package/esm/graphql-config.js +18 -34
  130. package/esm/index.d.mts +10 -4
  131. package/esm/index.js +1 -1
  132. package/esm/parser.d.mts +4 -3
  133. package/esm/parser.js +33 -27
  134. package/esm/processor.d.mts +5 -1
  135. package/esm/processor.js +21 -46
  136. package/esm/rules/alphabetize.d.mts +6 -16
  137. package/esm/rules/alphabetize.js +53 -118
  138. package/esm/rules/description-style.d.mts +4 -3
  139. package/esm/rules/description-style.js +7 -11
  140. package/esm/rules/graphql-js-validation.d.mts +4 -3
  141. package/esm/rules/graphql-js-validation.js +178 -218
  142. package/esm/rules/index.d.mts +15 -13
  143. package/esm/rules/index.js +5 -5
  144. package/esm/rules/input-name.d.mts +4 -3
  145. package/esm/rules/input-name.js +39 -52
  146. package/esm/rules/lone-executable-definition.d.mts +6 -5
  147. package/esm/rules/lone-executable-definition.js +10 -20
  148. package/esm/rules/match-document-filename.d.mts +4 -3
  149. package/esm/rules/match-document-filename.js +35 -61
  150. package/esm/rules/naming-convention.d.mts +4 -3
  151. package/esm/rules/naming-convention.js +51 -65
  152. package/esm/rules/no-anonymous-operations.d.mts +4 -3
  153. package/esm/rules/no-anonymous-operations.js +6 -9
  154. package/esm/rules/no-deprecated.d.mts +4 -3
  155. package/esm/rules/no-deprecated.js +10 -20
  156. package/esm/rules/no-duplicate-fields.d.mts +4 -3
  157. package/esm/rules/no-duplicate-fields.js +9 -16
  158. package/esm/rules/no-hashtag-description.d.mts +4 -3
  159. package/esm/rules/no-hashtag-description.js +11 -20
  160. package/esm/rules/no-one-place-fragments.d.mts +4 -3
  161. package/esm/rules/no-one-place-fragments.js +12 -19
  162. package/esm/rules/no-root-type.d.mts +4 -3
  163. package/esm/rules/no-root-type.js +11 -18
  164. package/esm/rules/no-scalar-result-type-on-mutation.d.mts +4 -3
  165. package/esm/rules/no-scalar-result-type-on-mutation.js +13 -21
  166. package/esm/rules/no-typename-prefix.d.mts +4 -3
  167. package/esm/rules/no-typename-prefix.js +22 -26
  168. package/esm/rules/no-unreachable-types.d.mts +4 -3
  169. package/esm/rules/no-unreachable-types.js +18 -33
  170. package/esm/rules/no-unused-fields.d.mts +4 -3
  171. package/esm/rules/no-unused-fields.js +19 -40
  172. package/esm/rules/relay-arguments.d.mts +4 -3
  173. package/esm/rules/relay-arguments.js +15 -34
  174. package/esm/rules/relay-connection-types.d.mts +4 -3
  175. package/esm/rules/relay-connection-types.js +10 -38
  176. package/esm/rules/relay-edge-types.d.mts +4 -3
  177. package/esm/rules/relay-edge-types.js +43 -89
  178. package/esm/rules/relay-page-info.d.mts +4 -3
  179. package/esm/rules/relay-page-info.js +16 -34
  180. package/esm/rules/require-deprecation-date.d.mts +4 -3
  181. package/esm/rules/require-deprecation-date.js +10 -22
  182. package/esm/rules/require-deprecation-reason.d.mts +4 -3
  183. package/esm/rules/require-deprecation-reason.js +7 -11
  184. package/esm/rules/require-description.d.mts +4 -3
  185. package/esm/rules/require-description.js +34 -55
  186. package/esm/rules/require-field-of-type-query-in-mutation-result.d.mts +4 -3
  187. package/esm/rules/require-field-of-type-query-in-mutation-result.js +11 -22
  188. package/esm/rules/require-import-fragment.d.mts +4 -3
  189. package/esm/rules/require-import-fragment.js +14 -26
  190. package/esm/rules/require-nullable-fields-with-oneof.d.mts +4 -3
  191. package/esm/rules/require-nullable-fields-with-oneof.js +6 -13
  192. package/esm/rules/require-nullable-result-in-root.d.mts +4 -3
  193. package/esm/rules/require-nullable-result-in-root.js +29 -35
  194. package/esm/rules/{require-id-when-available.d.mts → require-selections.d.mts} +4 -3
  195. package/esm/rules/{require-id-when-available.js → require-selections.js} +43 -80
  196. package/esm/rules/require-type-pattern-with-oneof.d.mts +4 -3
  197. package/esm/rules/require-type-pattern-with-oneof.js +11 -16
  198. package/esm/rules/selection-set-depth.d.mts +4 -3
  199. package/esm/rules/selection-set-depth.js +11 -20
  200. package/esm/rules/strict-id-in-types.d.mts +4 -3
  201. package/esm/rules/strict-id-in-types.js +20 -34
  202. package/esm/rules/{no-case-insensitive-enum-values-duplicates.d.mts → unique-enum-value-names.d.mts} +4 -3
  203. package/esm/rules/{no-case-insensitive-enum-values-duplicates.js → unique-enum-value-names.js} +8 -9
  204. package/esm/rules/unique-fragment-name.d.mts +3 -2
  205. package/esm/rules/unique-fragment-name.js +20 -27
  206. package/esm/rules/unique-operation-name.d.mts +4 -3
  207. package/esm/rules/unique-operation-name.js +6 -5
  208. package/esm/schema.d.mts +4 -3
  209. package/esm/schema.js +7 -12
  210. package/esm/siblings.d.mts +24 -8
  211. package/esm/siblings.js +37 -73
  212. package/esm/types.d.mts +74 -7
  213. package/esm/utils.d.mts +3 -2
  214. package/esm/utils.js +20 -31
  215. package/index.browser.mjs +5323 -0
  216. package/package.json +8 -13
  217. package/cjs/rules/require-id-when-available.js +0 -241
  218. package/cjs/types-8d5f4ae0.d.ts +0 -107
  219. package/esm/types-ace77d86.d.ts +0 -107
  220. /package/cjs/configs/{relay.d.ts → schema-relay.d.ts} +0 -0
  221. /package/cjs/configs/{relay.js → schema-relay.js} +0 -0
  222. /package/esm/configs/{relay.d.mts → schema-relay.d.mts} +0 -0
@@ -5,25 +5,20 @@ 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 graphql_js_validation_exports = {};
20
17
  __export(graphql_js_validation_exports, {
21
18
  GRAPHQL_JS_VALIDATIONS: () => GRAPHQL_JS_VALIDATIONS
22
19
  });
23
20
  module.exports = __toCommonJS(graphql_js_validation_exports);
24
- var import_graphql = require("graphql");
25
- var import_validate = require("graphql/validation/validate.js");
26
- var import_utils = require("../utils.js");
21
+ var import_graphql = require("graphql"), import_validation = require("graphql/validation/index.js"), import_validate = require("graphql/validation/validate.js"), import_utils = require("../utils.js");
27
22
  function validateDocument({
28
23
  context,
29
24
  schema = null,
@@ -31,78 +26,61 @@ function validateDocument({
31
26
  rule,
32
27
  hasDidYouMeanSuggestions
33
28
  }) {
34
- var _a;
35
- if (documentNode.definitions.length === 0) {
36
- return;
37
- }
38
- try {
39
- const validationErrors = schema ? (0, import_graphql.validate)(schema, documentNode, [rule]) : (0, import_validate.validateSDL)(documentNode, null, [rule]);
40
- for (const error of validationErrors) {
41
- const { line, column } = error.locations[0];
42
- const sourceCode = context.getSourceCode();
43
- const { tokens } = sourceCode.ast;
44
- const token = tokens.find(
45
- (token2) => token2.loc.start.line === line && token2.loc.start.column === column - 1
46
- );
47
- let loc = {
48
- line,
49
- column: column - 1
50
- };
51
- if (token) {
52
- loc = // if cursor on `@` symbol than use next node
53
- token.type === "@" ? sourceCode.getNodeByRangeIndex(token.range[1] + 1).loc : token.loc;
29
+ if (documentNode.definitions.length !== 0)
30
+ try {
31
+ const validationErrors = schema ? (0, import_graphql.validate)(schema, documentNode, [rule]) : (0, import_validate.validateSDL)(documentNode, null, [rule]);
32
+ for (const error of validationErrors) {
33
+ const { line, column } = error.locations[0], sourceCode = context.getSourceCode(), { tokens } = sourceCode.ast, token = tokens.find(
34
+ (token2) => token2.loc.start.line === line && token2.loc.start.column === column - 1
35
+ );
36
+ let loc = {
37
+ line,
38
+ column: column - 1
39
+ };
40
+ token && (loc = // if cursor on `@` symbol than use next node
41
+ token.type === "@" ? sourceCode.getNodeByRangeIndex(token.range[1] + 1).loc : token.loc);
42
+ const didYouMeanContent = error.message.match(/Did you mean (?<content>.*)\?$/)?.groups.content, matches = didYouMeanContent ? [...didYouMeanContent.matchAll(/"(?<name>[^"]*)"/g)] : [];
43
+ context.report({
44
+ loc,
45
+ message: error.message,
46
+ suggest: hasDidYouMeanSuggestions ? matches.map((match) => {
47
+ const { name } = match.groups;
48
+ return {
49
+ desc: `Rename to \`${name}\``,
50
+ fix: (fixer) => fixer.replaceText(token, name)
51
+ };
52
+ }) : []
53
+ });
54
54
  }
55
- const didYouMeanContent = (_a = error.message.match(/Did you mean (?<content>.*)\?$/)) == null ? void 0 : _a.groups.content;
56
- const matches = didYouMeanContent ? [...didYouMeanContent.matchAll(/"(?<name>[^"]*)"/g)] : [];
55
+ } catch (error) {
57
56
  context.report({
58
- loc,
59
- message: error.message,
60
- suggest: hasDidYouMeanSuggestions ? matches.map((match) => {
61
- const { name } = match.groups;
62
- return {
63
- desc: `Rename to \`${name}\``,
64
- fix: (fixer) => fixer.replaceText(token, name)
65
- };
66
- }) : []
57
+ loc: import_utils.REPORT_ON_FIRST_CHARACTER,
58
+ message: error.message
67
59
  });
68
60
  }
69
- } catch (error) {
70
- context.report({
71
- loc: import_utils.REPORT_ON_FIRST_CHARACTER,
72
- message: error.message
73
- });
74
- }
75
61
  }
76
62
  const getFragmentDefsAndFragmentSpreads = (node) => {
77
- const fragmentDefs = /* @__PURE__ */ new Set();
78
- const fragmentSpreads = /* @__PURE__ */ new Set();
79
- const visitor = {
63
+ const fragmentDefs = /* @__PURE__ */ new Set(), fragmentSpreads = /* @__PURE__ */ new Set();
64
+ return (0, import_graphql.visit)(node, {
80
65
  FragmentDefinition(node2) {
81
66
  fragmentDefs.add(node2.name.value);
82
67
  },
83
68
  FragmentSpread(node2) {
84
69
  fragmentSpreads.add(node2.name.value);
85
70
  }
86
- };
87
- (0, import_graphql.visit)(node, visitor);
88
- return { fragmentDefs, fragmentSpreads };
89
- };
90
- const getMissingFragments = (node) => {
71
+ }), { fragmentDefs, fragmentSpreads };
72
+ }, getMissingFragments = (node) => {
91
73
  const { fragmentDefs, fragmentSpreads } = getFragmentDefsAndFragmentSpreads(node);
92
74
  return [...fragmentSpreads].filter((name) => !fragmentDefs.has(name));
93
- };
94
- const handleMissingFragments = ({ ruleId, context, node }) => {
75
+ }, handleMissingFragments = ({ ruleId, context, node }) => {
95
76
  const missingFragments = getMissingFragments(node);
96
77
  if (missingFragments.length > 0) {
97
- const siblings = (0, import_utils.requireSiblingsOperations)(ruleId, context);
98
- const fragmentsToAdd = [];
78
+ const siblings = (0, import_utils.requireSiblingsOperations)(ruleId, context), fragmentsToAdd = [];
99
79
  for (const fragmentName of missingFragments) {
100
80
  const [foundFragment] = siblings.getFragment(fragmentName).map((source) => source.document);
101
- if (foundFragment) {
102
- fragmentsToAdd.push(foundFragment);
103
- }
81
+ foundFragment && fragmentsToAdd.push(foundFragment);
104
82
  }
105
- if (fragmentsToAdd.length > 0) {
83
+ if (fragmentsToAdd.length > 0)
106
84
  return handleMissingFragments({
107
85
  ruleId,
108
86
  context,
@@ -111,131 +89,105 @@ const handleMissingFragments = ({ ruleId, context, node }) => {
111
89
  definitions: [...node.definitions, ...fragmentsToAdd]
112
90
  }
113
91
  });
114
- }
115
92
  }
116
93
  return node;
117
- };
118
- const validationToRule = ({
94
+ }, validationToRule = ({
119
95
  ruleId,
120
- ruleName,
96
+ rule,
121
97
  getDocumentNode,
122
98
  schema = [],
123
99
  hasDidYouMeanSuggestions
124
- }, docs) => {
125
- let ruleFn = null;
126
- try {
127
- ruleFn = require(`graphql/validation/rules/${ruleName}Rule`)[`${ruleName}Rule`];
128
- } catch {
129
- try {
130
- ruleFn = require(`graphql/validation/rules/${ruleName}`)[`${ruleName}Rule`];
131
- } catch {
132
- ruleFn = require("graphql/validation")[`${ruleName}Rule`];
133
- }
134
- }
135
- return {
136
- [ruleId]: {
137
- meta: {
138
- docs: {
139
- recommended: true,
140
- ...docs,
141
- graphQLJSRuleName: ruleName,
142
- url: `https://the-guild.dev/graphql/eslint/rules/${ruleId}`,
143
- description: `${docs.description}
100
+ }, docs) => ({
101
+ [ruleId]: {
102
+ meta: {
103
+ docs: {
104
+ recommended: !0,
105
+ ...docs,
106
+ graphQLJSRuleName: rule.name,
107
+ url: `https://the-guild.dev/graphql/eslint/rules/${ruleId}`,
108
+ description: `${docs.description}
144
109
  > This rule is a wrapper around a \`graphql-js\` validation function.`
145
- },
146
- schema,
147
- hasSuggestions: hasDidYouMeanSuggestions
148
110
  },
149
- create(context) {
150
- if (!ruleFn) {
151
- import_utils.logger.warn(
152
- `Rule "${ruleId}" depends on a GraphQL validation rule "${ruleName}" but it's not available in the "graphql" version you are using. Skipping\u2026`
153
- );
154
- return {};
111
+ schema,
112
+ hasSuggestions: hasDidYouMeanSuggestions
113
+ },
114
+ create(context) {
115
+ return {
116
+ Document(node) {
117
+ const schema2 = docs.requiresSchema ? (0, import_utils.requireGraphQLSchemaFromContext)(ruleId, context) : null, documentNode = getDocumentNode ? getDocumentNode({ ruleId, context, node: node.rawNode() }) : node.rawNode();
118
+ validateDocument({
119
+ context,
120
+ schema: schema2,
121
+ documentNode,
122
+ rule,
123
+ hasDidYouMeanSuggestions
124
+ });
155
125
  }
156
- return {
157
- Document(node) {
158
- const schema2 = docs.requiresSchema ? (0, import_utils.requireGraphQLSchemaFromContext)(ruleId, context) : null;
159
- const documentNode = getDocumentNode ? getDocumentNode({ ruleId, context, node: node.rawNode() }) : node.rawNode();
160
- validateDocument({
161
- context,
162
- schema: schema2,
163
- documentNode,
164
- rule: ruleFn,
165
- hasDidYouMeanSuggestions
166
- });
167
- }
168
- };
169
- }
126
+ };
170
127
  }
171
- };
172
- };
173
- const GRAPHQL_JS_VALIDATIONS = Object.assign(
128
+ }
129
+ }), GRAPHQL_JS_VALIDATIONS = Object.assign(
174
130
  {},
175
131
  validationToRule(
176
132
  {
177
133
  ruleId: "executable-definitions",
178
- ruleName: "ExecutableDefinitions"
134
+ rule: import_validation.ExecutableDefinitionsRule
179
135
  },
180
136
  {
181
137
  category: "Operations",
182
138
  description: "A GraphQL document is only valid for execution if all definitions are either operation or fragment definitions.",
183
- requiresSchema: true
139
+ requiresSchema: !0
184
140
  }
185
141
  ),
186
142
  validationToRule(
187
143
  {
188
144
  ruleId: "fields-on-correct-type",
189
- ruleName: "FieldsOnCorrectType",
190
- hasDidYouMeanSuggestions: true
145
+ rule: import_validation.FieldsOnCorrectTypeRule,
146
+ hasDidYouMeanSuggestions: !0
191
147
  },
192
148
  {
193
149
  category: "Operations",
194
150
  description: "A GraphQL document is only valid if all fields selected are defined by the parent type, or are an allowed meta field such as `__typename`.",
195
- requiresSchema: true
151
+ requiresSchema: !0
196
152
  }
197
153
  ),
198
154
  validationToRule(
199
155
  {
200
156
  ruleId: "fragments-on-composite-type",
201
- ruleName: "FragmentsOnCompositeTypes"
157
+ rule: import_validation.FragmentsOnCompositeTypesRule
202
158
  },
203
159
  {
204
160
  category: "Operations",
205
161
  description: "Fragments use a type condition to determine if they apply, since fragments can only be spread into a composite type (object, interface, or union), the type condition must also be a composite type.",
206
- requiresSchema: true
162
+ requiresSchema: !0
207
163
  }
208
164
  ),
209
165
  validationToRule(
210
166
  {
211
167
  ruleId: "known-argument-names",
212
- ruleName: "KnownArgumentNames",
213
- hasDidYouMeanSuggestions: true
168
+ rule: import_validation.KnownArgumentNamesRule,
169
+ hasDidYouMeanSuggestions: !0
214
170
  },
215
171
  {
216
172
  category: ["Schema", "Operations"],
217
173
  description: "A GraphQL field is only valid if all supplied arguments are defined by that field.",
218
- requiresSchema: true
174
+ requiresSchema: !0
219
175
  }
220
176
  ),
221
177
  validationToRule(
222
178
  {
223
179
  ruleId: "known-directives",
224
- ruleName: "KnownDirectives",
180
+ rule: import_validation.KnownDirectivesRule,
225
181
  getDocumentNode({ context, node: documentNode }) {
226
182
  const { ignoreClientDirectives = [] } = context.options[0] || {};
227
- if (ignoreClientDirectives.length === 0) {
183
+ if (ignoreClientDirectives.length === 0)
228
184
  return documentNode;
229
- }
230
- const filterDirectives = (node) => {
231
- var _a;
232
- return {
233
- ...node,
234
- directives: (_a = node.directives) == null ? void 0 : _a.filter(
235
- (directive) => !ignoreClientDirectives.includes(directive.name.value)
236
- )
237
- };
238
- };
185
+ const filterDirectives = (node) => ({
186
+ ...node,
187
+ directives: node.directives?.filter(
188
+ (directive) => !ignoreClientDirectives.includes(directive.name.value)
189
+ )
190
+ });
239
191
  return (0, import_graphql.visit)(documentNode, {
240
192
  Field: filterDirectives,
241
193
  OperationDefinition: filterDirectives
@@ -246,7 +198,7 @@ const GRAPHQL_JS_VALIDATIONS = Object.assign(
246
198
  maxItems: 1,
247
199
  items: {
248
200
  type: "object",
249
- additionalProperties: false,
201
+ additionalProperties: !1,
250
202
  required: ["ignoreClientDirectives"],
251
203
  properties: {
252
204
  ignoreClientDirectives: import_utils.ARRAY_DEFAULT_OPTIONS
@@ -257,7 +209,7 @@ const GRAPHQL_JS_VALIDATIONS = Object.assign(
257
209
  {
258
210
  category: ["Schema", "Operations"],
259
211
  description: "A GraphQL document is only valid if all `@directive`s are known by the schema and legally positioned.",
260
- requiresSchema: true,
212
+ requiresSchema: !0,
261
213
  examples: [
262
214
  {
263
215
  title: "Valid",
@@ -279,14 +231,14 @@ const GRAPHQL_JS_VALIDATIONS = Object.assign(
279
231
  validationToRule(
280
232
  {
281
233
  ruleId: "known-fragment-names",
282
- ruleName: "KnownFragmentNames",
234
+ rule: import_validation.KnownFragmentNamesRule,
283
235
  getDocumentNode: handleMissingFragments
284
236
  },
285
237
  {
286
238
  category: "Operations",
287
239
  description: "A GraphQL document is only valid if all `...Fragment` fragment spreads refer to fragments defined in the same document.",
288
- requiresSchema: true,
289
- requiresSiblings: true,
240
+ requiresSchema: !0,
241
+ requiresSiblings: !0,
290
242
  examples: [
291
243
  {
292
244
  title: "Incorrect",
@@ -347,30 +299,30 @@ const GRAPHQL_JS_VALIDATIONS = Object.assign(
347
299
  validationToRule(
348
300
  {
349
301
  ruleId: "known-type-names",
350
- ruleName: "KnownTypeNames",
351
- hasDidYouMeanSuggestions: true
302
+ rule: import_validation.KnownTypeNamesRule,
303
+ hasDidYouMeanSuggestions: !0
352
304
  },
353
305
  {
354
306
  category: ["Schema", "Operations"],
355
307
  description: "A GraphQL document is only valid if referenced types (specifically variable definitions and fragment conditions) are defined by the type schema.",
356
- requiresSchema: true
308
+ requiresSchema: !0
357
309
  }
358
310
  ),
359
311
  validationToRule(
360
312
  {
361
313
  ruleId: "lone-anonymous-operation",
362
- ruleName: "LoneAnonymousOperation"
314
+ rule: import_validation.LoneAnonymousOperationRule
363
315
  },
364
316
  {
365
317
  category: "Operations",
366
318
  description: "A GraphQL document that contains an anonymous operation (the `query` short-hand) is only valid if it contains only that one operation definition.",
367
- requiresSchema: true
319
+ requiresSchema: !0
368
320
  }
369
321
  ),
370
322
  validationToRule(
371
323
  {
372
324
  ruleId: "lone-schema-definition",
373
- ruleName: "LoneSchemaDefinition"
325
+ rule: import_validation.LoneSchemaDefinitionRule
374
326
  },
375
327
  {
376
328
  category: "Schema",
@@ -380,174 +332,160 @@ const GRAPHQL_JS_VALIDATIONS = Object.assign(
380
332
  validationToRule(
381
333
  {
382
334
  ruleId: "no-fragment-cycles",
383
- ruleName: "NoFragmentCycles"
335
+ rule: import_validation.NoFragmentCyclesRule
384
336
  },
385
337
  {
386
338
  category: "Operations",
387
339
  description: "A GraphQL fragment is only valid when it does not have cycles in fragments usage.",
388
- requiresSchema: true
340
+ requiresSchema: !0
389
341
  }
390
342
  ),
391
343
  validationToRule(
392
344
  {
393
345
  ruleId: "no-undefined-variables",
394
- ruleName: "NoUndefinedVariables",
346
+ rule: import_validation.NoUndefinedVariablesRule,
395
347
  getDocumentNode: handleMissingFragments
396
348
  },
397
349
  {
398
350
  category: "Operations",
399
351
  description: "A GraphQL operation is only valid if all variables encountered, both directly and via fragment spreads, are defined by that operation.",
400
- requiresSchema: true,
401
- requiresSiblings: true
352
+ requiresSchema: !0,
353
+ requiresSiblings: !0
402
354
  }
403
355
  ),
404
356
  validationToRule(
405
357
  {
406
358
  ruleId: "no-unused-fragments",
407
- ruleName: "NoUnusedFragments",
359
+ rule: import_validation.NoUnusedFragmentsRule,
408
360
  getDocumentNode: ({ ruleId, context, node }) => {
409
- const siblings = (0, import_utils.requireSiblingsOperations)(ruleId, context);
410
- const FilePathToDocumentsMap = [
361
+ const siblings = (0, import_utils.requireSiblingsOperations)(ruleId, context), FilePathToDocumentsMap = [
411
362
  ...siblings.getOperations(),
412
363
  ...siblings.getFragments()
413
- ].reduce((map, { filePath, document }) => {
414
- var _a;
415
- (_a = map[filePath]) != null ? _a : map[filePath] = [];
416
- map[filePath].push(document);
417
- return map;
418
- }, /* @__PURE__ */ Object.create(null));
419
- const getParentNode = (currentFilePath, node2) => {
364
+ ].reduce((map, { filePath, document }) => (map[filePath] ??= [], map[filePath].push(document), map), /* @__PURE__ */ Object.create(null)), getParentNode = (currentFilePath, node2) => {
420
365
  const { fragmentDefs } = getFragmentDefsAndFragmentSpreads(node2);
421
- if (fragmentDefs.size === 0) {
366
+ if (fragmentDefs.size === 0)
422
367
  return node2;
423
- }
424
368
  delete FilePathToDocumentsMap[currentFilePath];
425
- for (const [filePath, documents] of Object.entries(FilePathToDocumentsMap)) {
426
- const missingFragments = getMissingFragments({
369
+ for (const [filePath, documents] of Object.entries(FilePathToDocumentsMap))
370
+ if (getMissingFragments({
427
371
  kind: import_graphql.Kind.DOCUMENT,
428
372
  definitions: documents
429
- });
430
- const isCurrentFileImportFragment = missingFragments.some(
373
+ }).some(
431
374
  (fragment) => fragmentDefs.has(fragment)
432
- );
433
- if (isCurrentFileImportFragment) {
375
+ ))
434
376
  return getParentNode(filePath, {
435
377
  kind: import_graphql.Kind.DOCUMENT,
436
378
  definitions: [...node2.definitions, ...documents]
437
379
  });
438
- }
439
- }
440
380
  return node2;
441
381
  };
442
- return getParentNode(context.getFilename(), node);
382
+ return getParentNode(context.filename, node);
443
383
  }
444
384
  },
445
385
  {
446
386
  category: "Operations",
447
387
  description: "A GraphQL document is only valid if all fragment definitions are spread within operations, or spread within other fragments spread within operations.",
448
- requiresSchema: true,
449
- requiresSiblings: true
388
+ requiresSchema: !0,
389
+ requiresSiblings: !0
450
390
  }
451
391
  ),
452
392
  validationToRule(
453
393
  {
454
394
  ruleId: "no-unused-variables",
455
- ruleName: "NoUnusedVariables",
395
+ rule: import_validation.NoUnusedVariablesRule,
456
396
  getDocumentNode: handleMissingFragments
457
397
  },
458
398
  {
459
399
  category: "Operations",
460
400
  description: "A GraphQL operation is only valid if all variables defined by an operation are used, either directly or within a spread fragment.",
461
- requiresSchema: true,
462
- requiresSiblings: true
401
+ requiresSchema: !0,
402
+ requiresSiblings: !0
463
403
  }
464
404
  ),
465
405
  validationToRule(
466
406
  {
467
407
  ruleId: "overlapping-fields-can-be-merged",
468
- ruleName: "OverlappingFieldsCanBeMerged"
408
+ rule: import_validation.OverlappingFieldsCanBeMergedRule
469
409
  },
470
410
  {
471
411
  category: "Operations",
472
412
  description: "A selection set is only valid if all fields (including spreading any fragments) either correspond to distinct response names or can be merged without ambiguity.",
473
- requiresSchema: true
413
+ requiresSchema: !0
474
414
  }
475
415
  ),
476
416
  validationToRule(
477
417
  {
478
418
  ruleId: "possible-fragment-spread",
479
- ruleName: "PossibleFragmentSpreads"
419
+ rule: import_validation.PossibleFragmentSpreadsRule
480
420
  },
481
421
  {
482
422
  category: "Operations",
483
423
  description: "A fragment spread is only valid if the type condition could ever possibly be true: if there is a non-empty intersection of the possible parent types, and possible types which pass the type condition.",
484
- requiresSchema: true
424
+ requiresSchema: !0
485
425
  }
486
426
  ),
487
427
  validationToRule(
488
428
  {
489
429
  ruleId: "possible-type-extension",
490
- ruleName: "PossibleTypeExtensions",
491
- hasDidYouMeanSuggestions: true
430
+ rule: import_validation.PossibleTypeExtensionsRule,
431
+ hasDidYouMeanSuggestions: !0
492
432
  },
493
433
  {
494
434
  category: "Schema",
495
435
  description: "A type extension is only valid if the type is defined and has the same kind.",
496
- // TODO: add in graphql-eslint v4
497
- recommended: false,
498
- requiresSchema: true,
499
- isDisabledForAllConfig: true
436
+ recommended: !0,
437
+ requiresSchema: !0
500
438
  }
501
439
  ),
502
440
  validationToRule(
503
441
  {
504
442
  ruleId: "provided-required-arguments",
505
- ruleName: "ProvidedRequiredArguments"
443
+ rule: import_validation.ProvidedRequiredArgumentsRule
506
444
  },
507
445
  {
508
446
  category: ["Schema", "Operations"],
509
447
  description: "A field or directive is only valid if all required (non-null without a default value) field arguments have been provided.",
510
- requiresSchema: true
448
+ requiresSchema: !0
511
449
  }
512
450
  ),
513
451
  validationToRule(
514
452
  {
515
453
  ruleId: "scalar-leafs",
516
- ruleName: "ScalarLeafs",
517
- hasDidYouMeanSuggestions: true
454
+ rule: import_validation.ScalarLeafsRule,
455
+ hasDidYouMeanSuggestions: !0
518
456
  },
519
457
  {
520
458
  category: "Operations",
521
459
  description: "A GraphQL document is valid only if all leaf fields (fields without sub selections) are of scalar or enum types.",
522
- requiresSchema: true
460
+ requiresSchema: !0
523
461
  }
524
462
  ),
525
463
  validationToRule(
526
464
  {
527
465
  ruleId: "one-field-subscriptions",
528
- ruleName: "SingleFieldSubscriptions"
466
+ rule: import_validation.SingleFieldSubscriptionsRule
529
467
  },
530
468
  {
531
469
  category: "Operations",
532
470
  description: "A GraphQL subscription is valid only if it contains a single root field.",
533
- requiresSchema: true
471
+ requiresSchema: !0
534
472
  }
535
473
  ),
536
474
  validationToRule(
537
475
  {
538
476
  ruleId: "unique-argument-names",
539
- ruleName: "UniqueArgumentNames"
477
+ rule: import_validation.UniqueArgumentNamesRule
540
478
  },
541
479
  {
542
480
  category: "Operations",
543
481
  description: "A GraphQL field or directive is only valid if all supplied arguments are uniquely named.",
544
- requiresSchema: true
482
+ requiresSchema: !0
545
483
  }
546
484
  ),
547
485
  validationToRule(
548
486
  {
549
487
  ruleId: "unique-directive-names",
550
- ruleName: "UniqueDirectiveNames"
488
+ rule: import_validation.UniqueDirectiveNamesRule
551
489
  },
552
490
  {
553
491
  category: "Schema",
@@ -557,30 +495,18 @@ const GRAPHQL_JS_VALIDATIONS = Object.assign(
557
495
  validationToRule(
558
496
  {
559
497
  ruleId: "unique-directive-names-per-location",
560
- ruleName: "UniqueDirectivesPerLocation"
498
+ rule: import_validation.UniqueDirectivesPerLocationRule
561
499
  },
562
500
  {
563
501
  category: ["Schema", "Operations"],
564
502
  description: "A GraphQL document is only valid if all non-repeatable directives at a given location are uniquely named.",
565
- requiresSchema: true
566
- }
567
- ),
568
- validationToRule(
569
- {
570
- ruleId: "unique-enum-value-names",
571
- ruleName: "UniqueEnumValueNames"
572
- },
573
- {
574
- category: "Schema",
575
- description: "A GraphQL enum type is only valid if all its values are uniquely named.",
576
- recommended: false,
577
- isDisabledForAllConfig: true
503
+ requiresSchema: !0
578
504
  }
579
505
  ),
580
506
  validationToRule(
581
507
  {
582
508
  ruleId: "unique-field-definition-names",
583
- ruleName: "UniqueFieldDefinitionNames"
509
+ rule: import_validation.UniqueFieldDefinitionNamesRule
584
510
  },
585
511
  {
586
512
  category: "Schema",
@@ -590,7 +516,7 @@ const GRAPHQL_JS_VALIDATIONS = Object.assign(
590
516
  validationToRule(
591
517
  {
592
518
  ruleId: "unique-input-field-names",
593
- ruleName: "UniqueInputFieldNames"
519
+ rule: import_validation.UniqueInputFieldNamesRule
594
520
  },
595
521
  {
596
522
  category: "Operations",
@@ -600,7 +526,7 @@ const GRAPHQL_JS_VALIDATIONS = Object.assign(
600
526
  validationToRule(
601
527
  {
602
528
  ruleId: "unique-operation-types",
603
- ruleName: "UniqueOperationTypes"
529
+ rule: import_validation.UniqueOperationTypesRule
604
530
  },
605
531
  {
606
532
  category: "Schema",
@@ -610,7 +536,7 @@ const GRAPHQL_JS_VALIDATIONS = Object.assign(
610
536
  validationToRule(
611
537
  {
612
538
  ruleId: "unique-type-names",
613
- ruleName: "UniqueTypeNames"
539
+ rule: import_validation.UniqueTypeNamesRule
614
540
  },
615
541
  {
616
542
  category: "Schema",
@@ -620,46 +546,46 @@ const GRAPHQL_JS_VALIDATIONS = Object.assign(
620
546
  validationToRule(
621
547
  {
622
548
  ruleId: "unique-variable-names",
623
- ruleName: "UniqueVariableNames"
549
+ rule: import_validation.UniqueVariableNamesRule
624
550
  },
625
551
  {
626
552
  category: "Operations",
627
553
  description: "A GraphQL operation is only valid if all its variables are uniquely named.",
628
- requiresSchema: true
554
+ requiresSchema: !0
629
555
  }
630
556
  ),
631
557
  validationToRule(
632
558
  {
633
559
  ruleId: "value-literals-of-correct-type",
634
- ruleName: "ValuesOfCorrectType",
635
- hasDidYouMeanSuggestions: true
560
+ rule: import_validation.ValuesOfCorrectTypeRule,
561
+ hasDidYouMeanSuggestions: !0
636
562
  },
637
563
  {
638
564
  category: "Operations",
639
565
  description: "A GraphQL document is only valid if all value literals are of the type expected at their position.",
640
- requiresSchema: true
566
+ requiresSchema: !0
641
567
  }
642
568
  ),
643
569
  validationToRule(
644
570
  {
645
571
  ruleId: "variables-are-input-types",
646
- ruleName: "VariablesAreInputTypes"
572
+ rule: import_validation.VariablesAreInputTypesRule
647
573
  },
648
574
  {
649
575
  category: "Operations",
650
576
  description: "A GraphQL operation is only valid if all the variables it defines are of input types (scalar, enum, or input object).",
651
- requiresSchema: true
577
+ requiresSchema: !0
652
578
  }
653
579
  ),
654
580
  validationToRule(
655
581
  {
656
582
  ruleId: "variables-in-allowed-position",
657
- ruleName: "VariablesInAllowedPosition"
583
+ rule: import_validation.VariablesInAllowedPositionRule
658
584
  },
659
585
  {
660
586
  category: "Operations",
661
587
  description: "Variables passed to field arguments conform to type.",
662
- requiresSchema: true
588
+ requiresSchema: !0
663
589
  }
664
590
  )
665
591
  );