@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
package/cjs/utils.js CHANGED
@@ -3,18 +3,14 @@ var __create = Object.create;
3
3
  var __defProp = Object.defineProperty;
4
4
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
5
  var __getOwnPropNames = Object.getOwnPropertyNames;
6
- var __getProtoOf = Object.getPrototypeOf;
7
- var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __getProtoOf = Object.getPrototypeOf, __hasOwnProp = Object.prototype.hasOwnProperty;
8
7
  var __export = (target, all) => {
9
8
  for (var name in all)
10
- __defProp(target, name, { get: all[name], enumerable: true });
11
- };
12
- var __copyProps = (to, from, except, desc) => {
13
- if (from && typeof from === "object" || typeof from === "function") {
9
+ __defProp(target, name, { get: all[name], enumerable: !0 });
10
+ }, __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from == "object" || typeof from == "function")
14
12
  for (let key of __getOwnPropNames(from))
15
- if (!__hasOwnProp.call(to, key) && key !== except)
16
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
- }
13
+ !__hasOwnProp.call(to, key) && key !== except && __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
18
14
  return to;
19
15
  };
20
16
  var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
@@ -22,10 +18,9 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
22
18
  // file that has been converted to a CommonJS file using a Babel-
23
19
  // compatible transform (i.e. "__esModule" has not been set), then set
24
20
  // "default" to the CommonJS "module.exports" for node compatibility.
25
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
21
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: !0 }) : target,
26
22
  mod
27
- ));
28
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
23
+ )), __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: !0 }), mod);
29
24
  var utils_exports = {};
