Git - enable ESLint rule for git extensions (#277156)

* Initial commit with all exceptions

* First pass of fixing

* Add ignored files explicitly
This commit is contained in:
Ladislau Szomoru
2025-11-13 15:35:01 +00:00
committed by GitHub
parent 8603e1dd3a
commit 2b52b93770
17 changed files with 67 additions and 55 deletions

View File

@@ -9,7 +9,7 @@ import { Command, commands, Disposable, MessageOptions, Position, QuickPickItem,
import TelemetryReporter from '@vscode/extension-telemetry';
import { uniqueNamesGenerator, adjectives, animals, colors, NumberDictionary } from '@joaomoreno/unique-names-generator';
import { ForcePushMode, GitErrorCodes, RefType, Status, CommitOptions, RemoteSourcePublisher, Remote, Branch, Ref } from './api/git';
import { Git, Stash, Worktree } from './git';
import { Git, GitError, Stash, Worktree } from './git';
import { Model } from './model';
import { GitResourceGroup, Repository, Resource, ResourceGroupType } from './repository';
import { DiffEditorSelectionHunkToolbarContext, LineChange, applyLineChanges, getIndexDiffInformation, getModifiedRange, getWorkingTreeDiffInformation, intersectDiffWithRange, invertLineChange, toLineChanges, toLineRanges, compareLineChanges } from './staging';
@@ -365,8 +365,8 @@ interface ScmCommand {
const Commands: ScmCommand[] = [];
function command(commandId: string, options: ScmCommandOptions = {}): Function {
return (value: any, context: ClassMethodDecoratorContext) => {
if (context.kind !== 'method') {
return (value: unknown, context: ClassMethodDecoratorContext) => {
if (typeof value !== 'function' || context.kind !== 'method') {
throw new Error('not supported');
}
const key = context.name.toString();
@@ -3591,10 +3591,8 @@ export class CommandCenter {
}
}
@command('git.createWorktree')
async createWorktree(repository: any): Promise<void> {
repository = this.model.getRepository(repository);
@command('git.createWorktree', { repository: true })
async createWorktree(repository?: Repository): Promise<void> {
if (!repository) {
// Single repository/submodule/worktree
if (this.model.repositories.length === 1) {
@@ -3786,9 +3784,9 @@ export class CommandCenter {
this.globalState.update(`${CommandCenter.WORKTREE_ROOT_KEY}:${repository.root}`, worktreeRoot);
}
} catch (err) {
if (err.gitErrorCode === GitErrorCodes.WorktreeAlreadyExists) {
if (err instanceof GitError && err.gitErrorCode === GitErrorCodes.WorktreeAlreadyExists) {
await this.handleWorktreeAlreadyExists(err);
} else if (err.gitErrorCode === GitErrorCodes.WorktreeBranchAlreadyUsed) {
} else if (err instanceof GitError && err.gitErrorCode === GitErrorCodes.WorktreeBranchAlreadyUsed) {
await this.handleWorktreeBranchAlreadyUsed(err);
} else {
throw err;
@@ -3798,8 +3796,8 @@ export class CommandCenter {
}
}
private async handleWorktreeBranchAlreadyUsed(err: any): Promise<void> {
const match = err.stderr.match(/fatal: '([^']+)' is already used by worktree at '([^']+)'/);
private async handleWorktreeBranchAlreadyUsed(err: GitError): Promise<void> {
const match = err.stderr?.match(/fatal: '([^']+)' is already used by worktree at '([^']+)'/);
if (!match) {
return;
@@ -3810,8 +3808,8 @@ export class CommandCenter {
await this.handleWorktreeConflict(path, message);
}
private async handleWorktreeAlreadyExists(err: any): Promise<void> {
const match = err.stderr.match(/fatal: '([^']+)'/);
private async handleWorktreeAlreadyExists(err: GitError): Promise<void> {
const match = err.stderr?.match(/fatal: '([^']+)'/);
if (!match) {
return;