@graphql-eslint/eslint-plugin 3.12.0-alpha-20220929103858-c00a837 → 3.12.0-alpha-20220929104135-4ef9ac0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/index.js +22 -29
- package/index.mjs +22 -29
- package/package.json +1 -1
- package/rules/alphabetize.d.ts +2 -0
- package/rules/match-document-filename.d.ts +0 -1
package/index.js
CHANGED
@@ -776,6 +776,14 @@ const rule = {
|
|
776
776
|
description: 'Definitions – `type`, `interface`, `enum`, `scalar`, `input`, `union` and `directive`.',
|
777
777
|
default: false,
|
778
778
|
},
|
779
|
+
ignorePrefix: {
|
780
|
+
type: 'array',
|
781
|
+
default: [],
|
782
|
+
},
|
783
|
+
ignoreSuffix: {
|
784
|
+
type: 'array',
|
785
|
+
default: [],
|
786
|
+
},
|
779
787
|
},
|
780
788
|
},
|
781
789
|
},
|
@@ -834,6 +842,18 @@ const rule = {
|
|
834
842
|
const prevName = ('alias' in prevNode && ((_c = prevNode.alias) === null || _c === void 0 ? void 0 : _c.value)) ||
|
835
843
|
('name' in prevNode && ((_d = prevNode.name) === null || _d === void 0 ? void 0 : _d.value));
|
836
844
|
if (prevName) {
|
845
|
+
if ((opts.ignorePrefix || []).length > 0) {
|
846
|
+
const shouldSkipIgnorePrefix = opts.ignorePrefix.some(prefix => prefix === prevName || prefix === currName || prevName.startsWith(prefix) || currName.startsWith(prefix));
|
847
|
+
if (shouldSkipIgnorePrefix) {
|
848
|
+
continue;
|
849
|
+
}
|
850
|
+
}
|
851
|
+
if ((opts.ignoreSuffix || []).length > 0) {
|
852
|
+
const shouldSkipIgnoreSuffix = opts.ignoreSuffix.some(suffix => suffix === prevName || suffix === currName || prevName.endsWith(suffix) || currName.endsWith(suffix));
|
853
|
+
if (shouldSkipIgnoreSuffix) {
|
854
|
+
continue;
|
855
|
+
}
|
856
|
+
}
|
837
857
|
// Compare with lexicographic order
|
838
858
|
const compareResult = prevName.localeCompare(currName);
|
839
859
|
const shouldSort = compareResult === 1;
|
@@ -1212,32 +1232,6 @@ const rule$3 = {
|
|
1212
1232
|
fullName
|
1213
1233
|
}
|
1214
1234
|
}
|
1215
|
-
`,
|
1216
|
-
},
|
1217
|
-
{
|
1218
|
-
title: 'Correct',
|
1219
|
-
usage: [{ fragment: { style: 'kebab-case', suffix: 'Mutation', prefix: 'mutation.' } }],
|
1220
|
-
name: 'mutation.add-alert.graphql',
|
1221
|
-
code: /* GraphQL */ `
|
1222
|
-
# mutation.add-alert.graphql
|
1223
|
-
mutation addAlert($input: AddAlertInput!) {
|
1224
|
-
addAlert(input: $input) {
|
1225
|
-
...AlertFields
|
1226
|
-
}
|
1227
|
-
}
|
1228
|
-
`,
|
1229
|
-
},
|
1230
|
-
{
|
1231
|
-
title: 'Correct',
|
1232
|
-
usage: [{ fragment: { prefix: 'query.' } }],
|
1233
|
-
name: 'query.me.graphql',
|
1234
|
-
code: /* GraphQL */ `
|
1235
|
-
# query.me.graphql
|
1236
|
-
query me {
|
1237
|
-
me {
|
1238
|
-
...UserFields
|
1239
|
-
}
|
1240
|
-
}
|
1241
1235
|
`,
|
1242
1236
|
},
|
1243
1237
|
],
|
@@ -1267,7 +1261,6 @@ const rule$3 = {
|
|
1267
1261
|
properties: {
|
1268
1262
|
style: { enum: CASE_STYLES },
|
1269
1263
|
suffix: { type: 'string' },
|
1270
|
-
prefix: { type: 'string' },
|
1271
1264
|
},
|
1272
1265
|
},
|
1273
1266
|
},
|
@@ -1333,13 +1326,13 @@ const rule$3 = {
|
|
1333
1326
|
option = { style: option };
|
1334
1327
|
}
|
1335
1328
|
const expectedExtension = options.fileExtension || fileExtension;
|
1336
|
-
let expectedFilename
|
1329
|
+
let expectedFilename;
|
1337
1330
|
if (option.style) {
|
1338
1331
|
expectedFilename =
|
1339
1332
|
option.style === 'matchDocumentStyle' ? docName : convertCase(option.style, docName);
|
1340
1333
|
}
|
1341
1334
|
else {
|
1342
|
-
expectedFilename
|
1335
|
+
expectedFilename = filename;
|
1343
1336
|
}
|
1344
1337
|
expectedFilename += (option.suffix || '') + expectedExtension;
|
1345
1338
|
const filenameWithExtension = filename + expectedExtension;
|
package/index.mjs
CHANGED
@@ -770,6 +770,14 @@ const rule = {
|
|
770
770
|
description: 'Definitions – `type`, `interface`, `enum`, `scalar`, `input`, `union` and `directive`.',
|
771
771
|
default: false,
|
772
772
|
},
|
773
|
+
ignorePrefix: {
|
774
|
+
type: 'array',
|
775
|
+
default: [],
|
776
|
+
},
|
777
|
+
ignoreSuffix: {
|
778
|
+
type: 'array',
|
779
|
+
default: [],
|
780
|
+
},
|
773
781
|
},
|
774
782
|
},
|
775
783
|
},
|
@@ -828,6 +836,18 @@ const rule = {
|
|
828
836
|
const prevName = ('alias' in prevNode && ((_c = prevNode.alias) === null || _c === void 0 ? void 0 : _c.value)) ||
|
829
837
|
('name' in prevNode && ((_d = prevNode.name) === null || _d === void 0 ? void 0 : _d.value));
|
830
838
|
if (prevName) {
|
839
|
+
if ((opts.ignorePrefix || []).length > 0) {
|
840
|
+
const shouldSkipIgnorePrefix = opts.ignorePrefix.some(prefix => prefix === prevName || prefix === currName || prevName.startsWith(prefix) || currName.startsWith(prefix));
|
841
|
+
if (shouldSkipIgnorePrefix) {
|
842
|
+
continue;
|
843
|
+
}
|
844
|
+
}
|
845
|
+
if ((opts.ignoreSuffix || []).length > 0) {
|
846
|
+
const shouldSkipIgnoreSuffix = opts.ignoreSuffix.some(suffix => suffix === prevName || suffix === currName || prevName.endsWith(suffix) || currName.endsWith(suffix));
|
847
|
+
if (shouldSkipIgnoreSuffix) {
|
848
|
+
continue;
|
849
|
+
}
|
850
|
+
}
|
831
851
|
// Compare with lexicographic order
|
832
852
|
const compareResult = prevName.localeCompare(currName);
|
833
853
|
const shouldSort = compareResult === 1;
|
@@ -1206,32 +1226,6 @@ const rule$3 = {
|
|
1206
1226
|
fullName
|
1207
1227
|
}
|
1208
1228
|
}
|
1209
|
-
`,
|
1210
|
-
},
|
1211
|
-
{
|
1212
|
-
title: 'Correct',
|
1213
|
-
usage: [{ fragment: { style: 'kebab-case', suffix: 'Mutation', prefix: 'mutation.' } }],
|
1214
|
-
name: 'mutation.add-alert.graphql',
|
1215
|
-
code: /* GraphQL */ `
|
1216
|
-
# mutation.add-alert.graphql
|
1217
|
-
mutation addAlert($input: AddAlertInput!) {
|
1218
|
-
addAlert(input: $input) {
|
1219
|
-
...AlertFields
|
1220
|
-
}
|
1221
|
-
}
|
1222
|
-
`,
|
1223
|
-
},
|
1224
|
-
{
|
1225
|
-
title: 'Correct',
|
1226
|
-
usage: [{ fragment: { prefix: 'query.' } }],
|
1227
|
-
name: 'query.me.graphql',
|
1228
|
-
code: /* GraphQL */ `
|
1229
|
-
# query.me.graphql
|
1230
|
-
query me {
|
1231
|
-
me {
|
1232
|
-
...UserFields
|
1233
|
-
}
|
1234
|
-
}
|
1235
1229
|
`,
|
1236
1230
|
},
|
1237
1231
|
],
|
@@ -1261,7 +1255,6 @@ const rule$3 = {
|
|
1261
1255
|
properties: {
|
1262
1256
|
style: { enum: CASE_STYLES },
|
1263
1257
|
suffix: { type: 'string' },
|
1264
|
-
prefix: { type: 'string' },
|
1265
1258
|
},
|
1266
1259
|
},
|
1267
1260
|
},
|
@@ -1327,13 +1320,13 @@ const rule$3 = {
|
|
1327
1320
|
option = { style: option };
|
1328
1321
|
}
|
1329
1322
|
const expectedExtension = options.fileExtension || fileExtension;
|
1330
|
-
let expectedFilename
|
1323
|
+
let expectedFilename;
|
1331
1324
|
if (option.style) {
|
1332
1325
|
expectedFilename =
|
1333
1326
|
option.style === 'matchDocumentStyle' ? docName : convertCase(option.style, docName);
|
1334
1327
|
}
|
1335
1328
|
else {
|
1336
|
-
expectedFilename
|
1329
|
+
expectedFilename = filename;
|
1337
1330
|
}
|
1338
1331
|
expectedFilename += (option.suffix || '') + expectedExtension;
|
1339
1332
|
const filenameWithExtension = filename + expectedExtension;
|
package/package.json
CHANGED
package/rules/alphabetize.d.ts
CHANGED
@@ -11,6 +11,8 @@ export declare type AlphabetizeConfig = {
|
|
11
11
|
variables?: typeof variablesEnum;
|
12
12
|
arguments?: typeof argumentsEnum;
|
13
13
|
definitions?: boolean;
|
14
|
+
ignorePrefix?: string[];
|
15
|
+
ignoreSuffix?: string[];
|
14
16
|
};
|
15
17
|
declare const rule: GraphQLESLintRule<[AlphabetizeConfig]>;
|
16
18
|
export default rule;
|