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