Skip to content

Commit 5b264a7

Browse files
committed
fixed linting issues
1 parent 2543aa5 commit 5b264a7

File tree

4 files changed

+28
-32
lines changed

4 files changed

+28
-32
lines changed

renamify-vscode/extension/src/cliService.ts

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { spawn } from 'node:child_process';
1+
import { type ChildProcess, spawn } from 'node:child_process';
22
import * as fs from 'node:fs';
33
import * as path from 'node:path';
44
import * as vscode from 'vscode';
@@ -12,9 +12,9 @@ type VersionInfo = {
1212
};
1313

1414
class CommandMutex {
15-
private currentProcess: any = null;
15+
private currentProcess: ChildProcess | null = null;
1616

17-
async acquire(): Promise<void> {
17+
acquire(): void {
1818
// Kill any existing process immediately
1919
this.killCurrentProcess();
2020
// No waiting, no queuing - just proceed
@@ -24,7 +24,7 @@ class CommandMutex {
2424
this.currentProcess = null;
2525
}
2626

27-
setCurrentProcess(process: any): void {
27+
setCurrentProcess(process: ChildProcess): void {
2828
this.currentProcess = process;
2929
}
3030

@@ -377,8 +377,8 @@ export class RenamifyCliService {
377377
}
378378

379379
// Acquire mutex to ensure only one command runs at a time
380-
await this.commandMutex.acquire();
381-
380+
this.commandMutex.acquire();
381+
382382
try {
383383
// Check version compatibility before every command (except for version command itself)
384384
// Skip version check when using mock spawn (in tests)
@@ -389,9 +389,9 @@ export class RenamifyCliService {
389389
// Try the command, with one retry after 100ms if it fails
390390
try {
391391
return await this.executeCliCommand(args);
392-
} catch (error) {
392+
} catch (_error) {
393393
// Wait 100ms and retry once
394-
await new Promise(resolve => setTimeout(resolve, 100));
394+
await new Promise((resolve) => setTimeout(resolve, 100));
395395
return await this.executeCliCommand(args);
396396
}
397397
} finally {

renamify-vscode/extension/src/test/suite/cliService.test.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -256,12 +256,12 @@ suite('CLI Service Test Suite', () => {
256256
test('Should handle CLI errors correctly', async () => {
257257
// Temporarily restore the original stub to modify it
258258
sandbox.restore();
259-
259+
260260
// Re-create the stub with mocked-cli-path to skip version check
261261
sandbox.stub(vscode.workspace, 'getConfiguration').returns({
262262
get: (key: string) => {
263263
if (key === 'cliPath') {
264-
return 'mocked-cli-path'; // Use special value to skip version check
264+
return 'mocked-cli-path'; // Use special value to skip version check
265265
}
266266
if (key === 'respectGitignore') {
267267
return true;
@@ -272,7 +272,7 @@ suite('CLI Service Test Suite', () => {
272272

273273
// Re-create the mock spawn
274274
mockSpawn = sandbox.stub();
275-
275+
276276
// Create a new CLI service with the updated configuration
277277
const testCliService = new RenamifyCliService(mockSpawn as any);
278278

renamify-vscode/extension/src/webviewProvider.ts

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ export class RenamifyViewProvider implements vscode.WebviewViewProvider {
123123
private async handleSearch(data: SearchMessage) {
124124
// Kill any running command before starting a new search
125125
this._cliService.killCurrentCommand();
126-
126+
127127
try {
128128
let results: SearchResult[];
129129
let paths: Rename[] = [];
@@ -194,21 +194,25 @@ export class RenamifyViewProvider implements vscode.WebviewViewProvider {
194194
type: 'searchResults',
195195
results,
196196
paths,
197-
searchId: (data as any).searchId,
197+
searchId: data.searchId,
198198
});
199199
} catch (error) {
200-
const errorMessage = error instanceof Error ? error.message : String(error);
200+
const errorMessage =
201+
error instanceof Error ? error.message : String(error);
201202
console.error('Search failed:', errorMessage);
202-
203+
203204
// Send error to webview to display in results area
204205
this._view?.webview.postMessage({
205206
type: 'searchError',
206207
error: errorMessage,
207-
searchId: (data as any).searchId,
208+
searchId: data.searchId,
208209
});
209-
210+
210211
// Show error notification for lock errors or other critical failures
211-
if (errorMessage.includes('lock') || errorMessage.includes('Another renamify process')) {
212+
if (
213+
errorMessage.includes('lock') ||
214+
errorMessage.includes('Another renamify process')
215+
) {
212216
vscode.window.showErrorMessage(`Search failed: ${errorMessage}`);
213217
}
214218
}
@@ -217,7 +221,7 @@ export class RenamifyViewProvider implements vscode.WebviewViewProvider {
217221
private async handlePlan(data: PlanMessage) {
218222
// Kill any running command before starting a new plan
219223
this._cliService.killCurrentCommand();
220-
224+
221225
try {
222226
const plan = await this._cliService.createPlan(
223227
data.search,
@@ -248,7 +252,7 @@ export class RenamifyViewProvider implements vscode.WebviewViewProvider {
248252
private async handleApply(data: ApplyMessage) {
249253
// Kill any running command before starting apply
250254
this._cliService.killCurrentCommand();
251-
255+
252256
const config = vscode.workspace.getConfiguration('renamify');
253257

254258
// Get current search and replace from the message

renamify-vscode/webview/src/webview.ts

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,9 @@ type SearchResult = {
2121

2222
let currentResults: SearchResult[] = [];
2323
const expandedFiles = new Set<number>();
24-
24+
2525
// Search state tracking
2626
let currentSearchId = 0;
27-
let isSearching = false;
2827

2928
// DOM elements
3029
const searchInput = document.getElementById('search') as HTMLInputElement;
@@ -204,7 +203,6 @@ type SearchResult = {
204203
// Clear results if search is empty
205204
if (!searchTerm) {
206205
clearResults();
207-
isSearching = false;
208206
return;
209207
}
210208

@@ -214,13 +212,11 @@ type SearchResult = {
214212
clearResults();
215213
resultsTree.innerHTML =
216214
'<div class="empty-state">Please select at least one case style</div>';
217-
isSearching = false;
218215
return;
219216
}
220217

221218
// Increment search ID and track this search
222219
const searchId = ++currentSearchId;
223-
isSearching = true;
224220

225221
// Clear previous results and summary immediately when starting new search
226222
clearResults();
@@ -235,7 +231,7 @@ type SearchResult = {
235231
exclude: excludeInput.value,
236232
excludeMatchingLines: excludeLinesInput.value,
237233
caseStyles: selectedStyles,
238-
searchId: searchId, // Include search ID to match responses
234+
searchId, // Include search ID to match responses
239235
});
240236
}
241237

@@ -334,15 +330,15 @@ type SearchResult = {
334330
expandedFiles.clear();
335331
resultsSummary.textContent = '';
336332
openInEditorLink.style.display = 'none';
337-
333+
338334
resultsTree.innerHTML = `<div class="error-state">
339335
<div class="error-icon">⚠️</div>
340336
<div class="error-message">
341337
<strong>Search failed:</strong><br>
342338
${escapeHtml(errorMessage)}
343339
</div>
344340
</div>`;
345-
341+
346342
updateExpandCollapseButtons();
347343
}
348344

@@ -723,26 +719,22 @@ type SearchResult = {
723719
case 'searchResults':
724720
if (message.searchId === currentSearchId) {
725721
renderResults(message.results, message.paths);
726-
isSearching = false;
727722
}
728723
break;
729724
case 'searchError':
730725
if (message.searchId === currentSearchId) {
731726
showError(message.error);
732-
isSearching = false;
733727
}
734728
break;
735729
case 'clearResults':
736730
clearResults();
737-
isSearching = false;
738731
break;
739732
case 'planCreated':
740733
// Update UI to show plan was created
741734
break;
742735
case 'changesApplied':
743736
// Clear results after successful apply
744737
clearResults();
745-
isSearching = false;
746738
break;
747739
default:
748740
console.warn(`Unknown message type: ${message.type}`);

0 commit comments

Comments
 (0)