@graphql-eslint/eslint-plugin 4.4.0-alpha-20241210130004-c86c74902285624344165bb32d972962226b7df8 → 4.4.0-alpha-20241210205144-662e65e39b519504be52c4dba23aaa08280b6322

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (161) hide show
  1. package/{programmatic.js → browser.js} +73 -104
  2. package/cjs/graphql-config.d.cts +2 -1
  3. package/cjs/index.d.cts +1 -0
  4. package/cjs/meta.js +1 -1
  5. package/cjs/parser.d.cts +2 -1
  6. package/cjs/rules/alphabetize/index.d.cts +1 -1
  7. package/cjs/rules/alphabetize/index.js +1 -2
  8. package/cjs/rules/description-style/index.d.cts +1 -1
  9. package/cjs/rules/description-style/index.js +1 -3
  10. package/cjs/rules/graphql-js-validation.d.cts +2 -1
  11. package/cjs/rules/graphql-js-validation.js +30 -31
  12. package/cjs/rules/index.d.cts +1 -0
  13. package/cjs/rules/input-name/index.d.cts +1 -1
  14. package/cjs/rules/input-name/index.js +1 -3
  15. package/cjs/rules/lone-executable-definition/index.d.cts +1 -1
  16. package/cjs/rules/lone-executable-definition/index.js +1 -2
  17. package/cjs/rules/match-document-filename/index.d.cts +1 -1
  18. package/cjs/rules/match-document-filename/index.js +1 -2
  19. package/cjs/rules/naming-convention/index.d.cts +1 -1
  20. package/cjs/rules/naming-convention/index.js +1 -3
  21. package/cjs/rules/no-anonymous-operations/index.d.cts +2 -1
  22. package/cjs/rules/no-anonymous-operations/index.js +1 -2
  23. package/cjs/rules/no-deprecated/index.d.cts +2 -1
  24. package/cjs/rules/no-deprecated/index.js +1 -2
  25. package/cjs/rules/no-duplicate-fields/index.d.cts +2 -1
  26. package/cjs/rules/no-duplicate-fields/index.js +1 -2
  27. package/cjs/rules/no-hashtag-description/index.d.cts +2 -1
  28. package/cjs/rules/no-hashtag-description/index.js +1 -2
  29. package/cjs/rules/no-one-place-fragments/index.d.cts +2 -1
  30. package/cjs/rules/no-one-place-fragments/index.js +1 -1
  31. package/cjs/rules/no-root-type/index.d.cts +1 -1
  32. package/cjs/rules/no-root-type/index.js +1 -3
  33. package/cjs/rules/no-scalar-result-type-on-mutation/index.d.cts +2 -1
  34. package/cjs/rules/no-scalar-result-type-on-mutation/index.js +1 -2
  35. package/cjs/rules/no-typename-prefix/index.d.cts +2 -1
  36. package/cjs/rules/no-typename-prefix/index.js +1 -2
  37. package/cjs/rules/no-unreachable-types/index.d.cts +2 -1
  38. package/cjs/rules/no-unreachable-types/index.js +1 -2
  39. package/cjs/rules/no-unused-fields/index.d.cts +1 -1
  40. package/cjs/rules/no-unused-fields/index.js +1 -2
  41. package/cjs/rules/relay-arguments/index.d.cts +1 -1
  42. package/cjs/rules/relay-arguments/index.js +1 -1
  43. package/cjs/rules/relay-connection-types/index.d.cts +2 -1
  44. package/cjs/rules/relay-connection-types/index.js +1 -1
  45. package/cjs/rules/relay-edge-types/index.d.cts +1 -1
  46. package/cjs/rules/relay-edge-types/index.js +1 -1
  47. package/cjs/rules/relay-page-info/index.d.cts +2 -1
  48. package/cjs/rules/relay-page-info/index.js +1 -1
  49. package/cjs/rules/require-deprecation-date/index.d.cts +1 -1
  50. package/cjs/rules/require-deprecation-date/index.js +1 -2
  51. package/cjs/rules/require-deprecation-reason/index.d.cts +2 -1
  52. package/cjs/rules/require-deprecation-reason/index.js +1 -1
  53. package/cjs/rules/require-description/index.d.cts +1 -1
  54. package/cjs/rules/require-description/index.js +1 -2
  55. package/cjs/rules/require-field-of-type-query-in-mutation-result/index.d.cts +2 -1
  56. package/cjs/rules/require-field-of-type-query-in-mutation-result/index.js +1 -1
  57. package/cjs/rules/require-import-fragment/index.d.cts +2 -1
  58. package/cjs/rules/require-import-fragment/index.js +1 -2
  59. package/cjs/rules/require-nullable-fields-with-oneof/index.d.cts +2 -1
  60. package/cjs/rules/require-nullable-fields-with-oneof/index.js +1 -1
  61. package/cjs/rules/require-nullable-result-in-root/index.d.cts +2 -1
  62. package/cjs/rules/require-nullable-result-in-root/index.js +1 -2
  63. package/cjs/rules/require-selections/index.d.cts +1 -1
  64. package/cjs/rules/require-selections/index.js +4 -8
  65. package/cjs/rules/require-type-pattern-with-oneof/index.d.cts +2 -1
  66. package/cjs/rules/require-type-pattern-with-oneof/index.js +1 -1
  67. package/cjs/rules/selection-set-depth/index.d.cts +1 -1
  68. package/cjs/rules/selection-set-depth/index.js +1 -3
  69. package/cjs/rules/strict-id-in-types/index.d.cts +1 -1
  70. package/cjs/rules/strict-id-in-types/index.js +5 -5
  71. package/cjs/rules/unique-enum-value-names/index.d.cts +2 -1
  72. package/cjs/rules/unique-enum-value-names/index.js +1 -2
  73. package/cjs/rules/unique-fragment-name/index.d.cts +1 -0
  74. package/cjs/rules/unique-fragment-name/index.js +2 -1
  75. package/cjs/rules/unique-operation-name/index.d.cts +2 -1
  76. package/cjs/rules/unique-operation-name/index.js +1 -1
  77. package/cjs/schema.d.cts +2 -1
  78. package/cjs/types.d.cts +17 -7
  79. package/cjs/utils.d.cts +2 -2
  80. package/cjs/utils.js +1 -5
  81. package/esm/graphql-config.d.ts +2 -1
  82. package/esm/index.d.ts +1 -0
  83. package/esm/meta.js +1 -1
  84. package/esm/parser.d.ts +2 -1
  85. package/esm/rules/alphabetize/index.d.ts +1 -1
  86. package/esm/rules/alphabetize/index.js +1 -2
  87. package/esm/rules/description-style/index.d.ts +1 -1
  88. package/esm/rules/description-style/index.js +1 -3
  89. package/esm/rules/graphql-js-validation.d.ts +2 -1
  90. package/esm/rules/graphql-js-validation.js +30 -31
  91. package/esm/rules/index.d.ts +1 -0
  92. package/esm/rules/input-name/index.d.ts +1 -1
  93. package/esm/rules/input-name/index.js +1 -3
  94. package/esm/rules/lone-executable-definition/index.d.ts +1 -1
  95. package/esm/rules/lone-executable-definition/index.js +1 -2
  96. package/esm/rules/match-document-filename/index.d.ts +1 -1
  97. package/esm/rules/match-document-filename/index.js +1 -2
  98. package/esm/rules/naming-convention/index.d.ts +1 -1
  99. package/esm/rules/naming-convention/index.js +1 -3
  100. package/esm/rules/no-anonymous-operations/index.d.ts +2 -1
  101. package/esm/rules/no-anonymous-operations/index.js +1 -2
  102. package/esm/rules/no-deprecated/index.d.ts +2 -1
  103. package/esm/rules/no-deprecated/index.js +1 -2
  104. package/esm/rules/no-duplicate-fields/index.d.ts +2 -1
  105. package/esm/rules/no-duplicate-fields/index.js +1 -2
  106. package/esm/rules/no-hashtag-description/index.d.ts +2 -1
  107. package/esm/rules/no-hashtag-description/index.js +1 -2
  108. package/esm/rules/no-one-place-fragments/index.d.ts +2 -1
  109. package/esm/rules/no-one-place-fragments/index.js +1 -1
  110. package/esm/rules/no-root-type/index.d.ts +1 -1
  111. package/esm/rules/no-root-type/index.js +1 -3
  112. package/esm/rules/no-scalar-result-type-on-mutation/index.d.ts +2 -1
  113. package/esm/rules/no-scalar-result-type-on-mutation/index.js +1 -2
  114. package/esm/rules/no-typename-prefix/index.d.ts +2 -1
  115. package/esm/rules/no-typename-prefix/index.js +1 -2
  116. package/esm/rules/no-unreachable-types/index.d.ts +2 -1
  117. package/esm/rules/no-unreachable-types/index.js +1 -2
  118. package/esm/rules/no-unused-fields/index.d.ts +1 -1
  119. package/esm/rules/no-unused-fields/index.js +1 -2
  120. package/esm/rules/relay-arguments/index.d.ts +1 -1
  121. package/esm/rules/relay-arguments/index.js +1 -1
  122. package/esm/rules/relay-connection-types/index.d.ts +2 -1
  123. package/esm/rules/relay-connection-types/index.js +1 -1
  124. package/esm/rules/relay-edge-types/index.d.ts +1 -1
  125. package/esm/rules/relay-edge-types/index.js +1 -1
  126. package/esm/rules/relay-page-info/index.d.ts +2 -1
  127. package/esm/rules/relay-page-info/index.js +1 -1
  128. package/esm/rules/require-deprecation-date/index.d.ts +1 -1
  129. package/esm/rules/require-deprecation-date/index.js +1 -2
  130. package/esm/rules/require-deprecation-reason/index.d.ts +2 -1
  131. package/esm/rules/require-deprecation-reason/index.js +1 -1
  132. package/esm/rules/require-description/index.d.ts +1 -1
  133. package/esm/rules/require-description/index.js +1 -2
  134. package/esm/rules/require-field-of-type-query-in-mutation-result/index.d.ts +2 -1
  135. package/esm/rules/require-field-of-type-query-in-mutation-result/index.js +1 -1
  136. package/esm/rules/require-import-fragment/index.d.ts +2 -1
  137. package/esm/rules/require-import-fragment/index.js +1 -2
  138. package/esm/rules/require-nullable-fields-with-oneof/index.d.ts +2 -1
  139. package/esm/rules/require-nullable-fields-with-oneof/index.js +1 -1
  140. package/esm/rules/require-nullable-result-in-root/index.d.ts +2 -1
  141. package/esm/rules/require-nullable-result-in-root/index.js +1 -2
  142. package/esm/rules/require-selections/index.d.ts +1 -1
  143. package/esm/rules/require-selections/index.js +4 -8
  144. package/esm/rules/require-type-pattern-with-oneof/index.d.ts +2 -1
  145. package/esm/rules/require-type-pattern-with-oneof/index.js +1 -1
  146. package/esm/rules/selection-set-depth/index.d.ts +1 -1
  147. package/esm/rules/selection-set-depth/index.js +1 -3
  148. package/esm/rules/strict-id-in-types/index.d.ts +1 -1
  149. package/esm/rules/strict-id-in-types/index.js +5 -5
  150. package/esm/rules/unique-enum-value-names/index.d.ts +2 -1
  151. package/esm/rules/unique-enum-value-names/index.js +1 -2
  152. package/esm/rules/unique-fragment-name/index.d.ts +1 -0
  153. package/esm/rules/unique-fragment-name/index.js +2 -1
  154. package/esm/rules/unique-operation-name/index.d.ts +2 -1
  155. package/esm/rules/unique-operation-name/index.js +1 -1
  156. package/esm/schema.d.ts +2 -1
  157. package/esm/types.d.ts +17 -7
  158. package/esm/utils.d.ts +2 -2
  159. package/esm/utils.js +0 -4
  160. package/package.json +10 -4
  161. package/programmatic.d.ts +0 -1323
