@graphql-eslint/eslint-plugin 4.0.0-alpha.6 → 4.0.0-alpha.7

Sign up to get free protection for your applications and to get access to all the features.
Files changed (209) hide show
  1. package/cjs/cache.js +8 -36
  2. package/cjs/chunk-UIAXBAMD.js +8 -0
  3. package/cjs/configs/index.d.cts +15 -5
  4. package/cjs/configs/index.js +31 -45
  5. package/cjs/configs/operations-all.js +33 -26
  6. package/cjs/configs/operations-recommended.js +59 -52
  7. package/cjs/configs/schema-all.js +29 -22
  8. package/cjs/configs/schema-recommended.js +73 -66
  9. package/cjs/configs/schema-relay.js +17 -10
  10. package/cjs/documents.js +12 -37
  11. package/cjs/estree-converter/converter.js +16 -30
  12. package/cjs/estree-converter/index.js +3 -23
  13. package/cjs/estree-converter/types.js +1 -14
  14. package/cjs/estree-converter/utils.js +22 -40
  15. package/cjs/graphql-config.js +15 -41
  16. package/cjs/index.d.cts +164 -9
  17. package/cjs/index.js +24 -41
  18. package/cjs/meta.js +5 -25
  19. package/cjs/parser.js +29 -49
  20. package/cjs/processor.js +22 -35
  21. package/{esm/rules/alphabetize.d.ts → cjs/rules/alphabetize/index.d.cts} +3 -3
  22. package/cjs/rules/{alphabetize.js → alphabetize/index.js} +47 -71
  23. package/{esm/rules/description-style.d.ts → cjs/rules/description-style/index.d.cts} +3 -3
  24. package/cjs/rules/{description-style.js → description-style/index.js} +7 -27
  25. package/cjs/rules/graphql-js-validation.js +93 -70
  26. package/cjs/rules/index.d.cts +5 -5
  27. package/cjs/rules/index.js +74 -60
  28. package/{esm/rules/input-name.d.ts → cjs/rules/input-name/index.d.cts} +3 -3
  29. package/cjs/rules/{input-name.js → input-name/index.js} +10 -28
  30. package/{esm/rules/lone-executable-definition.d.ts → cjs/rules/lone-executable-definition/index.d.cts} +3 -3
  31. package/cjs/rules/{lone-executable-definition.js → lone-executable-definition/index.js} +13 -32
  32. package/cjs/rules/{match-document-filename.d.cts → match-document-filename/index.d.cts} +4 -4
  33. package/cjs/rules/{match-document-filename.js → match-document-filename/index.js} +20 -34
  34. package/{esm/rules/naming-convention.d.ts → cjs/rules/naming-convention/index.d.cts} +3 -3
  35. package/cjs/rules/{naming-convention.js → naming-convention/index.js} +41 -54
  36. package/cjs/rules/no-anonymous-operations/index.d.cts +13 -0
  37. package/cjs/rules/{no-anonymous-operations.js → no-anonymous-operations/index.js} +9 -28
  38. package/cjs/rules/{no-deprecated.d.cts → no-deprecated/index.d.cts} +3 -3
  39. package/cjs/rules/{no-deprecated.js → no-deprecated/index.js} +11 -30
  40. package/cjs/rules/no-duplicate-fields/index.d.cts +13 -0
  41. package/cjs/rules/{no-duplicate-fields.js → no-duplicate-fields/index.js} +8 -28
  42. package/cjs/rules/{no-hashtag-description.d.cts → no-hashtag-description/index.d.cts} +3 -3
  43. package/cjs/rules/{no-hashtag-description.js → no-hashtag-description/index.js} +11 -31
  44. package/cjs/rules/no-one-place-fragments/index.d.cts +13 -0
  45. package/cjs/rules/{no-one-place-fragments.js → no-one-place-fragments/index.js} +11 -29
  46. package/cjs/rules/{no-root-type.d.cts → no-root-type/index.d.cts} +3 -3
  47. package/cjs/rules/{no-root-type.js → no-root-type/index.js} +9 -29
  48. package/cjs/rules/no-scalar-result-type-on-mutation/index.d.cts +13 -0
  49. package/cjs/rules/no-scalar-result-type-on-mutation/index.js +69 -0
  50. package/cjs/rules/no-typename-prefix/index.d.cts +13 -0
  51. package/cjs/rules/{no-typename-prefix.js → no-typename-prefix/index.js} +5 -25
  52. package/cjs/rules/no-unreachable-types/index.d.cts +13 -0
  53. package/cjs/rules/no-unreachable-types/index.js +155 -0
  54. package/cjs/rules/no-unused-fields/index.d.cts +13 -0
  55. package/cjs/rules/{no-unused-fields.js → no-unused-fields/index.js} +12 -30
  56. package/{esm/rules/relay-arguments.d.ts → cjs/rules/relay-arguments/index.d.cts} +3 -3
  57. package/cjs/rules/{relay-arguments.js → relay-arguments/index.js} +11 -30
  58. package/{esm/rules/relay-connection-types.d.ts → cjs/rules/relay-connection-types/index.d.cts} +3 -3
  59. package/cjs/rules/{relay-connection-types.js → relay-connection-types/index.js} +19 -40
  60. package/{esm/rules/relay-edge-types.d.ts → cjs/rules/relay-edge-types/index.d.cts} +3 -3
  61. package/cjs/rules/{relay-edge-types.js → relay-edge-types/index.js} +30 -43
  62. package/cjs/rules/relay-page-info/index.d.cts +13 -0
  63. package/cjs/rules/{relay-page-info.js → relay-page-info/index.js} +12 -30
  64. package/{esm/rules/require-deprecation-date.d.ts → cjs/rules/require-deprecation-date/index.d.cts} +3 -3
  65. package/cjs/rules/{require-deprecation-date.js → require-deprecation-date/index.js} +13 -32
  66. package/cjs/rules/require-deprecation-reason/index.d.cts +13 -0
  67. package/cjs/rules/require-deprecation-reason/index.js +66 -0
  68. package/cjs/rules/{require-description.d.cts → require-description/index.d.cts} +3 -3
  69. package/cjs/rules/{require-description.js → require-description/index.js} +30 -44
  70. package/cjs/rules/require-field-of-type-query-in-mutation-result/index.d.cts +13 -0
  71. package/cjs/rules/{require-field-of-type-query-in-mutation-result.js → require-field-of-type-query-in-mutation-result/index.js} +10 -29
  72. package/cjs/rules/require-import-fragment/index.d.cts +13 -0
  73. package/cjs/rules/{require-import-fragment.js → require-import-fragment/index.js} +11 -38
  74. package/cjs/rules/require-nullable-fields-with-oneof/index.d.cts +13 -0
  75. package/cjs/rules/require-nullable-fields-with-oneof/index.js +62 -0
  76. package/cjs/rules/require-nullable-result-in-root/index.d.cts +13 -0
  77. package/cjs/rules/{require-nullable-result-in-root.js → require-nullable-result-in-root/index.js} +12 -31
  78. package/cjs/rules/{require-selections.d.cts → require-selections/index.d.cts} +3 -3
  79. package/cjs/rules/{require-selections.js → require-selections/index.js} +38 -43
  80. package/cjs/rules/require-type-pattern-with-oneof/index.d.cts +13 -0
  81. package/cjs/rules/require-type-pattern-with-oneof/index.js +63 -0
  82. package/{esm/rules/selection-set-depth.d.ts → cjs/rules/selection-set-depth/index.d.cts} +3 -3
  83. package/cjs/rules/{selection-set-depth.js → selection-set-depth/index.js} +15 -41
  84. package/cjs/rules/{strict-id-in-types.d.cts → strict-id-in-types/index.d.cts} +3 -3
  85. package/cjs/rules/{strict-id-in-types.js → strict-id-in-types/index.js} +26 -39
  86. package/cjs/rules/unique-enum-value-names/index.d.cts +13 -0
  87. package/cjs/rules/{unique-enum-value-names.js → unique-enum-value-names/index.js} +10 -29
  88. package/{esm/rules/unique-fragment-name.d.ts → cjs/rules/unique-fragment-name/index.d.cts} +3 -3
  89. package/cjs/rules/unique-fragment-name/index.js +87 -0
  90. package/cjs/rules/unique-operation-name/index.d.cts +13 -0
  91. package/cjs/rules/{unique-operation-name.js → unique-operation-name/index.js} +7 -27
  92. package/cjs/schema.js +11 -36
  93. package/cjs/siblings.js +17 -33
  94. package/cjs/types.js +1 -14
  95. package/cjs/utils.d.cts +2 -2
  96. package/cjs/utils.js +71 -115
  97. package/esm/configs/index.d.ts +15 -5
  98. package/esm/configs/index.js +17 -7
  99. package/esm/index.d.ts +164 -9
  100. package/esm/index.js +9 -2
  101. package/esm/meta.js +1 -1
  102. package/{cjs/rules/alphabetize.d.cts → esm/rules/alphabetize/index.d.ts} +3 -3
  103. package/esm/rules/{alphabetize.js → alphabetize/index.js} +2 -2
  104. package/{cjs/rules/description-style.d.cts → esm/rules/description-style/index.d.ts} +3 -3
  105. package/esm/rules/{description-style.js → description-style/index.js} +2 -2
  106. package/esm/rules/index.d.ts +5 -5
  107. package/esm/rules/index.js +34 -34
  108. package/{cjs/rules/input-name.d.cts → esm/rules/input-name/index.d.ts} +3 -3
  109. package/esm/rules/{input-name.js → input-name/index.js} +1 -1
  110. package/{cjs/rules/lone-executable-definition.d.cts → esm/rules/lone-executable-definition/index.d.ts} +3 -3
  111. package/esm/rules/{lone-executable-definition.js → lone-executable-definition/index.js} +2 -2
  112. package/esm/rules/{match-document-filename.d.ts → match-document-filename/index.d.ts} +4 -4
  113. package/esm/rules/{match-document-filename.js → match-document-filename/index.js} +2 -2
  114. package/{cjs/rules/naming-convention.d.cts → esm/rules/naming-convention/index.d.ts} +3 -3
  115. package/esm/rules/{naming-convention.js → naming-convention/index.js} +2 -2
  116. package/{cjs/rules/no-anonymous-operations.d.cts → esm/rules/no-anonymous-operations/index.d.ts} +3 -3
  117. package/esm/rules/{no-anonymous-operations.js → no-anonymous-operations/index.js} +2 -2
  118. package/esm/rules/{no-deprecated.d.ts → no-deprecated/index.d.ts} +3 -3
  119. package/esm/rules/{no-deprecated.js → no-deprecated/index.js} +2 -2
  120. package/{cjs/rules/no-one-place-fragments.d.cts → esm/rules/no-duplicate-fields/index.d.ts} +3 -3
  121. package/esm/rules/{no-duplicate-fields.js → no-duplicate-fields/index.js} +1 -1
  122. package/esm/rules/{no-hashtag-description.d.ts → no-hashtag-description/index.d.ts} +3 -3
  123. package/esm/rules/{no-hashtag-description.js → no-hashtag-description/index.js} +2 -2
  124. package/{cjs/rules/no-duplicate-fields.d.cts → esm/rules/no-one-place-fragments/index.d.ts} +3 -3
  125. package/esm/rules/{no-one-place-fragments.js → no-one-place-fragments/index.js} +2 -2
  126. package/esm/rules/{no-root-type.d.ts → no-root-type/index.d.ts} +3 -3
  127. package/esm/rules/{no-root-type.js → no-root-type/index.js} +2 -2
  128. package/{cjs/rules/no-scalar-result-type-on-mutation.d.cts → esm/rules/no-scalar-result-type-on-mutation/index.d.ts} +3 -3
  129. package/esm/rules/{no-scalar-result-type-on-mutation.js → no-scalar-result-type-on-mutation/index.js} +2 -2
  130. package/esm/rules/no-typename-prefix/index.d.ts +13 -0
  131. package/esm/rules/{no-typename-prefix.js → no-typename-prefix/index.js} +1 -1
  132. package/esm/rules/no-unreachable-types/index.d.ts +13 -0
  133. package/esm/rules/{no-unreachable-types.js → no-unreachable-types/index.js} +3 -3
  134. package/esm/rules/no-unused-fields/index.d.ts +13 -0
  135. package/esm/rules/{no-unused-fields.js → no-unused-fields/index.js} +3 -3
  136. package/{cjs/rules/relay-arguments.d.cts → esm/rules/relay-arguments/index.d.ts} +3 -3
  137. package/esm/rules/{relay-arguments.js → relay-arguments/index.js} +2 -2
  138. package/{cjs/rules/relay-connection-types.d.cts → esm/rules/relay-connection-types/index.d.ts} +3 -3
  139. package/esm/rules/{relay-connection-types.js → relay-connection-types/index.js} +1 -1
  140. package/{cjs/rules/relay-edge-types.d.cts → esm/rules/relay-edge-types/index.d.ts} +3 -3
  141. package/esm/rules/{relay-edge-types.js → relay-edge-types/index.js} +2 -2
  142. package/esm/rules/relay-page-info/index.d.ts +13 -0
  143. package/esm/rules/{relay-page-info.js → relay-page-info/index.js} +3 -3
  144. package/{cjs/rules/require-deprecation-date.d.cts → esm/rules/require-deprecation-date/index.d.ts} +3 -3
  145. package/esm/rules/{require-deprecation-date.js → require-deprecation-date/index.js} +3 -3
  146. package/esm/rules/require-deprecation-reason/index.d.ts +13 -0
  147. package/esm/rules/{require-deprecation-reason.js → require-deprecation-reason/index.js} +3 -3
  148. package/esm/rules/{require-description.d.ts → require-description/index.d.ts} +3 -3
  149. package/esm/rules/{require-description.js → require-description/index.js} +2 -2
  150. package/esm/rules/require-field-of-type-query-in-mutation-result/index.d.ts +13 -0
  151. package/esm/rules/{require-field-of-type-query-in-mutation-result.js → require-field-of-type-query-in-mutation-result/index.js} +2 -2
  152. package/esm/rules/require-import-fragment/index.d.ts +13 -0
  153. package/esm/rules/{require-import-fragment.js → require-import-fragment/index.js} +2 -2
  154. package/esm/rules/require-nullable-fields-with-oneof/index.d.ts +13 -0
  155. package/esm/rules/{require-nullable-fields-with-oneof.js → require-nullable-fields-with-oneof/index.js} +2 -2
  156. package/esm/rules/require-nullable-result-in-root/index.d.ts +13 -0
  157. package/esm/rules/{require-nullable-result-in-root.js → require-nullable-result-in-root/index.js} +2 -2
  158. package/esm/rules/{require-selections.d.ts → require-selections/index.d.ts} +3 -3
  159. package/esm/rules/{require-selections.js → require-selections/index.js} +3 -4
  160. package/esm/rules/require-type-pattern-with-oneof/index.d.ts +13 -0
  161. package/esm/rules/{require-type-pattern-with-oneof.js → require-type-pattern-with-oneof/index.js} +2 -2
  162. package/{cjs/rules/selection-set-depth.d.cts → esm/rules/selection-set-depth/index.d.ts} +3 -3
  163. package/esm/rules/{selection-set-depth.js → selection-set-depth/index.js} +2 -2
  164. package/esm/rules/{strict-id-in-types.d.ts → strict-id-in-types/index.d.ts} +3 -3
  165. package/esm/rules/{strict-id-in-types.js → strict-id-in-types/index.js} +2 -2
  166. package/esm/rules/unique-enum-value-names/index.d.ts +13 -0
  167. package/esm/rules/{unique-enum-value-names.js → unique-enum-value-names/index.js} +2 -2
  168. package/{cjs/rules/unique-fragment-name.d.cts → esm/rules/unique-fragment-name/index.d.ts} +3 -3
  169. package/esm/rules/{unique-fragment-name.js → unique-fragment-name/index.js} +3 -3
  170. package/esm/rules/unique-operation-name/index.d.ts +13 -0
  171. package/esm/rules/{unique-operation-name.js → unique-operation-name/index.js} +2 -2
  172. package/esm/utils.d.ts +2 -2
  173. package/esm/utils.js +2 -2
  174. package/index.browser.js +53 -44
  175. package/package.json +2 -2
  176. package/cjs/rules/no-scalar-result-type-on-mutation.js +0 -88
  177. package/cjs/rules/no-typename-prefix.d.cts +0 -13
  178. package/cjs/rules/no-unreachable-types.d.cts +0 -13
  179. package/cjs/rules/no-unreachable-types.js +0 -175
  180. package/cjs/rules/no-unused-fields.d.cts +0 -13
  181. package/cjs/rules/relay-page-info.d.cts +0 -13
  182. package/cjs/rules/require-deprecation-reason.d.cts +0 -13
  183. package/cjs/rules/require-deprecation-reason.js +0 -85
  184. package/cjs/rules/require-field-of-type-query-in-mutation-result.d.cts +0 -13
  185. package/cjs/rules/require-import-fragment.d.cts +0 -13
  186. package/cjs/rules/require-nullable-fields-with-oneof.d.cts +0 -13
  187. package/cjs/rules/require-nullable-fields-with-oneof.js +0 -81
  188. package/cjs/rules/require-nullable-result-in-root.d.cts +0 -13
  189. package/cjs/rules/require-type-pattern-with-oneof.d.cts +0 -13
  190. package/cjs/rules/require-type-pattern-with-oneof.js +0 -83
  191. package/cjs/rules/unique-enum-value-names.d.cts +0 -13
  192. package/cjs/rules/unique-fragment-name.js +0 -106
  193. package/cjs/rules/unique-operation-name.d.cts +0 -13
  194. package/esm/rules/no-anonymous-operations.d.ts +0 -13
  195. package/esm/rules/no-duplicate-fields.d.ts +0 -13
  196. package/esm/rules/no-one-place-fragments.d.ts +0 -13
  197. package/esm/rules/no-scalar-result-type-on-mutation.d.ts +0 -13
  198. package/esm/rules/no-typename-prefix.d.ts +0 -13
  199. package/esm/rules/no-unreachable-types.d.ts +0 -13
  200. package/esm/rules/no-unused-fields.d.ts +0 -13
  201. package/esm/rules/relay-page-info.d.ts +0 -13
  202. package/esm/rules/require-deprecation-reason.d.ts +0 -13
  203. package/esm/rules/require-field-of-type-query-in-mutation-result.d.ts +0 -13
  204. package/esm/rules/require-import-fragment.d.ts +0 -13
  205. package/esm/rules/require-nullable-fields-with-oneof.d.ts +0 -13
  206. package/esm/rules/require-nullable-result-in-root.d.ts +0 -13
  207. package/esm/rules/require-type-pattern-with-oneof.d.ts +0 -13
  208. package/esm/rules/unique-enum-value-names.d.ts +0 -13
  209. package/esm/rules/unique-operation-name.d.ts +0 -13
