@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
package/cjs/rules/alphabetize.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,43 +18,34 @@ 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 alphabetize_exports = {};
|
30
25
|
__export(alphabetize_exports, {
|
31
26
|
rule: () => rule
|
32
27
|
});
|
33
28
|
module.exports = __toCommonJS(alphabetize_exports);
|
34
|
-
var import_graphql = require("graphql");
|
35
|
-
|
36
|
-
var import_utils = require("../utils.js");
|
37
|
-
const RULE_ID = "alphabetize";
|
38
|
-
const fieldsEnum = [
|
29
|
+
var import_graphql = require("graphql"), import_lodash = __toESM(require("lodash.lowercase")), import_utils = require("../utils.js");
|
30
|
+
const RULE_ID = "alphabetize", fieldsEnum = [
|
39
31
|
import_graphql.Kind.OBJECT_TYPE_DEFINITION,
|
40
32
|
import_graphql.Kind.INTERFACE_TYPE_DEFINITION,
|
41
33
|
import_graphql.Kind.INPUT_OBJECT_TYPE_DEFINITION
|
42
|
-
]
|
43
|
-
const valuesEnum = [import_graphql.Kind.ENUM_TYPE_DEFINITION];
|
44
|
-
const selectionsEnum = [
|
34
|
+
], selectionsEnum = [
|
45
35
|
import_graphql.Kind.OPERATION_DEFINITION,
|
46
36
|
import_graphql.Kind.FRAGMENT_DEFINITION
|
47
|
-
]
|
48
|
-
const variablesEnum = [import_graphql.Kind.OPERATION_DEFINITION];
|
49
|
-
const argumentsEnum = [
|
37
|
+
], argumentsEnum = [
|
50
38
|
import_graphql.Kind.FIELD_DEFINITION,
|
51
39
|
import_graphql.Kind.FIELD,
|
52
40
|
import_graphql.Kind.DIRECTIVE_DEFINITION,
|
53
41
|
import_graphql.Kind.DIRECTIVE
|
54
|
-
]
|
55
|
-
const schema = {
|
42
|
+
], schema = {
|
56
43
|
type: "array",
|
57
44
|
minItems: 1,
|
58
45
|
maxItems: 1,
|
59
46
|
items: {
|
60
47
|
type: "object",
|
61
|
-
additionalProperties:
|
48
|
+
additionalProperties: !1,
|
62
49
|
minProperties: 1,
|
63
50
|
properties: {
|
64
51
|
fields: {
|
@@ -69,10 +56,7 @@ const schema = {
|
|
69
56
|
description: "Fields of `type`, `interface`, and `input`."
|
70
57
|
},
|
71
58
|
values: {
|
72
|
-
|
73
|
-
items: {
|
74
|
-
enum: valuesEnum
|
75
|
-
},
|
59
|
+
type: "boolean",
|
76
60
|
description: "Values of `enum`."
|
77
61
|
},
|
78
62
|
selections: {
|
@@ -83,10 +67,7 @@ const schema = {
|
|
83
67
|
description: "Selections of `fragment` and operations `query`, `mutation` and `subscription`."
|
84
68
|
},
|
85
69
|
variables: {
|
86
|
-
|
87
|
-
items: {
|
88
|
-
enum: variablesEnum
|
89
|
-
},
|
70
|
+
type: "boolean",
|
90
71
|
description: "Variables of operations `query`, `mutation` and `subscription`."
|
91
72
|
},
|
92
73
|
arguments: {
|
@@ -98,8 +79,7 @@ const schema = {
|
|
98
79
|
},
|
99
80
|
definitions: {
|
100
81
|
type: "boolean",
|
101
|
-
description: "Definitions \u2013 `type`, `interface`, `enum`, `scalar`, `input`, `union` and `directive`."
|
102
|
-
default: false
|
82
|
+
description: "Definitions \u2013 `type`, `interface`, `enum`, `scalar`, `input`, `union` and `directive`."
|
103
83
|
},
|
104
84
|
groups: {
|
105
85
|
...import_utils.ARRAY_DEFAULT_OPTIONS,
|
@@ -108,8 +88,7 @@ const schema = {
|
|
108
88
|
}
|
109
89
|
}
|
110
90
|
}
|
111
|
-
}
|
112
|
-
const rule = {
|
91
|
+
}, rule = {
|
113
92
|
meta: {
|
114
93
|
type: "suggestion",
|
115
94
|
fixable: "code",
|
@@ -150,7 +129,7 @@ const rule = {
|
|
150
129
|
},
|
151
130
|
{
|
152
131
|
title: "Incorrect",
|
153
|
-
usage: [{ values:
|
132
|
+
usage: [{ values: !0 }],
|
154
133
|
code: (
|
155
134
|
/* GraphQL */
|
156
135
|
`
|
@@ -165,7 +144,7 @@ const rule = {
|
|
165
144
|
},
|
166
145
|
{
|
167
146
|
title: "Correct",
|
168
|
-
usage: [{ values:
|
147
|
+
usage: [{ values: !0 }],
|
169
148
|
code: (
|
170
149
|
/* GraphQL */
|
171
150
|
`
|
@@ -214,19 +193,20 @@ const rule = {
|
|
214
193
|
configOptions: {
|
215
194
|
schema: [
|
216
195
|
{
|
196
|
+
definitions: !0,
|
217
197
|
fields: fieldsEnum,
|
218
|
-
values:
|
219
|
-
arguments: argumentsEnum
|
220
|
-
|
221
|
-
// definitions: true,
|
222
|
-
// groups: ['id', '*', 'createdAt', 'updatedAt']
|
198
|
+
values: !0,
|
199
|
+
arguments: argumentsEnum,
|
200
|
+
groups: ["id", "*", "createdAt", "updatedAt"]
|
223
201
|
}
|
224
202
|
],
|
225
203
|
operations: [
|
226
204
|
{
|
205
|
+
definitions: !0,
|
227
206
|
selections: selectionsEnum,
|
228
|
-
variables:
|
229
|
-
arguments: [import_graphql.Kind.FIELD, import_graphql.Kind.DIRECTIVE]
|
207
|
+
variables: !0,
|
208
|
+
arguments: [import_graphql.Kind.FIELD, import_graphql.Kind.DIRECTIVE],
|
209
|
+
groups: ["id", "*", "createdAt", "updatedAt"]
|
230
210
|
}
|
231
211
|
]
|
232
212
|
}
|
@@ -237,77 +217,51 @@ const rule = {
|
|
237
217
|
schema
|
238
218
|
},
|
239
219
|
create(context) {
|
240
|
-
var _a, _b, _c, _d, _e;
|
241
220
|
const sourceCode = context.getSourceCode();
|
242
221
|
function isNodeAndCommentOnSameLine(node, comment) {
|
243
222
|
return node.loc.end.line === comment.loc.start.line;
|
244
223
|
}
|
245
224
|
function getBeforeComments(node) {
|
246
225
|
const commentsBefore = sourceCode.getCommentsBefore(node);
|
247
|
-
if (commentsBefore.length === 0)
|
226
|
+
if (commentsBefore.length === 0)
|
248
227
|
return [];
|
249
|
-
}
|
250
228
|
const tokenBefore = sourceCode.getTokenBefore(node);
|
251
|
-
if (tokenBefore)
|
229
|
+
if (tokenBefore)
|
252
230
|
return commentsBefore.filter((comment) => !isNodeAndCommentOnSameLine(tokenBefore, comment));
|
253
|
-
|
254
|
-
const filteredComments = [];
|
255
|
-
const nodeLine = node.loc.start.line;
|
231
|
+
const filteredComments = [], nodeLine = node.loc.start.line;
|
256
232
|
for (let i = commentsBefore.length - 1; i >= 0; i -= 1) {
|
257
233
|
const comment = commentsBefore[i];
|
258
|
-
if (nodeLine - comment.loc.start.line - filteredComments.length > 1)
|
234
|
+
if (nodeLine - comment.loc.start.line - filteredComments.length > 1)
|
259
235
|
break;
|
260
|
-
}
|
261
236
|
filteredComments.unshift(comment);
|
262
237
|
}
|
263
238
|
return filteredComments;
|
264
239
|
}
|
265
240
|
function getRangeWithComments(node) {
|
266
|
-
|
267
|
-
|
268
|
-
}
|
269
|
-
const [firstBeforeComment] = getBeforeComments(node);
|
270
|
-
const [firstAfterComment] = sourceCode.getCommentsAfter(node);
|
271
|
-
const from = firstBeforeComment || node;
|
272
|
-
const to = firstAfterComment && isNodeAndCommentOnSameLine(node, firstAfterComment) ? firstAfterComment : node;
|
241
|
+
node.kind === import_graphql.Kind.VARIABLE && (node = node.parent);
|
242
|
+
const [firstBeforeComment] = getBeforeComments(node), [firstAfterComment] = sourceCode.getCommentsAfter(node), from = firstBeforeComment || node, to = firstAfterComment && isNodeAndCommentOnSameLine(node, firstAfterComment) ? firstAfterComment : node;
|
273
243
|
return [from.range[0], to.range[1]];
|
274
244
|
}
|
275
245
|
function checkNodes(nodes = []) {
|
276
|
-
var _a2, _b2, _c2, _d2;
|
277
246
|
for (let i = 1; i < nodes.length; i += 1) {
|
278
|
-
const currNode = nodes[i];
|
279
|
-
|
280
|
-
if (!currName) {
|
247
|
+
const currNode = nodes[i], currName = "alias" in currNode && currNode.alias?.value || "name" in currNode && currNode.name?.value;
|
248
|
+
if (!currName)
|
281
249
|
continue;
|
282
|
-
|
283
|
-
const prevNode = nodes[i - 1];
|
284
|
-
const prevName = "alias" in prevNode && ((_c2 = prevNode.alias) == null ? void 0 : _c2.value) || "name" in prevNode && ((_d2 = prevNode.name) == null ? void 0 : _d2.value);
|
250
|
+
const prevNode = nodes[i - 1], prevName = "alias" in prevNode && prevNode.alias?.value || "name" in prevNode && prevNode.name?.value;
|
285
251
|
if (prevName) {
|
286
|
-
const compareResult = prevName.localeCompare(currName);
|
287
|
-
|
288
|
-
|
289
|
-
|
290
|
-
if (!groups.includes("*")) {
|
252
|
+
const compareResult = prevName.localeCompare(currName), { groups } = opts;
|
253
|
+
let shouldSortByGroup = !1;
|
254
|
+
if (groups?.length) {
|
255
|
+
if (!groups.includes("*"))
|
291
256
|
throw new Error("`groups` option should contain `*` string.");
|
292
|
-
}
|
293
257
|
let indexForPrev = groups.indexOf(prevName);
|
294
|
-
|
295
|
-
indexForPrev = groups.indexOf("*");
|
258
|
+
indexForPrev === -1 && (indexForPrev = groups.indexOf("*"));
|
296
259
|
let indexForCurr = groups.indexOf(currName);
|
297
|
-
if (indexForCurr === -1)
|
298
|
-
indexForCurr = groups.indexOf("*");
|
299
|
-
shouldSortByGroup = indexForPrev - indexForCurr > 0;
|
300
|
-
if (indexForPrev < indexForCurr) {
|
260
|
+
if (indexForCurr === -1 && (indexForCurr = groups.indexOf("*")), shouldSortByGroup = indexForPrev - indexForCurr > 0, indexForPrev < indexForCurr)
|
301
261
|
continue;
|
302
|
-
}
|
303
|
-
}
|
304
|
-
const shouldSort = compareResult === 1;
|
305
|
-
if (!shouldSortByGroup && !shouldSort) {
|
306
|
-
const isSameName = compareResult === 0;
|
307
|
-
if (!isSameName || !prevNode.kind.endsWith("Extension") || currNode.kind.endsWith("Extension")) {
|
308
|
-
continue;
|
309
|
-
}
|
310
262
|
}
|
263
|
+
if (!shouldSortByGroup && !(compareResult === 1) && (!(compareResult === 0) || !prevNode.kind.endsWith("Extension") || currNode.kind.endsWith("Extension")))
|
264
|
+
continue;
|
311
265
|
}
|
312
266
|
context.report({
|
313
267
|
// @ts-expect-error can't be undefined
|
@@ -318,13 +272,11 @@ const rule = {
|
|
318
272
|
prevNode: prevName ? (0, import_utils.displayNodeName)(prevNode) : (0, import_lodash.default)(prevNode.kind)
|
319
273
|
},
|
320
274
|
*fix(fixer) {
|
321
|
-
const prevRange = getRangeWithComments(prevNode);
|
322
|
-
const currRange = getRangeWithComments(currNode);
|
275
|
+
const prevRange = getRangeWithComments(prevNode), currRange = getRangeWithComments(currNode);
|
323
276
|
yield fixer.replaceTextRange(
|
324
277
|
prevRange,
|
325
278
|
sourceCode.getText({ range: currRange })
|
326
|
-
)
|
327
|
-
yield fixer.replaceTextRange(
|
279
|
+
), yield fixer.replaceTextRange(
|
328
280
|
currRange,
|
329
281
|
sourceCode.getText({ range: prevRange })
|
330
282
|
);
|
@@ -332,10 +284,7 @@ const rule = {
|
|
332
284
|
});
|
333
285
|
}
|
334
286
|
}
|
335
|
-
const opts = context.options[0]
|
336
|
-
const fields = new Set((_a = opts.fields) != null ? _a : []);
|
337
|
-
const listeners = {};
|
338
|
-
const kinds = [
|
287
|
+
const opts = context.options[0], fields = new Set(opts.fields ?? []), listeners = {}, fieldsSelector = [
|
339
288
|
fields.has(import_graphql.Kind.OBJECT_TYPE_DEFINITION) && [
|
340
289
|
import_graphql.Kind.OBJECT_TYPE_DEFINITION,
|
341
290
|
import_graphql.Kind.OBJECT_TYPE_EXTENSION
|
@@ -348,45 +297,24 @@ const rule = {
|
|
348
297
|
import_graphql.Kind.INPUT_OBJECT_TYPE_DEFINITION,
|
349
298
|
import_graphql.Kind.INPUT_OBJECT_TYPE_EXTENSION
|
350
299
|
]
|
351
|
-
].filter(import_utils.truthy).flat();
|
352
|
-
|
353
|
-
|
354
|
-
|
355
|
-
const hasVariables = ((_d = opts.variables) == null ? void 0 : _d[0]) === import_graphql.Kind.OPERATION_DEFINITION;
|
356
|
-
const argumentsSelector = (_e = opts.arguments) == null ? void 0 : _e.join(",");
|
357
|
-
if (fieldsSelector) {
|
358
|
-
listeners[fieldsSelector] = (node) => {
|
359
|
-
checkNodes(node.fields);
|
360
|
-
};
|
361
|
-
}
|
362
|
-
if (hasEnumValues) {
|
300
|
+
].filter(import_utils.truthy).flat().join(","), selectionsSelector = opts.selections?.join(","), argumentsSelector = opts.arguments?.join(",");
|
301
|
+
if (fieldsSelector && (listeners[fieldsSelector] = (node) => {
|
302
|
+
checkNodes(node.fields);
|
303
|
+
}), opts.values) {
|
363
304
|
const enumValuesSelector = [import_graphql.Kind.ENUM_TYPE_DEFINITION, import_graphql.Kind.ENUM_TYPE_EXTENSION].join(",");
|
364
305
|
listeners[enumValuesSelector] = (node) => {
|
365
306
|
checkNodes(node.values);
|
366
307
|
};
|
367
308
|
}
|
368
|
-
|
369
|
-
|
370
|
-
|
371
|
-
|
372
|
-
}
|
373
|
-
|
374
|
-
|
375
|
-
|
376
|
-
|
377
|
-
};
|
378
|
-
}
|
379
|
-
if (argumentsSelector) {
|
380
|
-
listeners[argumentsSelector] = (node) => {
|
381
|
-
checkNodes(node.arguments);
|
382
|
-
};
|
383
|
-
}
|
384
|
-
if (opts.definitions) {
|
385
|
-
listeners.Document = (node) => {
|
386
|
-
checkNodes(node.definitions);
|
387
|
-
};
|
388
|
-
}
|
389
|
-
return listeners;
|
309
|
+
return selectionsSelector && (listeners[`:matches(${selectionsSelector}) SelectionSet`] = (node) => {
|
310
|
+
checkNodes(node.selections);
|
311
|
+
}), opts.variables && (listeners.OperationDefinition = (node) => {
|
312
|
+
checkNodes(node.variableDefinitions?.map((varDef) => varDef.variable));
|
313
|
+
}), argumentsSelector && (listeners[argumentsSelector] = (node) => {
|
314
|
+
checkNodes(node.arguments);
|
315
|
+
}), opts.definitions && (listeners.Document = (node) => {
|
316
|
+
checkNodes(node.definitions);
|
317
|
+
}), listeners;
|
390
318
|
}
|
391
319
|
};
|
392
320
|
// Annotate the CommonJS export names for ESM import in node:
|
@@ -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 description_style_exports = {};
|
20
17
|
__export(description_style_exports, {
|
21
18
|
rule: () => rule
|
@@ -27,7 +24,7 @@ const schema = {
|
|
27
24
|
maxItems: 1,
|
28
25
|
items: {
|
29
26
|
type: "object",
|
30
|
-
additionalProperties:
|
27
|
+
additionalProperties: !1,
|
31
28
|
minProperties: 1,
|
32
29
|
properties: {
|
33
30
|
style: {
|
@@ -36,11 +33,10 @@ const schema = {
|
|
36
33
|
}
|
37
34
|
}
|
38
35
|
}
|
39
|
-
}
|
40
|
-
const rule = {
|
36
|
+
}, rule = {
|
41
37
|
meta: {
|
42
38
|
type: "suggestion",
|
43
|
-
hasSuggestions:
|
39
|
+
hasSuggestions: !0,
|
44
40
|
docs: {
|
45
41
|
examples: [
|
46
42
|
{
|
@@ -73,13 +69,12 @@ const rule = {
|
|
73
69
|
description: "Require all comments to follow the same style (either block or inline).",
|
74
70
|
category: "Schema",
|
75
71
|
url: "https://the-guild.dev/graphql/eslint/rules/description-style",
|
76
|
-
recommended:
|
72
|
+
recommended: !0
|
77
73
|
},
|
78
74
|
schema
|
79
75
|
},
|
80
76
|
create(context) {
|
81
|
-
const { style = "block" } = context.options[0] || {};
|
82
|
-
const isBlock = style === "block";
|
77
|
+
const { style = "block" } = context.options[0] || {}, isBlock = style === "block";
|
83
78
|
return {
|
84
79
|
[`.description[type=StringValue][block!=${isBlock}]`](node) {
|
85
80
|
context.report({
|
@@ -91,9 +86,7 @@ const rule = {
|
|
91
86
|
{
|
92
87
|
desc: `Change to ${isBlock ? "block" : "inline"} style description`,
|
93
88
|
fix(fixer) {
|
94
|
-
const
|
95
|
-
const originalText = sourceCode.getText(node);
|
96
|
-
const newText = isBlock ? originalText.replace(/(^")|("$)/g, '"""') : originalText.replace(/(^""")|("""$)/g, '"').replace(/\s+/g, " ");
|
89
|
+
const originalText = context.getSourceCode().getText(node), newText = isBlock ? originalText.replace(/(^")|("$)/g, '"""') : originalText.replace(/(^""")|("""$)/g, '"').replace(/\s+/g, " ");
|
97
90
|
return fixer.replaceText(node, newText);
|
98
91
|
}
|
99
92
|
}
|
@@ -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 GRAPHQL_JS_VALIDATIONS: Record<string, GraphQLESLintRule>;
|
11
12
|
|