@graphql-eslint/eslint-plugin 3.11.0-alpha-20220822143335-88b6bc0 → 3.11.0-alpha-20220828135426-e9545b1
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 +29 -30
- package/index.mjs +29 -30
- 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
@@ -705,6 +705,14 @@ const rule = {
|
|
705
705
|
description: 'Definitions – `type`, `interface`, `enum`, `scalar`, `input`, `union` and `directive`.',
|
706
706
|
default: false,
|
707
707
|
},
|
708
|
+
ignorePrefix: {
|
709
|
+
type: 'array',
|
710
|
+
default: [],
|
711
|
+
},
|
712
|
+
ignoreSuffix: {
|
713
|
+
type: 'array',
|
714
|
+
default: [],
|
715
|
+
},
|
708
716
|
},
|
709
717
|
},
|
710
718
|
},
|
@@ -759,6 +767,24 @@ const rule = {
|
|
759
767
|
const prevNode = nodes[i - 1];
|
760
768
|
const prevName = ('alias' in prevNode && ((_c = prevNode.alias) === null || _c === void 0 ? void 0 : _c.value)) || ('name' in prevNode && ((_d = prevNode.name) === null || _d === void 0 ? void 0 : _d.value));
|
761
769
|
if (prevName) {
|
770
|
+
if ((opts.ignorePrefix || []).length > 0) {
|
771
|
+
const shouldSkipIgnorePrefix = opts.ignorePrefix.some(prefix => prefix === prevName || prefix === currName || prevName.startsWith(prefix) || currName.startsWith(prefix));
|
772
|
+
if (shouldSkipIgnorePrefix) {
|
773
|
+
continue;
|
774
|
+
}
|
775
|
+
if (!shouldSkipIgnorePrefix) {
|
776
|
+
console.error(`${opts.ignorePrefix} is not match to "${prevName}" or "${currName}"`);
|
777
|
+
}
|
778
|
+
}
|
779
|
+
if ((opts.ignoreSuffix || []).length > 0) {
|
780
|
+
const shouldSkipIgnoreSuffix = opts.ignoreSuffix.some(suffix => suffix === prevName || suffix === currName || prevName.endsWith(suffix) || currName.endsWith(suffix));
|
781
|
+
if (shouldSkipIgnoreSuffix) {
|
782
|
+
continue;
|
783
|
+
}
|
784
|
+
if (!shouldSkipIgnoreSuffix) {
|
785
|
+
console.error(`${opts.ignoreSuffix} is not match to "${prevName}" or "${currName}"`);
|
786
|
+
}
|
787
|
+
}
|
762
788
|
// Compare with lexicographic order
|
763
789
|
const compareResult = prevName.localeCompare(currName);
|
764
790
|
const shouldSort = compareResult === 1;
|
@@ -1128,32 +1154,6 @@ const rule$3 = {
|
|
1128
1154
|
fullName
|
1129
1155
|
}
|
1130
1156
|
}
|
1131
|
-
`,
|
1132
|
-
},
|
1133
|
-
{
|
1134
|
-
title: 'Correct',
|
1135
|
-
usage: [{ fragment: { style: 'kebab-case', suffix: 'Mutation', prefix: 'mutation.' } }],
|
1136
|
-
name: 'mutation.add-alert.graphql',
|
1137
|
-
code: /* GraphQL */ `
|
1138
|
-
# mutation.add-alert.graphql
|
1139
|
-
mutation addAlert($input: AddAlertInput!) {
|
1140
|
-
addAlert(input: $input) {
|
1141
|
-
...AlertFields
|
1142
|
-
}
|
1143
|
-
}
|
1144
|
-
`,
|
1145
|
-
},
|
1146
|
-
{
|
1147
|
-
title: 'Correct',
|
1148
|
-
usage: [{ fragment: { prefix: 'query.' } }],
|
1149
|
-
name: 'query.me.graphql',
|
1150
|
-
code: /* GraphQL */ `
|
1151
|
-
# query.me.graphql
|
1152
|
-
query me {
|
1153
|
-
me {
|
1154
|
-
...UserFields
|
1155
|
-
}
|
1156
|
-
}
|
1157
1157
|
`,
|
1158
1158
|
},
|
1159
1159
|
],
|
@@ -1183,7 +1183,6 @@ const rule$3 = {
|
|
1183
1183
|
properties: {
|
1184
1184
|
style: { enum: CASE_STYLES },
|
1185
1185
|
suffix: { type: 'string' },
|
1186
|
-
prefix: { type: 'string' },
|
1187
1186
|
},
|
1188
1187
|
},
|
1189
1188
|
},
|
@@ -1249,12 +1248,12 @@ const rule$3 = {
|
|
1249
1248
|
option = { style: option };
|
1250
1249
|
}
|
1251
1250
|
const expectedExtension = options.fileExtension || fileExtension;
|
1252
|
-
let expectedFilename
|
1251
|
+
let expectedFilename;
|
1253
1252
|
if (option.style) {
|
1254
|
-
expectedFilename
|
1253
|
+
expectedFilename = option.style === 'matchDocumentStyle' ? docName : convertCase(option.style, docName);
|
1255
1254
|
}
|
1256
1255
|
else {
|
1257
|
-
expectedFilename
|
1256
|
+
expectedFilename = filename;
|
1258
1257
|
}
|
1259
1258
|
expectedFilename += (option.suffix || '') + expectedExtension;
|
1260
1259
|
const filenameWithExtension = filename + expectedExtension;
|
package/index.mjs
CHANGED
@@ -699,6 +699,14 @@ const rule = {
|
|
699
699
|
description: 'Definitions – `type`, `interface`, `enum`, `scalar`, `input`, `union` and `directive`.',
|
700
700
|
default: false,
|
701
701
|
},
|
702
|
+
ignorePrefix: {
|
703
|
+
type: 'array',
|
704
|
+
default: [],
|
705
|
+
},
|
706
|
+
ignoreSuffix: {
|
707
|
+
type: 'array',
|
708
|
+
default: [],
|
709
|
+
},
|
702
710
|
},
|
703
711
|
},
|
704
712
|
},
|
@@ -753,6 +761,24 @@ const rule = {
|
|
753
761
|
const prevNode = nodes[i - 1];
|
754
762
|
const prevName = ('alias' in prevNode && ((_c = prevNode.alias) === null || _c === void 0 ? void 0 : _c.value)) || ('name' in prevNode && ((_d = prevNode.name) === null || _d === void 0 ? void 0 : _d.value));
|
755
763
|
if (prevName) {
|
764
|
+
if ((opts.ignorePrefix || []).length > 0) {
|
765
|
+
const shouldSkipIgnorePrefix = opts.ignorePrefix.some(prefix => prefix === prevName || prefix === currName || prevName.startsWith(prefix) || currName.startsWith(prefix));
|
766
|
+
if (shouldSkipIgnorePrefix) {
|
767
|
+
continue;
|
768
|
+
}
|
769
|
+
if (!shouldSkipIgnorePrefix) {
|
770
|
+
console.error(`${opts.ignorePrefix} is not match to "${prevName}" or "${currName}"`);
|
771
|
+
}
|
772
|
+
}
|
773
|
+
if ((opts.ignoreSuffix || []).length > 0) {
|
774
|
+
const shouldSkipIgnoreSuffix = opts.ignoreSuffix.some(suffix => suffix === prevName || suffix === currName || prevName.endsWith(suffix) || currName.endsWith(suffix));
|
775
|
+
if (shouldSkipIgnoreSuffix) {
|
776
|
+
continue;
|
777
|
+
}
|
778
|
+
if (!shouldSkipIgnoreSuffix) {
|
779
|
+
console.error(`${opts.ignoreSuffix} is not match to "${prevName}" or "${currName}"`);
|
780
|
+
}
|
781
|
+
}
|
756
782
|
// Compare with lexicographic order
|
757
783
|
const compareResult = prevName.localeCompare(currName);
|
758
784
|
const shouldSort = compareResult === 1;
|
@@ -1122,32 +1148,6 @@ const rule$3 = {
|
|
1122
1148
|
fullName
|
1123
1149
|
}
|
1124
1150
|
}
|
1125
|
-
`,
|
1126
|
-
},
|
1127
|
-
{
|
1128
|
-
title: 'Correct',
|
1129
|
-
usage: [{ fragment: { style: 'kebab-case', suffix: 'Mutation', prefix: 'mutation.' } }],
|
1130
|
-
name: 'mutation.add-alert.graphql',
|
1131
|
-
code: /* GraphQL */ `
|
1132
|
-
# mutation.add-alert.graphql
|
1133
|
-
mutation addAlert($input: AddAlertInput!) {
|
1134
|
-
addAlert(input: $input) {
|
1135
|
-
...AlertFields
|
1136
|
-
}
|
1137
|
-
}
|
1138
|
-
`,
|
1139
|
-
},
|
1140
|
-
{
|
1141
|
-
title: 'Correct',
|
1142
|
-
usage: [{ fragment: { prefix: 'query.' } }],
|
1143
|
-
name: 'query.me.graphql',
|
1144
|
-
code: /* GraphQL */ `
|
1145
|
-
# query.me.graphql
|
1146
|
-
query me {
|
1147
|
-
me {
|
1148
|
-
...UserFields
|
1149
|
-
}
|
1150
|
-
}
|
1151
1151
|
`,
|
1152
1152
|
},
|
1153
1153
|
],
|
@@ -1177,7 +1177,6 @@ const rule$3 = {
|
|
1177
1177
|
properties: {
|
1178
1178
|
style: { enum: CASE_STYLES },
|
1179
1179
|
suffix: { type: 'string' },
|
1180
|
-
prefix: { type: 'string' },
|
1181
1180
|
},
|
1182
1181
|
},
|
1183
1182
|
},
|
@@ -1243,12 +1242,12 @@ const rule$3 = {
|
|
1243
1242
|
option = { style: option };
|
1244
1243
|
}
|
1245
1244
|
const expectedExtension = options.fileExtension || fileExtension;
|
1246
|
-
let expectedFilename
|
1245
|
+
let expectedFilename;
|
1247
1246
|
if (option.style) {
|
1248
|
-
expectedFilename
|
1247
|
+
expectedFilename = option.style === 'matchDocumentStyle' ? docName : convertCase(option.style, docName);
|
1249
1248
|
}
|
1250
1249
|
else {
|
1251
|
-
expectedFilename
|
1250
|
+
expectedFilename = filename;
|
1252
1251
|
}
|
1253
1252
|
expectedFilename += (option.suffix || '') + expectedExtension;
|
1254
1253
|
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;
|