Skip to content

Commit 9ff4661

Browse files
committed
linting
1 parent 3849977 commit 9ff4661

File tree

7 files changed

+34
-100
lines changed

7 files changed

+34
-100
lines changed

protographic/src/operation-to-proto.ts

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -78,25 +78,20 @@ export function compileOperationsToProto(
7878
const document: DocumentNode = typeof operationSource === 'string' ? parse(operationSource) : operationSource;
7979

8080
// Validate that only a single named operation is present
81-
const namedOperations = document.definitions.filter(
82-
(def) => def.kind === 'OperationDefinition' && def.name
83-
);
81+
const namedOperations = document.definitions.filter((def) => def.kind === 'OperationDefinition' && def.name);
8482

8583
if (namedOperations.length === 0) {
8684
throw new Error(
87-
'No named operations found in document. ' +
88-
'At least one named operation is required for proto compilation.'
85+
'No named operations found in document. ' + 'At least one named operation is required for proto compilation.',
8986
);
9087
}
9188

9289
if (namedOperations.length > 1) {
93-
const operationNames = namedOperations
94-
.map((op: any) => op.name.value)
95-
.join(', ');
90+
const operationNames = namedOperations.map((op: any) => op.name.value).join(', ');
9691
throw new Error(
9792
`Multiple operations found in document: ${operationNames}. ` +
98-
'Only a single named operation per document is supported for proto reversibility. ' +
99-
'Please compile each operation separately.'
93+
'Only a single named operation per document is supported for proto reversibility. ' +
94+
'Please compile each operation separately.',
10095
);
10196
}
10297

@@ -235,8 +230,8 @@ class OperationsToProtoVisitor {
235230
if (selection.kind === 'Field' && selection.alias) {
236231
throw new Error(
237232
`Root-level field alias "${selection.alias.value}: ${selection.name.value}" is not supported. ` +
238-
'Field aliases at the root level break proto-to-GraphQL reversibility. ' +
239-
'Please remove the alias or use it only on nested fields.'
233+
'Field aliases at the root level break proto-to-GraphQL reversibility. ' +
234+
'Please remove the alias or use it only on nested fields.',
240235
);
241236
}
242237
}

protographic/tests/operations/enum-support.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -797,7 +797,7 @@ describe('Enum Support', () => {
797797
`;
798798

799799
expect(() => compileOperationsToProto(operations, schema)).toThrow(
800-
'Multiple operations found in document: GetUser, UpdateUser'
800+
'Multiple operations found in document: GetUser, UpdateUser',
801801
);
802802
});
803803
});

protographic/tests/operations/field-ordering-stability.test.ts

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -826,7 +826,7 @@ describe('Operations Field Ordering Stability', () => {
826826
expectValidProto(result1.proto);
827827

828828
const root1 = loadProtoFromText(result1.proto);
829-
829+
830830
// Get field numbers at all nesting levels
831831
const criteriaFields1 = getFieldNumbersFromMessage(root1, 'SearchCriteria');
832832
const filterGroupFields1 = getFieldNumbersFromMessage(root1, 'FilterGroup');
@@ -837,17 +837,17 @@ describe('Operations Field Ordering Stability', () => {
837837
// Store original field numbers at each level
838838
const criteriaFiltersNumber = criteriaFields1['filters'];
839839
const criteriaSortingNumber = criteriaFields1['sorting'];
840-
840+
841841
const filterGroupUserNumber = filterGroupFields1['user'];
842842
const filterGroupDateNumber = filterGroupFields1['date'];
843-
843+
844844
const userFiltersNameNumber = userFiltersFields1['name'];
845845
const userFiltersEmailNumber = userFiltersFields1['email'];
846846
const userFiltersActiveNumber = userFiltersFields1['active'];
847-
847+
848848
const dateFiltersFromNumber = dateFiltersFields1['from'];
849849
const dateFiltersToNumber = dateFiltersFields1['to'];
850-
850+
851851
const sortFieldNumber = sortFields1['field'];
852852
const sortDirectionNumber = sortFields1['direction'];
853853

@@ -869,7 +869,7 @@ describe('Operations Field Ordering Stability', () => {
869869
expectValidProto(result2.proto);
870870

871871
const root2 = loadProtoFromText(result2.proto);
872-
872+
873873
const criteriaFields2 = getFieldNumbersFromMessage(root2, 'SearchCriteria');
874874
const filterGroupFields2 = getFieldNumbersFromMessage(root2, 'FilterGroup');
875875
const userFiltersFields2 = getFieldNumbersFromMessage(root2, 'UserFilters');
@@ -879,17 +879,17 @@ describe('Operations Field Ordering Stability', () => {
879879
// Verify all field numbers are preserved at all nesting levels
880880
expect(criteriaFields2['filters']).toBe(criteriaFiltersNumber);
881881
expect(criteriaFields2['sorting']).toBe(criteriaSortingNumber);
882-
882+
883883
expect(filterGroupFields2['user']).toBe(filterGroupUserNumber);
884884
expect(filterGroupFields2['date']).toBe(filterGroupDateNumber);
885-
885+
886886
expect(userFiltersFields2['name']).toBe(userFiltersNameNumber);
887887
expect(userFiltersFields2['email']).toBe(userFiltersEmailNumber);
888888
expect(userFiltersFields2['active']).toBe(userFiltersActiveNumber);
889-
889+
890890
expect(dateFiltersFields2['from']).toBe(dateFiltersFromNumber);
891891
expect(dateFiltersFields2['to']).toBe(dateFiltersToNumber);
892-
892+
893893
expect(sortFields2['field']).toBe(sortFieldNumber);
894894
expect(sortFields2['direction']).toBe(sortDirectionNumber);
895895
});
@@ -1072,7 +1072,7 @@ describe('Operations Field Ordering Stability', () => {
10721072
`;
10731073

10741074
expect(() => compileOperationsToProto(operations, schema)).toThrow(
1075-
'Multiple operations found in document: GetUser, GetUsers'
1075+
'Multiple operations found in document: GetUser, GetUsers',
10761076
);
10771077
});
10781078
});

