@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/package.json CHANGED
@@ -1,18 +1,18 @@
1
1
  {
2
2
  "name": "@graphql-eslint/eslint-plugin",
3
- "version": "4.0.0-alpha-20230801163310-8bc4340",
3
+ "version": "4.0.0-alpha-20230810160036-304c2c0",
4
4
  "description": "GraphQL plugin for ESLint",
5
5
  "repository": "https://github.com/B2o5T/graphql-eslint",
6
6
  "author": "Dotan Simha <dotansimha@gmail.com>",
7
7
  "license": "MIT",
8
8
  "engines": {
9
- "node": ">=12"
9
+ "node": ">=18"
10
10
  },
11
11
  "main": "cjs/index.js",
12
- "module": "esm/index.js",
13
12
  "exports": {
14
13
  "./package.json": "./package.json",
15
14
  ".": {
15
+ "browser": "./index.browser.mjs",
16
16
  "require": {
17
17
  "types": "./cjs/index.d.ts",
18
18
  "default": "./cjs/index.js"
@@ -27,7 +27,6 @@
27
27
  }
28
28
  }
29
29
  },
30
- "typings": "esm/index.d.mts",
31
30
  "keywords": [
32
31
  "eslint",
33
32
  "eslintplugin",
@@ -35,26 +34,22 @@
35
34
  "graphql"
36
35
  ],
37
36
  "peerDependencies": {
38
- "graphql": "^0.8.0 || ^0.9.0 || ^0.10.0 || ^0.11.0 || ^0.12.0 || ^0.13.0 || ^14.0.0 || ^15.0.0 || ^16.0.0"
37
+ "eslint": ">=8.44.0",
38
+ "graphql": "^16"
39
39
  },
40
40
  "dependencies": {
41
41
  "@graphql-tools/code-file-loader": "^7.3.6",
42
42
  "@graphql-tools/graphql-tag-pluck": "^7.3.6",
43
43
  "@graphql-tools/utils": "^9.0.0",
44
- "chalk": "^4.1.2",
45
44
  "debug": "^4.3.4",
46
45
  "fast-glob": "^3.2.12",
47
- "graphql-config": "^4.4.0",
46
+ "graphql-config": "^4.5.0",
48
47
  "graphql-depth-limit": "^1.1.0",
49
- "lodash.lowercase": "^4.3.0",
50
- "tslib": "^2.4.1"
48
+ "lodash.lowercase": "^4.3.0"
51
49
  },
52
50
  "publishConfig": {
53
51
  "directory": "dist",
54
52
  "access": "public"
55
53
  },
56
- "sideEffects": false,
57
- "typescript": {
58
- "definition": "cjs/index.d.ts"
59
- }
54
+ "sideEffects": false
60
55
  }
