@graphql-eslint/eslint-plugin 3.14.0-alpha-20221220160018-ba4832c → 3.14.0-alpha-20221220173226-ecd822d
Sign up to get free protection for your applications and to get access to all the features.
- package/index.js +44 -3
- package/index.mjs +44 -3
- package/package.json +1 -1
- package/rules/alphabetize.d.ts +16 -0
- package/rules/index.d.ts +6 -0
- package/rules/match-document-filename.d.ts +3 -0
package/index.js
CHANGED
@@ -782,6 +782,8 @@ const schema = {
|
|
782
782
|
description: 'Definitions – `type`, `interface`, `enum`, `scalar`, `input`, `union` and `directive`.',
|
783
783
|
default: false,
|
784
784
|
},
|
785
|
+
ignorePrefix: ARRAY_DEFAULT_OPTIONS,
|
786
|
+
ignoreSuffix: ARRAY_DEFAULT_OPTIONS,
|
785
787
|
},
|
786
788
|
},
|
787
789
|
};
|
@@ -947,6 +949,24 @@ const rule = {
|
|
947
949
|
const prevName = ('alias' in prevNode && ((_c = prevNode.alias) === null || _c === void 0 ? void 0 : _c.value)) ||
|
948
950
|
('name' in prevNode && ((_d = prevNode.name) === null || _d === void 0 ? void 0 : _d.value));
|
949
951
|
if (prevName) {
|
952
|
+
if ((opts.ignorePrefix || []).length > 0) {
|
953
|
+
const shouldSkipIgnorePrefix = opts.ignorePrefix.some(prefix => prefix === prevName ||
|
954
|
+
prefix === currName ||
|
955
|
+
prevName.startsWith(prefix) ||
|
956
|
+
currName.startsWith(prefix));
|
957
|
+
if (shouldSkipIgnorePrefix) {
|
958
|
+
continue;
|
959
|
+
}
|
960
|
+
}
|
961
|
+
if ((opts.ignoreSuffix || []).length > 0) {
|
962
|
+
const shouldSkipIgnoreSuffix = opts.ignoreSuffix.some(suffix => suffix === prevName ||
|
963
|
+
suffix === currName ||
|
964
|
+
prevName.endsWith(suffix) ||
|
965
|
+
currName.endsWith(suffix));
|
966
|
+
if (shouldSkipIgnoreSuffix) {
|
967
|
+
continue;
|
968
|
+
}
|
969
|
+
}
|
950
970
|
// Compare with lexicographic order
|
951
971
|
const compareResult = prevName.localeCompare(currName);
|
952
972
|
const shouldSort = compareResult === 1;
|
@@ -1353,6 +1373,7 @@ const schema$4 = {
|
|
1353
1373
|
properties: {
|
1354
1374
|
style: { enum: CASE_STYLES },
|
1355
1375
|
suffix: { type: 'string' },
|
1376
|
+
prefix: { type: 'string' },
|
1356
1377
|
},
|
1357
1378
|
},
|
1358
1379
|
},
|
@@ -1447,6 +1468,26 @@ const rule$4 = {
|
|
1447
1468
|
fullName
|
1448
1469
|
}
|
1449
1470
|
}
|
1471
|
+
`,
|
1472
|
+
},
|
1473
|
+
{
|
1474
|
+
title: 'Correct',
|
1475
|
+
usage: [{ fragment: { style: 'kebab-case', prefix: 'mutation.' } }],
|
1476
|
+
code: /* GraphQL */ `
|
1477
|
+
# mutation.add-alert.graphql
|
1478
|
+
mutation addAlert {
|
1479
|
+
foo
|
1480
|
+
}
|
1481
|
+
`,
|
1482
|
+
},
|
1483
|
+
{
|
1484
|
+
title: 'Correct',
|
1485
|
+
usage: [{ fragment: { prefix: 'query.' } }],
|
1486
|
+
code: /* GraphQL */ `
|
1487
|
+
# query.me.graphql
|
1488
|
+
query me {
|
1489
|
+
foo
|
1490
|
+
}
|
1450
1491
|
`,
|
1451
1492
|
},
|
1452
1493
|
],
|
@@ -1510,13 +1551,13 @@ const rule$4 = {
|
|
1510
1551
|
option = { style: option };
|
1511
1552
|
}
|
1512
1553
|
const expectedExtension = options.fileExtension || fileExtension;
|
1513
|
-
let expectedFilename;
|
1554
|
+
let expectedFilename = option.prefix || '';
|
1514
1555
|
if (option.style) {
|
1515
|
-
expectedFilename
|
1556
|
+
expectedFilename +=
|
1516
1557
|
option.style === 'matchDocumentStyle' ? docName : convertCase(option.style, docName);
|
1517
1558
|
}
|
1518
1559
|
else {
|
1519
|
-
expectedFilename
|
1560
|
+
expectedFilename += filename;
|
1520
1561
|
}
|
1521
1562
|
expectedFilename += (option.suffix || '') + expectedExtension;
|
1522
1563
|
const filenameWithExtension = filename + expectedExtension;
|
package/index.mjs
CHANGED
@@ -776,6 +776,8 @@ const schema = {
|
|
776
776
|
description: 'Definitions – `type`, `interface`, `enum`, `scalar`, `input`, `union` and `directive`.',
|
777
777
|
default: false,
|
778
778
|
},
|
779
|
+
ignorePrefix: ARRAY_DEFAULT_OPTIONS,
|
780
|
+
ignoreSuffix: ARRAY_DEFAULT_OPTIONS,
|
779
781
|
},
|
780
782
|
},
|
781
783
|
};
|
@@ -941,6 +943,24 @@ const rule = {
|
|
941
943
|
const prevName = ('alias' in prevNode && ((_c = prevNode.alias) === null || _c === void 0 ? void 0 : _c.value)) ||
|
942
944
|
('name' in prevNode && ((_d = prevNode.name) === null || _d === void 0 ? void 0 : _d.value));
|
943
945
|
if (prevName) {
|
946
|
+
if ((opts.ignorePrefix || []).length > 0) {
|
947
|
+
const shouldSkipIgnorePrefix = opts.ignorePrefix.some(prefix => prefix === prevName ||
|
948
|
+
prefix === currName ||
|
949
|
+
prevName.startsWith(prefix) ||
|
950
|
+
currName.startsWith(prefix));
|
951
|
+
if (shouldSkipIgnorePrefix) {
|
952
|
+
continue;
|
953
|
+
}
|
954
|
+
}
|
955
|
+
if ((opts.ignoreSuffix || []).length > 0) {
|
956
|
+
const shouldSkipIgnoreSuffix = opts.ignoreSuffix.some(suffix => suffix === prevName ||
|
957
|
+
suffix === currName ||
|
958
|
+
prevName.endsWith(suffix) ||
|
959
|
+
currName.endsWith(suffix));
|
960
|
+
if (shouldSkipIgnoreSuffix) {
|
961
|
+
continue;
|
962
|
+
}
|
963
|
+
}
|
944
964
|
// Compare with lexicographic order
|
945
965
|
const compareResult = prevName.localeCompare(currName);
|
946
966
|
const shouldSort = compareResult === 1;
|
@@ -1347,6 +1367,7 @@ const schema$4 = {
|
|
1347
1367
|
properties: {
|
1348
1368
|
style: { enum: CASE_STYLES },
|
1349
1369
|
suffix: { type: 'string' },
|
1370
|
+
prefix: { type: 'string' },
|
1350
1371
|
},
|
1351
1372
|
},
|
1352
1373
|
},
|
@@ -1441,6 +1462,26 @@ const rule$4 = {
|
|
1441
1462
|
fullName
|
1442
1463
|
}
|
1443
1464
|
}
|
1465
|
+
`,
|
1466
|
+
},
|
1467
|
+
{
|
1468
|
+
title: 'Correct',
|
1469
|
+
usage: [{ fragment: { style: 'kebab-case', prefix: 'mutation.' } }],
|
1470
|
+
code: /* GraphQL */ `
|
1471
|
+
# mutation.add-alert.graphql
|
1472
|
+
mutation addAlert {
|
1473
|
+
foo
|
1474
|
+
}
|
1475
|
+
`,
|
1476
|
+
},
|
1477
|
+
{
|
1478
|
+
title: 'Correct',
|
1479
|
+
usage: [{ fragment: { prefix: 'query.' } }],
|
1480
|
+
code: /* GraphQL */ `
|
1481
|
+
# query.me.graphql
|
1482
|
+
query me {
|
1483
|
+
foo
|
1484
|
+
}
|
1444
1485
|
`,
|
1445
1486
|
},
|
1446
1487
|
],
|
@@ -1504,13 +1545,13 @@ const rule$4 = {
|
|
1504
1545
|
option = { style: option };
|
1505
1546
|
}
|
1506
1547
|
const expectedExtension = options.fileExtension || fileExtension;
|
1507
|
-
let expectedFilename;
|
1548
|
+
let expectedFilename = option.prefix || '';
|
1508
1549
|
if (option.style) {
|
1509
|
-
expectedFilename
|
1550
|
+
expectedFilename +=
|
1510
1551
|
option.style === 'matchDocumentStyle' ? docName : convertCase(option.style, docName);
|
1511
1552
|
}
|
1512
1553
|
else {
|
1513
|
-
expectedFilename
|
1554
|
+
expectedFilename += filename;
|
1514
1555
|
}
|
1515
1556
|
expectedFilename += (option.suffix || '') + expectedExtension;
|
1516
1557
|
const filenameWithExtension = filename + expectedExtension;
|
package/package.json
CHANGED
package/rules/alphabetize.d.ts
CHANGED
@@ -59,6 +59,22 @@ declare const schema: {
|
|
59
59
|
readonly description: "Definitions – `type`, `interface`, `enum`, `scalar`, `input`, `union` and `directive`.";
|
60
60
|
readonly default: false;
|
61
61
|
};
|
62
|
+
readonly ignorePrefix: {
|
63
|
+
readonly type: "array";
|
64
|
+
readonly uniqueItems: true;
|
65
|
+
readonly minItems: 1;
|
66
|
+
readonly items: {
|
67
|
+
readonly type: "string";
|
68
|
+
};
|
69
|
+
};
|
70
|
+
readonly ignoreSuffix: {
|
71
|
+
readonly type: "array";
|
72
|
+
readonly uniqueItems: true;
|
73
|
+
readonly minItems: 1;
|
74
|
+
readonly items: {
|
75
|
+
readonly type: "string";
|
76
|
+
};
|
77
|
+
};
|
62
78
|
};
|
63
79
|
};
|
64
80
|
};
|
package/rules/index.d.ts
CHANGED
@@ -6,6 +6,8 @@ export declare const rules: {
|
|
6
6
|
values?: "EnumTypeDefinition"[];
|
7
7
|
fields?: import("json-schema-to-ts/lib/types/type-utils").Writable<"ObjectTypeDefinition" | "InterfaceTypeDefinition" | "InputObjectTypeDefinition">[];
|
8
8
|
variables?: "OperationDefinition"[];
|
9
|
+
ignorePrefix?: string[];
|
10
|
+
ignoreSuffix?: string[];
|
9
11
|
}[], false>;
|
10
12
|
'description-style': import("..").GraphQLESLintRule<{
|
11
13
|
style?: "block" | "inline";
|
@@ -23,18 +25,22 @@ export declare const rules: {
|
|
23
25
|
fragment?: import("json-schema-to-ts/lib/types/type-utils").Writable<import("../utils").CaseStyle | "matchDocumentStyle"> | {
|
24
26
|
style?: import("json-schema-to-ts/lib/types/type-utils").Writable<import("../utils").CaseStyle | "matchDocumentStyle">;
|
25
27
|
suffix?: string;
|
28
|
+
prefix?: string;
|
26
29
|
};
|
27
30
|
query?: import("json-schema-to-ts/lib/types/type-utils").Writable<import("../utils").CaseStyle | "matchDocumentStyle"> | {
|
28
31
|
style?: import("json-schema-to-ts/lib/types/type-utils").Writable<import("../utils").CaseStyle | "matchDocumentStyle">;
|
29
32
|
suffix?: string;
|
33
|
+
prefix?: string;
|
30
34
|
};
|
31
35
|
mutation?: import("json-schema-to-ts/lib/types/type-utils").Writable<import("../utils").CaseStyle | "matchDocumentStyle"> | {
|
32
36
|
style?: import("json-schema-to-ts/lib/types/type-utils").Writable<import("../utils").CaseStyle | "matchDocumentStyle">;
|
33
37
|
suffix?: string;
|
38
|
+
prefix?: string;
|
34
39
|
};
|
35
40
|
subscription?: import("json-schema-to-ts/lib/types/type-utils").Writable<import("../utils").CaseStyle | "matchDocumentStyle"> | {
|
36
41
|
style?: import("json-schema-to-ts/lib/types/type-utils").Writable<import("../utils").CaseStyle | "matchDocumentStyle">;
|
37
42
|
suffix?: string;
|
43
|
+
prefix?: string;
|
38
44
|
};
|
39
45
|
fileExtension?: ".gql" | ".graphql";
|
40
46
|
}[], false>;
|