protographic/tests/operations/operation-to-proto.test.ts

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -232,7 +232,7 @@ describe('Operation to Proto - Integration Tests', () => {
232232
`;
233233

234234
expect(() => compileOperationsToProto(operations, schema)).toThrow(
235-
'Multiple operations found in document: GetUser, GetPosts'
235+
'Multiple operations found in document: GetUser, GetPosts',
236236
);
237237
});
238238
});
@@ -385,7 +385,7 @@ describe('Operation to Proto - Integration Tests', () => {
385385
`;
386386

387387
expect(() => compileOperationsToProto(operations, schema)).toThrow(
388-
'Multiple operations found in document: OnMessageAdded, OnUserStatusChanged'
388+
'Multiple operations found in document: OnMessageAdded, OnUserStatusChanged',
389389
);
390390
});
391391

@@ -556,7 +556,7 @@ describe('Operation to Proto - Integration Tests', () => {
556556
`;
557557

558558
expect(() => compileOperationsToProto(operations, schema)).toThrow(
559-
'Multiple operations found in document: GetMessages, AddMessage, OnMessageAdded'
559+
'Multiple operations found in document: GetMessages, AddMessage, OnMessageAdded',
560560
);
561561
});
562562

@@ -606,7 +606,7 @@ describe('Operation to Proto - Integration Tests', () => {
606606
expect(() =>
607607
compileOperationsToProto(operations, schema, {
608608
queryIdempotency: 'NO_SIDE_EFFECTS',
609-
})
609+
}),
610610
).toThrow('Multiple operations found in document: GetMessages, AddMessage, OnMessageAdded');
611611
});
612612
});
@@ -1066,7 +1066,7 @@ describe('Operation to Proto - Integration Tests', () => {
10661066
expect(() =>
10671067
compileOperationsToProto(operation, schema, {
10681068
queryIdempotency: 'NO_SIDE_EFFECTS',
1069-
})
1069+
}),
10701070
).toThrow('Multiple operations found in document: GetHello, GetUser');
10711071
});
10721072

@@ -1142,7 +1142,7 @@ describe('Operation to Proto - Integration Tests', () => {
11421142
expect(() =>
11431143
compileOperationsToProto(operations, schema, {
11441144
queryIdempotency: 'NO_SIDE_EFFECTS',
1145-
})
1145+
}),
11461146
).toThrow('Multiple operations found in document: CreateUser, UpdateUser');
11471147
});
11481148

@@ -1181,7 +1181,7 @@ describe('Operation to Proto - Integration Tests', () => {
11811181
expect(() =>
11821182
compileOperationsToProto(operations, schema, {
11831183
queryIdempotency: 'NO_SIDE_EFFECTS',
1184-
})
1184+
}),
11851185
).toThrow('Multiple operations found in document: GetUser, CreateUser');
11861186
});
11871187

@@ -1396,7 +1396,7 @@ describe('Operation to Proto - Integration Tests', () => {
13961396
`;
13971397

13981398
expect(() => compileOperationsToProto(operations, schema)).toThrow(
1399-
'Multiple operations found in document: GetUser, CreateUser'
1399+
'Multiple operations found in document: GetUser, CreateUser',
14001400
);
14011401
});
14021402

