Skip to content

Commit d1f0787

Browse files
committed
lint fix
1 parent 4fdd286 commit d1f0787

3 files changed

Lines changed: 12 additions & 32 deletions

File tree

packages/codemod/src/migrations/v1-to-v2/transforms/specSchemaAccess.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
import type { SourceFile } from 'ts-morph';
22
import { Node, SyntaxKind } from 'ts-morph';
33

4+
import { SPEC_SCHEMA_NAMES, specSchemaToTypeName } from '../../../generated/specSchemaMap.js';
45
import type { Diagnostic, Transform, TransformContext, TransformResult } from '../../../types.js';
56
import { warning } from '../../../utils/diagnostics.js';
6-
import { addOrMergeImport, isAnyMcpSpecifier, resolveOriginalImportName } from '../../../utils/importUtils.js';
7-
import { SPEC_SCHEMA_NAMES, specSchemaToTypeName } from '../../../generated/specSchemaMap.js';
7+
import { addOrMergeImport, isAnyMcpSpecifier } from '../../../utils/importUtils.js';
88

99
export const specSchemaAccessTransform: Transform = {
1010
name: 'Spec schema standalone usage',

packages/codemod/test/v1-to-v2/transforms/handlerRegistration.test.ts

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -193,12 +193,7 @@ describe('handler-registration transform', () => {
193193
});
194194

195195
it('does not emit diagnostic when first arg is a string literal (v2 style)', () => {
196-
const input = [
197-
`server.setRequestHandler('tools/call', async (request) => {`,
198-
` return { content: [] };`,
199-
`});`,
200-
''
201-
].join('\n');
196+
const input = [`server.setRequestHandler('tools/call', async (request) => {`, ` return { content: [] };`, `});`, ''].join('\n');
202197
const project = new Project({ useInMemoryFileSystem: true });
203198
const sourceFile = project.createSourceFile('test.ts', input);
204199
const result = handlerRegistrationTransform.apply(sourceFile, ctx);

packages/codemod/test/v1-to-v2/transforms/specSchemaAccess.test.ts

Lines changed: 9 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -65,11 +65,7 @@ describe('spec-schema-access transform', () => {
6565
});
6666

6767
it('adds specTypeSchemas import', () => {
68-
const input = [
69-
`import { ToolSchema } from '@modelcontextprotocol/server';`,
70-
`const s = ToolSchema;`,
71-
''
72-
].join('\n');
68+
const input = [`import { ToolSchema } from '@modelcontextprotocol/server';`, `const s = ToolSchema;`, ''].join('\n');
7369
const { text } = applyTransform(input);
7470
expect(text).toContain('specTypeSchemas.Tool');
7571
expect(text).toMatch(/import.*specTypeSchemas.*from/);
@@ -93,11 +89,9 @@ describe('spec-schema-access transform', () => {
9389

9490
describe('diagnostic only: .parse(v)', () => {
9591
it('emits diagnostic for parse usage', () => {
96-
const input = [
97-
`import { ToolSchema } from '@modelcontextprotocol/server';`,
98-
`const tool = ToolSchema.parse(raw);`,
99-
''
100-
].join('\n');
92+
const input = [`import { ToolSchema } from '@modelcontextprotocol/server';`, `const tool = ToolSchema.parse(raw);`, ''].join(
93+
'\n'
94+
);
10195
const { text, result } = applyTransform(input);
10296
expect(text).toContain('ToolSchema.parse');
10397
expect(result.changesCount).toBe(0);
@@ -121,34 +115,25 @@ describe('spec-schema-access transform', () => {
121115

122116
describe('no-op cases', () => {
123117
it('does nothing for non-MCP imports', () => {
124-
const input = [
125-
`import { CallToolRequestSchema } from './local';`,
126-
`CallToolRequestSchema.safeParse(data);`,
127-
''
128-
].join('\n');
118+
const input = [`import { CallToolRequestSchema } from './local';`, `CallToolRequestSchema.safeParse(data);`, ''].join('\n');
129119
const { text, result } = applyTransform(input);
130120
expect(text).toContain('CallToolRequestSchema.safeParse');
131121
expect(result.changesCount).toBe(0);
132122
expect(result.diagnostics.length).toBe(0);
133123
});
134124

135125
it('does nothing for non-spec schema names', () => {
136-
const input = [
137-
`import { SomeRandomSchema } from '@modelcontextprotocol/server';`,
138-
`SomeRandomSchema.parse(data);`,
139-
''
140-
].join('\n');
126+
const input = [`import { SomeRandomSchema } from '@modelcontextprotocol/server';`, `SomeRandomSchema.parse(data);`, ''].join(
127+
'\n'
128+
);
141129
const { text, result } = applyTransform(input);
142130
expect(text).toContain('SomeRandomSchema.parse');
143131
expect(result.changesCount).toBe(0);
144132
expect(result.diagnostics.length).toBe(0);
145133
});
146134

147135
it('does nothing when no remaining references', () => {
148-
const input = [
149-
`import { CallToolRequestSchema } from '@modelcontextprotocol/server';`,
150-
''
151-
].join('\n');
136+
const input = [`import { CallToolRequestSchema } from '@modelcontextprotocol/server';`, ''].join('\n');
152137
const { result } = applyTransform(input);
153138
expect(result.changesCount).toBe(0);
154139
expect(result.diagnostics.length).toBe(0);

0 commit comments

Comments
 (0)