@graphql-eslint/eslint-plugin 4.0.0-alpha-20230801163310-8bc4340 → 4.0.0-alpha-20230810155929-e89edf7
Sign up to get free protection for your applications and to get access to all the features.
- package/README.md +2 -0
- package/cjs/cache.js +10 -19
- package/cjs/configs/index.d.ts +42 -16
- package/cjs/configs/index.js +10 -19
- package/cjs/configs/operations-all.d.ts +4 -3
- package/cjs/configs/operations-all.js +5 -4
- package/cjs/configs/operations-recommended.d.ts +3 -1
- package/cjs/configs/operations-recommended.js +3 -1
- package/cjs/configs/schema-all.d.ts +6 -1
- package/cjs/configs/schema-all.js +5 -2
- package/cjs/configs/schema-recommended.d.ts +19 -1
- package/cjs/configs/schema-recommended.js +22 -2
- package/cjs/documents.js +17 -32
- package/cjs/estree-converter/converter.js +14 -27
- package/cjs/estree-converter/index.js +4 -7
- package/cjs/estree-converter/types.js +3 -5
- package/cjs/estree-converter/utils.d.ts +2 -3
- package/cjs/estree-converter/utils.js +15 -45
- package/cjs/flat-configs.d.ts +59 -12
- package/cjs/flat-configs.js +9 -14
- package/cjs/graphql-config.d.ts +4 -3
- package/cjs/graphql-config.js +23 -44
- package/cjs/index.d.ts +10 -4
- package/cjs/index.js +8 -16
- package/cjs/parser.d.ts +4 -3
- package/cjs/parser.js +38 -45
- package/cjs/processor.d.ts +5 -1
- package/cjs/processor.js +25 -57
- package/cjs/rules/alphabetize.d.ts +6 -16
- package/cjs/rules/alphabetize.js +60 -132
- package/cjs/rules/description-style.d.ts +4 -3
- package/cjs/rules/description-style.js +11 -18
- package/cjs/rules/graphql-js-validation.d.ts +4 -3
- package/cjs/rules/graphql-js-validation.js +151 -225
- package/cjs/rules/index.d.ts +15 -13
- package/cjs/rules/index.js +8 -45
- package/cjs/rules/input-name.d.ts +4 -3
- package/cjs/rules/input-name.js +43 -59
- package/cjs/rules/lone-executable-definition.d.ts +6 -5
- package/cjs/rules/lone-executable-definition.js +14 -28
- package/cjs/rules/match-document-filename.d.ts +4 -3
- package/cjs/rules/match-document-filename.js +39 -70
- package/cjs/rules/naming-convention.d.ts +4 -3
- package/cjs/rules/naming-convention.js +56 -74
- package/cjs/rules/no-anonymous-operations.d.ts +4 -3
- package/cjs/rules/no-anonymous-operations.js +11 -18
- package/cjs/rules/no-deprecated.d.ts +4 -3
- package/cjs/rules/no-deprecated.js +15 -29
- package/cjs/rules/no-duplicate-fields.d.ts +4 -3
- package/cjs/rules/no-duplicate-fields.js +13 -23
- package/cjs/rules/no-hashtag-description.d.ts +4 -3
- package/cjs/rules/no-hashtag-description.js +16 -29
- package/cjs/rules/no-one-place-fragments.d.ts +4 -3
- package/cjs/rules/no-one-place-fragments.js +17 -29
- package/cjs/rules/no-root-type.d.ts +4 -3
- package/cjs/rules/no-root-type.js +15 -25
- package/cjs/rules/no-scalar-result-type-on-mutation.d.ts +4 -3
- package/cjs/rules/no-scalar-result-type-on-mutation.js +18 -30
- package/cjs/rules/no-typename-prefix.d.ts +4 -3
- package/cjs/rules/no-typename-prefix.js +26 -33
- package/cjs/rules/no-unreachable-types.d.ts +4 -3
- package/cjs/rules/no-unreachable-types.js +25 -47
- package/cjs/rules/no-unused-fields.d.ts +4 -3
- package/cjs/rules/no-unused-fields.js +24 -49
- package/cjs/rules/relay-arguments.d.ts +4 -3
- package/cjs/rules/relay-arguments.js +20 -43
- package/cjs/rules/relay-connection-types.d.ts +4 -3
- package/cjs/rules/relay-connection-types.js +14 -45
- package/cjs/rules/relay-edge-types.d.ts +4 -3
- package/cjs/rules/relay-edge-types.js +48 -99
- package/cjs/rules/relay-page-info.d.ts +4 -3
- package/cjs/rules/relay-page-info.js +21 -44
- package/cjs/rules/require-deprecation-date.d.ts +4 -3
- package/cjs/rules/require-deprecation-date.js +15 -31
- package/cjs/rules/require-deprecation-reason.d.ts +4 -3
- package/cjs/rules/require-deprecation-reason.js +12 -20
- package/cjs/rules/require-description.d.ts +4 -3
- package/cjs/rules/require-description.js +39 -65
- package/cjs/rules/require-field-of-type-query-in-mutation-result.d.ts +4 -3
- package/cjs/rules/require-field-of-type-query-in-mutation-result.js +16 -31
- package/cjs/rules/require-import-fragment.d.ts +4 -3
- package/cjs/rules/require-import-fragment.js +22 -40
- package/cjs/rules/require-nullable-fields-with-oneof.d.ts +4 -3
- package/cjs/rules/require-nullable-fields-with-oneof.js +11 -22
- package/cjs/rules/require-nullable-result-in-root.d.ts +4 -3
- package/cjs/rules/require-nullable-result-in-root.js +34 -44
- package/cjs/rules/{require-id-when-available.d.ts → require-selections.d.ts} +4 -3
- package/cjs/rules/require-selections.js +198 -0
- package/cjs/rules/require-type-pattern-with-oneof.d.ts +4 -3
- package/cjs/rules/require-type-pattern-with-oneof.js +15 -23
- package/cjs/rules/selection-set-depth.d.ts +4 -3
- package/cjs/rules/selection-set-depth.js +18 -34
- package/cjs/rules/strict-id-in-types.d.ts +4 -3
- package/cjs/rules/strict-id-in-types.js +25 -43
- package/cjs/rules/{no-case-insensitive-enum-values-duplicates.d.ts → unique-enum-value-names.d.ts} +4 -3
- package/cjs/rules/{no-case-insensitive-enum-values-duplicates.js → unique-enum-value-names.js} +16 -21
- package/cjs/rules/unique-fragment-name.d.ts +3 -2
- package/cjs/rules/unique-fragment-name.js +24 -36
- package/cjs/rules/unique-operation-name.d.ts +4 -3
- package/cjs/rules/unique-operation-name.js +10 -12
- package/cjs/schema.d.ts +4 -3
- package/cjs/schema.js +14 -27
- package/cjs/siblings.d.ts +24 -8
- package/cjs/siblings.js +42 -82
- package/cjs/types.d.ts +74 -7
- package/cjs/types.js +3 -5
- package/cjs/utils.d.ts +3 -2
- package/cjs/utils.js +27 -44
- package/esm/cache.js +4 -8
- package/esm/{chunk-BMTV3EA2.js → chunk-U3TKCM4X.js} +1 -1
- package/esm/configs/index.d.mts +42 -16
- package/esm/configs/index.js +4 -4
- package/esm/configs/operations-all.d.mts +4 -3
- package/esm/configs/operations-all.js +6 -5
- package/esm/configs/operations-recommended.d.mts +3 -1
- package/esm/configs/operations-recommended.js +4 -2
- package/esm/configs/schema-all.d.mts +6 -1
- package/esm/configs/schema-all.js +6 -3
- package/esm/configs/schema-recommended.d.mts +19 -1
- package/esm/configs/schema-recommended.js +23 -3
- package/esm/configs/{relay.js → schema-relay.js} +4 -4
- package/esm/documents.js +10 -17
- package/esm/estree-converter/converter.js +9 -18
- package/esm/estree-converter/utils.d.mts +2 -3
- package/esm/estree-converter/utils.js +11 -38
- package/esm/flat-configs.d.mts +59 -12
- package/esm/flat-configs.js +4 -5
- package/esm/graphql-config.d.mts +4 -3
- package/esm/graphql-config.js +18 -34
- package/esm/index.d.mts +10 -4
- package/esm/index.js +1 -1
- package/esm/parser.d.mts +4 -3
- package/esm/parser.js +33 -27
- package/esm/processor.d.mts +5 -1
- package/esm/processor.js +21 -46
- package/esm/rules/alphabetize.d.mts +6 -16
- package/esm/rules/alphabetize.js +53 -118
- package/esm/rules/description-style.d.mts +4 -3
- package/esm/rules/description-style.js +7 -11
- package/esm/rules/graphql-js-validation.d.mts +4 -3
- package/esm/rules/graphql-js-validation.js +178 -218
- package/esm/rules/index.d.mts +15 -13
- package/esm/rules/index.js +5 -5
- package/esm/rules/input-name.d.mts +4 -3
- package/esm/rules/input-name.js +39 -52
- package/esm/rules/lone-executable-definition.d.mts +6 -5
- package/esm/rules/lone-executable-definition.js +10 -20
- package/esm/rules/match-document-filename.d.mts +4 -3
- package/esm/rules/match-document-filename.js +35 -61
- package/esm/rules/naming-convention.d.mts +4 -3
- package/esm/rules/naming-convention.js +51 -65
- package/esm/rules/no-anonymous-operations.d.mts +4 -3
- package/esm/rules/no-anonymous-operations.js +6 -9
- package/esm/rules/no-deprecated.d.mts +4 -3
- package/esm/rules/no-deprecated.js +10 -20
- package/esm/rules/no-duplicate-fields.d.mts +4 -3
- package/esm/rules/no-duplicate-fields.js +9 -16
- package/esm/rules/no-hashtag-description.d.mts +4 -3
- package/esm/rules/no-hashtag-description.js +11 -20
- package/esm/rules/no-one-place-fragments.d.mts +4 -3
- package/esm/rules/no-one-place-fragments.js +12 -19
- package/esm/rules/no-root-type.d.mts +4 -3
- package/esm/rules/no-root-type.js +11 -18
- package/esm/rules/no-scalar-result-type-on-mutation.d.mts +4 -3
- package/esm/rules/no-scalar-result-type-on-mutation.js +13 -21
- package/esm/rules/no-typename-prefix.d.mts +4 -3
- package/esm/rules/no-typename-prefix.js +22 -26
- package/esm/rules/no-unreachable-types.d.mts +4 -3
- package/esm/rules/no-unreachable-types.js +18 -33
- package/esm/rules/no-unused-fields.d.mts +4 -3
- package/esm/rules/no-unused-fields.js +19 -40
- package/esm/rules/relay-arguments.d.mts +4 -3
- package/esm/rules/relay-arguments.js +15 -34
- package/esm/rules/relay-connection-types.d.mts +4 -3
- package/esm/rules/relay-connection-types.js +10 -38
- package/esm/rules/relay-edge-types.d.mts +4 -3
- package/esm/rules/relay-edge-types.js +43 -89
- package/esm/rules/relay-page-info.d.mts +4 -3
- package/esm/rules/relay-page-info.js +16 -34
- package/esm/rules/require-deprecation-date.d.mts +4 -3
- package/esm/rules/require-deprecation-date.js +10 -22
- package/esm/rules/require-deprecation-reason.d.mts +4 -3
- package/esm/rules/require-deprecation-reason.js +7 -11
- package/esm/rules/require-description.d.mts +4 -3
- package/esm/rules/require-description.js +34 -55
- package/esm/rules/require-field-of-type-query-in-mutation-result.d.mts +4 -3
- package/esm/rules/require-field-of-type-query-in-mutation-result.js +11 -22
- package/esm/rules/require-import-fragment.d.mts +4 -3
- package/esm/rules/require-import-fragment.js +14 -26
- package/esm/rules/require-nullable-fields-with-oneof.d.mts +4 -3
- package/esm/rules/require-nullable-fields-with-oneof.js +6 -13
- package/esm/rules/require-nullable-result-in-root.d.mts +4 -3
- package/esm/rules/require-nullable-result-in-root.js +29 -35
- package/esm/rules/{require-id-when-available.d.mts → require-selections.d.mts} +4 -3
- package/esm/rules/{require-id-when-available.js → require-selections.js} +43 -80
- package/esm/rules/require-type-pattern-with-oneof.d.mts +4 -3
- package/esm/rules/require-type-pattern-with-oneof.js +11 -16
- package/esm/rules/selection-set-depth.d.mts +4 -3
- package/esm/rules/selection-set-depth.js +11 -20
- package/esm/rules/strict-id-in-types.d.mts +4 -3
- package/esm/rules/strict-id-in-types.js +20 -34
- package/esm/rules/{no-case-insensitive-enum-values-duplicates.d.mts → unique-enum-value-names.d.mts} +4 -3
- package/esm/rules/{no-case-insensitive-enum-values-duplicates.js → unique-enum-value-names.js} +8 -9
- package/esm/rules/unique-fragment-name.d.mts +3 -2
- package/esm/rules/unique-fragment-name.js +20 -27
- package/esm/rules/unique-operation-name.d.mts +4 -3
- package/esm/rules/unique-operation-name.js +6 -5
- package/esm/schema.d.mts +4 -3
- package/esm/schema.js +7 -12
- package/esm/siblings.d.mts +24 -8
- package/esm/siblings.js +37 -73
- package/esm/types.d.mts +74 -7
- package/esm/utils.d.mts +3 -2
- package/esm/utils.js +20 -31
- package/index.browser.mjs +5323 -0
- package/package.json +8 -13
- package/cjs/rules/require-id-when-available.js +0 -241
- package/cjs/types-8d5f4ae0.d.ts +0 -107
- package/esm/types-ace77d86.d.ts +0 -107
- /package/cjs/configs/{relay.d.ts → schema-relay.d.ts} +0 -0
- /package/cjs/configs/{relay.js → schema-relay.js} +0 -0
- /package/esm/configs/{relay.d.mts → schema-relay.d.mts} +0 -0
@@ -5,58 +5,45 @@ var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
5
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
6
6
|
var __export = (target, all) => {
|
7
7
|
for (var name in all)
|
8
|
-
__defProp(target, name, { get: all[name], enumerable:
|
9
|
-
}
|
10
|
-
|
11
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: !0 });
|
9
|
+
}, __copyProps = (to, from, except, desc) => {
|
10
|
+
if (from && typeof from == "object" || typeof from == "function")
|
12
11
|
for (let key of __getOwnPropNames(from))
|
13
|
-
|
14
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
15
|
-
}
|
12
|
+
!__hasOwnProp.call(to, key) && key !== except && __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
16
13
|
return to;
|
17
14
|
};
|
18
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value:
|
15
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: !0 }), mod);
|
19
16
|
var unique_fragment_name_exports = {};
|
20
17
|
__export(unique_fragment_name_exports, {
|
21
18
|
checkNode: () => checkNode,
|
22
19
|
rule: () => rule
|
23
20
|
});
|
24
21
|
module.exports = __toCommonJS(unique_fragment_name_exports);
|
25
|
-
var
|
26
|
-
|
27
|
-
|
28
|
-
const
|
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);
|
22
|
+
var import_node_path = require("node:path"), import_graphql = require("graphql"), import_utils = require("../utils.js");
|
23
|
+
const RULE_ID = "unique-fragment-name", checkNode = (context, node, ruleId) => {
|
24
|
+
const documentName = node.name.value, siblings = (0, import_utils.requireSiblingsOperations)(ruleId, context), siblingDocuments = node.kind === import_graphql.Kind.FRAGMENT_DEFINITION ? siblings.getFragment(documentName) : siblings.getOperation(documentName), filepath = context.filename, conflictingDocuments = siblingDocuments.filter((f) => {
|
25
|
+
const isSameName = f.document.name?.value === documentName, isSamePath = (0, import_utils.normalizePath)(f.filePath) === (0, import_utils.normalizePath)(filepath);
|
38
26
|
return isSameName && !isSamePath;
|
39
27
|
});
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
};
|
52
|
-
const rule = {
|
28
|
+
conflictingDocuments.length > 0 && context.report({
|
29
|
+
messageId: ruleId,
|
30
|
+
data: {
|
31
|
+
documentName,
|
32
|
+
summary: conflictingDocuments.map((f) => ` ${(0, import_node_path.relative)(import_utils.CWD, f.filePath.replace(import_utils.VIRTUAL_DOCUMENT_REGEX, ""))}`).join(`
|
33
|
+
`)
|
34
|
+
},
|
35
|
+
// @ts-expect-error name will exist
|
36
|
+
node: node.name
|
37
|
+
});
|
38
|
+
}, rule = {
|
53
39
|
meta: {
|
54
40
|
type: "suggestion",
|
55
41
|
docs: {
|
56
42
|
category: "Operations",
|
57
43
|
description: "Enforce unique fragment names across your project.",
|
58
44
|
url: `https://the-guild.dev/graphql/eslint/rules/${RULE_ID}`,
|
59
|
-
requiresSiblings:
|
45
|
+
requiresSiblings: !0,
|
46
|
+
recommended: !0,
|
60
47
|
examples: [
|
61
48
|
{
|
62
49
|
title: "Incorrect",
|
@@ -99,7 +86,8 @@ const rule = {
|
|
99
86
|
]
|
100
87
|
},
|
101
88
|
messages: {
|
102
|
-
[RULE_ID]:
|
89
|
+
[RULE_ID]: `Fragment named "{{ documentName }}" already defined in:
|
90
|
+
{{ summary }}`
|
103
91
|
},
|
104
92
|
schema: []
|
105
93
|
},
|
@@ -1,11 +1,12 @@
|
|
1
|
-
import {
|
2
|
-
import '@graphql-tools/utils';
|
1
|
+
import { GraphQLESLintRule } from '../types.js';
|
3
2
|
import 'eslint';
|
4
3
|
import 'estree';
|
5
4
|
import 'graphql';
|
6
|
-
import 'graphql-config';
|
7
5
|
import 'json-schema-to-ts';
|
6
|
+
import '../siblings.js';
|
7
|
+
import '@graphql-tools/utils';
|
8
8
|
import '../estree-converter/types.js';
|
9
|
+
import 'graphql-config';
|
9
10
|
|
10
11
|
declare const rule: GraphQLESLintRule;
|
11
12
|
|
@@ -5,32 +5,29 @@ var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
5
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
6
6
|
var __export = (target, all) => {
|
7
7
|
for (var name in all)
|
8
|
-
__defProp(target, name, { get: all[name], enumerable:
|
9
|
-
}
|
10
|
-
|
11
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: !0 });
|
9
|
+
}, __copyProps = (to, from, except, desc) => {
|
10
|
+
if (from && typeof from == "object" || typeof from == "function")
|
12
11
|
for (let key of __getOwnPropNames(from))
|
13
|
-
|
14
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
15
|
-
}
|
12
|
+
!__hasOwnProp.call(to, key) && key !== except && __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
16
13
|
return to;
|
17
14
|
};
|
18
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value:
|
15
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: !0 }), mod);
|
19
16
|
var unique_operation_name_exports = {};
|
20
17
|
__export(unique_operation_name_exports, {
|
21
18
|
rule: () => rule
|
22
19
|
});
|
23
20
|
module.exports = __toCommonJS(unique_operation_name_exports);
|
24
21
|
var import_unique_fragment_name = require("./unique-fragment-name.js");
|
25
|
-
const RULE_ID = "unique-operation-name"
|
26
|
-
const rule = {
|
22
|
+
const RULE_ID = "unique-operation-name", rule = {
|
27
23
|
meta: {
|
28
24
|
type: "suggestion",
|
29
25
|
docs: {
|
30
26
|
category: "Operations",
|
31
27
|
description: "Enforce unique operation names across your project.",
|
32
28
|
url: `https://the-guild.dev/graphql/eslint/rules/${RULE_ID}`,
|
33
|
-
requiresSiblings:
|
29
|
+
requiresSiblings: !0,
|
30
|
+
recommended: !0,
|
34
31
|
examples: [
|
35
32
|
{
|
36
33
|
title: "Incorrect",
|
@@ -77,7 +74,8 @@ const rule = {
|
|
77
74
|
]
|
78
75
|
},
|
79
76
|
messages: {
|
80
|
-
[RULE_ID]:
|
77
|
+
[RULE_ID]: `Operation named "{{ documentName }}" already defined in:
|
78
|
+
{{ summary }}`
|
81
79
|
},
|
82
80
|
schema: []
|
83
81
|
},
|
package/cjs/schema.d.ts
CHANGED
@@ -1,12 +1,13 @@
|
|
1
1
|
import { GraphQLProjectConfig } from 'graphql-config';
|
2
|
-
import {
|
3
|
-
import '@graphql-tools/utils';
|
2
|
+
import { Schema } from './types.js';
|
4
3
|
import 'eslint';
|
5
4
|
import 'estree';
|
6
5
|
import 'graphql';
|
7
6
|
import 'json-schema-to-ts';
|
7
|
+
import './siblings.js';
|
8
|
+
import '@graphql-tools/utils';
|
8
9
|
import './estree-converter/types.js';
|
9
10
|
|
10
|
-
declare function getSchema(project: GraphQLProjectConfig
|
11
|
+
declare function getSchema(project: GraphQLProjectConfig): Schema;
|
11
12
|
|
12
13
|
export { getSchema };
|
package/cjs/schema.js
CHANGED
@@ -3,18 +3,14 @@ var __create = Object.create;
|
|
3
3
|
var __defProp = Object.defineProperty;
|
4
4
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
5
5
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
6
|
-
var __getProtoOf = Object.getPrototypeOf;
|
7
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
6
|
+
var __getProtoOf = Object.getPrototypeOf, __hasOwnProp = Object.prototype.hasOwnProperty;
|
8
7
|
var __export = (target, all) => {
|
9
8
|
for (var name in all)
|
10
|
-
__defProp(target, name, { get: all[name], enumerable:
|
11
|
-
}
|
12
|
-
|
13
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
9
|
+
__defProp(target, name, { get: all[name], enumerable: !0 });
|
10
|
+
}, __copyProps = (to, from, except, desc) => {
|
11
|
+
if (from && typeof from == "object" || typeof from == "function")
|
14
12
|
for (let key of __getOwnPropNames(from))
|
15
|
-
|
16
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
17
|
-
}
|
13
|
+
!__hasOwnProp.call(to, key) && key !== except && __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
18
14
|
return to;
|
19
15
|
};
|
20
16
|
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
@@ -22,42 +18,33 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
22
18
|
// file that has been converted to a CommonJS file using a Babel-
|
23
19
|
// compatible transform (i.e. "__esModule" has not been set), then set
|
24
20
|
// "default" to the CommonJS "module.exports" for node compatibility.
|
25
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable:
|
21
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: !0 }) : target,
|
26
22
|
mod
|
27
|
-
));
|
28
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
23
|
+
)), __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: !0 }), mod);
|
29
24
|
var schema_exports = {};
|
30
25
|
__export(schema_exports, {
|
31
26
|
getSchema: () => getSchema
|
32
27
|
});
|
33
28
|
module.exports = __toCommonJS(schema_exports);
|
34
|
-
var import_debug = __toESM(require("debug"));
|
35
|
-
|
36
|
-
|
37
|
-
var import_cache = require("./cache.js");
|
38
|
-
const schemaCache = new import_cache.ModuleCache();
|
39
|
-
const debug = (0, import_debug.default)("graphql-eslint:schema");
|
40
|
-
function getSchema(project, schemaOptions) {
|
29
|
+
var import_debug = __toESM(require("debug")), import_fast_glob = __toESM(require("fast-glob")), import_graphql = require("graphql"), import_cache = require("./cache.js");
|
30
|
+
const schemaCache = new import_cache.ModuleCache(), debug = (0, import_debug.default)("graphql-eslint:schema");
|
31
|
+
function getSchema(project) {
|
41
32
|
const schemaKey = project.schema;
|
42
|
-
if (!schemaKey)
|
33
|
+
if (!schemaKey)
|
43
34
|
return null;
|
44
|
-
}
|
45
35
|
const cache = schemaCache.get(schemaKey);
|
46
|
-
if (cache)
|
36
|
+
if (cache)
|
47
37
|
return cache;
|
48
|
-
}
|
49
38
|
debug("Loading schema from %o", project.schema);
|
50
39
|
const schema = project.loadSchemaSync(project.schema, "GraphQLSchema", {
|
51
|
-
...schemaOptions,
|
52
40
|
pluckConfig: project.extensions.pluckConfig
|
53
41
|
});
|
54
42
|
if (debug.enabled) {
|
55
43
|
debug("Schema loaded: %o", schema instanceof import_graphql.GraphQLSchema);
|
56
|
-
const schemaPaths = import_fast_glob.default.sync(project.schema, { absolute:
|
44
|
+
const schemaPaths = import_fast_glob.default.sync(project.schema, { absolute: !0 });
|
57
45
|
debug("Schema pointers %O", schemaPaths);
|
58
46
|
}
|
59
|
-
schemaCache.set(schemaKey, schema);
|
60
|
-
return schema;
|
47
|
+
return schemaCache.set(schemaKey, schema), schema;
|
61
48
|
}
|
62
49
|
// Annotate the CommonJS export names for ESM import in node:
|
63
50
|
0 && (module.exports = {
|
package/cjs/siblings.d.ts
CHANGED
@@ -1,8 +1,24 @@
|
|
1
|
-
import 'graphql';
|
2
|
-
import 'graphql
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
1
|
+
import { Source } from '@graphql-tools/utils';
|
2
|
+
import { FragmentDefinitionNode, OperationDefinitionNode, SelectionSetNode, OperationTypeNode } from 'graphql';
|
3
|
+
|
4
|
+
type FragmentSource = {
|
5
|
+
filePath: string;
|
6
|
+
document: FragmentDefinitionNode;
|
7
|
+
};
|
8
|
+
type OperationSource = {
|
9
|
+
filePath: string;
|
10
|
+
document: OperationDefinitionNode;
|
11
|
+
};
|
12
|
+
type SiblingOperations = {
|
13
|
+
available: boolean;
|
14
|
+
getFragment(fragmentName: string): FragmentSource[];
|
15
|
+
getFragments(): FragmentSource[];
|
16
|
+
getFragmentByType(typeName: string): FragmentSource[];
|
17
|
+
getFragmentsInUse(baseOperation: FragmentDefinitionNode | OperationDefinitionNode | SelectionSetNode, recursive?: boolean): FragmentDefinitionNode[];
|
18
|
+
getOperation(operationName: string): OperationSource[];
|
19
|
+
getOperations(): OperationSource[];
|
20
|
+
getOperationByType(operationType: OperationTypeNode): OperationSource[];
|
21
|
+
};
|
22
|
+
declare function getSiblings(documents: Source[]): SiblingOperations;
|
23
|
+
|
24
|
+
export { FragmentSource, OperationSource, SiblingOperations, getSiblings };
|
package/cjs/siblings.js
CHANGED
@@ -5,42 +5,29 @@ var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
5
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
6
6
|
var __export = (target, all) => {
|
7
7
|
for (var name in all)
|
8
|
-
__defProp(target, name, { get: all[name], enumerable:
|
9
|
-
}
|
10
|
-
|
11
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: !0 });
|
9
|
+
}, __copyProps = (to, from, except, desc) => {
|
10
|
+
if (from && typeof from == "object" || typeof from == "function")
|
12
11
|
for (let key of __getOwnPropNames(from))
|
13
|
-
|
14
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
15
|
-
}
|
12
|
+
!__hasOwnProp.call(to, key) && key !== except && __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
16
13
|
return to;
|
17
14
|
};
|
18
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value:
|
15
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: !0 }), mod);
|
19
16
|
var siblings_exports = {};
|
20
17
|
__export(siblings_exports, {
|
21
18
|
getSiblings: () => getSiblings
|
22
19
|
});
|
23
20
|
module.exports = __toCommonJS(siblings_exports);
|
24
|
-
var
|
25
|
-
var import_graphql = require("graphql");
|
26
|
-
var import_documents = require("./documents.js");
|
27
|
-
var import_utils2 = require("./utils.js");
|
21
|
+
var import_graphql = require("graphql"), import_utils2 = require("./utils.js");
|
28
22
|
const siblingOperationsCache = /* @__PURE__ */ new Map();
|
29
|
-
function getSiblings(
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
import_utils2.logger.warn(
|
36
|
-
'getSiblingOperations was called without any operations. Make sure to set "parserOptions.operations" to make this feature available!'
|
37
|
-
);
|
38
|
-
printed = true;
|
39
|
-
}
|
40
|
-
return [];
|
41
|
-
};
|
23
|
+
function getSiblings(documents) {
|
24
|
+
if (documents.length === 0) {
|
25
|
+
let printed = !1;
|
26
|
+
const noopWarn = () => (printed || (import_utils2.logger.warn(
|
27
|
+
"getSiblingOperations was called without any operations. Make sure to set graphql-config `documents` field to make this feature available! See https://the-guild.dev/graphql/config/docs/user/documents for more info"
|
28
|
+
), printed = !0), []);
|
42
29
|
return {
|
43
|
-
available:
|
30
|
+
available: !1,
|
44
31
|
getFragment: noopWarn,
|
45
32
|
getFragments: noopWarn,
|
46
33
|
getFragmentByType: noopWarn,
|
@@ -50,85 +37,58 @@ function getSiblings(project, documents) {
|
|
50
37
|
getOperationByType: noopWarn
|
51
38
|
};
|
52
39
|
}
|
53
|
-
const value = siblingOperationsCache.get(
|
54
|
-
if (value)
|
40
|
+
const value = siblingOperationsCache.get(documents);
|
41
|
+
if (value)
|
55
42
|
return value;
|
56
|
-
}
|
57
43
|
let fragmentsCache = null;
|
58
44
|
const getFragments = () => {
|
59
|
-
var _a;
|
60
45
|
if (fragmentsCache === null) {
|
61
46
|
const result = [];
|
62
|
-
for (const source of
|
63
|
-
for (const definition of
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
});
|
69
|
-
}
|
70
|
-
}
|
71
|
-
}
|
47
|
+
for (const source of documents)
|
48
|
+
for (const definition of source.document?.definitions || [])
|
49
|
+
definition.kind === import_graphql.Kind.FRAGMENT_DEFINITION && result.push({
|
50
|
+
filePath: source.location,
|
51
|
+
document: definition
|
52
|
+
});
|
72
53
|
fragmentsCache = result;
|
73
54
|
}
|
74
55
|
return fragmentsCache;
|
75
56
|
};
|
76
57
|
let cachedOperations = null;
|
77
58
|
const getOperations = () => {
|
78
|
-
var _a;
|
79
59
|
if (cachedOperations === null) {
|
80
60
|
const result = [];
|
81
|
-
for (const source of
|
82
|
-
for (const definition of
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
});
|
88
|
-
}
|
89
|
-
}
|
90
|
-
}
|
61
|
+
for (const source of documents)
|
62
|
+
for (const definition of source.document?.definitions || [])
|
63
|
+
definition.kind === import_graphql.Kind.OPERATION_DEFINITION && result.push({
|
64
|
+
filePath: source.location,
|
65
|
+
document: definition
|
66
|
+
});
|
91
67
|
cachedOperations = result;
|
92
68
|
}
|
93
69
|
return cachedOperations;
|
94
|
-
}
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
import_utils2.logger.warn(
|
103
|
-
`Unable to locate fragment named "${fragmentName}", please make sure it's loaded using "parserOptions.operations"`
|
104
|
-
);
|
105
|
-
return;
|
106
|
-
}
|
107
|
-
if (!collected.has(fragmentName)) {
|
108
|
-
collected.set(fragmentName, fragment.document);
|
109
|
-
if (recursive) {
|
110
|
-
collectFragments(fragment.document, recursive, collected);
|
111
|
-
}
|
112
|
-
}
|
70
|
+
}, getFragment = (name) => getFragments().filter((f) => f.document.name.value === name), collectFragments = (selectable, recursive, collected = /* @__PURE__ */ new Map()) => ((0, import_graphql.visit)(selectable, {
|
71
|
+
FragmentSpread(spread) {
|
72
|
+
const fragmentName = spread.name.value, [fragment] = getFragment(fragmentName);
|
73
|
+
if (!fragment) {
|
74
|
+
import_utils2.logger.warn(
|
75
|
+
`Unable to locate fragment named "${fragmentName}", please make sure it's loaded using "parserOptions.operations"`
|
76
|
+
);
|
77
|
+
return;
|
113
78
|
}
|
114
|
-
|
115
|
-
|
116
|
-
}
|
117
|
-
|
118
|
-
available: true,
|
79
|
+
collected.has(fragmentName) || (collected.set(fragmentName, fragment.document), recursive && collectFragments(fragment.document, recursive, collected));
|
80
|
+
}
|
81
|
+
}), collected), siblingOperations = {
|
82
|
+
available: !0,
|
119
83
|
getFragment,
|
120
84
|
getFragments,
|
121
85
|
getFragmentByType: (typeName) => getFragments().filter((f) => f.document.typeCondition.name.value === typeName),
|
122
|
-
getFragmentsInUse: (selectable, recursive =
|
123
|
-
getOperation: (name) => getOperations().filter((o) =>
|
124
|
-
var _a;
|
125
|
-
return ((_a = o.document.name) == null ? void 0 : _a.value) === name;
|
126
|
-
}),
|
86
|
+
getFragmentsInUse: (selectable, recursive = !0) => Array.from(collectFragments(selectable, recursive).values()),
|
87
|
+
getOperation: (name) => getOperations().filter((o) => o.document.name?.value === name),
|
127
88
|
getOperations,
|
128
89
|
getOperationByType: (type) => getOperations().filter((o) => o.document.operation === type)
|
129
90
|
};
|
130
|
-
siblingOperationsCache.set(
|
131
|
-
return siblingOperations;
|
91
|
+
return siblingOperationsCache.set(documents, siblingOperations), siblingOperations;
|
132
92
|
}
|
133
93
|
// Annotate the CommonJS export names for ESM import in node:
|
134
94
|
0 && (module.exports = {
|
package/cjs/types.d.ts
CHANGED
@@ -1,8 +1,75 @@
|
|
1
|
+
import { Linter, Rule, AST } from 'eslint';
|
2
|
+
import * as ESTree from 'estree';
|
3
|
+
import { GraphQLSchema, ASTKindToNode } from 'graphql';
|
4
|
+
import { JSONSchema } from 'json-schema-to-ts';
|
5
|
+
import { SiblingOperations } from './siblings.js';
|
6
|
+
import { GraphQLESTreeNode } from './estree-converter/types.js';
|
7
|
+
import { IGraphQLConfig } from 'graphql-config';
|
1
8
|
import '@graphql-tools/utils';
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
+
|
10
|
+
type Schema = GraphQLSchema | null;
|
11
|
+
type Pointer = string | string[];
|
12
|
+
interface ParserOptions {
|
13
|
+
graphQLConfig?: IGraphQLConfig;
|
14
|
+
filePath: string;
|
15
|
+
}
|
16
|
+
type ParserServices = {
|
17
|
+
schema: Schema;
|
18
|
+
siblingOperations: SiblingOperations;
|
19
|
+
};
|
20
|
+
type GraphQLESLintParseResult = Linter.ESLintParseResult & {
|
21
|
+
services: ParserServices;
|
22
|
+
};
|
23
|
+
type Location = AST.SourceLocation | ESTree.Position;
|
24
|
+
type ReportDescriptorLocation = {
|
25
|
+
loc: Location;
|
26
|
+
} | {
|
27
|
+
node: {
|
28
|
+
loc: Location;
|
29
|
+
};
|
30
|
+
};
|
31
|
+
type ReportDescriptor = ReportDescriptorLocation & Rule.ReportDescriptorMessage & Rule.ReportDescriptorOptions;
|
32
|
+
type GraphQLESLintRuleContext<Options = any[]> = Omit<Rule.RuleContext, 'options' | 'parserServices' | 'report'> & {
|
33
|
+
options: Options;
|
34
|
+
parserServices: ParserServices;
|
35
|
+
report(descriptor: ReportDescriptor): void;
|
36
|
+
};
|
37
|
+
type CategoryType = 'Operations' | 'Schema';
|
38
|
+
type RuleMetaDataDocs = Required<Rule.RuleMetaData>['docs'];
|
39
|
+
type RuleDocsInfo<T> = Omit<RuleMetaDataDocs, 'category' | 'suggestion'> & {
|
40
|
+
category: CategoryType | CategoryType[];
|
41
|
+
requiresSchema?: true;
|
42
|
+
requiresSiblings?: true;
|
43
|
+
examples?: {
|
44
|
+
title: string;
|
45
|
+
code: string;
|
46
|
+
usage?: T;
|
47
|
+
}[];
|
48
|
+
configOptions?: T | {
|
49
|
+
schema?: T;
|
50
|
+
operations?: T;
|
51
|
+
};
|
52
|
+
graphQLJSRuleName?: string;
|
53
|
+
isDisabledForAllConfig?: true;
|
54
|
+
};
|
55
|
+
type GraphQLESLintRuleListener<WithTypeInfo extends boolean = false> = Record<string, any> & {
|
56
|
+
[K in keyof ASTKindToNode]?: (node: GraphQLESTreeNode<ASTKindToNode[K], WithTypeInfo>) => void;
|
57
|
+
};
|
58
|
+
type GraphQLESLintRule<Options = [], WithTypeInfo extends boolean = false> = {
|
59
|
+
meta: Omit<Rule.RuleMetaData, 'docs' | 'schema'> & {
|
60
|
+
docs?: RuleDocsInfo<Options>;
|
61
|
+
schema: Readonly<JSONSchema> | [];
|
62
|
+
};
|
63
|
+
create(context: GraphQLESLintRuleContext<Options>): GraphQLESLintRuleListener<WithTypeInfo>;
|
64
|
+
};
|
65
|
+
type ValueOf<T> = T[keyof T];
|
66
|
+
type Id<T> = {
|
67
|
+
[P in keyof T]: T[P];
|
68
|
+
} & {};
|
69
|
+
type OmitDistributive<T, K extends PropertyKey> = T extends object ? Id<OmitRecursively<T, K>> : T;
|
70
|
+
type OmitRecursively<T extends object, K extends PropertyKey> = Omit<{
|
71
|
+
[P in keyof T]: OmitDistributive<T[P], K>;
|
72
|
+
}, K>;
|
73
|
+
type ConfigName = 'operations-all' | 'operations-recommended' | 'schema-all' | 'schema-recommended' | 'schema-relay';
|
74
|
+
|
75
|
+
export { CategoryType, ConfigName, GraphQLESLintParseResult, GraphQLESLintRule, GraphQLESLintRuleContext, GraphQLESLintRuleListener, OmitRecursively, ParserOptions, ParserServices, Pointer, ReportDescriptor, RuleDocsInfo, Schema, ValueOf };
|
package/cjs/types.js
CHANGED
@@ -4,13 +4,11 @@ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
4
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
5
5
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
6
6
|
var __copyProps = (to, from, except, desc) => {
|
7
|
-
if (from && typeof from
|
7
|
+
if (from && typeof from == "object" || typeof from == "function")
|
8
8
|
for (let key of __getOwnPropNames(from))
|
9
|
-
|
10
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
11
|
-
}
|
9
|
+
!__hasOwnProp.call(to, key) && key !== except && __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
12
10
|
return to;
|
13
11
|
};
|
14
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value:
|
12
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: !0 }), mod);
|
15
13
|
var types_exports = {};
|
16
14
|
module.exports = __toCommonJS(types_exports);
|
package/cjs/utils.d.ts
CHANGED
@@ -1,11 +1,12 @@
|
|
1
1
|
import { AST } from 'eslint';
|
2
2
|
import { Position } from 'estree';
|
3
3
|
import { GraphQLSchema, ASTNode, Kind } from 'graphql';
|
4
|
-
import {
|
4
|
+
import { SiblingOperations } from './siblings.js';
|
5
|
+
import { GraphQLESLintRuleContext } from './types.js';
|
5
6
|
import { GraphQLESTreeNode } from './estree-converter/types.js';
|
6
7
|
import '@graphql-tools/utils';
|
7
|
-
import 'graphql-config';
|
8
8
|
import 'json-schema-to-ts';
|
9
|
+
import 'graphql-config';
|
9
10
|
|
10
11
|
declare function requireSiblingsOperations(ruleId: string, context: GraphQLESLintRuleContext): SiblingOperations | never;
|
11
12
|
declare function requireGraphQLSchemaFromContext(ruleId: string, context: GraphQLESLintRuleContext): GraphQLSchema | never;
|