@graphql-eslint/eslint-plugin 2.4.0-alpha-a96ed5f.0 → 2.4.0-alpha-647cfc7.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 +28 -12
- package/index.mjs +28 -12
- package/package.json +1 -1
- package/types.d.ts +1 -0
package/index.js
CHANGED
@@ -910,15 +910,16 @@ const rule$2 = {
|
|
910
910
|
const testKeyword = caseSensitive ? keyword : keyword.toLowerCase();
|
911
911
|
const testName = caseSensitive ? node.name.value : node.name.value.toLowerCase();
|
912
912
|
if (testName.startsWith(testKeyword)) {
|
913
|
+
const { start } = node.name.loc;
|
913
914
|
context.report({
|
914
915
|
loc: {
|
915
916
|
start: {
|
916
|
-
line:
|
917
|
-
column:
|
917
|
+
line: start.line,
|
918
|
+
column: start.column - 1,
|
918
919
|
},
|
919
920
|
end: {
|
920
|
-
line:
|
921
|
-
column:
|
921
|
+
line: start.line,
|
922
|
+
column: start.column - 1 + testKeyword.length,
|
922
923
|
},
|
923
924
|
},
|
924
925
|
data: {
|
@@ -2043,11 +2044,23 @@ const rule$d = {
|
|
2043
2044
|
create(context) {
|
2044
2045
|
return {
|
2045
2046
|
'OperationDefinition, FragmentDefinition'(node) {
|
2046
|
-
|
2047
|
-
|
2048
|
-
|
2047
|
+
var _a;
|
2048
|
+
const name = ((_a = node.name) === null || _a === void 0 ? void 0 : _a.value) || '';
|
2049
|
+
if (name.length > 0) {
|
2050
|
+
const invalidSuffix = 'operation' in node ? node.operation : 'fragment';
|
2051
|
+
if (name.toLowerCase().endsWith(invalidSuffix)) {
|
2052
|
+
const { start, end } = node.name.loc;
|
2049
2053
|
context.report({
|
2050
|
-
|
2054
|
+
loc: {
|
2055
|
+
start: {
|
2056
|
+
column: start.column - 1 + name.length - invalidSuffix.length,
|
2057
|
+
line: start.line,
|
2058
|
+
},
|
2059
|
+
end: {
|
2060
|
+
column: end.column - 1 + name.length,
|
2061
|
+
line: end.line,
|
2062
|
+
},
|
2063
|
+
},
|
2051
2064
|
data: {
|
2052
2065
|
invalidSuffix,
|
2053
2066
|
},
|
@@ -2499,15 +2512,18 @@ const DESCRIBABLE_NODES = [
|
|
2499
2512
|
function verifyRule(context, node) {
|
2500
2513
|
if (node) {
|
2501
2514
|
if (!node.description || !node.description.value || node.description.value.trim().length === 0) {
|
2515
|
+
const { start, end } = ('name' in node ? node.name : node).loc;
|
2502
2516
|
context.report({
|
2503
2517
|
loc: {
|
2504
2518
|
start: {
|
2505
|
-
line:
|
2506
|
-
column:
|
2519
|
+
line: start.line,
|
2520
|
+
column: start.column - 1,
|
2507
2521
|
},
|
2508
2522
|
end: {
|
2509
|
-
line:
|
2510
|
-
column:
|
2523
|
+
line: end.line,
|
2524
|
+
column:
|
2525
|
+
// node.name don't exist on SchemaDefinition
|
2526
|
+
'name' in node ? end.column - 1 + node.name.value.length : end.column,
|
2511
2527
|
},
|
2512
2528
|
},
|
2513
2529
|
messageId: REQUIRE_DESCRIPTION_ERROR,
|
package/index.mjs
CHANGED
@@ -904,15 +904,16 @@ const rule$2 = {
|
|
904
904
|
const testKeyword = caseSensitive ? keyword : keyword.toLowerCase();
|
905
905
|
const testName = caseSensitive ? node.name.value : node.name.value.toLowerCase();
|
906
906
|
if (testName.startsWith(testKeyword)) {
|
907
|
+
const { start } = node.name.loc;
|
907
908
|
context.report({
|
908
909
|
loc: {
|
909
910
|
start: {
|
910
|
-
line:
|
911
|
-
column:
|
911
|
+
line: start.line,
|
912
|
+
column: start.column - 1,
|
912
913
|
},
|
913
914
|
end: {
|
914
|
-
line:
|
915
|
-
column:
|
915
|
+
line: start.line,
|
916
|
+
column: start.column - 1 + testKeyword.length,
|
916
917
|
},
|
917
918
|
},
|
918
919
|
data: {
|
@@ -2037,11 +2038,23 @@ const rule$d = {
|
|
2037
2038
|
create(context) {
|
2038
2039
|
return {
|
2039
2040
|
'OperationDefinition, FragmentDefinition'(node) {
|
2040
|
-
|
2041
|
-
|
2042
|
-
|
2041
|
+
var _a;
|
2042
|
+
const name = ((_a = node.name) === null || _a === void 0 ? void 0 : _a.value) || '';
|
2043
|
+
if (name.length > 0) {
|
2044
|
+
const invalidSuffix = 'operation' in node ? node.operation : 'fragment';
|
2045
|
+
if (name.toLowerCase().endsWith(invalidSuffix)) {
|
2046
|
+
const { start, end } = node.name.loc;
|
2043
2047
|
context.report({
|
2044
|
-
|
2048
|
+
loc: {
|
2049
|
+
start: {
|
2050
|
+
column: start.column - 1 + name.length - invalidSuffix.length,
|
2051
|
+
line: start.line,
|
2052
|
+
},
|
2053
|
+
end: {
|
2054
|
+
column: end.column - 1 + name.length,
|
2055
|
+
line: end.line,
|
2056
|
+
},
|
2057
|
+
},
|
2045
2058
|
data: {
|
2046
2059
|
invalidSuffix,
|
2047
2060
|
},
|
@@ -2493,15 +2506,18 @@ const DESCRIBABLE_NODES = [
|
|
2493
2506
|
function verifyRule(context, node) {
|
2494
2507
|
if (node) {
|
2495
2508
|
if (!node.description || !node.description.value || node.description.value.trim().length === 0) {
|
2509
|
+
const { start, end } = ('name' in node ? node.name : node).loc;
|
2496
2510
|
context.report({
|
2497
2511
|
loc: {
|
2498
2512
|
start: {
|
2499
|
-
line:
|
2500
|
-
column:
|
2513
|
+
line: start.line,
|
2514
|
+
column: start.column - 1,
|
2501
2515
|
},
|
2502
2516
|
end: {
|
2503
|
-
line:
|
2504
|
-
column:
|
2517
|
+
line: end.line,
|
2518
|
+
column:
|
2519
|
+
// node.name don't exist on SchemaDefinition
|
2520
|
+
'name' in node ? end.column - 1 + node.name.value.length : end.column,
|
2505
2521
|
},
|
2506
2522
|
},
|
2507
2523
|
messageId: REQUIRE_DESCRIPTION_ERROR,
|
package/package.json
CHANGED
package/types.d.ts
CHANGED
@@ -62,3 +62,4 @@ export declare type GraphQLESLintRule<Options = any[], WithTypeInfo extends bool
|
|
62
62
|
create(context: GraphQLESLintRuleContext<Options>): GraphQLESLintRuleListener<WithTypeInfo>;
|
63
63
|
meta: Rule.RuleMetaData & RuleDocsInfo<Options>;
|
64
64
|
};
|
65
|
+
export declare type ValueOf<T> = T[keyof T];
|