@graphql-eslint/eslint-plugin 2.3.2-alpha-6c4312e.0 → 2.3.2-alpha-da2ba63.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 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,9 +669,16 @@ 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;
672
673
  const isVariableNode = node.kind === graphql.Kind.VARIABLE;
673
674
  context.report({
674
- loc: getLocation(node.loc, node.name.value, { offsetEnd: isVariableNode ? 0 : 1 }),
675
+ loc: {
676
+ start: {
677
+ line: start.line,
678
+ column: start.column - (isVariableNode ? 2 : 1),
679
+ },
680
+ end,
681
+ },
675
682
  messageId: ALPHABETIZE,
676
683
  data: isVariableNode
677
684
  ? {
@@ -2155,7 +2162,7 @@ const rule$e = {
2155
2162
  const typeName = node.name.value;
2156
2163
  if (!reachableTypes.has(typeName)) {
2157
2164
  context.report({
2158
- node,
2165
+ loc: getLocation(node.name.loc, typeName, { offsetStart: node.kind === graphql.Kind.DIRECTIVE_DEFINITION ? 2 : 1 }),
2159
2166
  messageId: UNREACHABLE_TYPE,
2160
2167
  data: { typeName },
2161
2168
  fix: fixer => fixer.remove(node),
@@ -2253,7 +2260,7 @@ const rule$f = {
2253
2260
  return;
2254
2261
  }
2255
2262
  context.report({
2256
- node,
2263
+ loc: getLocation(node.loc, fieldName),
2257
2264
  messageId: UNUSED_FIELD,
2258
2265
  data: { fieldName },
2259
2266
  fix(fixer) {
@@ -3786,25 +3793,7 @@ class GraphQLRuleTester extends eslint.RuleTester {
3786
3793
  return fs.readFileSync(path.resolve(__dirname, `../tests/mocks/${path$1}`), 'utf-8');
3787
3794
  }
3788
3795
  runGraphQLTests(name, rule, tests) {
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);
3796
+ super.run(name, rule, tests);
3808
3797
  // Skip snapshot testing if `expect` variable is not defined
3809
3798
  if (typeof expect === 'undefined') {
3810
3799
  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,9 +663,16 @@ 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;
666
667
  const isVariableNode = node.kind === Kind.VARIABLE;
667
668
  context.report({
668
- loc: getLocation(node.loc, node.name.value, { offsetEnd: isVariableNode ? 0 : 1 }),
669
+ loc: {
670
+ start: {
671
+ line: start.line,
672
+ column: start.column - (isVariableNode ? 2 : 1),
673
+ },
674
+ end,
675
+ },
669
676
  messageId: ALPHABETIZE,
670
677
  data: isVariableNode
671
678
  ? {
@@ -2149,7 +2156,7 @@ const rule$e = {
2149
2156
  const typeName = node.name.value;
2150
2157
  if (!reachableTypes.has(typeName)) {
2151
2158
  context.report({
2152
- node,
2159
+ loc: getLocation(node.name.loc, typeName, { offsetStart: node.kind === Kind.DIRECTIVE_DEFINITION ? 2 : 1 }),
2153
2160
  messageId: UNREACHABLE_TYPE,
2154
2161
  data: { typeName },
2155
2162
  fix: fixer => fixer.remove(node),
@@ -2247,7 +2254,7 @@ const rule$f = {
2247
2254
  return;
2248
2255
  }
2249
2256
  context.report({
2250
- node,
2257
+ loc: getLocation(node.loc, fieldName),
2251
2258
  messageId: UNUSED_FIELD,
2252
2259
  data: { fieldName },
2253
2260
  fix(fixer) {
@@ -3780,25 +3787,7 @@ class GraphQLRuleTester extends RuleTester {
3780
3787
  return readFileSync(resolve(__dirname, `../tests/mocks/${path}`), 'utf-8');
3781
3788
  }
3782
3789
  runGraphQLTests(name, rule, tests) {
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);
3790
+ super.run(name, rule, tests);
3802
3791
  // Skip snapshot testing if `expect` variable is not defined
3803
3792
  if (typeof expect === 'undefined') {
3804
3793
  return;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@graphql-eslint/eslint-plugin",
3
- "version": "2.3.2-alpha-6c4312e.0",
3
+ "version": "2.3.2-alpha-da2ba63.0",
4
4
  "sideEffects": false,
5
5
  "peerDependencies": {
6
6
  "graphql": "^0.8.0 || ^0.9.0 || ^0.10.0 || ^0.11.0 || ^0.12.0 || ^0.13.0 || ^14.0.0 || ^15.0.0"
package/testkit.d.ts CHANGED
@@ -6,7 +6,6 @@ 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;
10
9
  options?: Options;
11
10
  parserOptions?: ParserOptions;
12
11
  };