@@ -1,10 +1,10 @@
1
1
  import { FromSchema } from 'json-schema-to-ts';
2
2
  import { GraphQLESLintRule } from '../../types.js';
3
3
  import 'eslint';
4
+ import 'estree';
4
5
  import 'graphql';
5
6
  import 'graphql-config';
6
7
  import '../../estree-converter/types.js';
7
- import 'estree';
8
8
  import '../../siblings.js';
9
9
  import '@graphql-tools/utils';
10
10
 
@@ -12,7 +12,6 @@ import { getBaseType } from "../../estree-converter/index.js";
12
12
  import {
13
13
  ARRAY_DEFAULT_OPTIONS,
14
14
  englishJoinWords,
15
- pluralize,
16
15
  requireGraphQLOperations,
17
16
  requireGraphQLSchema
18
17
  } from "../../utils.js";
@@ -47,7 +46,7 @@ const rule = {
47
46
  type: "suggestion",
48
47
  hasSuggestions: true,
49
48
  docs: {
50
- category: "operations",
49
+ category: "Operations",
51
50
  description: "Enforce selecting specific fields when they are available on the GraphQL type.",
52
51
  url: `https://the-guild.dev/graphql/eslint/rules/${RULE_ID}`,
53
52
  requiresSchema: true,
@@ -108,7 +107,6 @@ const rule = {
108
107
  messages: {
109
108
  [RULE_ID]: "Field{{ pluralSuffix }} {{ fieldName }} must be selected when it's available on a type.\nInclude it in your selection set{{ addition }}."
110
109
  },
111
- // @ts-expect-error -- fixme
112
110
  schema
113
111
  },
114
112
  create(context) {
@@ -214,14 +212,13 @@ const rule = {
214
212
  const fieldName2 = englishJoinWords(
215
213
  idNames2.map((name) => `\`${(parent.alias || parent.name).value}.${name}\``)
216
214
  );
217
- const addition = checkedFragmentSpreads.size === 0 ? "" : ` or add to used fragment${pluralize(
218
- checkedFragmentSpreads.size
219
- )} ${englishJoinWords([...checkedFragmentSpreads].map((name) => `\`${name}\``))}`;
215
+ const pluralSuffix = idNames2.length > 1 ? "s" : "";
216
+ const addition = checkedFragmentSpreads.size === 0 ? "" : ` or add to used fragment${checkedFragmentSpreads.size > 1 ? "s" : ""} ${englishJoinWords([...checkedFragmentSpreads].map((name) => `\`${name}\``))}`;
220
217
  const problem = {
221
218
  loc,
222
219
  messageId: RULE_ID,
223
220
  data: {
224
- pluralSuffix: pluralize(idNames2.length),
221
+ pluralSuffix,
225
222
  fieldName: fieldName2,
226
223
  addition
227
224
  }
@@ -229,7 +226,6 @@ const rule = {
229
226
  if ("type" in node) {
230
227
  problem.suggest = idNames2.map((idName) => ({
231
228
  desc: `Add \`${idName}\` selection`,
232
- // @ts-expect-error -- fixme
233
229
  fix: (fixer) => {
234
230
  let insertNode = node.selections[0];
235
231
  insertNode = insertNode.kind === Kind.INLINE_FRAGMENT ? insertNode.selectionSet.selections[0] : insertNode;
@@ -1,9 +1,10 @@
1
1
  import { GraphQLESLintRule } from '../../types.js';
2
2
  import 'eslint';
3
+ import 'estree';
3
4
  import 'graphql';
4
5
  import 'graphql-config';
6
+ import 'json-schema-to-ts';
5
7
  import '../../estree-converter/types.js';
6
- import 'estree';
7
8
  import '../../siblings.js';
8
9
  import '@graphql-tools/utils';
9
10
 
@@ -4,7 +4,7 @@ const rule = {
4
4
  meta: {
5
5
  type: "suggestion",
6
6
  docs: {
7
- category: "schema",
7
+ category: "Schema",
8
8
  description: "Enforce types with `@oneOf` directive have `error` and `ok` fields.",
9
9
  url: `https://the-guild.dev/graphql/eslint/rules/${RULE_ID}`,
10
10
  examples: [
@@ -1,10 +1,10 @@
1
1
  import { FromSchema } from 'json-schema-to-ts';
2
2
  import { GraphQLESLintRule } from '../../types.js';
3
3
  import 'eslint';
4
+ import 'estree';
4
5
  import 'graphql';
5
6
  import 'graphql-config';
6
7
  import '../../estree-converter/types.js';
7
- import 'estree';
8
8
  import '../../siblings.js';
9
9
  import '@graphql-tools/utils';
10
10
 
@@ -23,7 +23,7 @@ const rule = {
23
23
  type: "suggestion",
24
24
  hasSuggestions: true,
25
25
  docs: {
26
- category: "operations",
26
+ category: "Operations",
27
27
  description: "Limit the complexity of the GraphQL operations solely by their depth. Based on [graphql-depth-limit](https://npmjs.com/package/graphql-depth-limit).",
28
28
  url: `https://the-guild.dev/graphql/eslint/rules/${RULE_ID}`,
29
29
  requiresSiblings: true,
@@ -71,7 +71,6 @@ const rule = {
71
71
  recommended: true,
72
72
  configOptions: [{ maxDepth: 7 }]
73
73
  },
74
- // @ts-expect-error -- fixme
75
74
  schema
76
75
  },
77
76
  create(context) {
@@ -113,7 +112,6 @@ const rule = {
113
112
  suggest: [
114
113
  {
115
114
  desc: "Remove selections",
116
- // @ts-expect-error -- fixme
117
115
  fix(fixer) {
118
116
  const sourceCode = context.getSourceCode();
119
117
  const foundNode = sourceCode.getNodeByRangeIndex(token.range[0]);
@@ -1,10 +1,10 @@
1
1
  import { FromSchema } from 'json-schema-to-ts';
2
2
  import { GraphQLESLintRule } from '../../types.js';
3
3
  import 'eslint';
4
+ import 'estree';
4
5
  import 'graphql';
5
6
  import 'graphql-config';
6
7
  import '../../estree-converter/types.js';
7
- import 'estree';
8
8
  import '../../siblings.js';
9
9
  import '@graphql-tools/utils';
10
10
 
@@ -3,7 +3,6 @@ import {
3
3
  ARRAY_DEFAULT_OPTIONS,
4
4
  displayNodeName,
5
5
  englishJoinWords,
6
- pluralize,
7
6
  requireGraphQLSchema
8
7
  } from "../../utils.js";
9
8
  const RULE_ID = "strict-id-in-types";
@@ -44,7 +43,7 @@ const rule = {
44
43
  type: "suggestion",
45
44
  docs: {
46
45
  description: "Requires output types to have one unique identifier unless they do not have a logical one. Exceptions can be used to ignore output types that do not have unique identifiers.",
47
- category: "schema",
46
+ category: "Schema",
48
47
  recommended: true,
49
48
  url: `https://the-guild.dev/graphql/eslint/rules/${RULE_ID}`,
50
49
  requiresSchema: true,
@@ -116,7 +115,6 @@ const rule = {
116
115
  }
117
116
  ]
118
117
  },
119
- // @ts-expect-error -- fixme
120
118
  schema
121
119
  },
122
120
  create(context) {
@@ -150,11 +148,13 @@ const rule = {
150
148
  return isValidIdName && isValidIdType;
151
149
  });
152
150
  if (validIds?.length !== 1) {
151
+ const pluralNamesSuffix = options.acceptedIdNames.length > 1 ? "s" : "";
152
+ const pluralTypesSuffix = options.acceptedIdTypes.length > 1 ? "s" : "";
153
153
  context.report({
154
154
  node: node.name,
155
155
  message: `${displayNodeName(node)} must have exactly one non-nullable unique identifier.
156
- Accepted name${pluralize(options.acceptedIdNames.length)}: ${englishJoinWords(options.acceptedIdNames)}.
157
- Accepted type${pluralize(options.acceptedIdTypes.length)}: ${englishJoinWords(options.acceptedIdTypes)}.`
156
+ Accepted name${pluralNamesSuffix}: ${englishJoinWords(options.acceptedIdNames)}.
157
+ Accepted type${pluralTypesSuffix}: ${englishJoinWords(options.acceptedIdTypes)}.`
158
158
  });
159
159
  }
160
160
  }
@@ -1,9 +1,10 @@
1
1
  import { GraphQLESLintRule } from '../../types.js';
2
2
  import 'eslint';
3
+ import 'estree';
3
4
  import 'graphql';
4
5
  import 'graphql-config';
6
+ import 'json-schema-to-ts';
5
7
  import '../../estree-converter/types.js';
6
- import 'estree';
7
8
  import '../../siblings.js';
8
9
  import '@graphql-tools/utils';
9
10
 
@@ -6,7 +6,7 @@ const rule = {
6
6
  hasSuggestions: true,
7
7
  docs: {
8
8
  url: "https://the-guild.dev/graphql/eslint/rules/unique-enum-value-names",
9
- category: "schema",
9
+ category: "Schema",
10
10
  recommended: true,
11
11
  description: `A GraphQL enum type is only valid if all its values are uniquely named.
12
12
  > This rule disallows case-insensitive enum values duplicates too.`,
@@ -58,7 +58,6 @@ const rule = {
58
58
  suggest: [
59
59
  {
60
60
  desc: `Remove \`${enumName}\` enum value`,
61
- // @ts-expect-error -- fixme
62
61
  fix: (fixer) => fixer.remove(duplicate)
63
62
  }
64
63
  ]
@@ -4,6 +4,7 @@ import { GraphQLESLintRuleContext, GraphQLESLintRule } from '../../types.js';
4
4
  import 'eslint';
5
5
  import 'estree';
6
6
  import 'graphql-config';
7
+ import 'json-schema-to-ts';
7
8
  import '../../siblings.js';
8
9
  import '@graphql-tools/utils';
9
10
 
@@ -19,6 +19,7 @@ const checkNode = (context, node, ruleId) => {
19
19
  documentName,
20
20
  summary: conflictingDocuments.map((f) => ` ${relative(CWD, f.filePath.replace(VIRTUAL_DOCUMENT_REGEX, ""))}`).join("\n")
21
21
  },
22
+ // @ts-expect-error name will exist
22
23
  node: node.name
23
24
  });
24
25
  }
@@ -27,7 +28,7 @@ const rule = {
27
28
  meta: {
28
29
  type: "suggestion",
29
30
  docs: {
30
- category: "operations",
31
+ category: "Operations",
31
32
  description: "Enforce unique fragment names across your project.",
32
33
  url: `https://the-guild.dev/graphql/eslint/rules/${RULE_ID}`,
33
34
  requiresSiblings: true,
@@ -1,9 +1,10 @@
1
1
  import { GraphQLESLintRule } from '../../types.js';
2
2
  import 'eslint';
3
+ import 'estree';
3
4
  import 'graphql';
4
5
  import 'graphql-config';
6
+ import 'json-schema-to-ts';
5
7
  import '../../estree-converter/types.js';
6
- import 'estree';
7
8
  import '../../siblings.js';
8
9
  import '@graphql-tools/utils';
9
10
 
@@ -4,7 +4,7 @@ const rule = {
4
4
  meta: {
5
5
  type: "suggestion",
6
6
  docs: {
7
- category: "operations",
7
+ category: "Operations",
8
8
  description: "Enforce unique operation names across your project.",
9
9
  url: `https://the-guild.dev/graphql/eslint/rules/${RULE_ID}`,
10
10
  requiresSiblings: true,
package/esm/schema.d.ts CHANGED
@@ -1,9 +1,10 @@
1
1
  import { GraphQLProjectConfig } from 'graphql-config';
2
2
  import { Schema } from './types.js';
3
3
  import 'eslint';
4
+ import 'estree';
4
5
  import 'graphql';
6
+ import 'json-schema-to-ts';
5
7
  import './estree-converter/types.js';
6
- import 'estree';
7
8
  import './siblings.js';
8
9
  import '@graphql-tools/utils';
9
10
 
package/esm/types.d.ts CHANGED
@@ -1,9 +1,10 @@
1
- import { Linter, Rule } from 'eslint';
1
+ import { Linter, Rule, AST } from 'eslint';
2
+ import * as ESTree from 'estree';
2
3
  import { GraphQLSchema, ASTKindToNode } from 'graphql';
3
4
  import { IGraphQLConfig } from 'graphql-config';
5
+ import { JSONSchema } from 'json-schema-to-ts';
4
6
  import { GraphQLESTreeNode } from './estree-converter/types.js';
5
7
  import { SiblingOperations } from './siblings.js';
6
- import 'estree';
7
8
  import '@graphql-tools/utils';
8
9
 
9
10
  type Schema = GraphQLSchema | null;
@@ -20,16 +21,24 @@ type ParserServices = {
20
21
  type GraphQLESLintParseResult = Linter.ESLintParseResult & {
21
22
  services: ParserServices;
22
23
  };
23
- type ReportDescriptorLocation = any;
24
+ type Location = AST.SourceLocation | ESTree.Position;
25
+ type ReportDescriptorLocation = {
26
+ loc: Location;
27
+ } | {
28
+ node: {
29
+ loc: Location;
30
+ };
31
+ };
24
32
  type ReportDescriptor = ReportDescriptorLocation & Rule.ReportDescriptorMessage & Rule.ReportDescriptorOptions;
25
- type GraphQLESLintRuleContext<Options = any[]> = Omit<Rule.RuleContext, 'options' | 'report'> & {
33
+ type GraphQLESLintRuleContext<Options = any[]> = Omit<Rule.RuleContext, 'options' | 'parserServices' | 'report'> & {
26
34
  options: Options;
35
+ parserServices: ParserServices;
27
36
  report(descriptor: ReportDescriptor): void;
28
37
  };
29
- type CategoryType = 'schema' | 'operations' | 'schema-and-operations';
38
+ type CategoryType = 'Operations' | 'Schema';
30
39
  type RuleMetaDataDocs = Required<Rule.RuleMetaData>['docs'];
31
40
  type RuleDocsInfo<T> = Omit<RuleMetaDataDocs, 'category' | 'suggestion'> & {
32
- category?: string;
41
+ category: CategoryType | CategoryType[];
33
42
  requiresSchema?: true;
34
43
  requiresSiblings?: true;
35
44
  examples?: {
@@ -49,8 +58,9 @@ type GraphQLESLintRuleListener<WithTypeInfo extends boolean = false> = Record<st
49
58
  [K in keyof ASTKindToNode]?: (node: GraphQLESTreeNode<ASTKindToNode[K], WithTypeInfo>) => void;
50
59
  };
51
60
  type GraphQLESLintRule<Options = [], WithTypeInfo extends boolean = false> = {
52
- meta?: Omit<Rule.RuleMetaData, 'docs'> & {
61
+ meta: Omit<Rule.RuleMetaData, 'docs' | 'schema'> & {
53
62
  docs?: RuleDocsInfo<Options>;
63
+ schema: Readonly<JSONSchema> | [];
54
64
  };
55
65
  create(context: GraphQLESLintRuleContext<Options>): GraphQLESLintRuleListener<WithTypeInfo>;
56
66
  };
package/esm/utils.d.ts CHANGED
@@ -6,6 +6,7 @@ import { SiblingOperations } from './siblings.js';
6
6
  import { GraphQLESLintRuleContext } from './types.js';
7
7
  import '@graphql-tools/utils';
8
8
  import 'graphql-config';
9
+ import 'json-schema-to-ts';
9
10
 
10
11
  declare function requireGraphQLOperations(ruleId: string, context: GraphQLESLintRuleContext): SiblingOperations | never;
11
12
  declare function requireGraphQLSchema(ruleId: string, context: GraphQLESLintRuleContext): GraphQLSchema | never;
@@ -39,6 +40,5 @@ declare const englishJoinWords: (words: string[]) => string;
39
40
  declare function displayNodeName(node: GraphQLESTreeNode<ASTNode, boolean>): string;
40
41
  declare function getNodeName(node: GraphQLESTreeNode<ASTNode>): string;
41
42
  declare const eslintSelectorsTip = "> [!TIP]\n>\n> These fields are defined by ESLint [`selectors`](https://eslint.org/docs/developer-guide/selectors).\n> Paste or drop code into the editor in [ASTExplorer](https://astexplorer.net) and inspect the generated AST to compose your selector.";
42
- declare function pluralize(size: number): "" | "s";
43
43
 
44
- export { ARRAY_DEFAULT_OPTIONS, CWD, type CaseStyle, REPORT_ON_FIRST_CHARACTER, TYPES_KINDS, VIRTUAL_DOCUMENT_REGEX, camelCase, convertCase, displayNodeName, englishJoinWords, eslintSelectorsTip, getLocation, getNodeName, getTypeName, logger, pascalCase, pluralize, requireGraphQLOperations, requireGraphQLSchema, slash };
44
+ export { ARRAY_DEFAULT_OPTIONS, CWD, type CaseStyle, REPORT_ON_FIRST_CHARACTER, TYPES_KINDS, VIRTUAL_DOCUMENT_REGEX, camelCase, convertCase, displayNodeName, englishJoinWords, eslintSelectorsTip, getLocation, getNodeName, getTypeName, logger, pascalCase, requireGraphQLOperations, requireGraphQLSchema, slash };
package/esm/utils.js CHANGED
@@ -158,9 +158,6 @@ const eslintSelectorsTip = `> [!TIP]
158
158
  >
159
159
  > These fields are defined by ESLint [\`selectors\`](https://eslint.org/docs/developer-guide/selectors).
160
160
  > Paste or drop code into the editor in [ASTExplorer](https://astexplorer.net) and inspect the generated AST to compose your selector.`;
161
- function pluralize(size) {
162
- return size > 1 ? "s" : "";
163
- }
164
161
  export {
165
162
  ARRAY_DEFAULT_OPTIONS,
166
163
  CWD,
@@ -177,7 +174,6 @@ export {
177
174
  getTypeName,
178
175
  logger,
179
176
  pascalCase,
180
- pluralize,
181
177
  requireGraphQLOperations,
182
178
  requireGraphQLSchema,
183
179
  slash
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@graphql-eslint/eslint-plugin",
3
- "version": "4.4.0-alpha-20241210130004-c86c74902285624344165bb32d972962226b7df8",
3
+ "version": "4.4.0-alpha-20241210205144-662e65e39b519504be52c4dba23aaa08280b6322",
4
4
  "type": "module",
5
5
  "description": "GraphQL plugin for ESLint",
6
6
  "repository": "https://github.com/dimaMachina/graphql-eslint",
@@ -21,9 +21,15 @@
21
21
  "default": "./esm/index.js"
22
22
  }
23
23
  },
24
- "./programmatic": {
25
- "import": "./programmatic.js",
26
- "types": "./programmatic.d.ts"
24
+ "./*": {
25
+ "require": {
26
+ "types": "./cjs/*.d.cts",
27
+ "default": "./cjs/*.js"
28
+ },
29
+ "import": {
30
+ "types": "./esm/*.d.ts",
31
+ "default": "./esm/*.js"
32
+ }
27
33
  }
28
34
  },
29
35
  "types": "esm/index.d.ts",