Skip to content

Commit f2fa7c2

Browse files
committed
fix: resolve all linting issues
- Replace any types with proper type annotations - Convert forEach loops to for...of loops - Add interface for API response types
1 parent c87f45e commit f2fa7c2

File tree

7 files changed

+28
-19
lines changed

7 files changed

+28
-19
lines changed

src/cli.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@ vi.mock('./tools/search.js');
1111
vi.mock('./tools/status.js');
1212

1313
describe('CLI', () => {
14-
let consoleLogSpy: any;
15-
let consoleErrorSpy: any;
14+
let consoleLogSpy: ReturnType<typeof vi.spyOn>;
15+
let consoleErrorSpy: ReturnType<typeof vi.spyOn>;
1616

1717
beforeEach(() => {
1818
vi.clearAllMocks();

src/cli.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -81,13 +81,13 @@ export function createCLI() {
8181
if (result.success && result.results && result.results.length > 0) {
8282
spinner.succeed(chalk.green(`Found ${result.totalResults} archives`));
8383
console.log(`\n${chalk.bold('Archive snapshots:')}`);
84-
result.results.forEach((snapshot) => {
84+
for (const snapshot of result.results) {
8585
console.log(chalk.gray('─'.repeat(60)));
8686
console.log(chalk.blue('Date:'), snapshot.date);
8787
console.log(chalk.blue('URL:'), snapshot.archivedUrl);
8888
console.log(chalk.blue('Status:'), snapshot.statusCode);
8989
console.log(chalk.blue('Type:'), snapshot.mimeType);
90-
});
90+
}
9191
} else {
9292
spinner.fail(chalk.yellow(result.message || 'No archives found'));
9393
}
@@ -113,9 +113,9 @@ export function createCLI() {
113113
console.log(chalk.blue('Last capture:'), result.lastCapture);
114114
if (result.yearlyCaptures) {
115115
console.log(`\n${chalk.bold('Yearly captures:')}`);
116-
Object.entries(result.yearlyCaptures).forEach(([year, count]) => {
116+
for (const [year, count] of Object.entries(result.yearlyCaptures)) {
117117
console.log(chalk.blue(`${year}:`), count);
118-
});
118+
}
119119
}
120120
} else {
121121
spinner.warn(chalk.yellow('URL has not been archived'));

src/tools/retrieve.test.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,7 @@ vi.mock('../utils/rate-limit.js');
1616
describe('getArchivedUrl', () => {
1717
beforeEach(() => {
1818
vi.clearAllMocks();
19-
vi.spyOn(rateLimitModule.waybackRateLimiter, 'waitForSlot').mockResolvedValue(
20-
undefined as any,
21-
);
19+
vi.spyOn(rateLimitModule.waybackRateLimiter, 'waitForSlot').mockResolvedValue(undefined);
2220
vi.spyOn(rateLimitModule.waybackRateLimiter, 'recordRequest').mockImplementation(() => {});
2321
});
2422

src/tools/save.test.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,7 @@ vi.mock('../utils/rate-limit.js');
1616
describe('saveUrl', () => {
1717
beforeEach(() => {
1818
vi.clearAllMocks();
19-
vi.spyOn(rateLimitModule.waybackRateLimiter, 'waitForSlot').mockResolvedValue(
20-
undefined as any,
21-
);
19+
vi.spyOn(rateLimitModule.waybackRateLimiter, 'waitForSlot').mockResolvedValue(undefined);
2220
vi.spyOn(rateLimitModule.waybackRateLimiter, 'recordRequest').mockImplementation(() => {});
2321
});
2422

src/tools/search.test.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,7 @@ vi.mock('../utils/rate-limit.js');
1616
describe('searchArchives', () => {
1717
beforeEach(() => {
1818
vi.clearAllMocks();
19-
vi.spyOn(rateLimitModule.waybackRateLimiter, 'waitForSlot').mockResolvedValue(
20-
undefined as any,
21-
);
19+
vi.spyOn(rateLimitModule.waybackRateLimiter, 'waitForSlot').mockResolvedValue(undefined);
2220
vi.spyOn(rateLimitModule.waybackRateLimiter, 'recordRequest').mockImplementation(() => {});
2321
});
2422

src/tools/status.test.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,7 @@ vi.mock('../utils/rate-limit.js');
1616
describe('checkArchiveStatus', () => {
1717
beforeEach(() => {
1818
vi.clearAllMocks();
19-
vi.spyOn(rateLimitModule.waybackRateLimiter, 'waitForSlot').mockResolvedValue(
20-
undefined as any,
21-
);
19+
vi.spyOn(rateLimitModule.waybackRateLimiter, 'waitForSlot').mockResolvedValue(undefined);
2220
vi.spyOn(rateLimitModule.waybackRateLimiter, 'recordRequest').mockImplementation(() => {});
2321
});
2422

src/tools/status.ts

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,23 @@ import { HttpError, fetchWithTimeout, parseJsonResponse } from '../utils/http.js
77
import { waybackRateLimiter } from '../utils/rate-limit.js';
88
import { validateUrl } from '../utils/validation.js';
99

10+
interface AvailabilityResponse {
11+
archivedSnapshots?: {
12+
closest?: {
13+
available: boolean;
14+
timestamp: string;
15+
url?: string;
16+
};
17+
};
18+
archived_snapshots?: {
19+
closest?: {
20+
available: boolean;
21+
timestamp: string;
22+
url?: string;
23+
};
24+
};
25+
}
26+
1027
export const CheckArchiveStatusSchema = z.object({
1128
url: z.string().url().describe('The URL to check'),
1229
});
@@ -98,7 +115,7 @@ export async function checkArchiveStatus(input: CheckArchiveStatusInput): Promis
98115
},
99116
});
100117

101-
const availData = await parseJsonResponse<any>(availResponse);
118+
const availData = await parseJsonResponse<AvailabilityResponse>(availResponse);
102119

103120
if (availData.archived_snapshots?.closest?.available) {
104121
return {

0 commit comments

Comments
 (0)