@@ -1,241 +0,0 @@
1
- "use strict";
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __hasOwnProp = Object.prototype.hasOwnProperty;
6
- var __export = (target, all) => {
7
- for (var name in all)
8
- __defProp(target, name, { get: all[name], enumerable: true });
9
- };
10
- var __copyProps = (to, from, except, desc) => {
11
- if (from && typeof from === "object" || typeof from === "function") {
12
- 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
- }
16
- return to;
17
- };
18
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
- var require_id_when_available_exports = {};
20
- __export(require_id_when_available_exports, {
21
- rule: () => rule
22
- });
23
- module.exports = __toCommonJS(require_id_when_available_exports);
24
- var import_utils = require("@graphql-tools/utils");
25
- var import_graphql = require("graphql");
26
- var import_estree_converter = require("../estree-converter/index.js");
27
- var import_utils2 = require("../utils.js");
28
- const RULE_ID = "require-id-when-available";
29
- const DEFAULT_ID_FIELD_NAME = "id";
30
- const schema = {
31
- definitions: {
32
- asString: {
33
- type: "string"
34
- },
35
- asArray: import_utils2.ARRAY_DEFAULT_OPTIONS
36
- },
37
- type: "array",
38
- maxItems: 1,
39
- items: {
40
- type: "object",
41
- additionalProperties: false,
42
- properties: {
43
- fieldName: {
44
- oneOf: [{ $ref: "#/definitions/asString" }, { $ref: "#/definitions/asArray" }],
45
- default: DEFAULT_ID_FIELD_NAME
46
- }
47
- }
48
- }
49
- };
50
- const rule = {
51
- meta: {
52
- type: "suggestion",
53
- hasSuggestions: true,
54
- docs: {
55
- category: "Operations",
56
- description: "Enforce selecting specific fields when they are available on the GraphQL type.",
57
- url: `https://the-guild.dev/graphql/eslint/rules/${RULE_ID}`,
58
- requiresSchema: true,
59
- requiresSiblings: true,
60
- examples: [
61
- {
62
- title: "Incorrect",
63
- code: (
64
- /* GraphQL */
65
- `
66
- # In your schema
67
- type User {
68
- id: ID!
69
- name: String!
70
- }
71
-
72
- # Query
73
- query {
74
- user {
75
- name
76
- }
77
- }
78
- `
79
- )
80
- },
81
- {
82
- title: "Correct",
83
- code: (
84
- /* GraphQL */
85
- `
86
- # In your schema
87
- type User {
88
- id: ID!
89
- name: String!
90
- }
91
-
92
- # Query
93
- query {
94
- user {
95
- id
96
- name
97
- }
98
- }
99
-
100
- # Selecting \`id\` with an alias is also valid
101
- query {
102
- user {
103
- id: name
104
- }
105
- }
106
- `
107
- )
108
- }
109
- ],
110
- recommended: true
111
- },
112
- messages: {
113
- [RULE_ID]: "Field{{ pluralSuffix }} {{ fieldName }} must be selected when it's available on a type.\nInclude it in your selection set{{ addition }}."
114
- },
115
- schema
116
- },
117
- create(context) {
118
- const schema2 = (0, import_utils2.requireGraphQLSchemaFromContext)(RULE_ID, context);
119
- const siblings = (0, import_utils2.requireSiblingsOperations)(RULE_ID, context);
120
- const { fieldName = DEFAULT_ID_FIELD_NAME } = context.options[0] || {};
121
- const idNames = (0, import_utils.asArray)(fieldName);
122
- const selector = "OperationDefinition SelectionSet[parent.kind!=/(^OperationDefinition|InlineFragment)$/]";
123
- const typeInfo = new import_graphql.TypeInfo(schema2);
124
- function checkFragments(node) {
125
- for (const selection of node.selections) {
126
- if (selection.kind !== import_graphql.Kind.FRAGMENT_SPREAD) {
127
- continue;
128
- }
129
- const [foundSpread] = siblings.getFragment(selection.name.value);
130
- if (!foundSpread) {
131
- continue;
132
- }
133
- const checkedFragmentSpreads = /* @__PURE__ */ new Set();
134
- const visitor = (0, import_graphql.visitWithTypeInfo)(typeInfo, {
135
- SelectionSet(node2, key, _parent) {
136
- const parent = _parent;
137
- if (parent.kind === import_graphql.Kind.FRAGMENT_DEFINITION) {
138
- checkedFragmentSpreads.add(parent.name.value);
139
- } else if (parent.kind !== import_graphql.Kind.INLINE_FRAGMENT) {
140
- checkSelections(
141
- node2,
142
- typeInfo.getType(),
143
- selection.loc.start,
144
- parent,
145
- checkedFragmentSpreads
146
- );
147
- }
148
- }
149
- });
150
- (0, import_graphql.visit)(foundSpread.document, visitor);
151
- }
152
- }
153
- function checkSelections(node, type, loc, parent, checkedFragmentSpreads = /* @__PURE__ */ new Set()) {
154
- const rawType = (0, import_estree_converter.getBaseType)(type);
155
- if (rawType instanceof import_graphql.GraphQLObjectType || rawType instanceof import_graphql.GraphQLInterfaceType) {
156
- checkFields(rawType);
157
- } else if (rawType instanceof import_graphql.GraphQLUnionType) {
158
- for (const selection of node.selections) {
159
- if (selection.kind === import_graphql.Kind.INLINE_FRAGMENT) {
160
- const types = rawType.getTypes();
161
- const t = types.find((t2) => t2.name === selection.typeCondition.name.value);
162
- if (t) {
163
- checkFields(t);
164
- }
165
- }
166
- }
167
- }
168
- function checkFields(rawType2) {
169
- const fields = rawType2.getFields();
170
- const hasIdFieldInType = idNames.some((name) => fields[name]);
171
- if (!hasIdFieldInType) {
172
- return;
173
- }
174
- function hasIdField({ selections }) {
175
- return selections.some((selection) => {
176
- if (selection.kind === import_graphql.Kind.FIELD) {
177
- if (selection.alias && idNames.includes(selection.alias.value)) {
178
- return true;
179
- }
180
- return idNames.includes(selection.name.value);
181
- }
182
- if (selection.kind === import_graphql.Kind.INLINE_FRAGMENT) {
183
- return hasIdField(selection.selectionSet);
184
- }
185
- if (selection.kind === import_graphql.Kind.FRAGMENT_SPREAD) {
186
- const [foundSpread] = siblings.getFragment(selection.name.value);
187
- if (foundSpread) {
188
- const fragmentSpread = foundSpread.document;
189
- checkedFragmentSpreads.add(fragmentSpread.name.value);
190
- return hasIdField(fragmentSpread.selectionSet);
191
- }
192
- }
193
- return false;
194
- });
195
- }
196
- const hasId = hasIdField(node);
197
- checkFragments(node);
198
- if (hasId) {
199
- return;
200
- }
201
- const pluralSuffix = idNames.length > 1 ? "s" : "";
202
- const fieldName2 = (0, import_utils2.englishJoinWords)(
203
- idNames.map((name) => `\`${(parent.alias || parent.name).value}.${name}\``)
204
- );
205
- const addition = checkedFragmentSpreads.size === 0 ? "" : ` or add to used fragment${checkedFragmentSpreads.size > 1 ? "s" : ""} ${(0, import_utils2.englishJoinWords)([...checkedFragmentSpreads].map((name) => `\`${name}\``))}`;
206
- const problem = {
207
- loc,
208
- messageId: RULE_ID,
209
- data: {
210
- pluralSuffix,
211
- fieldName: fieldName2,
212
- addition
213
- }
214
- };
215
- if ("type" in node) {
216
- problem.suggest = idNames.map((idName) => ({
217
- desc: `Add \`${idName}\` selection`,
218
- fix: (fixer) => {
219
- let insertNode = node.selections[0];
220
- insertNode = insertNode.kind === import_graphql.Kind.INLINE_FRAGMENT ? insertNode.selectionSet.selections[0] : insertNode;
221
- return fixer.insertTextBefore(insertNode, `${idName} `);
222
- }
223
- }));
224
- }
225
- context.report(problem);
226
- }
227
- }
228
- return {
229
- [selector](node) {
230
- const typeInfo2 = node.typeInfo();
231
- if (typeInfo2.gqlType) {
232
- checkSelections(node, typeInfo2.gqlType, node.loc.start, node.parent);
233
- }
234
- }
235
- };
236
- }
237
- };
238
- // Annotate the CommonJS export names for ESM import in node:
239
- 0 && (module.exports = {
240
- rule
241
- });
@@ -1,107 +0,0 @@
1
- import { GraphQLParseOptions } from '@graphql-tools/utils';
2
- import { Linter, Rule, AST } from 'eslint';
3
- import * as ESTree from 'estree';
4
- import { FragmentDefinitionNode, OperationDefinitionNode, SelectionSetNode, OperationTypeNode, GraphQLSchema, ASTKindToNode } from 'graphql';
5
- import { GraphQLProjectConfig, IExtensions, IGraphQLProject } from 'graphql-config';
6
- import { JSONSchema } from 'json-schema-to-ts';
7
- import { GraphQLESTreeNode } from './estree-converter/types.js';
8
-
9
- type FragmentSource = {
10
- filePath: string;
11
- document: FragmentDefinitionNode;
12
- };
13
- type OperationSource = {
14
- filePath: string;
15
- document: OperationDefinitionNode;
16
- };
17
- type SiblingOperations = {
18
- available: boolean;
19
- getFragment(fragmentName: string): FragmentSource[];
20
- getFragments(): FragmentSource[];
21
- getFragmentByType(typeName: string): FragmentSource[];
22
- getFragmentsInUse(baseOperation: FragmentDefinitionNode | OperationDefinitionNode | SelectionSetNode, recursive?: boolean): FragmentDefinitionNode[];
23
- getOperation(operationName: string): OperationSource[];
24
- getOperations(): OperationSource[];
25
- getOperationByType(operationType: OperationTypeNode): OperationSource[];
26
- };
27
- declare function getSiblings(project?: GraphQLProjectConfig, documents?: ParserOptions['documents']): SiblingOperations;
28
-
29
- type Schema = GraphQLSchema | null;
30
- type Pointer = string | string[];
31
- interface ParserOptions {
32
- schema?: Pointer | Record<string, {
33
- headers: Record<string, string>;
34
- }>;
35
- documents?: Pointer;
36
- extensions?: IExtensions;
37
- include?: Pointer;
38
- exclude?: Pointer;
39
- projects?: Record<string, IGraphQLProject>;
40
- schemaOptions?: Omit<GraphQLParseOptions, 'assumeValidSDL'> & {
41
- headers: Record<string, string>;
42
- };
43
- graphQLParserOptions?: Omit<GraphQLParseOptions, 'noLocation'>;
44
- skipGraphQLConfig?: boolean;
45
- filePath: string;
46
- /** @deprecated Use `documents` instead */
47
- operations?: Pointer;
48
- }
49
- type ParserServices = {
50
- schema: Schema;
51
- siblingOperations: SiblingOperations;
52
- };
53
- type GraphQLESLintParseResult = Linter.ESLintParseResult & {
54
- services: ParserServices;
55
- };
56
- type Location = AST.SourceLocation | ESTree.Position;
57
- type ReportDescriptorLocation = {
58
- loc: Location;
59
- } | {
60
- node: {
61
- loc: Location;
62
- };
63
- };
64
- type ReportDescriptor = ReportDescriptorLocation & Rule.ReportDescriptorMessage & Rule.ReportDescriptorOptions;
65
- type GraphQLESLintRuleContext<Options = any[]> = Omit<Rule.RuleContext, 'options' | 'parserServices' | 'report'> & {
66
- options: Options;
67
- parserServices: ParserServices;
68
- report(descriptor: ReportDescriptor): void;
69
- };
70
- type CategoryType = 'Operations' | 'Schema';
71
- type RuleMetaDataDocs = Required<Rule.RuleMetaData>['docs'];
72
- type RuleDocsInfo<T> = Omit<RuleMetaDataDocs, 'category' | 'suggestion'> & {
73
- category: CategoryType | CategoryType[];
74
- requiresSchema?: true;
75
- requiresSiblings?: true;
76
- examples?: {
77
- title: string;
78
- code: string;
79
- usage?: T;
80
- }[];
81
- configOptions?: T | {
82
- schema?: T;
83
- operations?: T;
84
- };
85
- graphQLJSRuleName?: string;
86
- isDisabledForAllConfig?: true;
87
- };
88
- type GraphQLESLintRuleListener<WithTypeInfo extends boolean = false> = Record<string, any> & {
89
- [K in keyof ASTKindToNode]?: (node: GraphQLESTreeNode<ASTKindToNode[K], WithTypeInfo>) => void;
90
- };
91
- type GraphQLESLintRule<Options = [], WithTypeInfo extends boolean = false> = {
92
- meta: Omit<Rule.RuleMetaData, 'docs' | 'schema'> & {
93
- docs?: RuleDocsInfo<Options>;
94
- schema: Readonly<JSONSchema> | [];
95
- };
96
- create(context: GraphQLESLintRuleContext<Options>): GraphQLESLintRuleListener<WithTypeInfo>;
97
- };
98
- type ValueOf<T> = T[keyof T];
99
- type Id<T> = {
100
- [P in keyof T]: T[P];
101
- } & {};
102
- type OmitDistributive<T, K extends PropertyKey> = T extends object ? Id<OmitRecursively<T, K>> : T;
103
- type OmitRecursively<T extends object, K extends PropertyKey> = Omit<{
104
- [P in keyof T]: OmitDistributive<T[P], K>;
105
- }, K>;
106
-
107
- export { CategoryType as C, FragmentSource as F, GraphQLESLintParseResult as G, OmitRecursively as O, ParserOptions as P, ReportDescriptor as R, Schema as S, ValueOf as V, Pointer as a, ParserServices as b, GraphQLESLintRuleContext as c, RuleDocsInfo as d, GraphQLESLintRuleListener as e, GraphQLESLintRule as f, SiblingOperations as g, OperationSource as h, getSiblings as i };
@@ -1,107 +0,0 @@
1
- import { GraphQLParseOptions } from '@graphql-tools/utils';
2
- import { Linter, Rule, AST } from 'eslint';
3
- import * as ESTree from 'estree';
4
- import { FragmentDefinitionNode, OperationDefinitionNode, SelectionSetNode, OperationTypeNode, GraphQLSchema, ASTKindToNode } from 'graphql';
5
- import { GraphQLProjectConfig, IExtensions, IGraphQLProject } from 'graphql-config';
6
- import { JSONSchema } from 'json-schema-to-ts';
7
- import { GraphQLESTreeNode } from './estree-converter/types.mjs';
8
-
9
- type FragmentSource = {
10
- filePath: string;
11
- document: FragmentDefinitionNode;
12
- };
13
- type OperationSource = {
14
- filePath: string;
15
- document: OperationDefinitionNode;
16
- };
17
- type SiblingOperations = {
18
- available: boolean;
19
- getFragment(fragmentName: string): FragmentSource[];
20
- getFragments(): FragmentSource[];
21
- getFragmentByType(typeName: string): FragmentSource[];
22
- getFragmentsInUse(baseOperation: FragmentDefinitionNode | OperationDefinitionNode | SelectionSetNode, recursive?: boolean): FragmentDefinitionNode[];
23
- getOperation(operationName: string): OperationSource[];
24
- getOperations(): OperationSource[];
25
- getOperationByType(operationType: OperationTypeNode): OperationSource[];
26
- };
27
- declare function getSiblings(project?: GraphQLProjectConfig, documents?: ParserOptions['documents']): SiblingOperations;
28
-
29
- type Schema = GraphQLSchema | null;
30
- type Pointer = string | string[];
31
- interface ParserOptions {
32
- schema?: Pointer | Record<string, {
33
- headers: Record<string, string>;
34
- }>;
35
- documents?: Pointer;
36
- extensions?: IExtensions;
37
- include?: Pointer;
38
- exclude?: Pointer;
39
- projects?: Record<string, IGraphQLProject>;
40
- schemaOptions?: Omit<GraphQLParseOptions, 'assumeValidSDL'> & {
41
- headers: Record<string, string>;
42
- };
43
- graphQLParserOptions?: Omit<GraphQLParseOptions, 'noLocation'>;
44
- skipGraphQLConfig?: boolean;
45
- filePath: string;
46
- /** @deprecated Use `documents` instead */
47
- operations?: Pointer;
48
- }
49
- type ParserServices = {
50
- schema: Schema;
51
- siblingOperations: SiblingOperations;
52
- };
53
- type GraphQLESLintParseResult = Linter.ESLintParseResult & {
54
- services: ParserServices;
55
- };
56
- type Location = AST.SourceLocation | ESTree.Position;
57
- type ReportDescriptorLocation = {
58
- loc: Location;
59
- } | {
60
- node: {
61
- loc: Location;
62
- };
63
- };
64
- type ReportDescriptor = ReportDescriptorLocation & Rule.ReportDescriptorMessage & Rule.ReportDescriptorOptions;
65
- type GraphQLESLintRuleContext<Options = any[]> = Omit<Rule.RuleContext, 'options' | 'parserServices' | 'report'> & {
66
- options: Options;
67
- parserServices: ParserServices;
68
- report(descriptor: ReportDescriptor): void;
69
- };
70
- type CategoryType = 'Operations' | 'Schema';
71
- type RuleMetaDataDocs = Required<Rule.RuleMetaData>['docs'];
72
- type RuleDocsInfo<T> = Omit<RuleMetaDataDocs, 'category' | 'suggestion'> & {
73
- category: CategoryType | CategoryType[];
74
- requiresSchema?: true;
75
- requiresSiblings?: true;
76
- examples?: {
77
- title: string;
78
- code: string;
79
- usage?: T;
80
- }[];
81
- configOptions?: T | {
82
- schema?: T;
83
- operations?: T;
84
- };
85
- graphQLJSRuleName?: string;
86
- isDisabledForAllConfig?: true;
87
- };
88
- type GraphQLESLintRuleListener<WithTypeInfo extends boolean = false> = Record<string, any> & {
89
- [K in keyof ASTKindToNode]?: (node: GraphQLESTreeNode<ASTKindToNode[K], WithTypeInfo>) => void;
90
- };
91
- type GraphQLESLintRule<Options = [], WithTypeInfo extends boolean = false> = {
92
- meta: Omit<Rule.RuleMetaData, 'docs' | 'schema'> & {
93
- docs?: RuleDocsInfo<Options>;
94
- schema: Readonly<JSONSchema> | [];
95
- };
96
- create(context: GraphQLESLintRuleContext<Options>): GraphQLESLintRuleListener<WithTypeInfo>;
97
- };
98
- type ValueOf<T> = T[keyof T];
99
- type Id<T> = {
100
- [P in keyof T]: T[P];
101
- } & {};
102
- type OmitDistributive<T, K extends PropertyKey> = T extends object ? Id<OmitRecursively<T, K>> : T;
103
- type OmitRecursively<T extends object, K extends PropertyKey> = Omit<{
104
- [P in keyof T]: OmitDistributive<T[P], K>;
105
- }, K>;
106
-
107
- export { CategoryType as C, FragmentSource as F, GraphQLESLintParseResult as G, OmitRecursively as O, ParserOptions as P, ReportDescriptor as R, Schema as S, ValueOf as V, Pointer as a, ParserServices as b, GraphQLESLintRuleContext as c, RuleDocsInfo as d, GraphQLESLintRuleListener as e, GraphQLESLintRule as f, SiblingOperations as g, OperationSource as h, getSiblings as i };
File without changes
File without changes
File without changes