@graphql-eslint/eslint-plugin 4.0.0-alpha-20220821140530-e968cfc → 4.0.0-alpha-20230801163310-8bc4340
Sign up to get free protection for your applications and to get access to all the features.
- package/LICENSE +21 -0
- package/README.md +13 -253
- package/cjs/cache.d.ts +12 -0
- package/cjs/cache.js +62 -0
- package/cjs/configs/index.d.ts +148 -0
- package/cjs/configs/index.js +49 -0
- package/cjs/configs/operations-all.d.ts +22 -0
- package/cjs/configs/operations-all.js +27 -0
- package/cjs/configs/operations-recommended.d.ts +52 -0
- package/{configs/operations-recommended.json → cjs/configs/operations-recommended.js} +16 -14
- package/cjs/configs/relay.d.ts +12 -0
- package/{configs/relay.json → cjs/configs/relay.js} +6 -4
- package/cjs/configs/schema-all.d.ts +19 -0
- package/cjs/configs/schema-all.js +21 -0
- package/cjs/configs/schema-recommended.d.ts +49 -0
- package/{configs/schema-recommended.json → cjs/configs/schema-recommended.js} +19 -20
- package/cjs/documents.d.ts +6 -0
- package/cjs/documents.js +81 -0
- package/cjs/estree-converter/converter.d.ts +8 -0
- package/cjs/estree-converter/converter.js +83 -0
- package/cjs/estree-converter/index.d.ts +8 -0
- package/cjs/estree-converter/index.js +26 -0
- package/cjs/estree-converter/types.d.ts +42 -0
- package/cjs/estree-converter/types.js +16 -0
- package/cjs/estree-converter/utils.d.ts +18 -0
- package/cjs/estree-converter/utils.js +135 -0
- package/cjs/flat-configs.d.ts +260 -0
- package/cjs/flat-configs.js +60 -0
- package/cjs/graphql-config.d.ts +13 -0
- package/cjs/graphql-config.js +86 -0
- package/cjs/index.d.ts +22 -0
- package/cjs/index.js +49 -0
- package/cjs/parser.d.ts +12 -0
- package/cjs/parser.js +103 -0
- package/cjs/processor.d.ts +9 -0
- package/cjs/processor.js +127 -0
- package/cjs/rules/alphabetize.d.ts +84 -0
- package/cjs/rules/alphabetize.js +395 -0
- package/cjs/rules/description-style.d.ts +28 -0
- package/cjs/rules/description-style.js +109 -0
- package/cjs/rules/graphql-js-validation.d.ts +12 -0
- package/cjs/rules/graphql-js-validation.js +669 -0
- package/cjs/rules/index.d.ts +125 -0
- package/cjs/rules/index.js +99 -0
- package/cjs/rules/input-name.d.ts +43 -0
- package/cjs/rules/input-name.js +170 -0
- package/cjs/rules/lone-executable-definition.d.ts +34 -0
- package/cjs/rules/lone-executable-definition.js +119 -0
- package/cjs/rules/match-document-filename.d.ts +80 -0
- package/cjs/rules/match-document-filename.js +282 -0
- package/cjs/rules/naming-convention.d.ts +107 -0
- package/cjs/rules/naming-convention.js +434 -0
- package/cjs/rules/no-anonymous-operations.d.ts +12 -0
- package/cjs/rules/no-anonymous-operations.js +98 -0
- package/cjs/rules/no-case-insensitive-enum-values-duplicates.d.ts +12 -0
- package/cjs/rules/no-case-insensitive-enum-values-duplicates.js +96 -0
- package/cjs/rules/no-deprecated.d.ts +12 -0
- package/cjs/rules/no-deprecated.js +157 -0
- package/cjs/rules/no-duplicate-fields.d.ts +12 -0
- package/cjs/rules/no-duplicate-fields.js +146 -0
- package/cjs/rules/no-hashtag-description.d.ts +13 -0
- package/cjs/rules/no-hashtag-description.js +140 -0
- package/cjs/rules/no-one-place-fragments.d.ts +12 -0
- package/cjs/rules/no-one-place-fragments.js +113 -0
- package/cjs/rules/no-root-type.d.ts +33 -0
- package/cjs/rules/no-root-type.js +113 -0
- package/cjs/rules/no-scalar-result-type-on-mutation.d.ts +12 -0
- package/cjs/rules/no-scalar-result-type-on-mutation.js +100 -0
- package/cjs/rules/no-typename-prefix.d.ts +12 -0
- package/cjs/rules/no-typename-prefix.js +98 -0
- package/cjs/rules/no-unreachable-types.d.ts +12 -0
- package/cjs/rules/no-unreachable-types.js +199 -0
- package/cjs/rules/no-unused-fields.d.ts +12 -0
- package/cjs/rules/no-unused-fields.js +157 -0
- package/cjs/rules/relay-arguments.d.ts +29 -0
- package/cjs/rules/relay-arguments.js +149 -0
- package/cjs/rules/relay-connection-types.d.ts +13 -0
- package/cjs/rules/relay-connection-types.js +142 -0
- package/cjs/rules/relay-edge-types.d.ts +39 -0
- package/cjs/rules/relay-edge-types.js +212 -0
- package/cjs/rules/relay-page-info.d.ts +12 -0
- package/cjs/rules/relay-page-info.js +121 -0
- package/cjs/rules/require-deprecation-date.d.ts +26 -0
- package/cjs/rules/require-deprecation-date.js +164 -0
- package/cjs/rules/require-deprecation-reason.d.ts +12 -0
- package/cjs/rules/require-deprecation-reason.js +93 -0
- package/cjs/rules/require-description.d.ts +23 -0
- package/cjs/rules/require-description.js +205 -0
- package/cjs/rules/require-field-of-type-query-in-mutation-result.d.ts +12 -0
- package/cjs/rules/require-field-of-type-query-in-mutation-result.js +102 -0
- package/cjs/rules/require-id-when-available.d.ts +44 -0
- package/cjs/rules/require-id-when-available.js +241 -0
- package/cjs/rules/require-import-fragment.d.ts +12 -0
- package/cjs/rules/require-import-fragment.js +166 -0
- package/cjs/rules/require-nullable-fields-with-oneof.d.ts +12 -0
- package/cjs/rules/require-nullable-fields-with-oneof.js +92 -0
- package/cjs/rules/require-nullable-result-in-root.d.ts +12 -0
- package/cjs/rules/require-nullable-result-in-root.js +109 -0
- package/cjs/rules/require-type-pattern-with-oneof.d.ts +12 -0
- package/cjs/rules/require-type-pattern-with-oneof.js +91 -0
- package/cjs/rules/selection-set-depth.d.ts +36 -0
- package/cjs/rules/selection-set-depth.js +175 -0
- package/cjs/rules/strict-id-in-types.d.ts +65 -0
- package/cjs/rules/strict-id-in-types.js +186 -0
- package/cjs/rules/unique-fragment-name.d.ts +13 -0
- package/cjs/rules/unique-fragment-name.js +118 -0
- package/cjs/rules/unique-operation-name.d.ts +12 -0
- package/cjs/rules/unique-operation-name.js +95 -0
- package/cjs/schema.d.ts +12 -0
- package/cjs/schema.js +65 -0
- package/cjs/siblings.d.ts +8 -0
- package/cjs/siblings.js +136 -0
- package/cjs/types-8d5f4ae0.d.ts +107 -0
- package/cjs/types.d.ts +8 -0
- package/cjs/types.js +16 -0
- package/cjs/utils.d.ts +44 -0
- package/cjs/utils.js +205 -0
- package/esm/cache.d.mts +12 -0
- package/esm/cache.js +29 -0
- package/esm/chunk-BMTV3EA2.js +8 -0
- package/esm/configs/index.d.mts +148 -0
- package/esm/configs/index.js +16 -0
- package/esm/configs/operations-all.d.mts +22 -0
- package/esm/configs/operations-all.js +34 -0
- package/esm/configs/operations-recommended.d.mts +52 -0
- package/esm/configs/operations-recommended.js +59 -0
- package/esm/configs/relay.d.mts +12 -0
- package/esm/configs/relay.js +18 -0
- package/esm/configs/schema-all.d.mts +19 -0
- package/esm/configs/schema-all.js +28 -0
- package/esm/configs/schema-recommended.d.mts +49 -0
- package/esm/configs/schema-recommended.js +55 -0
- package/esm/documents.d.mts +6 -0
- package/esm/documents.js +48 -0
- package/esm/estree-converter/converter.d.mts +8 -0
- package/esm/estree-converter/converter.js +65 -0
- package/esm/estree-converter/index.d.mts +8 -0
- package/esm/estree-converter/index.js +3 -0
- package/esm/estree-converter/types.d.mts +42 -0
- package/esm/estree-converter/types.js +0 -0
- package/esm/estree-converter/utils.d.mts +18 -0
- package/esm/estree-converter/utils.js +114 -0
- package/esm/flat-configs.d.mts +260 -0
- package/esm/flat-configs.js +37 -0
- package/esm/graphql-config.d.mts +13 -0
- package/esm/graphql-config.js +55 -0
- package/esm/index.d.mts +22 -0
- package/esm/index.js +18 -0
- package/esm/package.json +1 -0
- package/esm/parser.d.mts +12 -0
- package/esm/parser.js +70 -0
- package/esm/processor.d.mts +9 -0
- package/esm/processor.js +106 -0
- package/esm/rules/alphabetize.d.mts +84 -0
- package/esm/rules/alphabetize.js +364 -0
- package/esm/rules/description-style.d.mts +28 -0
- package/esm/rules/description-style.js +86 -0
- package/esm/rules/graphql-js-validation.d.mts +12 -0
- package/esm/rules/graphql-js-validation.js +658 -0
- package/esm/rules/index.d.mts +125 -0
- package/esm/rules/index.js +76 -0
- package/esm/rules/input-name.d.mts +43 -0
- package/esm/rules/input-name.js +149 -0
- package/esm/rules/lone-executable-definition.d.mts +34 -0
- package/esm/rules/lone-executable-definition.js +96 -0
- package/esm/rules/match-document-filename.d.mts +80 -0
- package/esm/rules/match-document-filename.js +263 -0
- package/esm/rules/naming-convention.d.mts +107 -0
- package/esm/rules/naming-convention.js +417 -0
- package/esm/rules/no-anonymous-operations.d.mts +12 -0
- package/esm/rules/no-anonymous-operations.js +75 -0
- package/esm/rules/no-case-insensitive-enum-values-duplicates.d.mts +12 -0
- package/esm/rules/no-case-insensitive-enum-values-duplicates.js +73 -0
- package/esm/rules/no-deprecated.d.mts +12 -0
- package/esm/rules/no-deprecated.js +134 -0
- package/esm/rules/no-duplicate-fields.d.mts +12 -0
- package/esm/rules/no-duplicate-fields.js +123 -0
- package/esm/rules/no-hashtag-description.d.mts +13 -0
- package/esm/rules/no-hashtag-description.js +116 -0
- package/esm/rules/no-one-place-fragments.d.mts +12 -0
- package/esm/rules/no-one-place-fragments.js +90 -0
- package/esm/rules/no-root-type.d.mts +33 -0
- package/esm/rules/no-root-type.js +90 -0
- package/esm/rules/no-scalar-result-type-on-mutation.d.mts +12 -0
- package/esm/rules/no-scalar-result-type-on-mutation.js +77 -0
- package/esm/rules/no-typename-prefix.d.mts +12 -0
- package/esm/rules/no-typename-prefix.js +75 -0
- package/esm/rules/no-unreachable-types.d.mts +12 -0
- package/esm/rules/no-unreachable-types.js +171 -0
- package/esm/rules/no-unused-fields.d.mts +12 -0
- package/esm/rules/no-unused-fields.js +134 -0
- package/esm/rules/relay-arguments.d.mts +29 -0
- package/esm/rules/relay-arguments.js +126 -0
- package/esm/rules/relay-connection-types.d.mts +13 -0
- package/esm/rules/relay-connection-types.js +118 -0
- package/esm/rules/relay-edge-types.d.mts +39 -0
- package/esm/rules/relay-edge-types.js +194 -0
- package/esm/rules/relay-page-info.d.mts +12 -0
- package/esm/rules/relay-page-info.js +98 -0
- package/esm/rules/require-deprecation-date.d.mts +26 -0
- package/esm/rules/require-deprecation-date.js +141 -0
- package/esm/rules/require-deprecation-reason.d.mts +12 -0
- package/esm/rules/require-deprecation-reason.js +70 -0
- package/esm/rules/require-description.d.mts +23 -0
- package/esm/rules/require-description.js +186 -0
- package/esm/rules/require-field-of-type-query-in-mutation-result.d.mts +12 -0
- package/esm/rules/require-field-of-type-query-in-mutation-result.js +79 -0
- package/esm/rules/require-id-when-available.d.mts +44 -0
- package/esm/rules/require-id-when-available.js +231 -0
- package/esm/rules/require-import-fragment.d.mts +12 -0
- package/esm/rules/require-import-fragment.js +133 -0
- package/esm/rules/require-nullable-fields-with-oneof.d.mts +12 -0
- package/esm/rules/require-nullable-fields-with-oneof.js +69 -0
- package/esm/rules/require-nullable-result-in-root.d.mts +12 -0
- package/esm/rules/require-nullable-result-in-root.js +86 -0
- package/esm/rules/require-type-pattern-with-oneof.d.mts +12 -0
- package/esm/rules/require-type-pattern-with-oneof.js +68 -0
- package/esm/rules/selection-set-depth.d.mts +36 -0
- package/esm/rules/selection-set-depth.js +142 -0
- package/esm/rules/strict-id-in-types.d.mts +65 -0
- package/esm/rules/strict-id-in-types.js +169 -0
- package/esm/rules/unique-fragment-name.d.mts +13 -0
- package/esm/rules/unique-fragment-name.js +94 -0
- package/esm/rules/unique-operation-name.d.mts +12 -0
- package/esm/rules/unique-operation-name.js +72 -0
- package/esm/schema.d.mts +12 -0
- package/esm/schema.js +32 -0
- package/esm/siblings.d.mts +8 -0
- package/esm/siblings.js +116 -0
- package/esm/types-ace77d86.d.ts +107 -0
- package/esm/types.d.mts +8 -0
- package/esm/types.js +0 -0
- package/esm/utils.d.mts +44 -0
- package/esm/utils.js +155 -0
- package/package.json +47 -34
- package/configs/base.json +0 -4
- package/configs/operations-all.json +0 -24
- package/configs/schema-all.json +0 -26
- package/docs/README.md +0 -75
- package/docs/custom-rules.md +0 -148
- package/docs/deprecated-rules.md +0 -21
- package/docs/parser-options.md +0 -85
- package/docs/parser.md +0 -49
- package/docs/rules/alphabetize.md +0 -178
- package/docs/rules/description-style.md +0 -54
- package/docs/rules/executable-definitions.md +0 -17
- package/docs/rules/fields-on-correct-type.md +0 -17
- package/docs/rules/fragments-on-composite-type.md +0 -17
- package/docs/rules/input-name.md +0 -76
- package/docs/rules/known-argument-names.md +0 -17
- package/docs/rules/known-directives.md +0 -44
- package/docs/rules/known-fragment-names.md +0 -69
- package/docs/rules/known-type-names.md +0 -17
- package/docs/rules/lone-anonymous-operation.md +0 -17
- package/docs/rules/lone-schema-definition.md +0 -17
- package/docs/rules/match-document-filename.md +0 -156
- package/docs/rules/naming-convention.md +0 -300
- package/docs/rules/no-anonymous-operations.md +0 -39
- package/docs/rules/no-case-insensitive-enum-values-duplicates.md +0 -43
- package/docs/rules/no-deprecated.md +0 -85
- package/docs/rules/no-duplicate-fields.md +0 -65
- package/docs/rules/no-fragment-cycles.md +0 -17
- package/docs/rules/no-hashtag-description.md +0 -59
- package/docs/rules/no-root-type.md +0 -53
- package/docs/rules/no-scalar-result-type-on-mutation.md +0 -37
- package/docs/rules/no-typename-prefix.md +0 -39
- package/docs/rules/no-undefined-variables.md +0 -17
- package/docs/rules/no-unreachable-types.md +0 -49
- package/docs/rules/no-unused-fields.md +0 -62
- package/docs/rules/no-unused-fragments.md +0 -17
- package/docs/rules/no-unused-variables.md +0 -17
- package/docs/rules/one-field-subscriptions.md +0 -17
- package/docs/rules/overlapping-fields-can-be-merged.md +0 -17
- package/docs/rules/possible-fragment-spread.md +0 -17
- package/docs/rules/possible-type-extension.md +0 -15
- package/docs/rules/provided-required-arguments.md +0 -17
- package/docs/rules/relay-arguments.md +0 -57
- package/docs/rules/relay-connection-types.md +0 -42
- package/docs/rules/relay-edge-types.md +0 -56
- package/docs/rules/relay-page-info.md +0 -32
- package/docs/rules/require-deprecation-date.md +0 -56
- package/docs/rules/require-deprecation-reason.md +0 -47
- package/docs/rules/require-description.md +0 -115
- package/docs/rules/require-field-of-type-query-in-mutation-result.md +0 -47
- package/docs/rules/require-id-when-available.md +0 -88
- package/docs/rules/scalar-leafs.md +0 -17
- package/docs/rules/selection-set-depth.md +0 -76
- package/docs/rules/strict-id-in-types.md +0 -130
- package/docs/rules/unique-argument-names.md +0 -17
- package/docs/rules/unique-directive-names-per-location.md +0 -17
- package/docs/rules/unique-directive-names.md +0 -17
- package/docs/rules/unique-enum-value-names.md +0 -15
- package/docs/rules/unique-field-definition-names.md +0 -17
- package/docs/rules/unique-fragment-name.md +0 -51
- package/docs/rules/unique-input-field-names.md +0 -17
- package/docs/rules/unique-operation-name.md +0 -55
- package/docs/rules/unique-operation-types.md +0 -17
- package/docs/rules/unique-type-names.md +0 -17
- package/docs/rules/unique-variable-names.md +0 -17
- package/docs/rules/value-literals-of-correct-type.md +0 -17
- package/docs/rules/variables-are-input-types.md +0 -17
- package/docs/rules/variables-in-allowed-position.md +0 -17
- package/estree-converter/converter.d.ts +0 -3
- package/estree-converter/index.d.ts +0 -3
- package/estree-converter/types.d.ts +0 -40
- package/estree-converter/utils.d.ts +0 -13
- package/graphql-config.d.ts +0 -3
- package/index.d.ts +0 -16
- package/index.js +0 -4653
- package/index.mjs +0 -4641
- package/parser.d.ts +0 -2
- package/processor.d.ts +0 -7
- package/rules/alphabetize.d.ts +0 -16
- package/rules/description-style.d.ts +0 -6
- package/rules/graphql-js-validation.d.ts +0 -2
- package/rules/index.d.ts +0 -41
- package/rules/input-name.d.ts +0 -9
- package/rules/match-document-filename.d.ts +0 -18
- package/rules/naming-convention.d.ts +0 -37
- package/rules/no-anonymous-operations.d.ts +0 -3
- package/rules/no-case-insensitive-enum-values-duplicates.d.ts +0 -3
- package/rules/no-deprecated.d.ts +0 -3
- package/rules/no-duplicate-fields.d.ts +0 -3
- package/rules/no-hashtag-description.d.ts +0 -3
- package/rules/no-root-type.d.ts +0 -7
- package/rules/no-scalar-result-type-on-mutation.d.ts +0 -3
- package/rules/no-typename-prefix.d.ts +0 -3
- package/rules/no-unreachable-types.d.ts +0 -3
- package/rules/no-unused-fields.d.ts +0 -3
- package/rules/relay-arguments.d.ts +0 -6
- package/rules/relay-connection-types.d.ts +0 -5
- package/rules/relay-edge-types.d.ts +0 -8
- package/rules/relay-page-info.d.ts +0 -3
- package/rules/require-deprecation-date.d.ts +0 -5
- package/rules/require-deprecation-reason.d.ts +0 -3
- package/rules/require-description.d.ts +0 -11
- package/rules/require-field-of-type-query-in-mutation-result.d.ts +0 -3
- package/rules/require-id-when-available.d.ts +0 -6
- package/rules/selection-set-depth.d.ts +0 -7
- package/rules/strict-id-in-types.d.ts +0 -11
- package/rules/unique-fragment-name.d.ts +0 -6
- package/rules/unique-operation-name.d.ts +0 -3
- package/schema.d.ts +0 -3
- package/sibling-operations.d.ts +0 -21
- package/testkit.d.ts +0 -27
- package/types.d.ts +0 -79
- package/utils.d.ts +0 -39
@@ -0,0 +1,175 @@
|
|
1
|
+
"use strict";
|
2
|
+
var __create = Object.create;
|
3
|
+
var __defProp = Object.defineProperty;
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
8
|
+
var __export = (target, all) => {
|
9
|
+
for (var name in all)
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
11
|
+
};
|
12
|
+
var __copyProps = (to, from, except, desc) => {
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
14
|
+
for (let key of __getOwnPropNames(from))
|
15
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
16
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
17
|
+
}
|
18
|
+
return to;
|
19
|
+
};
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
25
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
26
|
+
mod
|
27
|
+
));
|
28
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
29
|
+
var selection_set_depth_exports = {};
|
30
|
+
__export(selection_set_depth_exports, {
|
31
|
+
rule: () => rule
|
32
|
+
});
|
33
|
+
module.exports = __toCommonJS(selection_set_depth_exports);
|
34
|
+
var import_graphql = require("graphql");
|
35
|
+
var import_graphql_depth_limit = __toESM(require("graphql-depth-limit"));
|
36
|
+
var import_utils = require("../utils.js");
|
37
|
+
const RULE_ID = "selection-set-depth";
|
38
|
+
const schema = {
|
39
|
+
type: "array",
|
40
|
+
minItems: 1,
|
41
|
+
maxItems: 1,
|
42
|
+
items: {
|
43
|
+
type: "object",
|
44
|
+
additionalProperties: false,
|
45
|
+
required: ["maxDepth"],
|
46
|
+
properties: {
|
47
|
+
maxDepth: {
|
48
|
+
type: "number"
|
49
|
+
},
|
50
|
+
ignore: import_utils.ARRAY_DEFAULT_OPTIONS
|
51
|
+
}
|
52
|
+
}
|
53
|
+
};
|
54
|
+
const rule = {
|
55
|
+
meta: {
|
56
|
+
type: "suggestion",
|
57
|
+
hasSuggestions: true,
|
58
|
+
docs: {
|
59
|
+
category: "Operations",
|
60
|
+
description: "Limit the complexity of the GraphQL operations solely by their depth. Based on [graphql-depth-limit](https://npmjs.com/package/graphql-depth-limit).",
|
61
|
+
url: `https://the-guild.dev/graphql/eslint/rules/${RULE_ID}`,
|
62
|
+
requiresSiblings: true,
|
63
|
+
examples: [
|
64
|
+
{
|
65
|
+
title: "Incorrect",
|
66
|
+
usage: [{ maxDepth: 1 }],
|
67
|
+
code: `
|
68
|
+
query deep2 {
|
69
|
+
viewer { # Level 0
|
70
|
+
albums { # Level 1
|
71
|
+
title # Level 2
|
72
|
+
}
|
73
|
+
}
|
74
|
+
}
|
75
|
+
`
|
76
|
+
},
|
77
|
+
{
|
78
|
+
title: "Correct",
|
79
|
+
usage: [{ maxDepth: 4 }],
|
80
|
+
code: `
|
81
|
+
query deep2 {
|
82
|
+
viewer { # Level 0
|
83
|
+
albums { # Level 1
|
84
|
+
title # Level 2
|
85
|
+
}
|
86
|
+
}
|
87
|
+
}
|
88
|
+
`
|
89
|
+
},
|
90
|
+
{
|
91
|
+
title: "Correct (ignored field)",
|
92
|
+
usage: [{ maxDepth: 1, ignore: ["albums"] }],
|
93
|
+
code: `
|
94
|
+
query deep2 {
|
95
|
+
viewer { # Level 0
|
96
|
+
albums { # Level 1
|
97
|
+
title # Level 2
|
98
|
+
}
|
99
|
+
}
|
100
|
+
}
|
101
|
+
`
|
102
|
+
}
|
103
|
+
],
|
104
|
+
recommended: true,
|
105
|
+
configOptions: [{ maxDepth: 7 }]
|
106
|
+
},
|
107
|
+
schema
|
108
|
+
},
|
109
|
+
create(context) {
|
110
|
+
let siblings = null;
|
111
|
+
try {
|
112
|
+
siblings = (0, import_utils.requireSiblingsOperations)(RULE_ID, context);
|
113
|
+
} catch {
|
114
|
+
import_utils.logger.warn(
|
115
|
+
`Rule "${RULE_ID}" works best with siblings operations loaded. For more info: https://bit.ly/graphql-eslint-operations`
|
116
|
+
);
|
117
|
+
}
|
118
|
+
const { maxDepth, ignore = [] } = context.options[0];
|
119
|
+
const checkFn = (0, import_graphql_depth_limit.default)(maxDepth, { ignore });
|
120
|
+
return {
|
121
|
+
"OperationDefinition, FragmentDefinition"(node) {
|
122
|
+
try {
|
123
|
+
const rawNode = node.rawNode();
|
124
|
+
const fragmentsInUse = siblings ? siblings.getFragmentsInUse(rawNode) : [];
|
125
|
+
const document = {
|
126
|
+
kind: import_graphql.Kind.DOCUMENT,
|
127
|
+
definitions: [rawNode, ...fragmentsInUse]
|
128
|
+
};
|
129
|
+
checkFn({
|
130
|
+
getDocument: () => document,
|
131
|
+
reportError(error) {
|
132
|
+
const { line, column } = error.locations[0];
|
133
|
+
const ancestors = context.getAncestors();
|
134
|
+
const token = ancestors[0].tokens.find(
|
135
|
+
(token2) => token2.loc.start.line === line && token2.loc.start.column === column - 1
|
136
|
+
);
|
137
|
+
context.report({
|
138
|
+
loc: {
|
139
|
+
line,
|
140
|
+
column: column - 1
|
141
|
+
},
|
142
|
+
message: error.message,
|
143
|
+
// Don't provide suggestions for fragment that can be in a separate file
|
144
|
+
...token && {
|
145
|
+
suggest: [
|
146
|
+
{
|
147
|
+
desc: "Remove selections",
|
148
|
+
fix(fixer) {
|
149
|
+
const sourceCode = context.getSourceCode();
|
150
|
+
const foundNode = sourceCode.getNodeByRangeIndex(token.range[0]);
|
151
|
+
const parentNode = foundNode.parent.parent;
|
152
|
+
return fixer.remove(
|
153
|
+
foundNode.kind === "Name" ? parentNode.parent : parentNode
|
154
|
+
);
|
155
|
+
}
|
156
|
+
}
|
157
|
+
]
|
158
|
+
}
|
159
|
+
});
|
160
|
+
}
|
161
|
+
});
|
162
|
+
} catch (e) {
|
163
|
+
import_utils.logger.warn(
|
164
|
+
`Rule "${RULE_ID}" check failed due to a missing siblings operations. For more info: https://bit.ly/graphql-eslint-operations`,
|
165
|
+
e
|
166
|
+
);
|
167
|
+
}
|
168
|
+
}
|
169
|
+
};
|
170
|
+
}
|
171
|
+
};
|
172
|
+
// Annotate the CommonJS export names for ESM import in node:
|
173
|
+
0 && (module.exports = {
|
174
|
+
rule
|
175
|
+
});
|
@@ -0,0 +1,65 @@
|
|
1
|
+
import { FromSchema } from 'json-schema-to-ts';
|
2
|
+
import { f as GraphQLESLintRule } from '../types-8d5f4ae0.js';
|
3
|
+
import '@graphql-tools/utils';
|
4
|
+
import 'eslint';
|
5
|
+
import 'estree';
|
6
|
+
import 'graphql';
|
7
|
+
import 'graphql-config';
|
8
|
+
import '../estree-converter/types.js';
|
9
|
+
|
10
|
+
declare const schema: {
|
11
|
+
readonly type: "array";
|
12
|
+
readonly maxItems: 1;
|
13
|
+
readonly items: {
|
14
|
+
readonly type: "object";
|
15
|
+
readonly additionalProperties: false;
|
16
|
+
readonly properties: {
|
17
|
+
readonly acceptedIdNames: {
|
18
|
+
readonly default: readonly ["id"];
|
19
|
+
readonly type: "array";
|
20
|
+
readonly uniqueItems: true;
|
21
|
+
readonly minItems: 1;
|
22
|
+
readonly items: {
|
23
|
+
readonly type: "string";
|
24
|
+
};
|
25
|
+
};
|
26
|
+
readonly acceptedIdTypes: {
|
27
|
+
readonly default: readonly ["ID"];
|
28
|
+
readonly type: "array";
|
29
|
+
readonly uniqueItems: true;
|
30
|
+
readonly minItems: 1;
|
31
|
+
readonly items: {
|
32
|
+
readonly type: "string";
|
33
|
+
};
|
34
|
+
};
|
35
|
+
readonly exceptions: {
|
36
|
+
readonly type: "object";
|
37
|
+
readonly additionalProperties: false;
|
38
|
+
readonly properties: {
|
39
|
+
readonly types: {
|
40
|
+
readonly description: "This is used to exclude types with names that match one of the specified values.";
|
41
|
+
readonly type: "array";
|
42
|
+
readonly uniqueItems: true;
|
43
|
+
readonly minItems: 1;
|
44
|
+
readonly items: {
|
45
|
+
readonly type: "string";
|
46
|
+
};
|
47
|
+
};
|
48
|
+
readonly suffixes: {
|
49
|
+
readonly description: "This is used to exclude types with names with suffixes that match one of the specified values.";
|
50
|
+
readonly type: "array";
|
51
|
+
readonly uniqueItems: true;
|
52
|
+
readonly minItems: 1;
|
53
|
+
readonly items: {
|
54
|
+
readonly type: "string";
|
55
|
+
};
|
56
|
+
};
|
57
|
+
};
|
58
|
+
};
|
59
|
+
};
|
60
|
+
};
|
61
|
+
};
|
62
|
+
type RuleOptions = FromSchema<typeof schema>;
|
63
|
+
declare const rule: GraphQLESLintRule<RuleOptions>;
|
64
|
+
|
65
|
+
export { RuleOptions, rule };
|
@@ -0,0 +1,186 @@
|
|
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 strict_id_in_types_exports = {};
|
20
|
+
__export(strict_id_in_types_exports, {
|
21
|
+
rule: () => rule
|
22
|
+
});
|
23
|
+
module.exports = __toCommonJS(strict_id_in_types_exports);
|
24
|
+
var import_graphql = require("graphql");
|
25
|
+
var import_utils = require("../utils.js");
|
26
|
+
const RULE_ID = "strict-id-in-types";
|
27
|
+
const schema = {
|
28
|
+
type: "array",
|
29
|
+
maxItems: 1,
|
30
|
+
items: {
|
31
|
+
type: "object",
|
32
|
+
additionalProperties: false,
|
33
|
+
properties: {
|
34
|
+
acceptedIdNames: {
|
35
|
+
...import_utils.ARRAY_DEFAULT_OPTIONS,
|
36
|
+
default: ["id"]
|
37
|
+
},
|
38
|
+
acceptedIdTypes: {
|
39
|
+
...import_utils.ARRAY_DEFAULT_OPTIONS,
|
40
|
+
default: ["ID"]
|
41
|
+
},
|
42
|
+
exceptions: {
|
43
|
+
type: "object",
|
44
|
+
additionalProperties: false,
|
45
|
+
properties: {
|
46
|
+
types: {
|
47
|
+
...import_utils.ARRAY_DEFAULT_OPTIONS,
|
48
|
+
description: "This is used to exclude types with names that match one of the specified values."
|
49
|
+
},
|
50
|
+
suffixes: {
|
51
|
+
...import_utils.ARRAY_DEFAULT_OPTIONS,
|
52
|
+
description: "This is used to exclude types with names with suffixes that match one of the specified values."
|
53
|
+
}
|
54
|
+
}
|
55
|
+
}
|
56
|
+
}
|
57
|
+
}
|
58
|
+
};
|
59
|
+
const rule = {
|
60
|
+
meta: {
|
61
|
+
type: "suggestion",
|
62
|
+
docs: {
|
63
|
+
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.",
|
64
|
+
category: "Schema",
|
65
|
+
recommended: true,
|
66
|
+
url: `https://the-guild.dev/graphql/eslint/rules/${RULE_ID}`,
|
67
|
+
requiresSchema: true,
|
68
|
+
examples: [
|
69
|
+
{
|
70
|
+
title: "Incorrect",
|
71
|
+
usage: [
|
72
|
+
{
|
73
|
+
acceptedIdNames: ["id", "_id"],
|
74
|
+
acceptedIdTypes: ["ID"],
|
75
|
+
exceptions: { suffixes: ["Payload"] }
|
76
|
+
}
|
77
|
+
],
|
78
|
+
code: (
|
79
|
+
/* GraphQL */
|
80
|
+
`
|
81
|
+
# Incorrect field name
|
82
|
+
type InvalidFieldName {
|
83
|
+
key: ID!
|
84
|
+
}
|
85
|
+
|
86
|
+
# Incorrect field type
|
87
|
+
type InvalidFieldType {
|
88
|
+
id: String!
|
89
|
+
}
|
90
|
+
|
91
|
+
# Incorrect exception suffix
|
92
|
+
type InvalidSuffixResult {
|
93
|
+
data: String!
|
94
|
+
}
|
95
|
+
|
96
|
+
# Too many unique identifiers. Must only contain one.
|
97
|
+
type InvalidFieldName {
|
98
|
+
id: ID!
|
99
|
+
_id: ID!
|
100
|
+
}
|
101
|
+
`
|
102
|
+
)
|
103
|
+
},
|
104
|
+
{
|
105
|
+
title: "Correct",
|
106
|
+
usage: [
|
107
|
+
{
|
108
|
+
acceptedIdNames: ["id", "_id"],
|
109
|
+
acceptedIdTypes: ["ID"],
|
110
|
+
exceptions: { types: ["Error"], suffixes: ["Payload"] }
|
111
|
+
}
|
112
|
+
],
|
113
|
+
code: (
|
114
|
+
/* GraphQL */
|
115
|
+
`
|
116
|
+
type User {
|
117
|
+
id: ID!
|
118
|
+
}
|
119
|
+
|
120
|
+
type Post {
|
121
|
+
_id: ID!
|
122
|
+
}
|
123
|
+
|
124
|
+
type CreateUserPayload {
|
125
|
+
data: String!
|
126
|
+
}
|
127
|
+
|
128
|
+
type Error {
|
129
|
+
message: String!
|
130
|
+
}
|
131
|
+
`
|
132
|
+
)
|
133
|
+
}
|
134
|
+
]
|
135
|
+
},
|
136
|
+
schema
|
137
|
+
},
|
138
|
+
create(context) {
|
139
|
+
const options = {
|
140
|
+
acceptedIdNames: ["id"],
|
141
|
+
acceptedIdTypes: ["ID"],
|
142
|
+
exceptions: {},
|
143
|
+
...context.options[0]
|
144
|
+
};
|
145
|
+
const schema2 = (0, import_utils.requireGraphQLSchemaFromContext)(RULE_ID, context);
|
146
|
+
const rootTypeNames = [
|
147
|
+
schema2.getQueryType(),
|
148
|
+
schema2.getMutationType(),
|
149
|
+
schema2.getSubscriptionType()
|
150
|
+
].filter(import_utils.truthy).map((type) => type.name);
|
151
|
+
const selector = `ObjectTypeDefinition[name.value!=/^(${rootTypeNames.join("|")})$/]`;
|
152
|
+
return {
|
153
|
+
[selector](node) {
|
154
|
+
var _a, _b, _c;
|
155
|
+
const typeName = node.name.value;
|
156
|
+
const shouldIgnoreNode = ((_a = options.exceptions.types) == null ? void 0 : _a.includes(typeName)) || ((_b = options.exceptions.suffixes) == null ? void 0 : _b.some((suffix) => typeName.endsWith(suffix)));
|
157
|
+
if (shouldIgnoreNode) {
|
158
|
+
return;
|
159
|
+
}
|
160
|
+
const validIds = (_c = node.fields) == null ? void 0 : _c.filter((field) => {
|
161
|
+
const fieldNode = field.rawNode();
|
162
|
+
const isValidIdName = options.acceptedIdNames.includes(fieldNode.name.value);
|
163
|
+
let isValidIdType = false;
|
164
|
+
if (fieldNode.type.kind === import_graphql.Kind.NON_NULL_TYPE && fieldNode.type.type.kind === import_graphql.Kind.NAMED_TYPE) {
|
165
|
+
isValidIdType = options.acceptedIdTypes.includes(fieldNode.type.type.name.value);
|
166
|
+
}
|
167
|
+
return isValidIdName && isValidIdType;
|
168
|
+
});
|
169
|
+
if ((validIds == null ? void 0 : validIds.length) !== 1) {
|
170
|
+
const pluralNamesSuffix = options.acceptedIdNames.length > 1 ? "s" : "";
|
171
|
+
const pluralTypesSuffix = options.acceptedIdTypes.length > 1 ? "s" : "";
|
172
|
+
context.report({
|
173
|
+
node: node.name,
|
174
|
+
message: `${(0, import_utils.displayNodeName)(node)} must have exactly one non-nullable unique identifier.
|
175
|
+
Accepted name${pluralNamesSuffix}: ${(0, import_utils.englishJoinWords)(options.acceptedIdNames)}.
|
176
|
+
Accepted type${pluralTypesSuffix}: ${(0, import_utils.englishJoinWords)(options.acceptedIdTypes)}.`
|
177
|
+
});
|
178
|
+
}
|
179
|
+
}
|
180
|
+
};
|
181
|
+
}
|
182
|
+
};
|
183
|
+
// Annotate the CommonJS export names for ESM import in node:
|
184
|
+
0 && (module.exports = {
|
185
|
+
rule
|
186
|
+
});
|
@@ -0,0 +1,13 @@
|
|
1
|
+
import { ExecutableDefinitionNode } from 'graphql';
|
2
|
+
import { GraphQLESTreeNode } from '../estree-converter/types.js';
|
3
|
+
import { c as GraphQLESLintRuleContext, f as GraphQLESLintRule } from '../types-8d5f4ae0.js';
|
4
|
+
import 'eslint';
|
5
|
+
import 'estree';
|
6
|
+
import '@graphql-tools/utils';
|
7
|
+
import 'graphql-config';
|
8
|
+
import 'json-schema-to-ts';
|
9
|
+
|
10
|
+
declare const checkNode: (context: GraphQLESLintRuleContext, node: GraphQLESTreeNode<ExecutableDefinitionNode>, ruleId: string) => void;
|
11
|
+
declare const rule: GraphQLESLintRule;
|
12
|
+
|
13
|
+
export { checkNode, rule };
|
@@ -0,0 +1,118 @@
|
|
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 unique_fragment_name_exports = {};
|
20
|
+
__export(unique_fragment_name_exports, {
|
21
|
+
checkNode: () => checkNode,
|
22
|
+
rule: () => rule
|
23
|
+
});
|
24
|
+
module.exports = __toCommonJS(unique_fragment_name_exports);
|
25
|
+
var import_path = require("path");
|
26
|
+
var import_graphql = require("graphql");
|
27
|
+
var import_utils = require("../utils.js");
|
28
|
+
const RULE_ID = "unique-fragment-name";
|
29
|
+
const checkNode = (context, node, ruleId) => {
|
30
|
+
const documentName = node.name.value;
|
31
|
+
const siblings = (0, import_utils.requireSiblingsOperations)(ruleId, context);
|
32
|
+
const siblingDocuments = node.kind === import_graphql.Kind.FRAGMENT_DEFINITION ? siblings.getFragment(documentName) : siblings.getOperation(documentName);
|
33
|
+
const filepath = context.getFilename();
|
34
|
+
const conflictingDocuments = siblingDocuments.filter((f) => {
|
35
|
+
var _a;
|
36
|
+
const isSameName = ((_a = f.document.name) == null ? void 0 : _a.value) === documentName;
|
37
|
+
const isSamePath = (0, import_utils.normalizePath)(f.filePath) === (0, import_utils.normalizePath)(filepath);
|
38
|
+
return isSameName && !isSamePath;
|
39
|
+
});
|
40
|
+
if (conflictingDocuments.length > 0) {
|
41
|
+
context.report({
|
42
|
+
messageId: ruleId,
|
43
|
+
data: {
|
44
|
+
documentName,
|
45
|
+
summary: conflictingDocuments.map((f) => ` ${(0, import_path.relative)(import_utils.CWD, f.filePath.replace(import_utils.VIRTUAL_DOCUMENT_REGEX, ""))}`).join("\n")
|
46
|
+
},
|
47
|
+
// @ts-expect-error name will exist
|
48
|
+
node: node.name
|
49
|
+
});
|
50
|
+
}
|
51
|
+
};
|
52
|
+
const rule = {
|
53
|
+
meta: {
|
54
|
+
type: "suggestion",
|
55
|
+
docs: {
|
56
|
+
category: "Operations",
|
57
|
+
description: "Enforce unique fragment names across your project.",
|
58
|
+
url: `https://the-guild.dev/graphql/eslint/rules/${RULE_ID}`,
|
59
|
+
requiresSiblings: true,
|
60
|
+
examples: [
|
61
|
+
{
|
62
|
+
title: "Incorrect",
|
63
|
+
code: (
|
64
|
+
/* GraphQL */
|
65
|
+
`
|
66
|
+
# user.fragment.graphql
|
67
|
+
fragment UserFields on User {
|
68
|
+
id
|
69
|
+
name
|
70
|
+
fullName
|
71
|
+
}
|
72
|
+
|
73
|
+
# user-fields.graphql
|
74
|
+
fragment UserFields on User {
|
75
|
+
id
|
76
|
+
}
|
77
|
+
`
|
78
|
+
)
|
79
|
+
},
|
80
|
+
{
|
81
|
+
title: "Correct",
|
82
|
+
code: (
|
83
|
+
/* GraphQL */
|
84
|
+
`
|
85
|
+
# user.fragment.graphql
|
86
|
+
fragment AllUserFields on User {
|
87
|
+
id
|
88
|
+
name
|
89
|
+
fullName
|
90
|
+
}
|
91
|
+
|
92
|
+
# user-fields.graphql
|
93
|
+
fragment UserFields on User {
|
94
|
+
id
|
95
|
+
}
|
96
|
+
`
|
97
|
+
)
|
98
|
+
}
|
99
|
+
]
|
100
|
+
},
|
101
|
+
messages: {
|
102
|
+
[RULE_ID]: 'Fragment named "{{ documentName }}" already defined in:\n{{ summary }}'
|
103
|
+
},
|
104
|
+
schema: []
|
105
|
+
},
|
106
|
+
create(context) {
|
107
|
+
return {
|
108
|
+
FragmentDefinition(node) {
|
109
|
+
checkNode(context, node, RULE_ID);
|
110
|
+
}
|
111
|
+
};
|
112
|
+
}
|
113
|
+
};
|
114
|
+
// Annotate the CommonJS export names for ESM import in node:
|
115
|
+
0 && (module.exports = {
|
116
|
+
checkNode,
|
117
|
+
rule
|
118
|
+
});
|
@@ -0,0 +1,12 @@
|
|
1
|
+
import { f as GraphQLESLintRule } from '../types-8d5f4ae0.js';
|
2
|
+
import '@graphql-tools/utils';
|
3
|
+
import 'eslint';
|
4
|
+
import 'estree';
|
5
|
+
import 'graphql';
|
6
|
+
import 'graphql-config';
|
7
|
+
import 'json-schema-to-ts';
|
8
|
+
import '../estree-converter/types.js';
|
9
|
+
|
10
|
+
declare const rule: GraphQLESLintRule;
|
11
|
+
|
12
|
+
export { rule };
|
@@ -0,0 +1,95 @@
|
|
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 unique_operation_name_exports = {};
|
20
|
+
__export(unique_operation_name_exports, {
|
21
|
+
rule: () => rule
|
22
|
+
});
|
23
|
+
module.exports = __toCommonJS(unique_operation_name_exports);
|
24
|
+
var import_unique_fragment_name = require("./unique-fragment-name.js");
|
25
|
+
const RULE_ID = "unique-operation-name";
|
26
|
+
const rule = {
|
27
|
+
meta: {
|
28
|
+
type: "suggestion",
|
29
|
+
docs: {
|
30
|
+
category: "Operations",
|
31
|
+
description: "Enforce unique operation names across your project.",
|
32
|
+
url: `https://the-guild.dev/graphql/eslint/rules/${RULE_ID}`,
|
33
|
+
requiresSiblings: true,
|
34
|
+
examples: [
|
35
|
+
{
|
36
|
+
title: "Incorrect",
|
37
|
+
code: (
|
38
|
+
/* GraphQL */
|
39
|
+
`
|
40
|
+
# foo.query.graphql
|
41
|
+
query user {
|
42
|
+
user {
|
43
|
+
id
|
44
|
+
}
|
45
|
+
}
|
46
|
+
|
47
|
+
# bar.query.graphql
|
48
|
+
query user {
|
49
|
+
me {
|
50
|
+
id
|
51
|
+
}
|
52
|
+
}
|
53
|
+
`
|
54
|
+
)
|
55
|
+
},
|
56
|
+
{
|
57
|
+
title: "Correct",
|
58
|
+
code: (
|
59
|
+
/* GraphQL */
|
60
|
+
`
|
61
|
+
# foo.query.graphql
|
62
|
+
query user {
|
63
|
+
user {
|
64
|
+
id
|
65
|
+
}
|
66
|
+
}
|
67
|
+
|
68
|
+
# bar.query.graphql
|
69
|
+
query me {
|
70
|
+
me {
|
71
|
+
id
|
72
|
+
}
|
73
|
+
}
|
74
|
+
`
|
75
|
+
)
|
76
|
+
}
|
77
|
+
]
|
78
|
+
},
|
79
|
+
messages: {
|
80
|
+
[RULE_ID]: 'Operation named "{{ documentName }}" already defined in:\n{{ summary }}'
|
81
|
+
},
|
82
|
+
schema: []
|
83
|
+
},
|
84
|
+
create(context) {
|
85
|
+
return {
|
86
|
+
"OperationDefinition[name!=undefined]"(node) {
|
87
|
+
(0, import_unique_fragment_name.checkNode)(context, node, RULE_ID);
|
88
|
+
}
|
89
|
+
};
|
90
|
+
}
|
91
|
+
};
|
92
|
+
// Annotate the CommonJS export names for ESM import in node:
|
93
|
+
0 && (module.exports = {
|
94
|
+
rule
|
95
|
+
});
|
package/cjs/schema.d.ts
ADDED
@@ -0,0 +1,12 @@
|
|
1
|
+
import { GraphQLProjectConfig } from 'graphql-config';
|
2
|
+
import { P as ParserOptions, S as Schema } from './types-8d5f4ae0.js';
|
3
|
+
import '@graphql-tools/utils';
|
4
|
+
import 'eslint';
|
5
|
+
import 'estree';
|
6
|
+
import 'graphql';
|
7
|
+
import 'json-schema-to-ts';
|
8
|
+
import './estree-converter/types.js';
|
9
|
+
|
10
|
+
declare function getSchema(project: GraphQLProjectConfig, schemaOptions?: ParserOptions['schemaOptions']): Schema;
|
11
|
+
|
12
|
+
export { getSchema };
|