@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.
- package/index.js +26 -13
- package/index.mjs +26 -13
- 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:
|
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 =
|
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
|
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
|
-
|
1216
|
+
const name = node.name.value;
|
1217
|
+
if (name !== 'input' && shouldCheckType(node.parent.parent)) {
|
1206
1218
|
context.report({
|
1207
|
-
|
1208
|
-
message: `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
|
-
|
1239
|
+
name.toLowerCase() !== mutationName.toLowerCase()) {
|
1227
1240
|
context.report({
|
1228
|
-
node,
|
1229
|
-
message: `InputType "${
|
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:
|
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 =
|
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
|
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
|
-
|
1210
|
+
const name = node.name.value;
|
1211
|
+
if (name !== 'input' && shouldCheckType(node.parent.parent)) {
|
1200
1212
|
context.report({
|
1201
|
-
|
1202
|
-
message: `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
|
-
|
1233
|
+
name.toLowerCase() !== mutationName.toLowerCase()) {
|
1221
1234
|
context.report({
|
1222
|
-
node,
|
1223
|
-
message: `InputType "${
|
1235
|
+
loc: getLocation(node.loc, name),
|
1236
|
+
message: `InputType "${name}" name should be "${mutationName}"`,
|
1224
1237
|
});
|
1225
1238
|
}
|
1226
1239
|
}
|
package/package.json
CHANGED