@graphql-eslint/eslint-plugin 2.3.2-alpha-5f59ef8.0 → 2.3.2-alpha-6c4312e.0
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 -11
- package/index.mjs +22 -11
- package/package.json +1 -1
- package/testkit.d.ts +1 -0
package/index.js
CHANGED
@@ -612,7 +612,7 @@ const rule = {
|
|
612
612
|
],
|
613
613
|
},
|
614
614
|
messages: {
|
615
|
-
[ALPHABETIZE]: '"{{ currName }}" should be before "{{ prevName }}"
|
615
|
+
[ALPHABETIZE]: '"{{ currName }}" should be before "{{ prevName }}"',
|
616
616
|
},
|
617
617
|
schema: {
|
618
618
|
type: 'array',
|
@@ -669,16 +669,9 @@ const rule = {
|
|
669
669
|
for (const node of nodes) {
|
670
670
|
const currName = node.name.value;
|
671
671
|
if (prevName && prevName > currName) {
|
672
|
-
const { start, end } = node.name.loc;
|
673
672
|
const isVariableNode = node.kind === graphql.Kind.VARIABLE;
|
674
673
|
context.report({
|
675
|
-
loc: {
|
676
|
-
start: {
|
677
|
-
line: start.line,
|
678
|
-
column: start.column - (isVariableNode ? 2 : 1),
|
679
|
-
},
|
680
|
-
end,
|
681
|
-
},
|
674
|
+
loc: getLocation(node.loc, node.name.value, { offsetEnd: isVariableNode ? 0 : 1 }),
|
682
675
|
messageId: ALPHABETIZE,
|
683
676
|
data: isVariableNode
|
684
677
|
? {
|
@@ -1126,7 +1119,7 @@ const rule$5 = {
|
|
1126
1119
|
'[description.type="StringValue"]': node => {
|
1127
1120
|
if (node.description.block !== (style === 'block')) {
|
1128
1121
|
context.report({
|
1129
|
-
|
1122
|
+
node: node.description,
|
1130
1123
|
message: `Unexpected ${wrongDescriptionType} description`,
|
1131
1124
|
});
|
1132
1125
|
}
|
@@ -3793,7 +3786,25 @@ class GraphQLRuleTester extends eslint.RuleTester {
|
|
3793
3786
|
return fs.readFileSync(path.resolve(__dirname, `../tests/mocks/${path$1}`), 'utf-8');
|
3794
3787
|
}
|
3795
3788
|
runGraphQLTests(name, rule, tests) {
|
3796
|
-
|
3789
|
+
const ruleTests = eslint.Linter.version.startsWith('8')
|
3790
|
+
? tests
|
3791
|
+
: {
|
3792
|
+
valid: tests.valid.map(test => {
|
3793
|
+
if (typeof test === 'string') {
|
3794
|
+
return test;
|
3795
|
+
}
|
3796
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
3797
|
+
const { name, ...testCaseOptions } = test;
|
3798
|
+
return testCaseOptions;
|
3799
|
+
}),
|
3800
|
+
invalid: tests.invalid.map(test => {
|
3801
|
+
// ESLint 7 throws an error on CI - Unexpected top-level property "name"
|
3802
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
3803
|
+
const { name, ...testCaseOptions } = test;
|
3804
|
+
return testCaseOptions;
|
3805
|
+
}),
|
3806
|
+
};
|
3807
|
+
super.run(name, rule, ruleTests);
|
3797
3808
|
// Skip snapshot testing if `expect` variable is not defined
|
3798
3809
|
if (typeof expect === 'undefined') {
|
3799
3810
|
return;
|
package/index.mjs
CHANGED
@@ -606,7 +606,7 @@ const rule = {
|
|
606
606
|
],
|
607
607
|
},
|
608
608
|
messages: {
|
609
|
-
[ALPHABETIZE]: '"{{ currName }}" should be before "{{ prevName }}"
|
609
|
+
[ALPHABETIZE]: '"{{ currName }}" should be before "{{ prevName }}"',
|
610
610
|
},
|
611
611
|
schema: {
|
612
612
|
type: 'array',
|
@@ -663,16 +663,9 @@ const rule = {
|
|
663
663
|
for (const node of nodes) {
|
664
664
|
const currName = node.name.value;
|
665
665
|
if (prevName && prevName > currName) {
|
666
|
-
const { start, end } = node.name.loc;
|
667
666
|
const isVariableNode = node.kind === Kind.VARIABLE;
|
668
667
|
context.report({
|
669
|
-
loc: {
|
670
|
-
start: {
|
671
|
-
line: start.line,
|
672
|
-
column: start.column - (isVariableNode ? 2 : 1),
|
673
|
-
},
|
674
|
-
end,
|
675
|
-
},
|
668
|
+
loc: getLocation(node.loc, node.name.value, { offsetEnd: isVariableNode ? 0 : 1 }),
|
676
669
|
messageId: ALPHABETIZE,
|
677
670
|
data: isVariableNode
|
678
671
|
? {
|
@@ -1120,7 +1113,7 @@ const rule$5 = {
|
|
1120
1113
|
'[description.type="StringValue"]': node => {
|
1121
1114
|
if (node.description.block !== (style === 'block')) {
|
1122
1115
|
context.report({
|
1123
|
-
|
1116
|
+
node: node.description,
|
1124
1117
|
message: `Unexpected ${wrongDescriptionType} description`,
|
1125
1118
|
});
|
1126
1119
|
}
|
@@ -3787,7 +3780,25 @@ class GraphQLRuleTester extends RuleTester {
|
|
3787
3780
|
return readFileSync(resolve(__dirname, `../tests/mocks/${path}`), 'utf-8');
|
3788
3781
|
}
|
3789
3782
|
runGraphQLTests(name, rule, tests) {
|
3790
|
-
|
3783
|
+
const ruleTests = Linter.version.startsWith('8')
|
3784
|
+
? tests
|
3785
|
+
: {
|
3786
|
+
valid: tests.valid.map(test => {
|
3787
|
+
if (typeof test === 'string') {
|
3788
|
+
return test;
|
3789
|
+
}
|
3790
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
3791
|
+
const { name, ...testCaseOptions } = test;
|
3792
|
+
return testCaseOptions;
|
3793
|
+
}),
|
3794
|
+
invalid: tests.invalid.map(test => {
|
3795
|
+
// ESLint 7 throws an error on CI - Unexpected top-level property "name"
|
3796
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
3797
|
+
const { name, ...testCaseOptions } = test;
|
3798
|
+
return testCaseOptions;
|
3799
|
+
}),
|
3800
|
+
};
|
3801
|
+
super.run(name, rule, ruleTests);
|
3791
3802
|
// Skip snapshot testing if `expect` variable is not defined
|
3792
3803
|
if (typeof expect === 'undefined') {
|
3793
3804
|
return;
|
package/package.json
CHANGED
package/testkit.d.ts
CHANGED
@@ -6,6 +6,7 @@ export declare type GraphQLESLintRuleListener<WithTypeInfo extends boolean = fal
|
|
6
6
|
[K in keyof ASTKindToNode]?: (node: GraphQLESTreeNode<ASTKindToNode[K], WithTypeInfo>) => void;
|
7
7
|
} & Record<string, any>;
|
8
8
|
export declare type GraphQLValidTestCase<Options> = Omit<RuleTester.ValidTestCase, 'options' | 'parserOptions'> & {
|
9
|
+
name: string;
|
9
10
|
options?: Options;
|
10
11
|
parserOptions?: ParserOptions;
|
11
12
|
};
|