@@ -1,5 +1,5 @@
1
- import "../chunk-UIAXBAMD.js";
2
- import { checkNode } from "./unique-fragment-name.js";
1
+ import "../../chunk-UIAXBAMD.js";
2
+ import { checkNode } from "../unique-fragment-name/index.js";
3
3
  const RULE_ID = "unique-operation-name", rule = {
4
4
  meta: {
5
5
  type: "suggestion",
package/esm/utils.d.ts CHANGED
@@ -14,7 +14,7 @@ declare const logger: {
14
14
  error: (...args: unknown[]) => void;
15
15
  warn: (...args: unknown[]) => void;
16
16
  };
17
- declare const normalizePath: (path: string) => string;
17
+ declare const slash: (path: string) => string;
18
18
  declare const VIRTUAL_DOCUMENT_REGEX: RegExp;
19
19
  declare const CWD: string;
20
20
  declare const getTypeName: (node: ASTNode) => string;
@@ -42,4 +42,4 @@ declare function truthy<T>(value: T): value is Truthy<T>;
42
42
  declare function displayNodeName(node: GraphQLESTreeNode<ASTNode>): string;
43
43
  declare function getNodeName(node: GraphQLESTreeNode<ASTNode>): string;
44
44
 
45
- export { ARRAY_DEFAULT_OPTIONS, CWD, type CaseStyle, REPORT_ON_FIRST_CHARACTER, TYPES_KINDS, VIRTUAL_DOCUMENT_REGEX, camelCase, convertCase, displayNodeName, englishJoinWords, getLocation, getNodeName, getTypeName, logger, normalizePath, pascalCase, requireGraphQLSchemaFromContext, requireSiblingsOperations, truthy };
45
+ export { ARRAY_DEFAULT_OPTIONS, CWD, type CaseStyle, REPORT_ON_FIRST_CHARACTER, TYPES_KINDS, VIRTUAL_DOCUMENT_REGEX, camelCase, convertCase, displayNodeName, englishJoinWords, getLocation, getNodeName, getTypeName, logger, pascalCase, requireGraphQLSchemaFromContext, requireSiblingsOperations, slash, truthy };
package/esm/utils.js CHANGED
@@ -29,7 +29,7 @@ const chalk = {
29
29
  // eslint-disable-next-line no-console
30
30
  console.warn(chalk.yellow("warning"), "[graphql-eslint]", ...args)
31
31
  )
32
- }, normalizePath = (path) => (path || "").replace(/\\/g, "/"), VIRTUAL_DOCUMENT_REGEX = /\/\d+_document.graphql$/, CWD = process.cwd(), getTypeName = (node) => "type" in node ? getTypeName(node.type) : "name" in node && node.name ? node.name.value : "", TYPES_KINDS = [
32
+ }, slash = (path) => path.replaceAll("\\", "/"), VIRTUAL_DOCUMENT_REGEX = /[\/\\]\d+_document.graphql$/, CWD = process.cwd(), getTypeName = (node) => "type" in node ? getTypeName(node.type) : "name" in node && node.name ? node.name.value : "", TYPES_KINDS = [
33
33
  Kind.OBJECT_TYPE_DEFINITION,
34
34
  Kind.INTERFACE_TYPE_DEFINITION,
35
35
  Kind.ENUM_TYPE_DEFINITION,
@@ -136,9 +136,9 @@ export {
136
136
  getNodeName,
137
137
  getTypeName,
138
138
  logger,
139
- normalizePath,
140
139
  pascalCase,
141
140
  requireGraphQLSchemaFromContext,
142
141
  requireSiblingsOperations,
142
+ slash,
143
143
  truthy
144
144
  };
package/index.browser.js CHANGED
@@ -427,7 +427,7 @@ var chalk = {
427
427
  // eslint-disable-next-line no-console
428
428
  console.warn(chalk.yellow("warning"), "[graphql-eslint]", ...args)
429
429
  )
430
- }, normalizePath = (path2) => (path2 || "").replace(/\\/g, "/"), VIRTUAL_DOCUMENT_REGEX = /\/\d+_document.graphql$/, CWD = process.cwd(), getTypeName = (node) => "type" in node ? getTypeName(node.type) : "name" in node && node.name ? node.name.value : "", TYPES_KINDS = [
430
+ }, slash = (path2) => path2.replaceAll("\\", "/"), VIRTUAL_DOCUMENT_REGEX = /[\/\\]\d+_document.graphql$/, CWD = process.cwd(), getTypeName = (node) => "type" in node ? getTypeName(node.type) : "name" in node && node.name ? node.name.value : "", TYPES_KINDS = [
431
431
  Kind2.OBJECT_TYPE_DEFINITION,
432
432
  Kind2.INTERFACE_TYPE_DEFINITION,
433
433
  Kind2.ENUM_TYPE_DEFINITION,
@@ -664,7 +664,7 @@ var parser = {
664
664
  }
665
665
  };
666
666
 
667
- // src/rules/alphabetize.ts
667
+ // src/rules/alphabetize/index.ts
668
668
  import {
669
669
  Kind as Kind4
670
670
  } from "graphql";
@@ -959,7 +959,7 @@ var RULE_ID = "alphabetize", fieldsEnum = [
959
959
  }
960
960
  };
