@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
@@ -1,11 +1,12 @@
1
- import { f as GraphQLESLintRule } from '../types-8d5f4ae0.js';
2
- import '@graphql-tools/utils';
1
+ import { GraphQLESLintRule } from '../types.js';
3
2
  import 'eslint';
4
3
  import 'estree';
5
4
  import 'graphql';
6
- import 'graphql-config';
7
5
  import 'json-schema-to-ts';
6
+ import '../siblings.js';
7
+ import '@graphql-tools/utils';
8
8
  import '../estree-converter/types.js';
9
+ import 'graphql-config';
9
10
 
10
11
  declare const rule: GraphQLESLintRule;
11
12
 
@@ -5,33 +5,29 @@ 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 no_duplicate_fields_exports = {};
20
17
  __export(no_duplicate_fields_exports, {
21
18
  rule: () => rule
22
19
  });
23
20
  module.exports = __toCommonJS(no_duplicate_fields_exports);
24
21
  var import_graphql = require("graphql");
25
- const RULE_ID = "no-duplicate-fields";
26
- const rule = {
22
+ const RULE_ID = "no-duplicate-fields", rule = {
27
23
  meta: {
28
24
  type: "suggestion",
29
- hasSuggestions: true,
25
+ hasSuggestions: !0,
30
26
  docs: {
31
27
  description: "Checks for duplicate fields in selection set, variables in operation definition, or in arguments set of a field.",
32
28
  category: "Operations",
33
29
  url: `https://the-guild.dev/graphql/eslint/rules/${RULE_ID}`,
34
- recommended: true,
30
+ recommended: !0,
35
31
  examples: [
36
32
  {
37
33
  title: "Incorrect",
@@ -112,30 +108,24 @@ const rule = {
112
108
  }
113
109
  ]
114
110
  });
115
- } else {
111
+ } else
116
112
  usedFields.add(fieldName);
117
- }
118
113
  }
119
114
  return {
120
115
  OperationDefinition(node) {
121
116
  const set = /* @__PURE__ */ new Set();
122
- for (const varDef of node.variableDefinitions || []) {
117
+ for (const varDef of node.variableDefinitions || [])
123
118
  checkNode(set, varDef.variable.name);
124
- }
125
119
  },
126
120
  Field(node) {
127
121
  const set = /* @__PURE__ */ new Set();
128
- for (const arg of node.arguments || []) {
122
+ for (const arg of node.arguments || [])
129
123
  checkNode(set, arg.name);
130
- }
131
124
  },
132
125
  SelectionSet(node) {
133
126
  const set = /* @__PURE__ */ new Set();
134
- for (const selection of node.selections) {
135
- if (selection.kind === import_graphql.Kind.FIELD) {
136
- checkNode(set, selection.alias || selection.name);
137
- }
138
- }
127
+ for (const selection of node.selections)
128
+ selection.kind === import_graphql.Kind.FIELD && checkNode(set, selection.alias || selection.name);
139
129
  }
140
130
  };
141
131
  }
@@ -1,11 +1,12 @@
1
- import { f as GraphQLESLintRule } from '../types-8d5f4ae0.js';
2
- import '@graphql-tools/utils';
1
+ import { GraphQLESLintRule } from '../types.js';
3
2
  import 'eslint';
4
3
  import 'estree';
5
4
  import 'graphql';
6
- import 'graphql-config';
7
5
  import 'json-schema-to-ts';
6
+ import '../siblings.js';
7
+ import '@graphql-tools/utils';
8
8
  import '../estree-converter/types.js';
9
+ import 'graphql-config';
9
10
 
10
11
  declare const RULE_ID = "HASHTAG_COMMENT";
11
12
  declare const rule: GraphQLESLintRule;
@@ -5,30 +5,25 @@ 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 no_hashtag_description_exports = {};
20
17
  __export(no_hashtag_description_exports, {
21
18
  RULE_ID: () => RULE_ID,
22
19
  rule: () => rule
23
20
  });
24
21
  module.exports = __toCommonJS(no_hashtag_description_exports);
