Skip to content
This repository was archived by the owner on Mar 10, 2022. It is now read-only.

Commit b15f9a5

Browse files
committed
fix: eslint errors
1 parent 02f89b0 commit b15f9a5

File tree

4 files changed

+24
-20
lines changed

4 files changed

+24
-20
lines changed

src/commands/updateCompareRangeCommand.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,13 @@ import { gitReferenceTag } from './switchGitRevisionCommand'
88
export async function updateCompareRange(diffs: DiffsTreeDataProvider, commandArguments: any[]): Promise<void> {
99
const repositoryName: string = commandArguments[0]
1010
if (typeof repositoryName !== 'string') {
11-
log.error(`updateCompareRange(${JSON.stringify(arguments)})`, `first argument is not a string`)
12-
throw new Error(`updateCompareRange(${JSON.stringify(arguments)})`)
11+
log.error(`updateCompareRange(${JSON.stringify(commandArguments)})`, 'first argument is not a string')
12+
throw new Error(`updateCompareRange(${JSON.stringify(commandArguments)})`)
1313
}
1414
const kind: 'base' | 'head' = commandArguments[1]
1515
if (kind !== 'base' && kind !== 'head') {
16-
log.error(`updateCompareRange(${JSON.stringify(arguments)})`, `second argument is not 'base' or 'head'`)
17-
throw new Error(`updateCompareRange(${JSON.stringify(arguments)})`)
16+
log.error(`updateCompareRange(${JSON.stringify(commandArguments)})`, "second argument is not 'base' or 'head'")
17+
throw new Error(`updateCompareRange(${JSON.stringify(commandArguments)})`)
1818
}
1919
const quick = new SourcegraphQuickPick(diffs.fs)
2020
quick.pick.title = 'Search for a git branch, git tag or a git commit'

src/extension.ts

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -99,11 +99,7 @@ export function activate(context: vscode.ExtensionContext): void {
9999
for (const color of ['green', 'orange', 'red']) {
100100
for (const index of [1, 2, 3]) {
101101
const name = `extension.${color}${index}`
102-
context.subscriptions.push(
103-
vscode.commands.registerCommand(name, () => {
104-
log.appendLine(`COMMAND ${name}`)
105-
})
106-
)
102+
context.subscriptions.push(vscode.commands.registerCommand(name, () => {}))
107103
}
108104
}
109105
context.subscriptions.push(
@@ -136,8 +132,8 @@ export function activate(context: vscode.ExtensionContext): void {
136132
)
137133
)
138134
context.subscriptions.push(
139-
vscode.commands.registerCommand('extension.updateCompareRange', (...commandArguments) => {
140-
updateCompareRange(diffsTreeProvider, commandArguments)
135+
vscode.commands.registerCommand('extension.updateCompareRange', async (...commandArguments) => {
136+
await updateCompareRange(diffsTreeProvider, commandArguments)
141137
})
142138
)
143139
context.subscriptions.push(

src/file-system/DiffsTreeDataProvider.ts

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ export class DiffsTreeDataProvider implements vscode.TreeDataProvider<string> {
6060
label: `${node.kind[0].toUpperCase()}${node.kind.slice(1)}: ${
6161
this.compareRange(node)[node.kind]
6262
}`,
63-
resourceUri: vscode.Uri.parse(`sourcegraph://host/.gitignore`),
63+
resourceUri: vscode.Uri.parse('sourcegraph://host/.gitignore'),
6464
tooltip: `Update ${node.kind} revision`,
6565
command: {
6666
command: 'extension.updateCompareRange',
@@ -276,7 +276,6 @@ export class DiffsTreeDataProvider implements vscode.TreeDataProvider<string> {
276276

277277
const fileStats = fileDiffStats(uri, fileDiff, comparison)
278278
const label = uri.treeItemLabel(parent)
279-
log.appendLine(`label=${label} contextValue=${fileStats.contextValue}`)
280279
return {
281280
id: childNode.toString(),
282281
label,
@@ -316,7 +315,7 @@ function fileDiffStats(
316315
}
317316
}
318317
}
319-
let parts: string[] = []
318+
const parts: string[] = []
320319
const addCount = (what: string, count: number): void => {
321320
if (count < 1) {
322321
return
@@ -397,8 +396,8 @@ class DiffNode {
397396
}
398397
private static fromAny(any: any): DiffNode {
399398
const repositoryName = any?.repositoryName
400-
if (typeof repositoryName != 'string') {
401-
throw new Error(`DiffUri.fromAny() missing repositoryName`)
399+
if (typeof repositoryName !== 'string') {
400+
throw new TypeError('DiffUri.fromAny() missing repositoryName')
402401
}
403402
let kind: DiffNodeKind | undefined
404403
if (any?.kind === 'base' || any?.kind === 'head' || any?.kind === 'commits' || any?.kind === 'files') {

src/file-system/FilesTreeDataProvider.ts

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -91,8 +91,11 @@ export class FilesTreeDataProvider implements vscode.TreeDataProvider<string> {
9191
}
9292
return ancestor
9393
} catch (error) {
94-
log.error(`getParent(${uriString})`, error)
95-
throw error
94+
log.error(`getParent(${uriString || 'undefined'})`, error)
95+
if (error instanceof Error) {
96+
throw error
97+
}
98+
return undefined
9699
}
97100
}
98101

@@ -113,7 +116,10 @@ export class FilesTreeDataProvider implements vscode.TreeDataProvider<string> {
113116
return directChildren
114117
} catch (error) {
115118
log.error(`getChildren(${uriString || ''})`, error)
116-
throw error
119+
if (error instanceof Error) {
120+
throw error
121+
}
122+
return undefined
117123
}
118124
}
119125

@@ -146,8 +152,11 @@ export class FilesTreeDataProvider implements vscode.TreeDataProvider<string> {
146152
return this.newTreeItem(uri, parentUri ? SourcegraphUri.parse(parentUri) : undefined, 0)
147153
} catch (error) {
148154
log.error(`getTreeItem(${uriString})`, error)
149-
throw error
155+
if (error instanceof Error) {
156+
throw error
157+
}
150158
}
159+
return {}
151160
}
152161

153162
private async didFocusString(

0 commit comments

Comments
 (0)