@graphql-eslint/eslint-plugin 2.3.2-alpha-99be3d2.0 → 2.3.2-alpha-6695e95.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 +20 -13
  2. package/index.mjs +20 -13
  3. package/package.json +1 -1
package/index.js CHANGED
@@ -988,16 +988,20 @@ const rule$3 = {
988
988
  if (!mutationType) {
989
989
  return {};
990
990
  }
991
- 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(' ');
992
997
  return {
993
998
  [selector](node) {
994
- const rawNode = node.rawNode();
995
- const typeName = getTypeName(rawNode);
999
+ const typeName = node.name.value;
996
1000
  const graphQLType = schema.getType(typeName);
997
1001
  if (graphql.isScalarType(graphQLType)) {
998
1002
  context.report({
999
- node,
1000
- message: `Unexpected scalar result type "${typeName}".`,
1003
+ loc: getLocation(node.loc, typeName),
1004
+ message: `Unexpected scalar result type "${typeName}"`,
1001
1005
  });
1002
1006
  }
1003
1007
  },
@@ -2411,10 +2415,10 @@ const rule$g = {
2411
2415
  ],
2412
2416
  },
2413
2417
  messages: {
2414
- [MESSAGE_REQUIRE_DATE]: 'Directive "@deprecated" must have a deletion date.',
2415
- [MESSAGE_INVALID_FORMAT]: 'Deletion date must be in format "DD/MM/YYYY".',
2416
- [MESSAGE_INVALID_DATE]: 'Invalid "{{ deletionDate }}" deletion date.',
2417
- [MESSAGE_CAN_BE_REMOVED]: '"{{ nodeName }}" сan be removed.',
2418
+ [MESSAGE_REQUIRE_DATE]: 'Directive "@deprecated" must have a deletion date',
2419
+ [MESSAGE_INVALID_FORMAT]: 'Deletion date must be in format "DD/MM/YYYY"',
2420
+ [MESSAGE_INVALID_DATE]: 'Invalid "{{ deletionDate }}" deletion date',
2421
+ [MESSAGE_CAN_BE_REMOVED]: '"{{ nodeName }}" сan be removed',
2418
2422
  },
2419
2423
  schema: [
2420
2424
  {
@@ -2435,13 +2439,16 @@ const rule$g = {
2435
2439
  const argName = ((_a = context.options[0]) === null || _a === void 0 ? void 0 : _a.argumentName) || 'deletionDate';
2436
2440
  const deletionDateNode = node.arguments.find(arg => arg.name.value === argName);
2437
2441
  if (!deletionDateNode) {
2438
- context.report({ node: node.name, messageId: MESSAGE_REQUIRE_DATE });
2442
+ context.report({
2443
+ loc: getLocation(node.loc, node.name.value, { offsetEnd: 0 }),
2444
+ messageId: MESSAGE_REQUIRE_DATE,
2445
+ });
2439
2446
  return;
2440
2447
  }
2441
2448
  const deletionDate = valueFromNode(deletionDateNode.value);
2442
2449
  const isValidDate = DATE_REGEX.test(deletionDate);
2443
2450
  if (!isValidDate) {
2444
- context.report({ node: node.name, messageId: MESSAGE_INVALID_FORMAT });
2451
+ context.report({ node: deletionDateNode.value, messageId: MESSAGE_INVALID_FORMAT });
2445
2452
  return;
2446
2453
  }
2447
2454
  let [day, month, year] = deletionDate.split('/');
@@ -2450,7 +2457,7 @@ const rule$g = {
2450
2457
  const deletionDateInMS = Date.parse(`${year}-${month}-${day}`);
2451
2458
  if (Number.isNaN(deletionDateInMS)) {
2452
2459
  context.report({
2453
- node: node.name,
2460
+ node: deletionDateNode.value,
2454
2461
  messageId: MESSAGE_INVALID_DATE,
2455
2462
  data: {
2456
2463
  deletionDate,
@@ -2461,7 +2468,7 @@ const rule$g = {
2461
2468
  const canRemove = Date.now() > deletionDateInMS;
2462
2469
  if (canRemove) {
2463
2470
  context.report({
2464
- node: node.name,
2471
+ node,
2465
2472
  messageId: MESSAGE_CAN_BE_REMOVED,
2466
2473
  data: {
2467
2474
  nodeName: node.parent.name.value,
package/index.mjs CHANGED
@@ -982,16 +982,20 @@ const rule$3 = {
982
982
  if (!mutationType) {
983
983
  return {};
984
984
  }
985
- 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(' ');
986
991
  return {
987
992
  [selector](node) {
988
- const rawNode = node.rawNode();
989
- const typeName = getTypeName(rawNode);
993
+ const typeName = node.name.value;
990
994
  const graphQLType = schema.getType(typeName);
991
995
  if (isScalarType(graphQLType)) {
992
996
  context.report({
993
- node,
994
- message: `Unexpected scalar result type "${typeName}".`,
997
+ loc: getLocation(node.loc, typeName),
998
+ message: `Unexpected scalar result type "${typeName}"`,
995
999
  });
996
1000
  }
997
1001
  },
@@ -2405,10 +2409,10 @@ const rule$g = {
2405
2409
  ],
2406
2410
  },
2407
2411
  messages: {
2408
- [MESSAGE_REQUIRE_DATE]: 'Directive "@deprecated" must have a deletion date.',
2409
- [MESSAGE_INVALID_FORMAT]: 'Deletion date must be in format "DD/MM/YYYY".',
2410
- [MESSAGE_INVALID_DATE]: 'Invalid "{{ deletionDate }}" deletion date.',
2411
- [MESSAGE_CAN_BE_REMOVED]: '"{{ nodeName }}" сan be removed.',
2412
+ [MESSAGE_REQUIRE_DATE]: 'Directive "@deprecated" must have a deletion date',
2413
+ [MESSAGE_INVALID_FORMAT]: 'Deletion date must be in format "DD/MM/YYYY"',
2414
+ [MESSAGE_INVALID_DATE]: 'Invalid "{{ deletionDate }}" deletion date',
2415
+ [MESSAGE_CAN_BE_REMOVED]: '"{{ nodeName }}" сan be removed',
2412
2416
  },
2413
2417
  schema: [
2414
2418
  {
@@ -2429,13 +2433,16 @@ const rule$g = {
2429
2433
  const argName = ((_a = context.options[0]) === null || _a === void 0 ? void 0 : _a.argumentName) || 'deletionDate';
2430
2434
  const deletionDateNode = node.arguments.find(arg => arg.name.value === argName);
2431
2435
  if (!deletionDateNode) {
2432
- context.report({ node: node.name, messageId: MESSAGE_REQUIRE_DATE });
2436
+ context.report({
2437
+ loc: getLocation(node.loc, node.name.value, { offsetEnd: 0 }),
2438
+ messageId: MESSAGE_REQUIRE_DATE,
2439
+ });
2433
2440
  return;
2434
2441
  }
2435
2442
  const deletionDate = valueFromNode(deletionDateNode.value);
2436
2443
  const isValidDate = DATE_REGEX.test(deletionDate);
2437
2444
  if (!isValidDate) {
2438
- context.report({ node: node.name, messageId: MESSAGE_INVALID_FORMAT });
2445
+ context.report({ node: deletionDateNode.value, messageId: MESSAGE_INVALID_FORMAT });
2439
2446
  return;
2440
2447
  }
2441
2448
  let [day, month, year] = deletionDate.split('/');
@@ -2444,7 +2451,7 @@ const rule$g = {
2444
2451
  const deletionDateInMS = Date.parse(`${year}-${month}-${day}`);
2445
2452
  if (Number.isNaN(deletionDateInMS)) {
2446
2453
  context.report({
2447
- node: node.name,
2454
+ node: deletionDateNode.value,
2448
2455
  messageId: MESSAGE_INVALID_DATE,
2449
2456
  data: {
2450
2457
  deletionDate,
@@ -2455,7 +2462,7 @@ const rule$g = {
2455
2462
  const canRemove = Date.now() > deletionDateInMS;
2456
2463
  if (canRemove) {
2457
2464
  context.report({
2458
- node: node.name,
2465
+ node,
2459
2466
  messageId: MESSAGE_CAN_BE_REMOVED,
2460
2467
  data: {
2461
2468
  nodeName: node.parent.name.value,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@graphql-eslint/eslint-plugin",
3
- "version": "2.3.2-alpha-99be3d2.0",
3
+ "version": "2.3.2-alpha-6695e95.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"