30
25
  __export(utils_exports, {
31
26
  ARRAY_DEFAULT_OPTIONS: () => ARRAY_DEFAULT_OPTIONS,
@@ -48,55 +43,46 @@ __export(utils_exports, {
48
43
  truthy: () => truthy
49
44
  });
50
45
  module.exports = __toCommonJS(utils_exports);
51
- var import_chalk = __toESM(require("chalk"));
52
- var import_graphql = require("graphql");
53
- var import_lodash = __toESM(require("lodash.lowercase"));
46
+ var import_graphql = require("graphql"), import_lodash = __toESM(require("lodash.lowercase"));
54
47
  function requireSiblingsOperations(ruleId, context) {
55
- const { siblingOperations } = context.parserServices;
56
- if (!siblingOperations.available) {
48
+ const { siblingOperations } = context.sourceCode.parserServices;
49
+ if (!siblingOperations.available)
57
50
  throw new Error(
58
- `Rule \`${ruleId}\` requires \`parserOptions.operations\` to be set and loaded. See https://bit.ly/graphql-eslint-operations for more info`
51
+ `Rule \`${ruleId}\` requires graphql-config \`documents\` field to be set and loaded. See https://the-guild.dev/graphql/config/docs/user/documents for more info`
59
52
  );
60
- }
61
53
  return siblingOperations;
62
54
  }
63
55
  function requireGraphQLSchemaFromContext(ruleId, context) {
64
- const { schema } = context.parserServices;
65
- if (!schema) {
56
+ const { schema } = context.sourceCode.parserServices;
57
+ if (!schema)
66
58
  throw new Error(
67
- `Rule \`${ruleId}\` requires \`parserOptions.schema\` to be set and loaded. See https://bit.ly/graphql-eslint-schema for more info`
59
+ `Rule \`${ruleId}\` requires graphql-config \`schema\` field to be set and loaded. See https://the-guild.dev/graphql/config/docs/user/schema for more info`
68
60
  );
69
- }
70
61
  return schema;
71
62
  }
72
- const logger = {
63
+ const chalk = {
64
+ red: (str) => `\x1B[31m${str}\x1B[39m`,
65
+ yellow: (str) => `\x1B[33m${str}\x1B[39m`
66
+ }, logger = {
73
67
  error: (...args) => (
74
68
  // eslint-disable-next-line no-console
75
- console.error(import_chalk.default.red("error"), "[graphql-eslint]", (0, import_chalk.default)(...args))
69
+ console.error(chalk.red("error"), "[graphql-eslint]", ...args)
76
70
  ),
77
71
  warn: (...args) => (
78
72
  // eslint-disable-next-line no-console
79
- console.warn(import_chalk.default.yellow("warning"), "[graphql-eslint]", (0, import_chalk.default)(...args))
73
+ console.warn(chalk.yellow("warning"), "[graphql-eslint]", ...args)
80
74
  )
81
- };
82
- const normalizePath = (path) => (path || "").replace(/\\/g, "/");
83
- const VIRTUAL_DOCUMENT_REGEX = /\/\d+_document.graphql$/;
84
- const CWD = process.cwd();
85
- const getTypeName = (node) => "type" in node ? getTypeName(node.type) : "name" in node && node.name ? node.name.value : "";
86
- const TYPES_KINDS = [
75
+ }, 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 = [
87
76
  import_graphql.Kind.OBJECT_TYPE_DEFINITION,
88
77
  import_graphql.Kind.INTERFACE_TYPE_DEFINITION,
89
78
  import_graphql.Kind.ENUM_TYPE_DEFINITION,
90
79
  import_graphql.Kind.SCALAR_TYPE_DEFINITION,
91
80
  import_graphql.Kind.INPUT_OBJECT_TYPE_DEFINITION,
92
81
  import_graphql.Kind.UNION_TYPE_DEFINITION
93
- ];
94
- const pascalCase = (str) => (0, import_lodash.default)(str).split(" ").map((word) => word.charAt(0).toUpperCase() + word.slice(1)).join("");
95
- const camelCase = (str) => {
82
+ ], pascalCase = (str) => (0, import_lodash.default)(str).split(" ").map((word) => word.charAt(0).toUpperCase() + word.slice(1)).join(""), camelCase = (str) => {
96
83
  const result = pascalCase(str);
97
84
  return result.charAt(0).toLowerCase() + result.slice(1);
98
- };
99
- const convertCase = (style, str) => {
85
+ }, convertCase = (style, str) => {
100
86
  switch (style) {
101
87
  case "camelCase":
102
88
  return camelCase(str);
@@ -123,16 +109,14 @@ function getLocation(start, fieldName = "") {
123
109
  }
124
110
  };
125
111
  }
126
- const REPORT_ON_FIRST_CHARACTER = { column: 0, line: 1 };
127
- const ARRAY_DEFAULT_OPTIONS = {
112
+ const REPORT_ON_FIRST_CHARACTER = { column: 0, line: 1 }, ARRAY_DEFAULT_OPTIONS = {
128
113
  type: "array",
129
- uniqueItems: true,
114
+ uniqueItems: !0,
130
115
  minItems: 1,
131
116
  items: {
132
117
  type: "string"
133
118
  }
134
- };
135
- const englishJoinWords = (words) => new Intl.ListFormat("en-US", { type: "disjunction" }).format(words);
119
+ }, englishJoinWords = (words) => new Intl.ListFormat("en-US", { type: "disjunction" }).format(words);
136
120
  function truthy(value) {
137
121
  return !!value;
138
122
  }
@@ -159,8 +143,7 @@ const DisplayNodeNameMap = {
159
143
  [import_graphql.Kind.FIELD]: "field"
160
144
  };
161
145
  function displayNodeName(node) {
162
- var _a, _b;
163
- return `${node.kind === import_graphql.Kind.OPERATION_DEFINITION ? node.operation : DisplayNodeNameMap[node.kind]} "${"alias" in node && ((_a = node.alias) == null ? void 0 : _a.value) || "name" in node && ((_b = node.name) == null ? void 0 : _b.value)}"`;
146
+ return `${node.kind === import_graphql.Kind.OPERATION_DEFINITION ? node.operation : DisplayNodeNameMap[node.kind]} "${"alias" in node && node.alias?.value || "name" in node && node.name?.value}"`;
164
147
  }
165
148
  function getNodeName(node) {
166
149
  switch (node.kind) {
package/esm/cache.js CHANGED
@@ -1,13 +1,10 @@
1
- import "./chunk-BMTV3EA2.js";
1
+ import "./chunk-U3TKCM4X.js";
2
2
  import debugFactory from "debug";
3
3
  const log = debugFactory("graphql-eslint:ModuleCache");
4
4
  class ModuleCache {
5
- constructor() {
6
- this.map = /* @__PURE__ */ new Map();
7
- }
5
+ map = /* @__PURE__ */ new Map();
8
6
  set(cacheKey, result) {
9
- this.map.set(cacheKey, { lastSeen: process.hrtime(), result });
10
- log("setting entry for", cacheKey);
7
+ this.map.set(cacheKey, { lastSeen: process.hrtime(), result }), log("setting entry for", cacheKey);
11
8
  }
12
9
  get(cacheKey, settings = {
13
10
  lifetime: 10
@@ -19,9 +16,8 @@ class ModuleCache {
19
16
  return;
20
17
  }
21
18
  const { lastSeen, result } = value;
22
- if (process.env.NODE || process.hrtime(lastSeen)[0] < settings.lifetime) {
19
+ if (process.env.NODE || process.hrtime(lastSeen)[0] < settings.lifetime)
23
20
  return result;
24
- }
25
21
  }
26
22
  }
27
23
  export {
@@ -1,5 +1,5 @@
1
1
  var __getOwnPropNames = Object.getOwnPropertyNames;
2
- var __commonJS = (cb, mod) => function __require() {
2
+ var __commonJS = (cb, mod) => function() {
3
3
  return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
4
4
  };
5
5
 
@@ -27,20 +27,38 @@ declare const configs: {
27
27
  forbiddenPrefixes: string[];
28
28
  forbiddenSuffixes: string[];
29
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
+ };
30
46
  })[];
31
- '@graphql-eslint/no-case-insensitive-enum-values-duplicates': string;
32
47
  '@graphql-eslint/no-hashtag-description': string;
33
48
  '@graphql-eslint/no-typename-prefix': string;
34
49
  '@graphql-eslint/no-unreachable-types': string;
50
+ '@graphql-eslint/possible-type-extension': string;
35
51
  '@graphql-eslint/provided-required-arguments': string;
36
52
  '@graphql-eslint/require-deprecation-reason': string;
37
53
  '@graphql-eslint/require-description': (string | {
38
54
  types: boolean;
39
55
  DirectiveDefinition: boolean;
56
+ rootField: boolean;
40
57
  })[];
41
58
  '@graphql-eslint/strict-id-in-types': string;
42
59
  '@graphql-eslint/unique-directive-names': string;
43
60
  '@graphql-eslint/unique-directive-names-per-location': string;
61
+ '@graphql-eslint/unique-enum-value-names': string;
44
62
  '@graphql-eslint/unique-field-definition-names': string;
45
63
  '@graphql-eslint/unique-operation-types': string;
46
64
  '@graphql-eslint/unique-type-names': string;
@@ -50,11 +68,16 @@ declare const configs: {
50
68
  extends: string;
51
69
  rules: {
52
70
  '@graphql-eslint/alphabetize': (string | {
71
+ definitions: boolean;
53
72
  fields: string[];
54
- values: string[];
73
+ values: boolean;
55
74
  arguments: string[];
75
+ groups: string[];
56
76
  })[];
57
77
  '@graphql-eslint/input-name': string;
78
+ '@graphql-eslint/no-root-type': (string | {
79
+ disallow: string[];
80
+ })[];
58
81
  '@graphql-eslint/no-scalar-result-type-on-mutation': string;
59
82
  '@graphql-eslint/require-deprecation-date': string;
60
83
  '@graphql-eslint/require-field-of-type-query-in-mutation-result': string;
@@ -63,6 +86,16 @@ declare const configs: {
63
86
  '@graphql-eslint/require-type-pattern-with-oneof': string;
64
87
  };
65
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
+ };
66
99
  'operations-recommended': {
67
100
  parser: string;
68
101
  plugins: string[];
@@ -99,14 +132,16 @@ declare const configs: {
99
132
  '@graphql-eslint/overlapping-fields-can-be-merged': string;
100
133
  '@graphql-eslint/possible-fragment-spread': string;
101
134
  '@graphql-eslint/provided-required-arguments': string;
102
- '@graphql-eslint/require-id-when-available': string;
135
+ '@graphql-eslint/require-selections': string;
103
136
  '@graphql-eslint/scalar-leafs': string;
104
137
  '@graphql-eslint/selection-set-depth': (string | {
105
138
  maxDepth: number;
106
139
  })[];
107
140
  '@graphql-eslint/unique-argument-names': string;
108
141
  '@graphql-eslint/unique-directive-names-per-location': string;
142
+ '@graphql-eslint/unique-fragment-name': string;
109
143
  '@graphql-eslint/unique-input-field-names': string;
144
+ '@graphql-eslint/unique-operation-name': string;
110
145
  '@graphql-eslint/unique-variable-names': string;
111
146
  '@graphql-eslint/value-literals-of-correct-type': string;
112
147
  '@graphql-eslint/variables-are-input-types': string;
@@ -117,9 +152,11 @@ declare const configs: {
117
152
  extends: string;
118
153
  rules: {
119
154
  '@graphql-eslint/alphabetize': (string | {
155
+ definitions: boolean;
120
156
  selections: string[];
121
- variables: string[];
157
+ variables: boolean;
122
158
  arguments: string[];
159
+ groups: string[];
123
160
  })[];
124
161
  '@graphql-eslint/lone-executable-definition': string;
125
162
  '@graphql-eslint/match-document-filename': (string | {
@@ -129,18 +166,7 @@ declare const configs: {
129
166
  fragment: string;
130
167
  })[];
131
168
  '@graphql-eslint/no-one-place-fragments': string;
132
- '@graphql-eslint/unique-fragment-name': string;
133
- '@graphql-eslint/unique-operation-name': string;
134
- };
135
- };
136
- relay: {
137
- parser: string;
138
- plugins: string[];
139
- rules: {
140
- '@graphql-eslint/relay-arguments': string;
141
- '@graphql-eslint/relay-connection-types': string;
142
- '@graphql-eslint/relay-edge-types': string;
143
- '@graphql-eslint/relay-page-info': string;
169
+ '@graphql-eslint/require-import-fragment': string;
144
170
  };
145
171
  };
146
172
  };
@@ -1,15 +1,15 @@
1
- import "../chunk-BMTV3EA2.js";
1
+ import "../chunk-U3TKCM4X.js";
2
2
  import operationsAllConfig from "./operations-all.js";
3
3
  import operationsRecommendedConfig from "./operations-recommended.js";
4
- import relayConfig from "./relay.js";
5
4
  import schemaAllConfig from "./schema-all.js";
6
5
  import schemaRecommendedConfig from "./schema-recommended.js";
6
+ import relayConfig from "./schema-relay.js";
7
7
  const configs = {
8
8
  "schema-recommended": schemaRecommendedConfig,
9
9
  "schema-all": schemaAllConfig,
10
+ "schema-relay": relayConfig,
10
11
  "operations-recommended": operationsRecommendedConfig,
11
- "operations-all": operationsAllConfig,
12
- relay: relayConfig
12
+ "operations-all": operationsAllConfig
13
13
  };
14
14
  export {
15
15
  configs
@@ -2,9 +2,11 @@ declare const _default: {
2
2
  extends: string;
3
3
  rules: {
4
4
  '@graphql-eslint/alphabetize': (string | {
5
+ definitions: boolean;
5
6
  selections: string[];
6
- variables: string[];
7
+ variables: boolean;
7
8
  arguments: string[];
9
+ groups: string[];
8
10
  })[];
9
11
  '@graphql-eslint/lone-executable-definition': string;
10
12
  '@graphql-eslint/match-document-filename': (string | {
@@ -14,8 +16,7 @@ declare const _default: {
14
16
  fragment: string;
15
17
  })[];
16
18
  '@graphql-eslint/no-one-place-fragments': string;
17
- '@graphql-eslint/unique-fragment-name': string;
18
- '@graphql-eslint/unique-operation-name': string;
19
+ '@graphql-eslint/require-import-fragment': string;
19
20
  };
20
21
  };
21
22
 
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  __commonJS
3
- } from "../chunk-BMTV3EA2.js";
3
+ } from "../chunk-U3TKCM4X.js";
4
4
  var require_operations_all = __commonJS({
5
5
  "src/configs/operations-all.ts"(exports, module) {
6
6
  module.exports = {
@@ -9,9 +9,11 @@ var require_operations_all = __commonJS({
9
9
  "@graphql-eslint/alphabetize": [
10
10
  "error",
11
11
  {
12
+ definitions: !0,
12
13
  selections: ["OperationDefinition", "FragmentDefinition"],
13
- variables: ["OperationDefinition"],
14
- arguments: ["Field", "Directive"]
14
+ variables: !0,
15
+ arguments: ["Field", "Directive"],
16
+ groups: ["id", "*", "createdAt", "updatedAt"]
15
17
  }
16
18
  ],
17
19
  "@graphql-eslint/lone-executable-definition": "error",
@@ -25,8 +27,7 @@ var require_operations_all = __commonJS({
25
27
  }
26
28
  ],
27
29
  "@graphql-eslint/no-one-place-fragments": "error",
28
- "@graphql-eslint/unique-fragment-name": "error",
29
- "@graphql-eslint/unique-operation-name": "error"
30
+ "@graphql-eslint/require-import-fragment": "error"
30
31
  }
31
32
  };
32
33
  }
@@ -34,14 +34,16 @@ declare const _default: {
34
34
  '@graphql-eslint/overlapping-fields-can-be-merged': string;
35
35
  '@graphql-eslint/possible-fragment-spread': string;
36
36
  '@graphql-eslint/provided-required-arguments': string;
37
- '@graphql-eslint/require-id-when-available': string;
37
+ '@graphql-eslint/require-selections': string;
38
38
  '@graphql-eslint/scalar-leafs': string;
39
39
  '@graphql-eslint/selection-set-depth': (string | {
40
40
  maxDepth: number;
41
41
  })[];
42
42
  '@graphql-eslint/unique-argument-names': string;
43
43
  '@graphql-eslint/unique-directive-names-per-location': string;
44
+ '@graphql-eslint/unique-fragment-name': string;
44
45
  '@graphql-eslint/unique-input-field-names': string;
46
+ '@graphql-eslint/unique-operation-name': string;
45
47
  '@graphql-eslint/unique-variable-names': string;
46
48
  '@graphql-eslint/value-literals-of-correct-type': string;
47
49
  '@graphql-eslint/variables-are-input-types': string;
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  __commonJS
3
- } from "../chunk-BMTV3EA2.js";
3
+ } from "../chunk-U3TKCM4X.js";
4
4
  var require_operations_recommended = __commonJS({
5
5
  "src/configs/operations-recommended.ts"(exports, module) {
6
6
  module.exports = {
@@ -42,12 +42,14 @@ var require_operations_recommended = __commonJS({
42
42
  "@graphql-eslint/overlapping-fields-can-be-merged": "error",
43
43
  "@graphql-eslint/possible-fragment-spread": "error",
44
44
  "@graphql-eslint/provided-required-arguments": "error",
45
- "@graphql-eslint/require-id-when-available": "error",
45
+ "@graphql-eslint/require-selections": "error",
46
46
  "@graphql-eslint/scalar-leafs": "error",
47
47
  "@graphql-eslint/selection-set-depth": ["error", { maxDepth: 7 }],
48
48
  "@graphql-eslint/unique-argument-names": "error",
49
49
  "@graphql-eslint/unique-directive-names-per-location": "error",
50
+ "@graphql-eslint/unique-fragment-name": "error",
50
51
  "@graphql-eslint/unique-input-field-names": "error",
52
+ "@graphql-eslint/unique-operation-name": "error",
51
53
  "@graphql-eslint/unique-variable-names": "error",
52
54
  "@graphql-eslint/value-literals-of-correct-type": "error",
53
55
  "@graphql-eslint/variables-are-input-types": "error",
@@ -2,11 +2,16 @@ declare const _default: {
2
2
  extends: string;
3
3
  rules: {
4
4
  '@graphql-eslint/alphabetize': (string | {
5
+ definitions: boolean;
5
6
  fields: string[];
6
- values: string[];
7
+ values: boolean;
7
8
  arguments: string[];
9
+ groups: string[];
8
10
  })[];
9
11
  '@graphql-eslint/input-name': string;
12
+ '@graphql-eslint/no-root-type': (string | {
13
+ disallow: string[];
14
+ })[];
10
15
  '@graphql-eslint/no-scalar-result-type-on-mutation': string;
11
16
  '@graphql-eslint/require-deprecation-date': string;
12
17
  '@graphql-eslint/require-field-of-type-query-in-mutation-result': string;
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  __commonJS
3
- } from "../chunk-BMTV3EA2.js";
3
+ } from "../chunk-U3TKCM4X.js";
4
4
  var require_schema_all = __commonJS({
5
5
  "src/configs/schema-all.ts"(exports, module) {
6
6
  module.exports = {
@@ -9,12 +9,15 @@ var require_schema_all = __commonJS({
9
9
  "@graphql-eslint/alphabetize": [
10
10
  "error",
11
11
  {
12
+ definitions: !0,
12
13
  fields: ["ObjectTypeDefinition", "InterfaceTypeDefinition", "InputObjectTypeDefinition"],
13
- values: ["EnumTypeDefinition"],
14
- arguments: ["FieldDefinition", "Field", "DirectiveDefinition", "Directive"]
14
+ values: !0,
15
+ arguments: ["FieldDefinition", "Field", "DirectiveDefinition", "Directive"],
16
+ groups: ["id", "*", "createdAt", "updatedAt"]
15
17
  }
16
18
  ],
17
19
  "@graphql-eslint/input-name": "error",
20
+ "@graphql-eslint/no-root-type": ["error", { disallow: ["mutation", "subscription"] }],
18
21
  "@graphql-eslint/no-scalar-result-type-on-mutation": "error",
19
22
  "@graphql-eslint/require-deprecation-date": "error",
20
23
  "@graphql-eslint/require-field-of-type-query-in-mutation-result": "error",
@@ -26,20 +26,38 @@ declare const _default: {
26
26
  forbiddenPrefixes: string[];
27
27
  forbiddenSuffixes: string[];
28
28
  };
29
+ 'EnumTypeDefinition,EnumTypeExtension': {
30
+ forbiddenPrefixes: string[];
31
+ forbiddenSuffixes: string[];
32
+ };
33
+ 'InterfaceTypeDefinition,InterfaceTypeExtension': {
34
+ forbiddenPrefixes: string[];
35
+ forbiddenSuffixes: string[];
36
+ };
37
+ 'UnionTypeDefinition,UnionTypeExtension': {
38
+ forbiddenPrefixes: string[];
39
+ forbiddenSuffixes: string[];
40
+ };
41
+ 'ObjectTypeDefinition,ObjectTypeExtension': {
42
+ forbiddenPrefixes: string[];
43
+ forbiddenSuffixes: string[];
44
+ };
29
45
  })[];
30
- '@graphql-eslint/no-case-insensitive-enum-values-duplicates': string;
31
46
  '@graphql-eslint/no-hashtag-description': string;
32
47
  '@graphql-eslint/no-typename-prefix': string;
33
48
  '@graphql-eslint/no-unreachable-types': string;
49
+ '@graphql-eslint/possible-type-extension': string;
34
50
  '@graphql-eslint/provided-required-arguments': string;
35
51
  '@graphql-eslint/require-deprecation-reason': string;
36
52
  '@graphql-eslint/require-description': (string | {
37
53
  types: boolean;
38
54
  DirectiveDefinition: boolean;
55
+ rootField: boolean;
39
56
  })[];
40
57
  '@graphql-eslint/strict-id-in-types': string;
41
58
  '@graphql-eslint/unique-directive-names': string;
42
59
  '@graphql-eslint/unique-directive-names-per-location': string;
60
+ '@graphql-eslint/unique-enum-value-names': string;
43
61
  '@graphql-eslint/unique-field-definition-names': string;
44
62
  '@graphql-eslint/unique-operation-types': string;
45
63
  '@graphql-eslint/unique-type-names': string;
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  __commonJS
3
- } from "../chunk-BMTV3EA2.js";
3
+ } from "../chunk-U3TKCM4X.js";
4
4
  var require_schema_recommended = __commonJS({
5
5
  "src/configs/schema-recommended.ts"(exports, module) {
6
6
  module.exports = {
@@ -32,19 +32,39 @@ var require_schema_recommended = __commonJS({
32
32
  "FieldDefinition[parent.name.value=Subscription]": {
33
33
  forbiddenPrefixes: ["subscription"],
34
34
  forbiddenSuffixes: ["Subscription"]
35
+ },
36
+ "EnumTypeDefinition,EnumTypeExtension": {
37
+ forbiddenPrefixes: ["Enum"],
38
+ forbiddenSuffixes: ["Enum"]
39
+ },
40
+ "InterfaceTypeDefinition,InterfaceTypeExtension": {
41
+ forbiddenPrefixes: ["Interface"],
42
+ forbiddenSuffixes: ["Interface"]
43
+ },
44
+ "UnionTypeDefinition,UnionTypeExtension": {
45
+ forbiddenPrefixes: ["Union"],
46
+ forbiddenSuffixes: ["Union"]
47
+ },
48
+ "ObjectTypeDefinition,ObjectTypeExtension": {
49
+ forbiddenPrefixes: ["Type"],
50
+ forbiddenSuffixes: ["Type"]
35
51
  }
36
52
  }
37
53
  ],
38
- "@graphql-eslint/no-case-insensitive-enum-values-duplicates": "error",
39
54
  "@graphql-eslint/no-hashtag-description": "error",
40
55
  "@graphql-eslint/no-typename-prefix": "error",
41
56
  "@graphql-eslint/no-unreachable-types": "error",
57
+ "@graphql-eslint/possible-type-extension": "error",
42
58
  "@graphql-eslint/provided-required-arguments": "error",
43
59
  "@graphql-eslint/require-deprecation-reason": "error",
44
- "@graphql-eslint/require-description": ["error", { types: true, DirectiveDefinition: true }],
60
+ "@graphql-eslint/require-description": [
61
+ "error",
62
+ { types: !0, DirectiveDefinition: !0, rootField: !0 }
63
+ ],
45
64
  "@graphql-eslint/strict-id-in-types": "error",
46
65
  "@graphql-eslint/unique-directive-names": "error",
47
66
  "@graphql-eslint/unique-directive-names-per-location": "error",
67
+ "@graphql-eslint/unique-enum-value-names": "error",
48
68
  "@graphql-eslint/unique-field-definition-names": "error",
49
69
  "@graphql-eslint/unique-operation-types": "error",
50
70
  "@graphql-eslint/unique-type-names": "error"
@@ -1,8 +1,8 @@
1
1
  import {
2
2
  __commonJS
3
- } from "../chunk-BMTV3EA2.js";
4
- var require_relay = __commonJS({
5
- "src/configs/relay.ts"(exports, module) {
3
+ } from "../chunk-U3TKCM4X.js";
4
+ var require_schema_relay = __commonJS({
5
+ "src/configs/schema-relay.ts"(exports, module) {
6
6
  module.exports = {
7
7
  parser: "@graphql-eslint/eslint-plugin",
8
8
  plugins: ["@graphql-eslint"],
@@ -15,4 +15,4 @@ var require_relay = __commonJS({
15
15
  };
16
16
  }
17
17
  });
18
- export default require_relay();
18
+ export default require_schema_relay();
package/esm/documents.js CHANGED
@@ -1,45 +1,38 @@
1
- import "./chunk-BMTV3EA2.js";
2
- import { resolve } from "path";
1
+ import "./chunk-U3TKCM4X.js";
2
+ import { resolve } from "node:path";
3
3
  import debugFactory from "debug";
4
4
  import fg from "fast-glob";
5
5
  import { ModuleCache } from "./cache.js";
6
- const debug = debugFactory("graphql-eslint:operations");
7
- const operationsCache = new ModuleCache();
8
- const handleVirtualPath = (documents) => {
6
+ const debug = debugFactory("graphql-eslint:operations"), operationsCache = new ModuleCache(), handleVirtualPath = (documents) => {
9
7
  const filepathMap = /* @__PURE__ */ Object.create(null);
10
8
  return documents.map((source) => {
11
- var _a;
12
9
  const location = source.location;
13
- if ([".gql", ".graphql"].some((extension) => location.endsWith(extension))) {
10
+ if ([".gql", ".graphql"].some((extension) => location.endsWith(extension)))
14
11
  return source;
15
- }
16
- (_a = filepathMap[location]) != null ? _a : filepathMap[location] = -1;
12
+ filepathMap[location] ??= -1;
17
13
  const index = filepathMap[location] += 1;
18
14
  return {
19
15
  ...source,
20
16
  location: resolve(location, `${index}_document.graphql`)
21
17
  };
22
18
  });
23
- };
24
- const getDocuments = (project) => {
19
+ }, getDocuments = (project) => {
25
20
  const documentsKey = project.documents;
26
- if (!documentsKey) {
21
+ if (!documentsKey)
27
22
  return [];
28
- }
29
23
  let siblings = operationsCache.get(documentsKey);
30
24
  if (!siblings) {
31
25
  debug("Loading operations from %o", project.documents);
32
26
  const documents = project.loadDocumentsSync(project.documents, {
33
- skipGraphQLImport: true,
27
+ skipGraphQLImport: !0,
34
28
  pluckConfig: project.extensions.pluckConfig
35
29
  });
36
30
  if (debug.enabled) {
37
31
  debug("Loaded %d operations", documents.length);
38
- const operationsPaths = fg.sync(project.documents, { absolute: true });
32
+ const operationsPaths = fg.sync(project.documents, { absolute: !0 });
39
33
  debug("Operations pointers %O", operationsPaths);
40
34
  }
41
- siblings = handleVirtualPath(documents);
42
- operationsCache.set(documentsKey, siblings);
35
+ siblings = handleVirtualPath(documents), operationsCache.set(documentsKey, siblings);
43
36
  }
44
37
  return siblings;
45
38
  };