961
961
 
962
- // src/rules/description-style.ts
962
+ // src/rules/description-style/index.ts
963
963
  var schema2 = {
964
964
  type: "array",
965
965
  maxItems: 1,
@@ -1647,7 +1647,7 @@ var getFragmentDefsAndFragmentSpreads = (node) => {
1647
1647
  )
1648
1648
  );
1649
1649
 
1650
- // src/rules/input-name.ts
1650
+ // src/rules/input-name/index.ts
1651
1651
  import {
1652
1652
  Kind as Kind6
1653
1653
  } from "graphql";
@@ -1781,7 +1781,7 @@ Using the same name for all input parameters will make your schemas easier to co
1781
1781
  }
1782
1782
  };
1783
1783
 
1784
- // src/rules/lone-executable-definition.ts
1784
+ // src/rules/lone-executable-definition/index.ts
1785
1785
  import { OperationTypeNode as OperationTypeNode2 } from "graphql";
1786
1786
  var RULE_ID2 = "lone-executable-definition", definitionTypes = ["fragment", ...Object.values(OperationTypeNode2)], schema4 = {
1787
1787
  type: "array",
@@ -1863,7 +1863,7 @@ var RULE_ID2 = "lone-executable-definition", definitionTypes = ["fragment", ...O
1863
1863
  }
1864
1864
  };