@@ -1447,9 +1447,7 @@ describe('Operation to Proto - Integration Tests', () => {
14471447
}
14481448
`;
14491449

1450-
expect(() => compileOperationsToProto(operation, schema)).toThrow(
1451-
'No named operations found in document'
1452-
);
1450+
expect(() => compileOperationsToProto(operation, schema)).toThrow('No named operations found in document');
14531451
});
14541452

14551453
test('should handle empty selection sets', () => {
@@ -1510,7 +1508,7 @@ describe('Operation to Proto - Integration Tests', () => {
15101508
`;
15111509

15121510
expect(() => compileOperationsToProto(operation, schema)).toThrow(
1513-
'Root-level field alias "currentUser: user" is not supported'
1511+
'Root-level field alias "currentUser: user" is not supported',
15141512
);
15151513
});
15161514
});

protographic/tests/operations/operation-validation.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,7 @@ describe('Operation Validation', () => {
190190
`;
191191

192192
const result = compileOperationsToProto(operation, schema);
193-
193+
194194
// Verify the proto can be generated
195195
expect(result.proto).toContain('rpc GetUser');
196196
expect(result.proto).toContain('message GetUserRequest');
@@ -285,4 +285,4 @@ describe('Operation Validation', () => {
285285
}).toThrow(/Root-level field alias "myUser: user" is not supported/);
286286
});
287287
});
288-
});
288+
});

protographic/tests/util.ts

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -62,10 +62,7 @@ export function getFieldNumbersFromMessage(root: protobufjs.Root, messagePath: s
6262
} catch (error) {
6363
// Provide helpful error message with available types
6464
const availableTypes = getAllNestedTypeNames(root);
65-
throw new Error(
66-
`Could not find message "${messagePath}". ` +
67-
`Available types: ${availableTypes.join(', ')}`
68-
);
65+
throw new Error(`Could not find message "${messagePath}". ` + `Available types: ${availableTypes.join(', ')}`);
6966
}
7067
}
7168

@@ -74,7 +71,7 @@ export function getFieldNumbersFromMessage(root: protobufjs.Root, messagePath: s
7471
*/
7572
function getAllNestedTypeNames(root: protobufjs.Root): string[] {
7673
const names: string[] = [];
77-
74+
7875
function collectNames(obj: any, prefix: string = '') {
7976
if (obj.nested) {
8077
for (const [name, nested] of Object.entries(obj.nested)) {
@@ -84,7 +81,7 @@ function getAllNestedTypeNames(root: protobufjs.Root): string[] {
8481
}
8582
}
8683
}
87-
84+
8885
collectNames(root);
8986
return names;
9087
}

router/mcp.config.yaml

Lines changed: 0 additions & 56 deletions
This file was deleted.

0 commit comments

Comments
 (0)