@graphql-eslint/eslint-plugin 2.3.2-alpha-6695e95.0 → 2.3.2-alpha-53e82da.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 +21 -17
- package/index.mjs +21 -17
- package/package.json +1 -1
package/index.js
CHANGED
@@ -1626,7 +1626,7 @@ const rule$8 = {
|
|
1626
1626
|
});
|
1627
1627
|
if (result.ok === false) {
|
1628
1628
|
context.report({
|
1629
|
-
node,
|
1629
|
+
loc: getLocation(node.loc, node.value),
|
1630
1630
|
message: result.errorMessage,
|
1631
1631
|
data: {
|
1632
1632
|
prefix,
|
@@ -1653,10 +1653,16 @@ const rule$8 = {
|
|
1653
1653
|
return {
|
1654
1654
|
Name: node => {
|
1655
1655
|
if (node.value.startsWith('_') && options.leadingUnderscore === 'forbid') {
|
1656
|
-
context.report({
|
1656
|
+
context.report({
|
1657
|
+
loc: getLocation(node.loc, node.value),
|
1658
|
+
message: 'Leading underscores are not allowed',
|
1659
|
+
});
|
1657
1660
|
}
|
1658
1661
|
if (node.value.endsWith('_') && options.trailingUnderscore === 'forbid') {
|
1659
|
-
context.report({
|
1662
|
+
context.report({
|
1663
|
+
loc: getLocation(node.loc, node.value),
|
1664
|
+
message: 'Trailing underscores are not allowed',
|
1665
|
+
});
|
1660
1666
|
}
|
1661
1667
|
},
|
1662
1668
|
ObjectTypeDefinition: node => {
|
@@ -2415,10 +2421,10 @@ const rule$g = {
|
|
2415
2421
|
],
|
2416
2422
|
},
|
2417
2423
|
messages: {
|
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',
|
2424
|
+
[MESSAGE_REQUIRE_DATE]: 'Directive "@deprecated" must have a deletion date.',
|
2425
|
+
[MESSAGE_INVALID_FORMAT]: 'Deletion date must be in format "DD/MM/YYYY".',
|
2426
|
+
[MESSAGE_INVALID_DATE]: 'Invalid "{{ deletionDate }}" deletion date.',
|
2427
|
+
[MESSAGE_CAN_BE_REMOVED]: '"{{ nodeName }}" сan be removed.',
|
2422
2428
|
},
|
2423
2429
|
schema: [
|
2424
2430
|
{
|
@@ -2439,16 +2445,13 @@ const rule$g = {
|
|
2439
2445
|
const argName = ((_a = context.options[0]) === null || _a === void 0 ? void 0 : _a.argumentName) || 'deletionDate';
|
2440
2446
|
const deletionDateNode = node.arguments.find(arg => arg.name.value === argName);
|
2441
2447
|
if (!deletionDateNode) {
|
2442
|
-
context.report({
|
2443
|
-
loc: getLocation(node.loc, node.name.value, { offsetEnd: 0 }),
|
2444
|
-
messageId: MESSAGE_REQUIRE_DATE,
|
2445
|
-
});
|
2448
|
+
context.report({ node: node.name, messageId: MESSAGE_REQUIRE_DATE });
|
2446
2449
|
return;
|
2447
2450
|
}
|
2448
2451
|
const deletionDate = valueFromNode(deletionDateNode.value);
|
2449
2452
|
const isValidDate = DATE_REGEX.test(deletionDate);
|
2450
2453
|
if (!isValidDate) {
|
2451
|
-
context.report({ node:
|
2454
|
+
context.report({ node: node.name, messageId: MESSAGE_INVALID_FORMAT });
|
2452
2455
|
return;
|
2453
2456
|
}
|
2454
2457
|
let [day, month, year] = deletionDate.split('/');
|
@@ -2457,7 +2460,7 @@ const rule$g = {
|
|
2457
2460
|
const deletionDateInMS = Date.parse(`${year}-${month}-${day}`);
|
2458
2461
|
if (Number.isNaN(deletionDateInMS)) {
|
2459
2462
|
context.report({
|
2460
|
-
node:
|
2463
|
+
node: node.name,
|
2461
2464
|
messageId: MESSAGE_INVALID_DATE,
|
2462
2465
|
data: {
|
2463
2466
|
deletionDate,
|
@@ -2468,7 +2471,7 @@ const rule$g = {
|
|
2468
2471
|
const canRemove = Date.now() > deletionDateInMS;
|
2469
2472
|
if (canRemove) {
|
2470
2473
|
context.report({
|
2471
|
-
node,
|
2474
|
+
node: node.name,
|
2472
2475
|
messageId: MESSAGE_CAN_BE_REMOVED,
|
2473
2476
|
data: {
|
2474
2477
|
nodeName: node.parent.name.value,
|
@@ -3192,15 +3195,16 @@ const rule$m = {
|
|
3192
3195
|
}
|
3193
3196
|
return isValidIdName && isValidIdType;
|
3194
3197
|
});
|
3198
|
+
const typeName = node.name.value;
|
3195
3199
|
// Usually, there should be only one unique identifier field per type.
|
3196
3200
|
// Some clients allow multiple fields to be used. If more people need this,
|
3197
3201
|
// we can extend this rule later.
|
3198
3202
|
if (validIds.length !== 1) {
|
3199
3203
|
context.report({
|
3200
|
-
node,
|
3201
|
-
message:
|
3204
|
+
loc: getLocation(node.name.loc, typeName),
|
3205
|
+
message: `{{ typeName }} must have exactly one non-nullable unique identifier. Accepted name(s): {{ acceptedNamesString }} ; Accepted type(s): {{ acceptedTypesString }}`,
|
3202
3206
|
data: {
|
3203
|
-
|
3207
|
+
typeName,
|
3204
3208
|
acceptedNamesString: options.acceptedIdNames.join(','),
|
3205
3209
|
acceptedTypesString: options.acceptedIdTypes.join(','),
|
3206
3210
|
},
|
package/index.mjs
CHANGED
@@ -1620,7 +1620,7 @@ const rule$8 = {
|
|
1620
1620
|
});
|
1621
1621
|
if (result.ok === false) {
|
1622
1622
|
context.report({
|
1623
|
-
node,
|
1623
|
+
loc: getLocation(node.loc, node.value),
|
1624
1624
|
message: result.errorMessage,
|
1625
1625
|
data: {
|
1626
1626
|
prefix,
|
@@ -1647,10 +1647,16 @@ const rule$8 = {
|
|
1647
1647
|
return {
|
1648
1648
|
Name: node => {
|
1649
1649
|
if (node.value.startsWith('_') && options.leadingUnderscore === 'forbid') {
|
1650
|
-
context.report({
|
1650
|
+
context.report({
|
1651
|
+
loc: getLocation(node.loc, node.value),
|
1652
|
+
message: 'Leading underscores are not allowed',
|
1653
|
+
});
|
1651
1654
|
}
|
1652
1655
|
if (node.value.endsWith('_') && options.trailingUnderscore === 'forbid') {
|
1653
|
-
context.report({
|
1656
|
+
context.report({
|
1657
|
+
loc: getLocation(node.loc, node.value),
|
1658
|
+
message: 'Trailing underscores are not allowed',
|
1659
|
+
});
|
1654
1660
|
}
|
1655
1661
|
},
|
1656
1662
|
ObjectTypeDefinition: node => {
|
@@ -2409,10 +2415,10 @@ const rule$g = {
|
|
2409
2415
|
],
|
2410
2416
|
},
|
2411
2417
|
messages: {
|
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',
|
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.',
|
2416
2422
|
},
|
2417
2423
|
schema: [
|
2418
2424
|
{
|
@@ -2433,16 +2439,13 @@ const rule$g = {
|
|
2433
2439
|
const argName = ((_a = context.options[0]) === null || _a === void 0 ? void 0 : _a.argumentName) || 'deletionDate';
|
2434
2440
|
const deletionDateNode = node.arguments.find(arg => arg.name.value === argName);
|
2435
2441
|
if (!deletionDateNode) {
|
2436
|
-
context.report({
|
2437
|
-
loc: getLocation(node.loc, node.name.value, { offsetEnd: 0 }),
|
2438
|
-
messageId: MESSAGE_REQUIRE_DATE,
|
2439
|
-
});
|
2442
|
+
context.report({ node: node.name, messageId: MESSAGE_REQUIRE_DATE });
|
2440
2443
|
return;
|
2441
2444
|
}
|
2442
2445
|
const deletionDate = valueFromNode(deletionDateNode.value);
|
2443
2446
|
const isValidDate = DATE_REGEX.test(deletionDate);
|
2444
2447
|
if (!isValidDate) {
|
2445
|
-
context.report({ node:
|
2448
|
+
context.report({ node: node.name, messageId: MESSAGE_INVALID_FORMAT });
|
2446
2449
|
return;
|
2447
2450
|
}
|
2448
2451
|
let [day, month, year] = deletionDate.split('/');
|
@@ -2451,7 +2454,7 @@ const rule$g = {
|
|
2451
2454
|
const deletionDateInMS = Date.parse(`${year}-${month}-${day}`);
|
2452
2455
|
if (Number.isNaN(deletionDateInMS)) {
|
2453
2456
|
context.report({
|
2454
|
-
node:
|
2457
|
+
node: node.name,
|
2455
2458
|
messageId: MESSAGE_INVALID_DATE,
|
2456
2459
|
data: {
|
2457
2460
|
deletionDate,
|
@@ -2462,7 +2465,7 @@ const rule$g = {
|
|
2462
2465
|
const canRemove = Date.now() > deletionDateInMS;
|
2463
2466
|
if (canRemove) {
|
2464
2467
|
context.report({
|
2465
|
-
node,
|
2468
|
+
node: node.name,
|
2466
2469
|
messageId: MESSAGE_CAN_BE_REMOVED,
|
2467
2470
|
data: {
|
2468
2471
|
nodeName: node.parent.name.value,
|
@@ -3186,15 +3189,16 @@ const rule$m = {
|
|
3186
3189
|
}
|
3187
3190
|
return isValidIdName && isValidIdType;
|
3188
3191
|
});
|
3192
|
+
const typeName = node.name.value;
|
3189
3193
|
// Usually, there should be only one unique identifier field per type.
|
3190
3194
|
// Some clients allow multiple fields to be used. If more people need this,
|
3191
3195
|
// we can extend this rule later.
|
3192
3196
|
if (validIds.length !== 1) {
|
3193
3197
|
context.report({
|
3194
|
-
node,
|
3195
|
-
message:
|
3198
|
+
loc: getLocation(node.name.loc, typeName),
|
3199
|
+
message: `{{ typeName }} must have exactly one non-nullable unique identifier. Accepted name(s): {{ acceptedNamesString }} ; Accepted type(s): {{ acceptedTypesString }}`,
|
3196
3200
|
data: {
|
3197
|
-
|
3201
|
+
typeName,
|
3198
3202
|
acceptedNamesString: options.acceptedIdNames.join(','),
|
3199
3203
|
acceptedTypesString: options.acceptedIdTypes.join(','),
|
3200
3204
|
},
|
package/package.json
CHANGED