@graphql-eslint/eslint-plugin 3.11.2 → 3.12.0-alpha-20220929104135-4ef9ac0
Sign up to get free protection for your applications and to get access to all the features.
- package/index.js +20 -0
- package/index.mjs +20 -0
- package/package.json +1 -1
- package/rules/alphabetize.d.ts +2 -0
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;
|
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;
|
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;
|