Skip to content

Commit f0c2a34

Browse files
authored
test: lint consistency (#45)
1 parent 3c49d4b commit f0c2a34

File tree

9 files changed

+34
-9
lines changed

9 files changed

+34
-9
lines changed

eslint.config.js

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -72,13 +72,24 @@ export default [
7272
argsIgnorePattern: '^_',
7373
varsIgnorePattern: '^_'
7474
}],
75+
'import/exports-last': 2,
76+
'import/group-exports': 1,
77+
'id-length': ['error', {
78+
min: 2,
79+
properties: 'never',
80+
exceptions: ['a', 'b', 'i', 'j', 'k', '_']
81+
}],
7582
'n/no-process-exit': 0,
7683
// Disallow console.log/info in runtime to protect STDIO; allow warn/error
7784
'no-console': ['error', { allow: ['warn', 'error'] }]
7885
}
7986
},
80-
81-
// Test files
87+
{
88+
files: ['src/*.d.ts'],
89+
rules: {
90+
'import/group-exports': 0
91+
}
92+
},
8293
{
8394
files: [
8495
'**/*.test.ts',
@@ -87,12 +98,12 @@ export default [
8798
],
8899
rules: {
89100
'@typescript-eslint/no-explicit-any': 0,
90-
'@typescript-eslint/ban-ts-comment': 1,
101+
'@typescript-eslint/ban-ts-comment': 0,
102+
'import/exports-last': 0,
103+
'import/group-exports': 0,
91104
'no-sparse-arrays': 0,
92105
// Allow console usage in tests (spies, debug)
93-
'no-console': 0,
94-
// Relax stylistic padding in tests to reduce churn
95-
'@stylistic/padding-line-between-statements': 0
106+
'no-console': 0
96107
}
97108
}
98109
];

src/__tests__/logger.test.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,7 @@ describe('registerStderrSubscriber', () => {
156156
const stderrSpy = jest.spyOn(process.stderr, 'write').mockImplementation(() => true as any);
157157

158158
const unsubscribe = registerStderrSubscriber(getLoggerOptions());
159+
159160
publish('debug', getLoggerOptions(), 'debug suppressed');
160161
publish('info', getLoggerOptions(), 'lorem ipsum', 123, { a: 1 });
161162

@@ -210,6 +211,7 @@ describe('createLogger', () => {
210211
const stderrSpy = jest.spyOn(process.stderr, 'write').mockImplementation(() => true as any);
211212

212213
const unsubscribe = createLogger(getLoggerOptions());
214+
213215
publish('debug', getLoggerOptions(), 'debug suppressed');
214216
publish('info', getLoggerOptions(), 'lorem ipsum', 123, { a: 1 });
215217

src/__tests__/options.test.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,12 +71,14 @@ describe('parseCliOptions', () => {
7171
it('parses from a provided argv independent of process.argv', () => {
7272
const customArgv = ['node', 'cli', '--http', '--port', '3101'];
7373
const result = parseCliOptions(customArgv);
74+
7475
expect(result.http?.port).toBe(3101);
7576
});
7677

7778
it('trims spaces in list flags', () => {
7879
const argv = ['node', 'cli', '--http', '--allowed-hosts', ' localhost , 127.0.0.1 '];
7980
const result = parseCliOptions(argv);
81+
8082
expect(result.http?.allowedHosts).toEqual(['localhost', '127.0.0.1']);
8183
});
8284
});

src/__tests__/server.caching.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,8 @@ describe('memo', () => {
4949

5050
try {
5151
successValue = await value();
52-
} catch (e) {
53-
const error = e as Error;
52+
} catch (err) {
53+
const error = err as Error;
5454

5555
errorValue = error.message;
5656
}

src/__tests__/server.http.test.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ describe('startHttpTransport', () => {
6161

6262
MockCreateServer.mockImplementation((handler: any) => {
6363
mockRequestHandler = handler;
64+
6465
return mockHttpServer as any;
6566
});
6667
});

src/__tests__/server.logger.test.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,7 @@ describe('createServerLogger', () => {
107107
setOptions({ logging: { stderr: true, level: 'debug' } as any });
108108

109109
const stderrSpy = jest.spyOn(process.stderr, 'write').mockImplementation(() => true as any);
110+
110111
class MockServer { sendLoggingMessage = jest.fn(async () => {}); }
111112
const server = new MockServer() as any;
112113

src/logger.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ const publish = (level: LogLevel, options: LoggingSession = getLoggerOptions(),
7171
event.args = args;
7272
}
7373
} else {
74-
const arr = [msg, ...args].filter(v => v !== undefined);
74+
const arr = [msg, ...args].filter(value => value !== undefined);
7575

7676
if (arr.length) {
7777
event.args = arr as unknown[];

tests/utils/fetchMock.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@ const startHttpFixture = (
7171
// String pattern with wildcards
7272
const pattern = regexRoute.url.replace(/\*/g, '.*');
7373
const regex = new RegExp(`^${pattern}$`);
74+
7475
if (regex.test(pathname) || regex.test(`http://${address}${pathname}`)) {
7576
route = {
7677
status: regexRoute.status || 200,
@@ -251,6 +252,7 @@ export const setupFetchMock = async (options: FetchMockSetup = {}): Promise<Fetc
251252

252253
// Start fixture server with regex routes for dynamic matching
253254
const fixtureOptions: StartHttpFixtureOptions = { routes: fixtureRoutes, address };
255+
254256
if (port) {
255257
fixtureOptions.port = port;
256258
}
@@ -260,12 +262,15 @@ export const setupFetchMock = async (options: FetchMockSetup = {}): Promise<Fetc
260262
const matchRoute = (url: string): FetchRoute | undefined => {
261263
// Extract pathname from URL for matching
262264
let pathname: string;
265+
263266
try {
264267
const urlObj = new URL(url);
268+
265269
pathname = urlObj.pathname;
266270
} catch {
267271
// If URL parsing fails, try to extract pathname manually
268272
const match = url.match(/^https?:\/\/[^/]+(\/.*)$/);
273+
269274
pathname = match && match[1] ? match[1] : url;
270275
}
271276

@@ -307,6 +312,7 @@ export const setupFetchMock = async (options: FetchMockSetup = {}): Promise<Fetc
307312
// For regex/pattern matches, extract the pathname from the matched URL
308313
try {
309314
const urlObj = new URL(url);
315+
310316
fixturePath = urlObj.pathname;
311317
} catch {
312318
// If URL parsing fails, fall back to index-based path
@@ -318,6 +324,7 @@ export const setupFetchMock = async (options: FetchMockSetup = {}): Promise<Fetc
318324
// Note: This is important for stdio servers that run in separate processes
319325
// and make real HTTP requests to the fixture server
320326
const normalizedPath = fixturePath.startsWith('/') ? fixturePath : `/${fixturePath}`;
327+
321328
if (fixture.addRoute) {
322329
// Check if route already exists to avoid overwriting
323330
if (!fixtureRoutes[normalizedPath]) {

tests/utils/httpTransportClient.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,7 @@ export const startServer = async (
9595
try {
9696
// Construct base URL from options
9797
const baseUrl = `http://${host}:${port}/mcp`;
98+
9899
httpClientUrl = new URL(baseUrl);
99100
} catch (error) {
100101
throw new Error(`Failed to construct base URL: ${error}, host: ${host}, port: ${port}`);

0 commit comments

Comments
 (0)