1865
1865
 
1866
- // src/rules/match-document-filename.ts
1866
+ // src/rules/match-document-filename/index.ts
1867
1867
  import { basename, extname } from "node:path";
1868
1868
  import { Kind as Kind7 } from "graphql";
1869
1869
  var MATCH_EXTENSION = "MATCH_EXTENSION", MATCH_STYLE = "MATCH_STYLE", CASE_STYLES = [
@@ -2091,7 +2091,7 @@ var MATCH_EXTENSION = "MATCH_EXTENSION", MATCH_STYLE = "MATCH_STYLE", CASE_STYLE
2091
2091
  }
2092
2092
  };
2093
2093
 
2094
- // src/rules/naming-convention.ts
2094
+ // src/rules/naming-convention/index.ts
2095
2095
  import { Kind as Kind8 } from "graphql";
2096
2096
  var KindToDisplayName = {
2097
2097
  // types
@@ -2485,7 +2485,7 @@ ${TYPES_KINDS.map((kind) => `- \`${kind}\``).join(`
2485
2485
  }
2486
2486
  };
2487
2487
 
2488
- // src/rules/no-anonymous-operations.ts
2488
+ // src/rules/no-anonymous-operations/index.ts
2489
2489
  import { Kind as Kind9 } from "graphql";
2490
2490
  var RULE_ID3 = "no-anonymous-operations", rule7 = {
2491
2491
  meta: {
@@ -2554,7 +2554,7 @@ var RULE_ID3 = "no-anonymous-operations", rule7 = {
2554
2554
  }
2555
2555
  };
2556
2556
 
2557
- // src/rules/no-deprecated.ts
2557
+ // src/rules/no-deprecated/index.ts
2558
2558
  import { Kind as Kind10 } from "graphql";
2559
2559
  var RULE_ID4 = "no-deprecated", rule8 = {
2560
2560
  meta: {
@@ -2675,7 +2675,7 @@ var RULE_ID4 = "no-deprecated", rule8 = {
2675
2675
  }
2676
2676
  };
2677
2677
 
2678
- // src/rules/no-duplicate-fields.ts
2678
+ // src/rules/no-duplicate-fields/index.ts
2679
2679
  import { Kind as Kind11 } from "graphql";
2680
2680
  var RULE_ID5 = "no-duplicate-fields", rule9 = {
2681
2681
  meta: {
@@ -2789,7 +2789,7 @@ var RULE_ID5 = "no-duplicate-fields", rule9 = {
2789
2789
  }
2790
2790
  };
2791
2791
 
2792
- // src/rules/no-hashtag-description.ts
2792
+ // src/rules/no-hashtag-description/index.ts
2793
2793
  import { TokenKind as TokenKind2 } from "graphql";
2794
2794
  var RULE_ID6 = "HASHTAG_COMMENT", rule10 = {
2795
2795
  meta: {
@@ -2892,7 +2892,7 @@ var RULE_ID6 = "HASHTAG_COMMENT", rule10 = {
2892
2892
  }
2893
2893
  };
2894
2894
 
2895
- // src/rules/no-one-place-fragments.ts
2895
+ // src/rules/no-one-place-fragments/index.ts
2896
2896
  import { relative } from "node:path";
2897
2897
  import { visit as visit4 } from "graphql";
2898
2898
  var RULE_ID7 = "no-one-place-fragments", rule11 = {
@@ -2972,7 +2972,7 @@ var RULE_ID7 = "no-one-place-fragments", rule11 = {
2972
2972
  }
2973
2973
  };
2974
2974
 
2975
- // src/rules/no-root-type.ts
2975
+ // src/rules/no-root-type/index.ts
2976
2976
  var schema7 = {
2977
2977
  type: "array",
2978
2978
  minItems: 1,
@@ -3052,7 +3052,7 @@ var schema7 = {
3052
3052
  }
3053
3053
  };
3054
3054
 
3055
- // src/rules/no-scalar-result-type-on-mutation.ts
3055
+ // src/rules/no-scalar-result-type-on-mutation/index.ts
3056
3056
  import { isScalarType, Kind as Kind12 } from "graphql";
3057
3057
  var RULE_ID8 = "no-scalar-result-type-on-mutation", rule13 = {
3058
3058
  meta: {
@@ -3118,7 +3118,7 @@ var RULE_ID8 = "no-scalar-result-type-on-mutation", rule13 = {
3118
3118
  }
3119
3119
  };
3120
3120
 
3121
- // src/rules/no-typename-prefix.ts
3121
+ // src/rules/no-typename-prefix/index.ts
3122
3122
  var NO_TYPENAME_PREFIX = "NO_TYPENAME_PREFIX", rule14 = {
3123
3123
  meta: {
3124
3124
  type: "suggestion",
@@ -3187,7 +3187,7 @@ var NO_TYPENAME_PREFIX = "NO_TYPENAME_PREFIX", rule14 = {
3187
3187
  }
3188
3188
  };
3189
3189
 
3190
- // src/rules/no-unreachable-types.ts
3190
+ // src/rules/no-unreachable-types/index.ts
3191
3191
  import {
3192
3192
  DirectiveLocation,
3193
3193
  isInterfaceType,
@@ -3338,7 +3338,7 @@ var rule15 = {
3338
3338
  }
3339
3339
  };
3340
3340
 
3341
- // src/rules/no-unused-fields.ts
3341
+ // src/rules/no-unused-fields/index.ts
3342
3342
  import { TypeInfo as TypeInfo2, visit as visit6, visitWithTypeInfo as visitWithTypeInfo2 } from "graphql";
3343
3343
  var RULE_ID10 = "no-unused-fields", usedFieldsCache = new ModuleCache();
3344
3344
  function getUsedFields(schema15, operations) {
@@ -3448,7 +3448,7 @@ var rule16 = {
3448
3448
  }
3449
3449
  };
3450
3450
 
3451
- // src/rules/relay-arguments.ts
3451
+ // src/rules/relay-arguments/index.ts
3452
3452
  import { isScalarType as isScalarType2, Kind as Kind14 } from "graphql";
3453
3453
  var RULE_ID11 = "relay-arguments", MISSING_ARGUMENTS = "MISSING_ARGUMENTS", schema8 = {
3454
3454
  type: "array",
@@ -3551,7 +3551,7 @@ var RULE_ID11 = "relay-arguments", MISSING_ARGUMENTS = "MISSING_ARGUMENTS", sche
3551
3551
  }
3552
3552
  };
3553
3553
 
3554
- // src/rules/relay-connection-types.ts
3554
+ // src/rules/relay-connection-types/index.ts
3555
3555
  import { Kind as Kind15 } from "graphql";
3556
3556
  var MUST_BE_OBJECT_TYPE = "MUST_BE_OBJECT_TYPE", MUST_CONTAIN_FIELD_EDGES = "MUST_CONTAIN_FIELD_EDGES", MUST_CONTAIN_FIELD_PAGE_INFO = "MUST_CONTAIN_FIELD_PAGE_INFO", MUST_HAVE_CONNECTION_SUFFIX = "MUST_HAVE_CONNECTION_SUFFIX", EDGES_FIELD_MUST_RETURN_LIST_TYPE = "EDGES_FIELD_MUST_RETURN_LIST_TYPE", PAGE_INFO_FIELD_MUST_RETURN_NON_NULL_TYPE = "PAGE_INFO_FIELD_MUST_RETURN_NON_NULL_TYPE", NON_OBJECT_TYPES = [
3557
3557
  Kind15.SCALAR_TYPE_DEFINITION,
@@ -3638,7 +3638,7 @@ var MUST_BE_OBJECT_TYPE = "MUST_BE_OBJECT_TYPE", MUST_CONTAIN_FIELD_EDGES = "MUS
3638
3638
  }
3639
3639
  };
3640
3640
 
3641
- // src/rules/relay-edge-types.ts
3641
+ // src/rules/relay-edge-types/index.ts
3642
3642
  import {
3643
3643
  isObjectType as isObjectType2,
3644
3644
  isScalarType as isScalarType3,
@@ -3782,7 +3782,7 @@ var schema9 = {
3782
3782
  }
3783
3783
  };
3784
3784
 
3785
- // src/rules/relay-page-info.ts
3785
+ // src/rules/relay-page-info/index.ts
3786
3786
  import { isScalarType as isScalarType4, Kind as Kind17 } from "graphql";
3787
3787
  var RULE_ID13 = "relay-page-info", MESSAGE_MUST_EXIST = "MESSAGE_MUST_EXIST", MESSAGE_MUST_BE_OBJECT_TYPE2 = "MESSAGE_MUST_BE_OBJECT_TYPE", notPageInfoTypesSelector = `:matches(${NON_OBJECT_TYPES})[name.value=PageInfo] > .name`, hasPageInfoChecked = !1, rule20 = {
3788
3788
  meta: {
@@ -3855,7 +3855,7 @@ var RULE_ID13 = "relay-page-info", MESSAGE_MUST_EXIST = "MESSAGE_MUST_EXIST", ME
3855
3855
  }
3856
3856
  };
3857
3857
 
3858
- // src/rules/require-deprecation-date.ts
3858
+ // src/rules/require-deprecation-date/index.ts
3859
3859
  var DATE_REGEX = /^\d{2}\/\d{2}\/\d{4}$/, MESSAGE_REQUIRE_DATE = "MESSAGE_REQUIRE_DATE", MESSAGE_INVALID_FORMAT = "MESSAGE_INVALID_FORMAT", MESSAGE_INVALID_DATE = "MESSAGE_INVALID_DATE", MESSAGE_CAN_BE_REMOVED = "MESSAGE_CAN_BE_REMOVED", schema10 = {
3860
3860
  type: "array",
3861
3861
  maxItems: 1,
@@ -3980,7 +3980,7 @@ var DATE_REGEX = /^\d{2}\/\d{2}\/\d{4}$/, MESSAGE_REQUIRE_DATE = "MESSAGE_REQUIR
3980
3980
  }
3981
3981
  };
3982
3982
 
3983
- // src/rules/require-deprecation-reason.ts
3983
+ // src/rules/require-deprecation-reason/index.ts
3984
3984
  var rule22 = {
3985
3985
  meta: {
3986
3986
  docs: {
@@ -4042,7 +4042,7 @@ var rule22 = {
4042
4042
  }
4043
4043
  };
4044
4044
 
4045
- // src/rules/require-description.ts
4045
+ // src/rules/require-description/index.ts
4046
4046
  import { Kind as Kind18, TokenKind as TokenKind3 } from "graphql";
4047
4047
  import { getRootTypeNames } from "@graphql-tools/utils";
4048
4048
  var RULE_ID14 = "require-description", ALLOWED_KINDS2 = [
@@ -4197,7 +4197,7 @@ ${TYPES_KINDS.map((kind) => `- \`${kind}\``).join(`
4197
4197
  }
4198
4198
  };
4199
4199
 
4200
- // src/rules/require-field-of-type-query-in-mutation-result.ts
4200
+ // src/rules/require-field-of-type-query-in-mutation-result/index.ts
4201
4201
  import { isObjectType as isObjectType3 } from "graphql";
4202
4202
  var RULE_ID15 = "require-field-of-type-query-in-mutation-result", rule24 = {
4203
4203
  meta: {
@@ -4262,7 +4262,7 @@ var RULE_ID15 = "require-field-of-type-query-in-mutation-result", rule24 = {
4262
4262
  }
4263
4263
  };
4264
4264
 
4265
- // src/rules/require-import-fragment.ts
4265
+ // src/rules/require-import-fragment/index.ts
4266
4266
  import path from "node:path";
4267
4267
  var RULE_ID16 = "require-import-fragment", SUGGESTION_ID = "add-import-expression", rule25 = {
4268
4268
  meta: {
@@ -4376,7 +4376,7 @@ var RULE_ID16 = "require-import-fragment", SUGGESTION_ID = "add-import-expressio
4376
4376
  }
4377
4377
  };
4378
4378
 
4379
- // src/rules/require-nullable-fields-with-oneof.ts
4379
+ // src/rules/require-nullable-fields-with-oneof/index.ts
4380
4380
  import { Kind as Kind19 } from "graphql";
4381
4381
  var RULE_ID17 = "require-nullable-fields-with-oneof", rule26 = {
4382
4382
  meta: {
@@ -4435,7 +4435,7 @@ var RULE_ID17 = "require-nullable-fields-with-oneof", rule26 = {
4435
4435
  }
4436
4436
  };
4437
4437
 
4438
- // src/rules/require-nullable-result-in-root.ts
4438
+ // src/rules/require-nullable-result-in-root/index.ts
4439
4439
  import { Kind as Kind20 } from "graphql";
4440
4440
  var RULE_ID18 = "require-nullable-result-in-root", rule27 = {
4441
4441
  meta: {
@@ -4512,7 +4512,7 @@ var RULE_ID18 = "require-nullable-result-in-root", rule27 = {
4512
4512
  }
4513
4513
  };
4514
4514
 
4515
- // src/rules/require-selections.ts
4515
+ // src/rules/require-selections/index.ts
4516
4516
  import {
4517
4517
  GraphQLInterfaceType,
4518
4518
  GraphQLObjectType,
@@ -4545,7 +4545,6 @@ var RULE_ID19 = "require-selections", DEFAULT_ID_FIELD_NAME = "id", schema12 = {
4545
4545
  }, rule28 = {
4546
4546
  meta: {
4547
4547
  type: "suggestion",
4548
- // eslint-disable-next-line eslint-plugin/require-meta-has-suggestions -- false positive since we assign `problem.suggest` conditionally
4549
4548
  hasSuggestions: !0,
4550
4549
  docs: {
4551
4550
  category: "Operations",
@@ -4698,7 +4697,7 @@ Include it in your selection set{{ addition }}.`
4698
4697
  }
4699
4698
  };
4700
4699
 
4701
- // src/rules/require-type-pattern-with-oneof.ts
4700
+ // src/rules/require-type-pattern-with-oneof/index.ts
4702
4701
  var RULE_ID20 = "require-type-pattern-with-oneof", rule29 = {
4703
4702
  meta: {
4704
4703
  type: "suggestion",
@@ -4758,7 +4757,7 @@ var RULE_ID20 = "require-type-pattern-with-oneof", rule29 = {
4758
4757
  }
4759
4758
  };
4760
4759
 
4761
- // src/rules/selection-set-depth.ts
4760
+ // src/rules/selection-set-depth/index.ts
4762
4761
  import { Kind as Kind22 } from "graphql";
4763
4762
  import depthLimit from "graphql-depth-limit";
4764
4763
  var RULE_ID21 = "selection-set-depth", schema13 = {
@@ -4888,7 +4887,7 @@ var RULE_ID21 = "selection-set-depth", schema13 = {
4888
4887
  }
4889
4888
  };
4890
4889
 
4891
- // src/rules/strict-id-in-types.ts
4890
+ // src/rules/strict-id-in-types/index.ts
4892
4891
  import { Kind as Kind23 } from "graphql";
4893
4892
  var RULE_ID22 = "strict-id-in-types", schema14 = {
4894
4893
  type: "array",
@@ -5033,7 +5032,7 @@ Accepted type${pluralTypesSuffix}: ${englishJoinWords(options.acceptedIdTypes)}.
5033
5032
  }
5034
5033
  };
5035
5034
 
5036
- // src/rules/unique-enum-value-names.ts
5035
+ // src/rules/unique-enum-value-names/index.ts
5037
5036
  import { Kind as Kind24 } from "graphql";
5038
5037
  var rule32 = {
5039
5038
  meta: {
@@ -5102,12 +5101,12 @@ var rule32 = {
5102
5101
  }
5103
5102
  };
5104
5103
 
5105
- // src/rules/unique-fragment-name.ts
5104
+ // src/rules/unique-fragment-name/index.ts
5106
5105
  import { relative as relative2 } from "node:path";
5107
5106
  import { Kind as Kind25 } from "graphql";
5108
5107
  var RULE_ID23 = "unique-fragment-name", checkNode = (context, node, ruleId) => {
5109
5108
  let documentName = node.name.value, siblings = requireSiblingsOperations(ruleId, context), siblingDocuments = node.kind === Kind25.FRAGMENT_DEFINITION ? siblings.getFragment(documentName) : siblings.getOperation(documentName), filepath = context.filename, conflictingDocuments = siblingDocuments.filter((f) => {
5110
- let isSameName = f.document.name?.value === documentName, isSamePath = normalizePath(f.filePath) === normalizePath(filepath);
5109
+ let isSameName = f.document.name?.value === documentName, isSamePath = slash(f.filePath) === slash(filepath);
5111
5110
  return isSameName && !isSamePath;
5112
5111
  });
5113
5112
  conflictingDocuments.length > 0 && context.report({
@@ -5185,7 +5184,7 @@ var RULE_ID23 = "unique-fragment-name", checkNode = (context, node, ruleId) => {
5185
5184
  }
5186
5185
  };
5187
5186
 
5188
- // src/rules/unique-operation-name.ts
5187
+ // src/rules/unique-operation-name/index.ts
5189
5188
  var RULE_ID24 = "unique-operation-name", rule34 = {
5190
5189
  meta: {
5191
5190
  type: "suggestion",
@@ -5301,16 +5300,26 @@ var import_operations_all = __toESM(require_operations_all(), 1), import_operati
5301
5300
  "schema-relay": import_schema_relay.default,
5302
5301
  "operations-recommended": import_operations_recommended.default,
5303
5302
  "operations-all": import_operations_all.default,
5304
- "flat/schema-recommended": import_schema_recommended.default.rules,
5303
+ "flat/schema-recommended": {
5304
+ rules: import_schema_recommended.default.rules
5305
+ },
5305
5306
  "flat/schema-all": {
5306
- ...import_schema_recommended.default.rules,
5307
- ...import_schema_all.default.rules
5307
+ rules: {
5308
+ ...import_schema_recommended.default.rules,
5309
+ ...import_schema_all.default.rules
5310
+ }
5311
+ },
5312
+ "flat/schema-relay": {
5313
+ rules: import_schema_relay.default.rules
5314
+ },
5315
+ "flat/operations-recommended": {
5316
+ rules: import_operations_recommended.default.rules
5308
5317
  },
5309
- "flat/schema-relay": import_schema_relay.default.rules,
5310
- "flat/operations-recommended": import_operations_recommended.default.rules,
5311
5318
  "flat/operations-all": {
5312
- ...import_operations_recommended.default.rules,
5313
- ...import_operations_all.default.rules
5319
+ rules: {
5320
+ ...import_operations_recommended.default.rules,
5321
+ ...import_operations_all.default.rules
5322
+ }
5314
5323
  }
5315
5324
  };
5316
5325
  export {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@graphql-eslint/eslint-plugin",
3
- "version": "4.0.0-alpha.6",
3
+ "version": "4.0.0-alpha.7",
4
4
  "type": "module",
5
5
  "description": "GraphQL plugin for ESLint",
6
6
  "repository": "https://github.com/B2o5T/graphql-eslint",
@@ -35,7 +35,7 @@
35
35
  },
36
36
  "dependencies": {
37
37
  "@graphql-tools/code-file-loader": "^8.0.0",
38
- "@graphql-tools/graphql-tag-pluck": "8.3.3",
38
+ "@graphql-tools/graphql-tag-pluck": "8.3.4",
39
39
  "@graphql-tools/utils": "^10.0.0",
40
40
  "debug": "^4.3.4",
41
41
  "fast-glob": "^3.2.12",
@@ -1,88 +0,0 @@
1
- "use strict";
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __hasOwnProp = Object.prototype.hasOwnProperty;
6
- var __export = (target, all) => {
7
- for (var name in all)
8
- __defProp(target, name, { get: all[name], enumerable: !0 });
9
- }, __copyProps = (to, from, except, desc) => {
10
- if (from && typeof from == "object" || typeof from == "function")
11
- for (let key of __getOwnPropNames(from))
12
- !__hasOwnProp.call(to, key) && key !== except && __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
13
- return to;
14
- };
15
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: !0 }), mod);
16
- var no_scalar_result_type_on_mutation_exports = {};
17
- __export(no_scalar_result_type_on_mutation_exports, {
18
- rule: () => rule
19
- });
20
- module.exports = __toCommonJS(no_scalar_result_type_on_mutation_exports);
21
- var import_graphql = require("graphql"), import_utils = require("../utils.js");
22
- const RULE_ID = "no-scalar-result-type-on-mutation", rule = {
23
- meta: {
24
- type: "suggestion",
25
- hasSuggestions: !0,
26
- docs: {
27
- category: "Schema",
28
- description: "Avoid scalar result type on mutation type to make sure to return a valid state.",
29
- url: `https://the-guild.dev/graphql/eslint/rules/${RULE_ID}`,
30
- requiresSchema: !0,
31
- examples: [
32
- {
33
- title: "Incorrect",
34
- code: (
35
- /* GraphQL */
36
- `
37
- type Mutation {
38
- createUser: Boolean
39
- }
40
- `
41
- )
42
- },
43
- {
44
- title: "Correct",
45
- code: (
46
- /* GraphQL */
47
- `
48
- type Mutation {
49
- createUser: User!
50
- }
51
- `
52
- )
53
- }
54
- ]
55
- },
56
- schema: []
57
- },
58
- create(context) {
59
- const schema = (0, import_utils.requireGraphQLSchemaFromContext)(RULE_ID, context), mutationType = schema.getMutationType();
60
- return mutationType ? {
61
- [[
62
- `:matches(ObjectTypeDefinition, ObjectTypeExtension)[name.value=${mutationType.name}]`,
63
- "> FieldDefinition > .gqlType Name"
64
- ].join(" ")](node) {
65
- const typeName = node.value, graphQLType = schema.getType(typeName);
66
- if ((0, import_graphql.isScalarType)(graphQLType)) {
67
- let fieldDef = node.parent;
68
- for (; fieldDef.kind !== import_graphql.Kind.FIELD_DEFINITION; )
69
- fieldDef = fieldDef.parent;
70
- context.report({
71
- node,
72
- message: `Unexpected scalar result type \`${typeName}\` for ${(0, import_utils.getNodeName)(fieldDef)}`,
73
- suggest: [
74
- {
75
- desc: `Remove \`${typeName}\``,
76
- fix: (fixer) => fixer.remove(node)
77
- }
78
- ]
79
- });
80
- }
81
- }
82
- } : {};
83
- }
84
- };
85
- // Annotate the CommonJS export names for ESM import in node:
86
- 0 && (module.exports = {
87
- rule
88
- });
@@ -1,13 +0,0 @@
1
- import { GraphQLESLintRule } from '../types.cjs';
2
- import 'eslint';
3
- import 'estree';
4
- import 'graphql';
5
- import 'graphql-config';
6
- import 'json-schema-to-ts';
7
- import '../estree-converter/types.cjs';
8
- import '../siblings.cjs';
9
- import '@graphql-tools/utils';
10
-
11
- declare const rule: GraphQLESLintRule;
12
-
13
- export { rule };
@@ -1,13 +0,0 @@
1
- import { GraphQLESLintRule } from '../types.cjs';
2
- import 'eslint';
3
- import 'estree';
4
- import 'graphql';
5
- import 'graphql-config';
6
- import 'json-schema-to-ts';
7
- import '../estree-converter/types.cjs';
8
- import '../siblings.cjs';
9
- import '@graphql-tools/utils';
10
-
11
- declare const rule: GraphQLESLintRule;
12
-
13
- export { rule };