@graphql-eslint/eslint-plugin 2.3.2-alpha-2901045.0 → 2.3.2-alpha-13a11c2.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.
Files changed (3) hide show
  1. package/index.js +26 -13
  2. package/index.mjs +26 -13
  3. package/package.json +1 -1
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
  ? {
@@ -981,16 +988,20 @@ const rule$3 = {
981
988
  if (!mutationType) {
982
989
  return {};
983
990
  }
984
- const selector = `:matches(${graphql.Kind.OBJECT_TYPE_DEFINITION}, ${graphql.Kind.OBJECT_TYPE_EXTENSION})[name.value=${mutationType.name}] > ${graphql.Kind.FIELD_DEFINITION}`;
991
+ const selector = [
992
+ `:matches(${graphql.Kind.OBJECT_TYPE_DEFINITION}, ${graphql.Kind.OBJECT_TYPE_EXTENSION})[name.value=${mutationType.name}]`,
993
+ '>',
994
+ graphql.Kind.FIELD_DEFINITION,
995
+ graphql.Kind.NAMED_TYPE,
996
+ ].join(' ');
985
997
  return {
986
998
  [selector](node) {
987
- const rawNode = node.rawNode();
988
- const typeName = getTypeName(rawNode);
999
+ const typeName = node.name.value;
989
1000
  const graphQLType = schema.getType(typeName);
990
1001
  if (graphql.isScalarType(graphQLType)) {
991
1002
  context.report({
992
- node,
993
- message: `Unexpected scalar result type "${typeName}".`,
1003
+ loc: getLocation(node.loc, typeName),
1004
+ message: `Unexpected scalar result type "${typeName}"`,
994
1005
  });
995
1006
  }
996
1007
  },
@@ -1202,10 +1213,11 @@ const rule$6 = {
1202
1213
  const shouldCheckType = node => (options.checkMutations && isMutationType(node)) || (options.checkQueries && isQueryType(node));
1203
1214
  const listeners = {
1204
1215
  'FieldDefinition > InputValueDefinition': node => {
1205
- if (node.name.value !== 'input' && shouldCheckType(node.parent.parent)) {
1216
+ const name = node.name.value;
1217
+ if (name !== 'input' && shouldCheckType(node.parent.parent)) {
1206
1218
  context.report({
1207
- node: node.name,
1208
- message: `Input "${node.name.value}" should be called "input"`,
1219
+ loc: getLocation(node.loc, name),
1220
+ message: `Input "${name}" should be called "input"`,
1209
1221
  });
1210
1222
  }
1211
1223
  },
@@ -1222,11 +1234,12 @@ const rule$6 = {
1222
1234
  const inputValueNode = findInputType(node);
1223
1235
  if (shouldCheckType(inputValueNode.parent.parent)) {
1224
1236
  const mutationName = `${inputValueNode.parent.name.value}Input`;
1237
+ const name = node.name.value;
1225
1238
  if ((options.caseSensitiveInputType && node.name.value !== mutationName) ||
1226
- node.name.value.toLowerCase() !== mutationName.toLowerCase()) {
1239
+ name.toLowerCase() !== mutationName.toLowerCase()) {
1227
1240
  context.report({
1228
- node,
1229
- message: `InputType "${node.name.value}" name should be "${mutationName}"`,
1241
+ loc: getLocation(node.loc, name),
1242
+ message: `InputType "${name}" name should be "${mutationName}"`,
1230
1243
  });
1231
1244
  }
1232
1245
  }
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
  ? {
@@ -975,16 +982,20 @@ const rule$3 = {
975
982
  if (!mutationType) {
976
983
  return {};
977
984
  }
978
- const selector = `:matches(${Kind.OBJECT_TYPE_DEFINITION}, ${Kind.OBJECT_TYPE_EXTENSION})[name.value=${mutationType.name}] > ${Kind.FIELD_DEFINITION}`;
985
+ const selector = [
986
+ `:matches(${Kind.OBJECT_TYPE_DEFINITION}, ${Kind.OBJECT_TYPE_EXTENSION})[name.value=${mutationType.name}]`,
987
+ '>',
988
+ Kind.FIELD_DEFINITION,
989
+ Kind.NAMED_TYPE,
990
+ ].join(' ');
979
991
  return {
980
992
  [selector](node) {
981
- const rawNode = node.rawNode();
982
- const typeName = getTypeName(rawNode);
993
+ const typeName = node.name.value;
983
994
  const graphQLType = schema.getType(typeName);
984
995
  if (isScalarType(graphQLType)) {
985
996
  context.report({
986
- node,
987
- message: `Unexpected scalar result type "${typeName}".`,
997
+ loc: getLocation(node.loc, typeName),
998
+ message: `Unexpected scalar result type "${typeName}"`,
988
999
  });
989
1000
  }
990
1001
  },
@@ -1196,10 +1207,11 @@ const rule$6 = {
1196
1207
  const shouldCheckType = node => (options.checkMutations && isMutationType(node)) || (options.checkQueries && isQueryType(node));
1197
1208
  const listeners = {
1198
1209
  'FieldDefinition > InputValueDefinition': node => {
1199
- if (node.name.value !== 'input' && shouldCheckType(node.parent.parent)) {
1210
+ const name = node.name.value;
1211
+ if (name !== 'input' && shouldCheckType(node.parent.parent)) {
1200
1212
  context.report({
1201
- node: node.name,
1202
- message: `Input "${node.name.value}" should be called "input"`,
1213
+ loc: getLocation(node.loc, name),
1214
+ message: `Input "${name}" should be called "input"`,
1203
1215
  });
1204
1216
  }
1205
1217
  },
@@ -1216,11 +1228,12 @@ const rule$6 = {
1216
1228
  const inputValueNode = findInputType(node);
1217
1229
  if (shouldCheckType(inputValueNode.parent.parent)) {
1218
1230
  const mutationName = `${inputValueNode.parent.name.value}Input`;
1231
+ const name = node.name.value;
1219
1232
  if ((options.caseSensitiveInputType && node.name.value !== mutationName) ||
1220
- node.name.value.toLowerCase() !== mutationName.toLowerCase()) {
1233
+ name.toLowerCase() !== mutationName.toLowerCase()) {
1221
1234
  context.report({
1222
- node,
1223
- message: `InputType "${node.name.value}" name should be "${mutationName}"`,
1235
+ loc: getLocation(node.loc, name),
1236
+ message: `InputType "${name}" name should be "${mutationName}"`,
1224
1237
  });
1225
1238
  }
1226
1239
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@graphql-eslint/eslint-plugin",
3
- "version": "2.3.2-alpha-2901045.0",
3
+ "version": "2.3.2-alpha-13a11c2.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"