25
- var import_graphql = require("graphql");
26
- var import_utils = require("../utils.js");
27
- const RULE_ID = "HASHTAG_COMMENT";
28
- const rule = {
22
+ var import_graphql = require("graphql"), import_utils = require("../utils.js");
23
+ const RULE_ID = "HASHTAG_COMMENT", rule = {
29
24
  meta: {
30
25
  type: "suggestion",
31
- hasSuggestions: true,
26
+ hasSuggestions: !0,
32
27
  schema: [],
33
28
  messages: {
34
29
  [RULE_ID]: 'Unexpected GraphQL descriptions as hashtag `#` for {{ nodeName }}.\nPrefer using `"""` for multiline, or `"` for a single line description.'
@@ -81,27 +76,21 @@ const rule = {
81
76
  )
82
77
  }
83
78
  ],
84
- recommended: true
79
+ recommended: !0
85
80
  }
86
81
  },
87
82
  create(context) {
88
- const selector = "Document[definitions.0.kind!=/^(OperationDefinition|FragmentDefinition)$/]";
89
83
  return {
90
- [selector](node) {
91
- const rawNode = node.rawNode();
92
- let token = rawNode.loc.startToken;
93
- while (token) {
84
+ ["Document[definitions.0.kind!=/^(OperationDefinition|FragmentDefinition)$/]"](node) {
85
+ let token = node.rawNode().loc.startToken;
86
+ for (; token; ) {
94
87
  const { kind, prev, next, value, line, column } = token;
95
88
  if (kind === import_graphql.TokenKind.COMMENT && prev && next) {
96
- const isEslintComment = value.trimStart().startsWith("eslint");
97
- const linesAfter = next.line - line;
89
+ const isEslintComment = value.trimStart().startsWith("eslint"), linesAfter = next.line - line;
98
90
  if (!isEslintComment && line !== prev.line && next.kind === import_graphql.TokenKind.NAME && linesAfter < 2) {
99
- const sourceCode = context.getSourceCode();
100
- const { tokens } = sourceCode.ast;
101
- const t = tokens.find(
91
+ const sourceCode = context.getSourceCode(), { tokens } = sourceCode.ast, t = tokens.find(
102
92
  (token2) => token2.loc.start.line === next.line && token2.loc.start.column === next.column - 1
103
- );
104
- const nextNode = sourceCode.getNodeByRangeIndex(t.range[1] + 1);
93
+ ), nextNode = sourceCode.getNodeByRangeIndex(t.range[1] + 1);
105
94
  context.report({
106
95
  messageId: RULE_ID,
107
96
  data: {
@@ -117,16 +106,14 @@ const rule = {
117
106
  desc: `Replace with \`${descriptionSyntax}\` description syntax`,
118
107
  fix: (fixer) => fixer.replaceTextRange(
119
108
  [token.start, token.end],
120
- // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion -- TODO: remove `!` when drop support of graphql@15
121
109
  [descriptionSyntax, value.trim(), descriptionSyntax].join("")
122
110
  )
123
111
  }))
124
112
  });
125
113
  }
126
114
  }
127
- if (!next) {
115
+ if (!next)
128
116
  break;
129
- }
130
117
  token = next;
131
118
  }
132
119
  }
@@ -1,11 +1,12 @@
1
- import { f as GraphQLESLintRule } from '../types-8d5f4ae0.js';
2
- import '@graphql-tools/utils';
1
+ import { GraphQLESLintRule } from '../types.js';
3
2
  import 'eslint';
4
3
  import 'estree';
5
4
  import 'graphql';
6
- import 'graphql-config';
7
5
  import 'json-schema-to-ts';
6
+ import '../siblings.js';
7
+ import '@graphql-tools/utils';
8
8
  import '../estree-converter/types.js';
9
+ import 'graphql-config';
9
10
 
10
11
  declare const rule: GraphQLESLintRule;
11
12
 
@@ -5,27 +5,21 @@ 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 no_one_place_fragments_exports = {};
20
17
  __export(no_one_place_fragments_exports, {
21
18
  rule: () => rule
22
19
  });
23
20
  module.exports = __toCommonJS(no_one_place_fragments_exports);
24
- var import_path = require("path");
25
- var import_graphql = require("graphql");
26
- var import_utils = require("../utils.js");
27
- const RULE_ID = "no-one-place-fragments";
28
- const rule = {
21
+ var import_node_path = require("node:path"), import_graphql = require("graphql"), import_utils = require("../utils.js");
22
+ const RULE_ID = "no-one-place-fragments", rule = {
29
23
  meta: {
30
24
  type: "suggestion",
31
25
  docs: {
@@ -71,7 +65,7 @@ const rule = {
71
65
  )
72
66
  }
73
67
  ],
74
- requiresSiblings: true
68
+ requiresSiblings: !0
75
69
  },
76
70
  messages: {
77
71
  [RULE_ID]: 'Fragment `{{fragmentName}}` used only once. Inline him in "{{filePath}}".'
@@ -79,30 +73,24 @@ const rule = {
79
73
  schema: []
80
74
  },
81
75
  create(context) {
82
- const operations = (0, import_utils.requireSiblingsOperations)(RULE_ID, context);
83
- const allDocuments = [...operations.getOperations(), ...operations.getFragments()];
84
- const usedFragmentsMap = /* @__PURE__ */ Object.create(null);
76
+ const operations = (0, import_utils.requireSiblingsOperations)(RULE_ID, context), allDocuments = [...operations.getOperations(), ...operations.getFragments()], usedFragmentsMap = /* @__PURE__ */ Object.create(null);
85
77
  for (const { document, filePath } of allDocuments) {
86
- const relativeFilePath = (0, import_path.relative)(import_utils.CWD, filePath);
78
+ const relativeFilePath = (0, import_node_path.relative)(import_utils.CWD, filePath);
87
79
  (0, import_graphql.visit)(document, {
88
80
  FragmentSpread({ name }) {
89
81
  const spreadName = name.value;
90
- usedFragmentsMap[spreadName] || (usedFragmentsMap[spreadName] = []);
91
- usedFragmentsMap[spreadName].push(relativeFilePath);
82
+ usedFragmentsMap[spreadName] ||= [], usedFragmentsMap[spreadName].push(relativeFilePath);
92
83
  }
93
84
  });
94
85
  }
95
86
  return {
96
87
  "FragmentDefinition > Name"(node) {
97
- const fragmentName = node.value;
98
- const fragmentUsage = usedFragmentsMap[fragmentName];
99
- if (fragmentUsage.length === 1) {
100
- context.report({
101
- node,
102
- messageId: RULE_ID,
103
- data: { fragmentName, filePath: fragmentUsage[0] }
104
- });
105
- }
88
+ const fragmentName = node.value, fragmentUsage = usedFragmentsMap[fragmentName];
89
+ fragmentUsage.length === 1 && context.report({
90
+ node,
91
+ messageId: RULE_ID,
92
+ data: { fragmentName, filePath: fragmentUsage[0] }
93
+ });
106
94
  }
107
95
  };
108
96
  }
@@ -1,11 +1,12 @@
1
1
  import { FromSchema } from 'json-schema-to-ts';
2
- import { f as GraphQLESLintRule } from '../types-8d5f4ae0.js';
3
- import '@graphql-tools/utils';
2
+ import { GraphQLESLintRule } from '../types.js';
4
3
  import 'eslint';
5
4
  import 'estree';
6
5
  import 'graphql';
7
- import 'graphql-config';
6
+ import '../siblings.js';
7
+ import '@graphql-tools/utils';
8
8
  import '../estree-converter/types.js';
9
+ import 'graphql-config';
9
10
 
10
11
  declare const schema: {
11
12
  readonly type: "array";
@@ -5,17 +5,14 @@ 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 no_root_type_exports = {};
20
17
  __export(no_root_type_exports, {
21
18
  rule: () => rule
@@ -28,7 +25,7 @@ const schema = {
28
25
  maxItems: 1,
29
26
  items: {
30
27
  type: "object",
31
- additionalProperties: false,
28
+ additionalProperties: !1,
32
29
  required: ["disallow"],
33
30
  properties: {
34
31
  disallow: {
@@ -39,17 +36,15 @@ const schema = {
39
36
  }
40
37
  }
41
38
  }
42
- };
43
- const rule = {
39
+ }, rule = {
44
40
  meta: {
45
41
  type: "suggestion",
46
- hasSuggestions: true,
42
+ hasSuggestions: !0,
47
43
  docs: {
48
44
  category: "Schema",
49
45
  description: "Disallow using root types `mutation` and/or `subscription`.",
50
46
  url: "https://the-guild.dev/graphql/eslint/rules/no-root-type",
51
- requiresSchema: true,
52
- isDisabledForAllConfig: true,
47
+ requiresSchema: !0,
53
48
  examples: [
54
49
  {
55
50
  title: "Incorrect",
@@ -75,23 +70,18 @@ const rule = {
75
70
  `
76
71
  )
77
72
  }
78
- ]
73
+ ],
74
+ configOptions: [{ disallow: ["mutation", "subscription"] }]
79
75
  },
80
76
  schema
81
77
  },
82
78
  create(context) {
83
- const schema2 = (0, import_utils.requireGraphQLSchemaFromContext)("no-root-type", context);
84
- const disallow = new Set(context.options[0].disallow);
85
- const rootTypeNames = [
79
+ const schema2 = (0, import_utils.requireGraphQLSchemaFromContext)("no-root-type", context), disallow = new Set(context.options[0].disallow), rootTypeNames = [
86
80
  disallow.has("mutation") && schema2.getMutationType(),
87
81
  disallow.has("subscription") && schema2.getSubscriptionType()
88
82
  ].filter(import_utils.truthy).map((type) => type.name).join("|");
89
- if (!rootTypeNames) {
90
- return {};
91
- }
92
- const selector = `:matches(ObjectTypeDefinition, ObjectTypeExtension) > .name[value=/^(${rootTypeNames})$/]`;
93
- return {
94
- [selector](node) {
83
+ return rootTypeNames ? {
84
+ [`:matches(ObjectTypeDefinition, ObjectTypeExtension) > .name[value=/^(${rootTypeNames})$/]`](node) {
95
85
  const typeName = node.value;
96
86
  context.report({
97
87
  node,
@@ -104,7 +94,7 @@ const rule = {
104
94
  ]
105
95
  });
106
96
  }
107
- };
97
+ } : {};
108
98
  }
109
99
  };
110
100
  // Annotate the CommonJS export names for ESM import in node:
@@ -1,11 +1,12 @@
1
- import { f as GraphQLESLintRule } from '../types-8d5f4ae0.js';
2
- import '@graphql-tools/utils';
1
+ import { GraphQLESLintRule } from '../types.js';
3
2
  import 'eslint';
4
3
  import 'estree';
5
4
  import 'graphql';
6
- import 'graphql-config';
7
5
  import 'json-schema-to-ts';
6
+ import '../siblings.js';
7
+ import '@graphql-tools/utils';
8
8
  import '../estree-converter/types.js';
9
+ import 'graphql-config';
9
10
 
10
11
  declare const rule: GraphQLESLintRule;
11
12
 
@@ -5,34 +5,29 @@ 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 no_scalar_result_type_on_mutation_exports = {};
20
17
  __export(no_scalar_result_type_on_mutation_exports, {
21
18
  rule: () => rule
22
19
  });
23
20
  module.exports = __toCommonJS(no_scalar_result_type_on_mutation_exports);
24
- var import_graphql = require("graphql");
25
- var import_utils = require("../utils.js");
26
- const RULE_ID = "no-scalar-result-type-on-mutation";
27
- const rule = {
21
+ var import_graphql = require("graphql"), import_utils = require("../utils.js");
22
+ const RULE_ID = "no-scalar-result-type-on-mutation", rule = {
28
23
  meta: {
29
24
  type: "suggestion",
30
- hasSuggestions: true,
25
+ hasSuggestions: !0,
31
26
  docs: {
32
27
  category: "Schema",
33
28
  description: "Avoid scalar result type on mutation type to make sure to return a valid state.",
34
29
  url: `https://the-guild.dev/graphql/eslint/rules/${RULE_ID}`,
35
- requiresSchema: true,
30
+ requiresSchema: !0,
36
31
  examples: [
37
32
  {
38
33
  title: "Incorrect",
@@ -61,24 +56,17 @@ const rule = {
61
56
  schema: []
62
57
  },
63
58
  create(context) {
64
- const schema = (0, import_utils.requireGraphQLSchemaFromContext)(RULE_ID, context);
65
- const mutationType = schema.getMutationType();
66
- if (!mutationType) {
67
- return {};
68
- }
69
- const selector = [
70
- `:matches(ObjectTypeDefinition, ObjectTypeExtension)[name.value=${mutationType.name}]`,
71
- "> FieldDefinition > .gqlType Name"
72
- ].join(" ");
73
- return {
74
- [selector](node) {
75
- const typeName = node.value;
76
- const graphQLType = schema.getType(typeName);
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);
77
66
  if ((0, import_graphql.isScalarType)(graphQLType)) {
78
67
  let fieldDef = node.parent;
79
- while (fieldDef.kind !== import_graphql.Kind.FIELD_DEFINITION) {
68
+ for (; fieldDef.kind !== import_graphql.Kind.FIELD_DEFINITION; )
80
69
  fieldDef = fieldDef.parent;
81
- }
82
70
  context.report({
83
71
  node,
84
72
  message: `Unexpected scalar result type \`${typeName}\` for ${(0, import_utils.getNodeName)(fieldDef)}`,
@@ -91,7 +79,7 @@ const rule = {
91
79
  });
92
80
  }
93
81
  }
94
- };
82
+ } : {};
95
83
  }
96
84
  };
97
85
  // Annotate the CommonJS export names for ESM import in node:
@@ -1,11 +1,12 @@
1
- import { f as GraphQLESLintRule } from '../types-8d5f4ae0.js';
2
- import '@graphql-tools/utils';
1
+ import { GraphQLESLintRule } from '../types.js';
3
2
  import 'eslint';
4
3
  import 'estree';
5
4
  import 'graphql';
6
- import 'graphql-config';
7
5
  import 'json-schema-to-ts';
6
+ import '../siblings.js';
7
+ import '@graphql-tools/utils';
8
8
  import '../estree-converter/types.js';
9
+ import 'graphql-config';
9
10
 
10
11
  declare const rule: GraphQLESLintRule;
11
12
 
@@ -5,31 +5,27 @@ 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 no_typename_prefix_exports = {};
20
17
  __export(no_typename_prefix_exports, {
21
18
  rule: () => rule
22
19
  });
23
20
  module.exports = __toCommonJS(no_typename_prefix_exports);
24
- const NO_TYPENAME_PREFIX = "NO_TYPENAME_PREFIX";
25
- const rule = {
21
+ const NO_TYPENAME_PREFIX = "NO_TYPENAME_PREFIX", rule = {
26
22
  meta: {
27
23
  type: "suggestion",
28
- hasSuggestions: true,
24
+ hasSuggestions: !0,
29
25
  docs: {
30
26
  category: "Schema",
31
27
  description: "Enforces users to avoid using the type name in a field name while defining your schema.",
32
- recommended: true,
28
+ recommended: !0,
33
29
  url: "https://the-guild.dev/graphql/eslint/rules/no-typename-prefix",
34
30
  examples: [
35
31
  {
@@ -64,29 +60,26 @@ const rule = {
64
60
  create(context) {
65
61
  return {
66
62
  "ObjectTypeDefinition, ObjectTypeExtension, InterfaceTypeDefinition, InterfaceTypeExtension"(node) {
67
- const typeName = node.name.value;
68
- const lowerTypeName = typeName.toLowerCase();
63
+ const typeName = node.name.value, lowerTypeName = typeName.toLowerCase();
69
64
  for (const field of node.fields || []) {
70
65
  const fieldName = field.name.value;
71
- if (fieldName.toLowerCase().startsWith(lowerTypeName)) {
72
- context.report({
73
- data: {
74
- fieldName,
75
- typeName
76
- },
77
- messageId: NO_TYPENAME_PREFIX,
78
- node: field.name,
79
- suggest: [
80
- {
81
- desc: `Remove \`${fieldName.slice(0, typeName.length)}\` prefix`,
82
- fix: (fixer) => fixer.replaceText(
83
- field.name,
84
- fieldName.replace(new RegExp(`^${typeName}`, "i"), "")
85
- )
86
- }
87
- ]
88
- });
89
- }
66
+ fieldName.toLowerCase().startsWith(lowerTypeName) && context.report({
67
+ data: {
68
+ fieldName,
69
+ typeName
70
+ },
71
+ messageId: NO_TYPENAME_PREFIX,
72
+ node: field.name,
73
+ suggest: [
74
+ {
75
+ desc: `Remove \`${fieldName.slice(0, typeName.length)}\` prefix`,
76
+ fix: (fixer) => fixer.replaceText(
77
+ field.name,
78
+ fieldName.replace(new RegExp(`^${typeName}`, "i"), "")
79
+ )
80
+ }
81
+ ]
82
+ });
90
83
  }
91
84
  }
92
85
  };
@@ -1,11 +1,12 @@
1
- import { f as GraphQLESLintRule } from '../types-8d5f4ae0.js';
2
- import '@graphql-tools/utils';
1
+ import { GraphQLESLintRule } from '../types.js';
3
2
  import 'eslint';
4
3
  import 'estree';
5
4
  import 'graphql';
6
- import 'graphql-config';
7
5
  import 'json-schema-to-ts';
6
+ import '../siblings.js';
7
+ import '@graphql-tools/utils';
8
8
  import '../estree-converter/types.js';
9
+ import 'graphql-config';
9
10
 
10
11
  declare const rule: GraphQLESLintRule;
11
12