Kaynağa Gözat

Changes some lint rules

main
Eric Amodio 4 yıl önce
ebeveyn
işleme
4c7366a345
60 değiştirilmiş dosya ile 208 ekleme ve 195 silme
  1. +12
    -4
      .eslintrc.json
  2. +1
    -1
      src/annotations/autolinks.ts
  3. +5
    -5
      src/annotations/lineAnnotationController.ts
  4. +1
    -1
      src/codelens/codeLensProvider.ts
  5. +1
    -1
      src/commands/closeUnchangedFiles.ts
  6. +1
    -1
      src/commands/copyMessageToClipboard.ts
  7. +1
    -1
      src/commands/copyShaToClipboard.ts
  8. +4
    -3
      src/commands/git/pull.ts
  9. +1
    -2
      src/commands/git/reset.ts
  10. +1
    -2
      src/commands/git/revert.ts
  11. +23
    -22
      src/commands/git/stash.ts
  12. +2
    -3
      src/commands/gitCommands.actions.ts
  13. +3
    -2
      src/commands/gitCommands.ts
  14. +1
    -1
      src/commands/openBranchOnRemote.ts
  15. +1
    -1
      src/commands/openBranchesOnRemote.ts
  16. +1
    -1
      src/commands/openRepoOnRemote.ts
  17. +3
    -4
      src/commands/quickCommand.steps.ts
  18. +1
    -1
      src/commands/showQuickBranchHistory.ts
  19. +1
    -1
      src/commands/switchMode.ts
  20. +10
    -6
      src/configuration.ts
  21. +1
    -2
      src/git/formatters/commitFormatter.ts
  22. +15
    -19
      src/git/formatters/formatter.ts
  23. +4
    -4
      src/git/git.ts
  24. +1
    -0
      src/git/gitService.ts
  25. +1
    -1
      src/git/models/logCommit.ts
  26. +5
    -4
      src/git/models/repository.ts
  27. +1
    -1
      src/git/remotes/azure-devops.ts
  28. +1
    -1
      src/git/remotes/bitbucket-server.ts
  29. +1
    -1
      src/git/remotes/bitbucket.ts
  30. +1
    -1
      src/git/remotes/custom.ts
  31. +1
    -1
      src/git/remotes/github.ts
  32. +1
    -1
      src/git/remotes/gitlab.ts
  33. +52
    -31
      src/git/shell.ts
  34. +6
    -6
      src/keyboard.ts
  35. +0
    -1
      src/logger.ts
  36. +1
    -1
      src/messages.ts
  37. +2
    -3
      src/quickpicks/commitPicker.ts
  38. +2
    -2
      src/quickpicks/gitQuickPickItems.ts
  39. +2
    -3
      src/quickpicks/referencePicker.ts
  40. +1
    -1
      src/system/array.ts
  41. +0
    -1
      src/system/decorators/gate.ts
  42. +0
    -2
      src/system/decorators/log.ts
  43. +0
    -1
      src/system/decorators/memoize.ts
  44. +0
    -1
      src/system/decorators/timeout.ts
  45. +0
    -1
      src/system/function.ts
  46. +0
    -1
      src/system/string.ts
  47. +1
    -1
      src/views/branchesView.ts
  48. +1
    -1
      src/views/commitsView.ts
  49. +1
    -1
      src/views/contributorsView.ts
  50. +1
    -1
      src/views/nodes/compareBranchNode.ts
  51. +2
    -1
      src/views/nodes/helpers.ts
  52. +2
    -2
      src/views/nodes/repositoryNode.ts
  53. +1
    -1
      src/views/remotesView.ts
  54. +1
    -1
      src/views/stashesView.ts
  55. +1
    -1
      src/views/tagsView.ts
  56. +2
    -2
      src/webviews/apps/rebase/rebase.ts
  57. +1
    -1
      src/webviews/apps/settings/settings.ts
  58. +17
    -24
      src/webviews/apps/shared/events.ts
  59. +1
    -1
      src/webviews/apps/welcome/snow.ts
  60. +3
    -3
      src/webviews/webviewBase.ts

+ 12
- 4
.eslintrc.json Dosyayı Görüntüle

@ -134,9 +134,9 @@
"message": "Use symbol instead",
"fixWith": "symbol"
},
"Function": {
"message": "The `Function` type accepts any function-like value.\nIt provides no type safety when calling the function, which can be a common source of bugs.\nIt also accepts things like class declarations, which will throw at runtime as they will not be called with `new`.\nIf you are expecting the function to accept certain arguments, you should explicitly define the function shape."
},
// "Function": {
// "message": "The `Function` type accepts any function-like value.\nIt provides no type safety when calling the function, which can be a common source of bugs.\nIt also accepts things like class declarations, which will throw at runtime as they will not be called with `new`.\nIf you are expecting the function to accept certain arguments, you should explicitly define the function shape."
// },
"Object": {
"message": "The `Object` type actually means \"any non-nullish value\", so it is marginally better than `unknown`.\n- If you want a type meaning \"any object\", you probably want `Record<string, unknown>` instead.\n- If you want a type meaning \"any value\", you probably want `unknown` instead."
},
@ -239,7 +239,15 @@
],
"@typescript-eslint/strict-boolean-expressions": [
"warn",
{ "allowNullableBoolean": true, "allowNullableNumber": true, "allowNullableString": true }
{
"allowString": true,
"allowNumber": true,
"allowNullableObject": false,
"allowNullableBoolean": true,
"allowNullableNumber": true,
"allowNullableString": true,
"allowAny": false
}
],
"@typescript-eslint/unbound-method": "off" // Too many bugs right now: https://github.com/typescript-eslint/typescript-eslint/issues?utf8=%E2%9C%93&q=is%3Aissue+is%3Aopen+unbound-method
}

+ 1
- 1
src/annotations/autolinks.ts Dosyayı Görüntüle

@ -175,7 +175,7 @@ export class Autolinks implements Disposable {
if (ref.title) {
title = ` "${ref.title.replace(numRegex, num)}`;
if (issue) {
if (issue != null) {
if (issue instanceof Promises.CancellationError) {
title += `\n${GlyphChars.Dash.repeat(2)}\nDetails timed out`;
} else {

+ 5
- 5
src/annotations/lineAnnotationController.ts Dosyayı Görüntüle

@ -178,7 +178,7 @@ export class LineAnnotationController implements Disposable {
const selections = Container.lineTracker.selections;
if (editor == null || selections == null || !isTextEditor(editor)) {
if (cc) {
if (cc != null) {
cc.exitDetails = ` ${GlyphChars.Dot} Skipped because there is no valid editor or no valid selections`;
}
@ -195,7 +195,7 @@ export class LineAnnotationController implements Disposable {
const cfg = Container.config.currentLine;
if (this.suspended) {
if (cc) {
if (cc != null) {
cc.exitDetails = ` ${GlyphChars.Dot} Skipped because the controller is suspended`;
}
@ -205,7 +205,7 @@ export class LineAnnotationController implements Disposable {
const trackedDocument = await Container.tracker.getOrAdd(editor.document);
if (!trackedDocument.isBlameable && this.suspended) {
if (cc) {
if (cc != null) {
cc.exitDetails = ` ${GlyphChars.Dot} Skipped because the ${
this.suspended
? 'controller is suspended'
@ -219,7 +219,7 @@ export class LineAnnotationController implements Disposable {
// Make sure the editor hasn't died since the await above and that we are still on the same line(s)
if (editor.document == null || !Container.lineTracker.includes(selections)) {
if (cc) {
if (cc != null) {
cc.exitDetails = ` ${GlyphChars.Dot} Skipped because the ${
editor.document == null
? 'editor is gone'
@ -231,7 +231,7 @@ export class LineAnnotationController implements Disposable {
return;
}
if (cc) {
if (cc != null) {
cc.exitDetails = ` ${GlyphChars.Dot} selection(s)=${selections
.map(s => `[${s.anchor}-${s.active}]`)
.join()}`;

+ 1
- 1
src/codelens/codeLensProvider.ts Dosyayı Görüntüle

@ -205,7 +205,7 @@ export class GitCodeLensProvider implements CodeLensProvider {
!languageScope.symbolScopes.includes('!file')
) {
// Check if we have a lens for the whole document -- if not add one
if (!lenses.find(l => l.range.start.line === 0 && l.range.end.line === 0)) {
if (lenses.find(l => l.range.start.line === 0 && l.range.end.line === 0) == null) {
const blameRange = documentRangeFn();
let blameForRangeFn: (() => GitBlameLines | undefined) | undefined = undefined;

+ 1
- 1
src/commands/closeUnchangedFiles.ts Dosyayı Görüntüle

@ -133,7 +133,7 @@ export class CloseUnchangedFilesCommand extends Command {
let timer: NodeJS.Timer | undefined;
this._onEditorChangedFn = (editor: TextEditor | undefined) => {
if (timer) {
if (timer != null) {
clearTimeout(timer);
timer = undefined;

+ 1
- 1
src/commands/copyMessageToClipboard.ts Dosyayı Görüntüle

@ -47,7 +47,7 @@ export class CopyMessageToClipboardCommand extends ActiveEditorCommand {
if (!repoPath) return;
const log = await Container.git.getLog(repoPath, { limit: 1 });
if (!log) return;
if (log == null) return;
args.message = Iterables.first(log.commits.values()).message;
} else if (args.message == null) {

+ 1
- 1
src/commands/copyShaToClipboard.ts Dosyayı Görüntüle

@ -45,7 +45,7 @@ export class CopyShaToClipboardCommand extends ActiveEditorCommand {
if (!repoPath) return;
const log = await Container.git.getLog(repoPath, { limit: 1 });
if (!log) return;
if (log == null) return;
args.sha = Iterables.first(log.commits.values()).sha;
} else if (args.sha == null) {

+ 4
- 3
src/commands/git/pull.ts Dosyayı Görüntüle

@ -195,9 +195,10 @@ export class PullGitCommand extends QuickCommand {
).fromNow()}`;
}
const pullDetails = status?.state.behind
? ` ${Strings.pluralize('commit', status.state.behind)} into $(repo) ${repo.formattedName}`
: ` into $(repo) ${repo.formattedName}`;
const pullDetails =
status?.state.behind != null
? ` ${Strings.pluralize('commit', status.state.behind)} into $(repo) ${repo.formattedName}`
: ` into $(repo) ${repo.formattedName}`;
step = this.createConfirmStep(
appendReposToTitle(`Confirm ${context.title}`, state, context, lastFetchedOn),

+ 1
- 2
src/commands/git/reset.ts Dosyayı Görüntüle

@ -150,8 +150,7 @@ export class ResetGitCommand extends QuickCommand {
return state.counter < 0 ? StepResult.Break : undefined;
}
// eslint-disable-next-line @typescript-eslint/require-await
private async *confirmStep(state: ResetStepState, context: Context): StepResultGenerator<Flags[]> {
private *confirmStep(state: ResetStepState, context: Context): StepResultGenerator<Flags[]> {
const step: QuickPickStep<FlagsQuickPickItem<Flags>> = this.createConfirmStep(
appendReposToTitle(`Confirm ${context.title}`, state, context),
[

+ 1
- 2
src/commands/git/revert.ts Dosyayı Görüntüle

@ -150,8 +150,7 @@ export class RevertGitCommand extends QuickCommand {
return state.counter < 0 ? StepResult.Break : undefined;
}
// eslint-disable-next-line @typescript-eslint/require-await
private async *confirmStep(
private *confirmStep(
state: RevertStepState<State<GitRevisionReference[]>>,
context: Context,
): StepResultGenerator<void> {

+ 23
- 22
src/commands/git/stash.ts Dosyayı Görüntüle

@ -2,7 +2,7 @@
import { QuickInputButtons, QuickPickItem, Uri, window } from 'vscode';
import { GlyphChars } from '../../constants';
import { Container } from '../../container';
import { GitReference, GitStashCommit, GitStashReference, Repository } from '../../git/git';
import { GitReference, GitStashCommit, GitStashReference, Repository, RunError } from '../../git/git';
import { GitUri } from '../../git/gitUri';
import { GitActions, GitCommandsCommand } from '../gitCommands';
import {
@ -287,32 +287,33 @@ export class StashGitCommand extends QuickCommand {
} catch (ex) {
Logger.error(ex, context.title);
const msg: string = ex?.message ?? '';
if (msg.includes('Your local changes to the following files would be overwritten by merge')) {
void window.showWarningMessage(
'Unable to apply stash. Your working tree changes would be overwritten. Please commit or stash your changes before trying again',
);
if (ex instanceof Error) {
const msg: string = ex.message ?? '';
if (msg.includes('Your local changes to the following files would be overwritten by merge')) {
void window.showWarningMessage(
'Unable to apply stash. Your working tree changes would be overwritten. Please commit or stash your changes before trying again',
);
return;
}
return;
}
if (
(msg.includes('Auto-merging') && msg.includes('CONFLICT')) ||
// eslint-disable-next-line @typescript-eslint/strict-boolean-expressions
(ex?.stdout?.includes('Auto-merging') && ex?.stdout?.includes('CONFLICT')) ||
// eslint-disable-next-line @typescript-eslint/strict-boolean-expressions
ex?.stdout?.includes('needs merge')
) {
void window.showInformationMessage('Stash applied with conflicts');
if (
(msg.includes('Auto-merging') && msg.includes('CONFLICT')) ||
(ex instanceof RunError &&
((ex.stdout.includes('Auto-merging') && ex.stdout.includes('CONFLICT')) ||
ex.stdout.includes('needs merge')))
) {
void window.showInformationMessage('Stash applied with conflicts');
return;
}
return;
}
void Messages.showGenericErrorMessage(
`Unable to apply stash \u2014 ${msg.trim().replace(/\n+?/g, '; ')}`,
);
void Messages.showGenericErrorMessage(
`Unable to apply stash \u2014 ${msg.trim().replace(/\n+?/g, '; ')}`,
);
return;
return;
}
}
}
}

+ 2
- 3
src/commands/gitCommands.actions.ts Dosyayı Görüntüle

@ -576,12 +576,11 @@ export namespace GitActions {
);
}
// eslint-disable-next-line @typescript-eslint/consistent-type-assertions
const { annotationType, line, ...opts } = {
const { annotationType, line, ...opts }: Exclude<typeof options, undefined> = {
preserveFocus: true,
preview: false,
...options,
} as Exclude<typeof options, undefined>;
};
if (line != null && line !== 0) {
opts.selection = new Range(line, 0, line, 0);

+ 3
- 2
src/commands/gitCommands.ts Dosyayı Görüntüle

@ -58,8 +58,9 @@ export type GitCommandsCommandArgs =
| SwitchGitCommandArgs
| TagGitCommandArgs;
// eslint-disable-next-line @typescript-eslint/no-empty-function
function* nullSteps(): StepGenerator {}
function* nullSteps(): StepGenerator {
/* noop */
}
@command()
export class GitCommandsCommand extends Command {

+ 1
- 1
src/commands/openBranchOnRemote.ts Dosyayı Görüntüle

@ -47,7 +47,7 @@ export class OpenBranchOnRemoteCommand extends ActiveEditorCommand {
async execute(editor?: TextEditor, uri?: Uri, args?: OpenBranchOnRemoteCommandArgs) {
uri = getCommandUri(uri, editor);
const gitUri = uri && (await GitUri.fromUri(uri));
const gitUri = uri != null ? await GitUri.fromUri(uri) : undefined;
const repoPath = await getRepoPathOrActiveOrPrompt(
gitUri,

+ 1
- 1
src/commands/openBranchesOnRemote.ts Dosyayı Görüntüle

@ -41,7 +41,7 @@ export class OpenBranchesOnRemoteCommand extends ActiveEditorCommand {
async execute(editor?: TextEditor, uri?: Uri, args?: OpenBranchesOnRemoteCommandArgs) {
uri = getCommandUri(uri, editor);
const gitUri = uri && (await GitUri.fromUri(uri));
const gitUri = uri != null ? await GitUri.fromUri(uri) : undefined;
const repoPath = await getRepoPathOrActiveOrPrompt(
gitUri,

+ 1
- 1
src/commands/openRepoOnRemote.ts Dosyayı Görüntüle

@ -41,7 +41,7 @@ export class OpenRepoOnRemoteCommand extends ActiveEditorCommand {
async execute(editor?: TextEditor, uri?: Uri, args?: OpenRepoOnRemoteCommandArgs) {
uri = getCommandUri(uri, editor);
const gitUri = uri && (await GitUri.fromUri(uri));
const gitUri = uri != null ? await GitUri.fromUri(uri) : undefined;
const repoPath = await getRepoPathOrActiveOrPrompt(
gitUri,

+ 3
- 4
src/commands/quickCommand.steps.ts Dosyayı Görüntüle

@ -1052,7 +1052,7 @@ export async function* pickRepositoriesStep<
options = { placeholder: 'Choose repositories', skipIfPossible: false, ...options };
let actives: Repository[];
if (state.repos) {
if (state.repos != null) {
if (Arrays.isStringArray(state.repos)) {
actives = Arrays.filterMap(state.repos, path => context.repos.find(r => r.path === path));
if (options.skipIfPossible && actives.length !== 0 && state.repos.length === actives.length) {
@ -1063,7 +1063,7 @@ export async function* pickRepositoriesStep<
}
} else {
const active = await Container.git.getActiveRepository();
actives = active ? [active] : [];
actives = active != null ? [active] : [];
}
const step = QuickCommand.createPickStep<RepositoryQuickPickItem>({
@ -1516,8 +1516,7 @@ async function getShowCommitOrStashStepItems<
return items;
}
// eslint-disable-next-line @typescript-eslint/require-await
export async function* showCommitOrStashFilesStep<
export function* showCommitOrStashFilesStep<
State extends PartialStepState & {
repo: Repository;
reference: GitLogCommit | GitStashCommit;

+ 1
- 1
src/commands/showQuickBranchHistory.ts Dosyayı Görüntüle

@ -29,7 +29,7 @@ export class ShowQuickBranchHistoryCommand extends ActiveEditorCachedCommand {
async execute(editor?: TextEditor, uri?: Uri, args?: ShowQuickBranchHistoryCommandArgs) {
uri = getCommandUri(uri, editor);
const gitUri = uri && (await GitUri.fromUri(uri));
const gitUri = uri != null ? await GitUri.fromUri(uri) : undefined;
const repoPath = args?.repoPath ?? gitUri?.repoPath;

+ 1
- 1
src/commands/switchMode.ts Dosyayı Görüntüle

@ -20,7 +20,7 @@ export class SwitchModeCommand extends Command {
const pick = await ModePicker.show();
if (pick === undefined) return;
if (cc) {
if (cc != null) {
cc.exitDetails = ` \u2014 mode=${pick.key ?? ''}`;
}

+ 10
- 6
src/configuration.ts Dosyayı Görüntüle

@ -308,7 +308,7 @@ export class Configuration {
if (inspection.globalValue !== undefined) {
await this.update(
to as any,
options.migrationFn ? options.migrationFn(inspection.globalValue) : inspection.globalValue,
options.migrationFn != null ? options.migrationFn(inspection.globalValue) : inspection.globalValue,
ConfigurationTarget.Global,
);
migrated = true;
@ -324,7 +324,9 @@ export class Configuration {
if (inspection.workspaceValue !== undefined) {
await this.update(
to as any,
options.migrationFn ? options.migrationFn(inspection.workspaceValue) : inspection.workspaceValue,
options.migrationFn != null
? options.migrationFn(inspection.workspaceValue)
: inspection.workspaceValue,
ConfigurationTarget.Workspace,
);
migrated = true;
@ -340,7 +342,7 @@ export class Configuration {
if (inspection.workspaceFolderValue !== undefined) {
await this.update(
to as any,
options.migrationFn
options.migrationFn != null
? options.migrationFn(inspection.workspaceFolderValue)
: inspection.workspaceFolderValue,
ConfigurationTarget.WorkspaceFolder,
@ -427,7 +429,9 @@ export class Configuration {
if (toInspection === undefined || toInspection.globalValue === undefined) {
await this.update(
to as any,
options.migrationFn ? options.migrationFn(fromInspection.globalValue) : fromInspection.globalValue,
options.migrationFn != null
? options.migrationFn(fromInspection.globalValue)
: fromInspection.globalValue,
ConfigurationTarget.Global,
);
// Can't delete the old setting currently because it errors with `Unable to write to User Settings because <setting name> is not a registered configuration`
@ -444,7 +448,7 @@ export class Configuration {
if (toInspection === undefined || toInspection.workspaceValue === undefined) {
await this.update(
to as any,
options.migrationFn
options.migrationFn != null
? options.migrationFn(fromInspection.workspaceValue)
: fromInspection.workspaceValue,
ConfigurationTarget.Workspace,
@ -463,7 +467,7 @@ export class Configuration {
if (toInspection === undefined || toInspection.workspaceFolderValue === undefined) {
await this.update(
to as any,
options.migrationFn
options.migrationFn != null
? options.migrationFn(fromInspection.workspaceFolderValue)
: fromInspection.workspaceFolderValue,
ConfigurationTarget.WorkspaceFolder,

+ 1
- 2
src/git/formatters/commitFormatter.ts Dosyayı Görüntüle

@ -459,10 +459,9 @@ export class CommitFormatter extends Formatter {
): string {
if (CommitFormatter.has(template, 'footnotes')) {
if (dateFormatOrOptions == null || typeof dateFormatOrOptions === 'string') {
// eslint-disable-next-line @typescript-eslint/consistent-type-assertions
dateFormatOrOptions = {
dateFormat: dateFormatOrOptions,
} as CommitFormatOptions;
};
}
if (dateFormatOrOptions.footnotes == null) {

+ 15
- 19
src/git/formatters/formatter.ts Dosyayı Görüntüle

@ -13,24 +13,24 @@ type Constructor> = new (...args: any[]) => T;
const hasTokenRegexMap = new Map<string, RegExp>();
const spaceReplacementRegex = / /g;
declare type RequiredTokenOptions<TOptions extends FormatOptions> = TOptions & Required<Pick<TOptions, 'tokenOptions'>>;
declare type RequiredTokenOptions<Options extends FormatOptions> = Options & Required<Pick<Options, 'tokenOptions'>>;
export abstract class Formatter<TItem = any, TOptions extends FormatOptions = FormatOptions> {
protected _item!: TItem;
protected _options!: RequiredTokenOptions<TOptions>;
export abstract class Formatter<Item = any, Options extends FormatOptions = FormatOptions> {
protected _item!: Item;
protected _options!: RequiredTokenOptions<Options>;
constructor(item: TItem, options?: TOptions) {
constructor(item: Item, options?: Options) {
this.reset(item, options);
}
reset(item: TItem, options?: TOptions) {
reset(item: Item, options?: Options) {
this._item = item;
if (options === undefined && this._options !== undefined) return;
if (options == null && this._options != null) return;
if (options === undefined) {
if (options == null) {
// eslint-disable-next-line @typescript-eslint/consistent-type-assertions
options = {} as TOptions;
options = {} as Options;
}
if (options.dateFormat == null) {
@ -41,7 +41,7 @@ export abstract class Formatter
options.tokenOptions = {};
}
this._options = options as RequiredTokenOptions<TOptions>;
this._options = options as RequiredTokenOptions<Options>;
}
private collapsableWhitespace: number = 0;
@ -96,26 +96,22 @@ export abstract class Formatter
private static _formatter: Formatter | undefined = undefined;
protected static fromTemplateCore<
TFormatter extends Formatter<TItem, TOptions>,
TItem,
TOptions extends FormatOptions
>(
protected static fromTemplateCore<TFormatter extends Formatter<Item, Options>, Item, Options extends FormatOptions>(
formatter: TFormatter | Constructor<TFormatter>,
template: string,
item: TItem,
dateFormatOrOptions?: string | null | TOptions,
item: Item,
dateFormatOrOptions?: string | null | Options,
): string {
// Preserve spaces
template = template.replace(spaceReplacementRegex, '\u00a0');
if (formatter instanceof Formatter) return Strings.interpolate(template, formatter);
let options: TOptions | undefined = undefined;
let options: Options | undefined = undefined;
if (dateFormatOrOptions == null || typeof dateFormatOrOptions === 'string') {
// eslint-disable-next-line @typescript-eslint/consistent-type-assertions
options = {
dateFormat: dateFormatOrOptions,
} as TOptions;
} as Options;
} else {
options = dateFormatOrOptions;
}

+ 4
- 4
src/git/git.ts Dosyayı Görüntüle

@ -8,7 +8,7 @@ import { Container } from '../container';
import { Logger } from '../logger';
import { Objects, Strings } from '../system';
import { findGitPath, GitLocation } from './locator';
import { fsExists, run, RunOptions } from './shell';
import { fsExists, run, RunError, RunOptions } from './shell';
import { GitBranchParser, GitLogParser, GitReflogParser, GitStashParser, GitTagParser } from './parsers/parsers';
import { GitFileStatus, GitRevision } from './models/models';
@ -17,6 +17,7 @@ export * from './parsers/parsers';
export * from './formatters/formatters';
export * from './remotes/provider';
export * from './search';
export { RunError } from './shell';
export type GitDiffFilter = Exclude<GitFileStatus, '!' | '?'>;
@ -566,8 +567,7 @@ export namespace Git {
'-',
);
} catch (ex) {
// eslint-disable-next-line @typescript-eslint/strict-boolean-expressions
if (ex.stdout) {
if (ex instanceof RunError && ex.stdout) {
return ex.stdout;
}
@ -730,7 +730,7 @@ export namespace Git {
params.push('--first-parent');
}
if (authors) {
if (authors != null && authors.length !== 0) {
params.push('--use-mailmap', ...authors.map(a => `--author=${a}`));
}

+ 1
- 0
src/git/gitService.ts Dosyayı Görüntüle

@ -512,6 +512,7 @@ export class GitService implements Disposable {
if (result.title === 'Yes') {
try {
void (await Git.apply(uri.repoPath, patch, { allowConflicts: true }));
return;
} catch (e) {
// eslint-disable-next-line no-ex-assign

+ 1
- 1
src/git/models/logCommit.ts Dosyayı Görüntüle

@ -81,7 +81,7 @@ export class GitLogCommit extends GitCommit {
}
get isMerge() {
return this.parentShas && this.parentShas.length > 1;
return this.parentShas != null && this.parentShas.length > 1;
}
get nextUri(): Uri {

+ 5
- 4
src/git/models/repository.ts Dosyayı Görüntüle

@ -354,9 +354,10 @@ export class Repository implements Disposable {
return void (await window.withProgress(
{
location: ProgressLocation.Notification,
title: opts.branch
? `Pulling ${opts.branch.name}...`
: `Fetching ${opts.remote ? `${opts.remote} of ` : ''}${this.formattedName}...`,
title:
opts.branch != null
? `Pulling ${opts.branch.name}...`
: `Fetching ${opts.remote ? `${opts.remote} of ` : ''}${this.formattedName}...`,
},
() => this.fetchCore(opts),
));
@ -549,7 +550,7 @@ export class Repository implements Disposable {
{
location: ProgressLocation.Notification,
title: GitReference.isBranch(opts.reference)
? `${opts.publish ? 'Publishing ' : 'Pushing '}${opts.reference.name}...`
? `${opts.publish != null ? 'Publishing ' : 'Pushing '}${opts.reference.name}...`
: `Pushing ${this.formattedName}...`,
},
() => this.pushCore(opts),

+ 1
- 1
src/git/remotes/azure-devops.ts Dosyayı Görüntüle

@ -117,7 +117,7 @@ export class AzureDevOpsRemote extends RemoteProvider {
protected getUrlForFile(fileName: string, branch?: string, sha?: string, range?: Range): string {
let line;
if (range) {
if (range != null) {
if (range.start.line === range.end.line) {
line = `&line=${range.start.line}`;
} else {

+ 1
- 1
src/git/remotes/bitbucket-server.ts Dosyayı Görüntüle

@ -124,7 +124,7 @@ export class BitbucketServerRemote extends RemoteProvider {
protected getUrlForFile(fileName: string, branch?: string, sha?: string, range?: Range): string {
let line;
if (range) {
if (range != null) {
if (range.start.line === range.end.line) {
line = `#${range.start.line}`;
} else {

+ 1
- 1
src/git/remotes/bitbucket.ts Dosyayı Görüntüle

@ -117,7 +117,7 @@ export class BitbucketRemote extends RemoteProvider {
protected getUrlForFile(fileName: string, branch?: string, sha?: string, range?: Range): string {
let line;
if (range) {
if (range != null) {
if (range.start.line === range.end.line) {
line = `#${fileName}-${range.start.line}`;
} else {

+ 1
- 1
src/git/remotes/custom.ts Dosyayı Görüntüle

@ -42,7 +42,7 @@ export class CustomRemote extends RemoteProvider {
protected getUrlForFile(fileName: string, branch?: string, sha?: string, range?: Range): string {
let line;
if (range) {
if (range != null) {
if (range.start.line === range.end.line) {
line = Strings.interpolate(this.urls.fileLine, { line: range.start.line });
} else {

+ 1
- 1
src/git/remotes/github.ts Dosyayı Görüntüle

@ -140,7 +140,7 @@ export class GitHubRemote extends RemoteProviderWithApi {
protected getUrlForFile(fileName: string, branch?: string, sha?: string, range?: Range): string {
let line;
if (range) {
if (range != null) {
if (range.start.line === range.end.line) {
line = `#L${range.start.line}`;
} else {

+ 1
- 1
src/git/remotes/gitlab.ts Dosyayı Görüntüle

@ -112,7 +112,7 @@ export class GitLabRemote extends RemoteProvider {
protected getUrlForFile(fileName: string, branch?: string, sha?: string, range?: Range): string {
let line;
if (range) {
if (range != null) {
if (range.start.line === range.end.line) {
line = `#L${range.start.line}`;
} else {

+ 52
- 31
src/git/shell.ts Dosyayı Görüntüle

@ -1,5 +1,5 @@
'use strict';
import { execFile } from 'child_process';
import { ExecException, execFile } from 'child_process';
import * as fs from 'fs';
import * as paths from 'path';
import * as iconv from 'iconv-lite';
@ -53,10 +53,8 @@ function runDownPath(exe: string): string {
function isExecutable(stats: fs.Stats) {
if (isWindows) return true;
// eslint-disable-next-line @typescript-eslint/strict-boolean-expressions
const isGroup = stats.gid ? process.getgid && stats.gid === process.getgid() : true;
// eslint-disable-next-line @typescript-eslint/strict-boolean-expressions
const isUser = stats.uid ? process.getuid && stats.uid === process.getuid() : true;
const isGroup = stats.gid ? process.getgid != null && stats.gid === process.getgid() : true;
const isUser = stats.uid ? process.getuid != null && stats.uid === process.getuid() : true;
return Boolean(stats.mode & 0o0001 || (stats.mode & 0o0010 && isGroup) || (stats.mode & 0o0100 && isUser));
}
@ -143,6 +141,31 @@ export interface RunOptions {
const bufferExceededRegex = /stdout maxBuffer( length)? exceeded/;
export class RunError extends Error {
constructor(private readonly original: ExecException, public readonly stdout: string) {
super(original.message);
stdout = stdout.trim();
Error.captureStackTrace(this, RunError);
}
get cmd(): string | undefined {
return this.original.cmd;
}
get killed(): boolean | undefined {
return this.original.killed;
}
get code(): number | undefined {
return this.original.code;
}
get signal(): NodeJS.Signals | undefined {
return this.original.signal;
}
}
export function run<TOut extends string | Buffer>(
command: string,
args: any[],
@ -152,36 +175,34 @@ export function run(
const { stdin, stdinEncoding, ...opts }: RunOptions = { maxBuffer: 100 * 1024 * 1024, ...options };
return new Promise<TOut>((resolve, reject) => {
const proc = execFile(
command,
args,
opts,
(error: (Error & { stdout?: TOut | undefined }) | null, stdout, stderr) => {
if (error != null) {
if (bufferExceededRegex.test(error.message)) {
error.message = `Command output exceeded the allocated stdout buffer. Set 'options.maxBuffer' to a larger value than ${opts.maxBuffer} bytes`;
}
error.stdout =
const proc = execFile(command, args, opts, (error: ExecException | null, stdout, stderr) => {
if (error != null) {
if (bufferExceededRegex.test(error.message)) {
error.message = `Command output exceeded the allocated stdout buffer. Set 'options.maxBuffer' to a larger value than ${opts.maxBuffer} bytes`;
}
reject(
new RunError(
error,
encoding === 'utf8' || encoding === 'binary' || encoding === 'buffer'
? (stdout as TOut)
: (iconv.decode(Buffer.from(stdout, 'binary'), encoding) as TOut);
reject(error);
? stdout
: iconv.decode(Buffer.from(stdout, 'binary'), encoding),
),
);
return;
}
return;
}
if (stderr) {
Logger.warn(`Warning(${command} ${args.join(' ')}): ${stderr}`);
}
if (stderr) {
Logger.warn(`Warning(${command} ${args.join(' ')}): ${stderr}`);
}
resolve(
encoding === 'utf8' || encoding === 'binary' || encoding === 'buffer'
? (stdout as TOut)
: (iconv.decode(Buffer.from(stdout, 'binary'), encoding) as TOut),
);
},
);
resolve(
encoding === 'utf8' || encoding === 'binary' || encoding === 'buffer'
? (stdout as TOut)
: (iconv.decode(Buffer.from(stdout, 'binary'), encoding) as TOut),
);
});
if (stdin != null) {
proc.stdin?.end(stdin, stdinEncoding ?? 'utf8');

+ 6
- 6
src/keyboard.ts Dosyayı Görüntüle

@ -50,7 +50,7 @@ export class KeyboardScope implements Disposable {
const index = mappings.indexOf(this._mapping);
const cc = Logger.getCorrelationContext();
if (cc) {
if (cc != null) {
cc.exitDetails = ` \u2022 index=${index}`;
}
@ -75,8 +75,8 @@ export class KeyboardScope implements Disposable {
const cc = Logger.getCorrelationContext();
const mapping = mappings[mappings.length - 1];
if (mapping !== this._mapping || !mapping[key]) {
if (cc) {
if (mapping !== this._mapping || mapping[key] == null) {
if (cc != null) {
cc.exitDetails = ' \u2022 skipped';
}
@ -127,7 +127,7 @@ export class KeyboardScope implements Disposable {
const mapping = mappings[mappings.length - 1];
if (mapping !== this._mapping) {
if (cc) {
if (cc != null) {
cc.exitDetails = ' \u2022 skipped';
}
@ -186,7 +186,7 @@ export class Keyboard implements Disposable {
const cc = Logger.getCorrelationContext();
if (!mappings.length) {
if (cc) {
if (cc != null) {
cc.exitDetails = ' \u2022 skipped, no mappings';
}
@ -201,7 +201,7 @@ export class Keyboard implements Disposable {
command = await command();
}
if (typeof command?.onDidPressKey !== 'function') {
if (cc) {
if (cc != null) {
cc.exitDetails = ' \u2022 skipped, no callback';
}

+ 0
- 1
src/logger.ts Dosyayı Görüntüle

@ -222,7 +222,6 @@ export class Logger {
}
}
// eslint-disable-next-line @typescript-eslint/ban-types
static toLoggableName(instance: Function | object) {
let name: string;
if (typeof instance === 'function') {

+ 1
- 1
src/messages.ts Dosyayı Görüntüle

@ -181,7 +181,7 @@ export class Messages {
Logger.log(
`ShowMessage(${type}, '${message}', ${suppressionKey}, ${JSON.stringify(dontShowAgain)}) returned ${
result ? result.title : result
result != null ? result.title : result
}`,
);
return result;

+ 2
- 3
src/quickpicks/commitPicker.ts Dosyayı Görüntüle

@ -3,7 +3,7 @@ import { Disposable, QuickPick, window } from 'vscode';
import { configuration } from '../configuration';
import { Container } from '../container';
import { GitLog, GitLogCommit } from '../git/git';
import { KeyboardScope, KeyCommand, Keys } from '../keyboard';
import { KeyboardScope, Keys } from '../keyboard';
import { CommitQuickPickItem, Directive, DirectiveQuickPickItem, getQuickPickIgnoreFocusOut } from '../quickpicks';
import { Iterables, Promises } from '../system';
@ -99,14 +99,13 @@ export namespace CommitPicker {
Object.fromEntries(
options.keys.map(key => [
key,
// eslint-disable-next-line @typescript-eslint/consistent-type-assertions
{
onDidPressKey: key => {
if (quickpick.activeItems.length !== 0) {
void options.onDidPressKey!(key, quickpick);
}
},
} as KeyCommand,
},
]),
),
);

+ 2
- 2
src/quickpicks/gitQuickPickItems.ts Dosyayı Görüntüle

@ -304,11 +304,11 @@ export namespace RepositoryQuickPickItem {
}
let description = '';
if (options.branch && repoStatus) {
if (options.branch && repoStatus != null) {
description = repoStatus.branch;
}
if (options.status && repoStatus) {
if (options.status && repoStatus != null) {
let workingStatus = '';
if (repoStatus.files.length !== 0) {
workingStatus = repoStatus.getFormattedDiffStatus({

+ 2
- 3
src/quickpicks/referencePicker.ts Dosyayı Görüntüle

@ -3,7 +3,7 @@ import { CancellationTokenSource, Disposable, QuickPick, window } from 'vscode';
import { GlyphChars } from '../constants';
import { Container } from '../container';
import { GitBranch, GitReference, GitTag } from '../git/git';
import { KeyboardScope, KeyCommand, Keys } from '../keyboard';
import { KeyboardScope, Keys } from '../keyboard';
import { BranchQuickPickItem, getQuickPickIgnoreFocusOut, RefQuickPickItem, TagQuickPickItem } from '../quickpicks';
import { getBranchesAndOrTags, getValidateGitReferenceFn } from '../commands/quickCommand';
@ -53,14 +53,13 @@ export namespace ReferencePicker {
Object.fromEntries(
options.keys.map(key => [
key,
// eslint-disable-next-line @typescript-eslint/consistent-type-assertions
{
onDidPressKey: key => {
if (quickpick.activeItems.length !== 0) {
void options.onDidPressKey!(key, quickpick);
}
},
} as KeyCommand,
},
]),
),
);

+ 1
- 1
src/system/array.ts Dosyayı Görüntüle

@ -194,7 +194,7 @@ export namespace Arrays {
if (uniqueValues[value]) return false;
uniqueValues[value] = accessor;
return predicate ? predicate(item) : true;
return predicate?.(item) ?? true;
});
}
}

+ 0
- 1
src/system/decorators/gate.ts Dosyayı Görüntüle

@ -20,7 +20,6 @@ function defaultResolver(...args: any[]): string {
export function gate<T extends (...arg: any) => any>(resolver?: (...args: Parameters<T>) => string) {
return (target: any, key: string, descriptor: PropertyDescriptor) => {
// eslint-disable-next-line @typescript-eslint/ban-types
let fn: Function | undefined;
if (typeof descriptor.value === 'function') {
fn = descriptor.value;

+ 0
- 2
src/system/decorators/log.ts Dosyayı Görüntüle

@ -44,7 +44,6 @@ export interface LogContext {
export const LogInstanceNameFn = Symbol('logInstanceNameFn');
export function logName<T>(fn: (c: T, name: string) => string) {
// eslint-disable-next-line @typescript-eslint/ban-types
return (target: Function) => {
(target as any)[LogInstanceNameFn] = fn;
};
@ -89,7 +88,6 @@ export function log any>(
| typeof Logger.log;
return (target: any, key: string, descriptor: PropertyDescriptor & Record<string, any>) => {
// eslint-disable-next-line @typescript-eslint/ban-types
let fn: Function | undefined;
let fnKey: string | undefined;
if (typeof descriptor.value === 'function') {

+ 0
- 1
src/system/decorators/memoize.ts Dosyayı Görüntüle

@ -19,7 +19,6 @@ function defaultResolver(...args: any[]): string {
export function memoize<T extends (...arg: any) => any>(resolver?: (...args: Parameters<T>) => string) {
return (target: any, key: string, descriptor: PropertyDescriptor & Record<string, any>) => {
// eslint-disable-next-line @typescript-eslint/ban-types
let fn: Function | undefined;
let fnKey: string | undefined;

+ 0
- 1
src/system/decorators/timeout.ts Dosyayı Görüntüle

@ -13,7 +13,6 @@ export function timeout(timeoutOrTimeoutFromLastArg: number | boolean, defaultTi
}
return (target: any, key: string, descriptor: PropertyDescriptor) => {
// eslint-disable-next-line @typescript-eslint/ban-types
let fn: Function | undefined;
if (typeof descriptor.value === 'function') {
fn = descriptor.value;

+ 0
- 1
src/system/function.ts Dosyayı Görüntüle

@ -103,7 +103,6 @@ export namespace Functions {
const fnBodyStripCommentsRegex = /(\/\*([\s\S]*?)\*\/|([^:]|^)\/\/(.*)$)/gm;
const fnBodyStripParamDefaultValueRegex = /\s?=.*$/;
// eslint-disable-next-line @typescript-eslint/ban-types
export function getParameters(fn: Function): string[] {
if (typeof fn !== 'function') throw new Error('Not supported');

+ 0
- 1
src/system/string.ts Dosyayı Görüntüle

@ -112,7 +112,6 @@ export namespace Strings {
return tokens;
}
// eslint-disable-next-line @typescript-eslint/ban-types
const interpolationMap = new Map<string, Function>();
export function interpolate(template: string, context: object | undefined): string {

+ 1
- 1
src/views/branchesView.ts Dosyayı Görüntüle

@ -98,7 +98,7 @@ export class BranchesRepositoryNode extends SubscribeableViewNode
@debug({
args: {
0: (e: RepositoryChangeEvent) =>
`{ repository: ${e.repository ? e.repository.name : ''}, changes: ${e.changes.join()} }`,
`{ repository: ${e.repository?.name ?? ''}, changes: ${e.changes.join()} }`,
},
})
private onRepositoryChanged(e: RepositoryChangeEvent) {

+ 1
- 1
src/views/commitsView.ts Dosyayı Görüntüle

@ -121,7 +121,7 @@ export class CommitsRepositoryNode extends SubscribeableViewNode {
@debug({
args: {
0: (e: RepositoryChangeEvent) =>
`{ repository: ${e.repository ? e.repository.name : ''}, changes: ${e.changes.join()} }`,
`{ repository: ${e.repository?.name ?? ''}, changes: ${e.changes.join()} }`,
},
})
private onRepositoryChanged(e: RepositoryChangeEvent) {

+ 1
- 1
src/views/contributorsView.ts Dosyayı Görüntüle

@ -78,7 +78,7 @@ export class ContributorsRepositoryNode extends SubscribeableViewNode
@debug({
args: {
0: (e: RepositoryChangeEvent) =>
`{ repository: ${e.repository ? e.repository.name : ''}, changes: ${e.changes.join()} }`,
`{ repository: ${e.repository?.name ?? ''}, changes: ${e.changes.join()} }`,
},
})
private onRepositoryChanged(e: RepositoryChangeEvent) {

+ 1
- 1
src/views/nodes/compareBranchNode.ts Dosyayı Görüntüle

@ -268,7 +268,7 @@ export class CompareBranchNode extends ViewNode
comparisons = Object.create(null) as BranchComparisons;
}
if (compareWith) {
if (compareWith != null) {
comparisons[this.branch.id] = { ...compareWith };
} else {
const { [this.branch.id]: _, ...rest } = comparisons;

+ 2
- 1
src/views/nodes/helpers.ts Dosyayı Görüntüle

@ -10,7 +10,6 @@ const markers: [number, string][] = [
[90, 'Over 3 months ago'],
];
// eslint-disable-next-line consistent-return
export function* insertDateMarkers<T extends ViewNode & { commit: GitLogCommit }>(
iterable: Iterable<T>,
parent: ViewNode,
@ -62,4 +61,6 @@ export function* insertDateMarkers
first = false;
yield node;
}
return undefined;
}

+ 2
- 2
src/views/nodes/repositoryNode.ts Dosyayı Görüntüle

@ -265,7 +265,7 @@ export class RepositoryNode extends SubscribeableViewNode {
@debug({
args: {
0: (e: RepositoryFileSystemChangeEvent) =>
`{ repository: ${e.repository ? e.repository.name : ''}, uris(${e.uris.length}): [${e.uris
`{ repository: ${e.repository?.name ?? ''}, uris(${e.uris.length}): [${e.uris
.slice(0, 1)
.map(u => u.fsPath)
.join(', ')}${e.uris.length > 1 ? ', ...' : ''}] }`,
@ -302,7 +302,7 @@ export class RepositoryNode extends SubscribeableViewNode {
@debug({
args: {
0: (e: RepositoryChangeEvent) =>
`{ repository: ${e.repository ? e.repository.name : ''}, changes: ${e.changes.join()} }`,
`{ repository: ${e.repository?.name ?? ''}, changes: ${e.changes.join()} }`,
},
})
private onRepositoryChanged(e: RepositoryChangeEvent) {

+ 1
- 1
src/views/remotesView.ts Dosyayı Görüntüle

@ -95,7 +95,7 @@ export class RemotesRepositoryNode extends SubscribeableViewNode {
@debug({
args: {
0: (e: RepositoryChangeEvent) =>
`{ repository: ${e.repository ? e.repository.name : ''}, changes: ${e.changes.join()} }`,
`{ repository: ${e.repository?.name ?? ''}, changes: ${e.changes.join()} }`,
},
})
private onRepositoryChanged(e: RepositoryChangeEvent) {

+ 1
- 1
src/views/stashesView.ts Dosyayı Görüntüle

@ -83,7 +83,7 @@ export class StashesRepositoryNode extends SubscribeableViewNode {
@debug({
args: {
0: (e: RepositoryChangeEvent) =>
`{ repository: ${e.repository ? e.repository.name : ''}, changes: ${e.changes.join()} }`,
`{ repository: ${e.repository?.name ?? ''}, changes: ${e.changes.join()} }`,
},
})
private onRepositoryChanged(e: RepositoryChangeEvent) {

+ 1
- 1
src/views/tagsView.ts Dosyayı Görüntüle

@ -83,7 +83,7 @@ export class TagsRepositoryNode extends SubscribeableViewNode {
@debug({
args: {
0: (e: RepositoryChangeEvent) =>
`{ repository: ${e.repository ? e.repository.name : ''}, changes: ${e.changes.join()} }`,
`{ repository: ${e.repository?.name ?? ''}, changes: ${e.changes.join()} }`,
},
})
private onRepositoryChanged(e: RepositoryChangeEvent) {

+ 2
- 2
src/webviews/apps/rebase/rebase.ts Dosyayı Görüntüle

@ -288,7 +288,7 @@ class RebaseEditor extends App {
}
const commit = state.commits.find(c => c.ref.startsWith(state.onto));
if (commit) {
if (commit != null) {
const [$el] = this.createEntry(
{
action: undefined!,
@ -352,7 +352,7 @@ class RebaseEditor extends App {
$entry.appendChild($message);
const commit = state.commits.find(c => c.ref.startsWith(entry.ref));
if (commit) {
if (commit != null) {
$message.title = commit.message ?? '';
if (commit.author) {

+ 1
- 1
src/webviews/apps/settings/settings.ts Dosyayı Görüntüle

@ -220,7 +220,7 @@ export class SettingsApp extends AppWithConfig {
private toggleJumpLink(anchor: string, active: boolean) {
const el = document.querySelector(`a.sidebar__jump-link[href="#${anchor}"]`);
if (el) {
if (el != null) {
el.classList.toggle('active', active);
}
}

+ 17
- 24
src/webviews/apps/shared/events.ts Dosyayı Görüntüle

@ -1,4 +1,3 @@
/* eslint-disable @typescript-eslint/ban-types */
'use strict';
// Taken from github.com/microsoft/vscode/src/vs/base/common/event.ts
@ -22,8 +21,9 @@ export interface EmitterOptions {
}
export class Emitter<T> {
// eslint-disable-next-line @typescript-eslint/no-empty-function
private static readonly _noop = function () {};
private static readonly _noop = function () {
/* noop */
};
private readonly _options?: EmitterOptions;
private _disposed: boolean = false;
@ -40,35 +40,33 @@ export class Emitter {
* to events from this Emitter
*/
get event(): Event<T> {
if (!this._event) {
if (this._event == null) {
this._event = (listener: (e: T) => any, thisArgs?: any, disposables?: Disposable[]) => {
if (!this._listeners) {
if (this._listeners == null) {
this._listeners = new LinkedList();
}
const firstListener = this._listeners.isEmpty();
if (firstListener && this._options && this._options.onFirstListenerAdd) {
this._options.onFirstListenerAdd(this);
if (firstListener) {
this._options?.onFirstListenerAdd?.(this);
}
const remove = this._listeners.push(thisArgs != null ? listener : [listener, thisArgs]);
if (firstListener && this._options && this._options.onFirstListenerDidAdd) {
this._options.onFirstListenerDidAdd(this);
if (firstListener) {
this._options?.onFirstListenerDidAdd?.(this);
}
if (this._options?.onListenerDidAdd) {
this._options.onListenerDidAdd(this, listener, thisArgs);
}
this._options?.onListenerDidAdd?.(this, listener, thisArgs);
const result = {
dispose: () => {
result.dispose = Emitter._noop;
if (!this._disposed) {
remove();
if (this._options?.onLastListenerRemove) {
const hasListeners = this._listeners && !this._listeners.isEmpty();
if (this._options?.onLastListenerRemove != null) {
const hasListeners = !(this._listeners?.isEmpty() ?? true);
if (!hasListeners) {
this._options.onLastListenerRemove(this);
}
@ -91,12 +89,12 @@ export class Emitter {
* subscribers
*/
fire(event: T): void {
if (this._listeners) {
if (this._listeners != null) {
// put all [listener,event]-pairs into delivery queue
// then emit all event. an inner/nested event might be
// the driver of this
if (!this._deliveryQueue) {
if (this._deliveryQueue == null) {
this._deliveryQueue = new LinkedList();
}
@ -108,8 +106,7 @@ export class Emitter {
const [listener, event] = this._deliveryQueue.shift()!;
try {
if (typeof listener === 'function') {
// eslint-disable-next-line no-useless-call
listener.call(undefined, event);
listener(event);
} else {
listener[0].call(listener[1], event);
}
@ -122,12 +119,8 @@ export class Emitter {
}
dispose() {
if (this._listeners) {
this._listeners.clear();
}
if (this._deliveryQueue) {
this._deliveryQueue.clear();
}
this._listeners?.clear();
this._deliveryQueue?.clear();
this._disposed = true;
}
}

+ 1
- 1
src/webviews/apps/welcome/snow.ts Dosyayı Görüntüle

@ -57,7 +57,7 @@ export class Snow {
this._ctx = this._canvas.getContext('2d');
const trigger = document.querySelector('.snow__trigger');
if (trigger) {
if (trigger != null) {
trigger.addEventListener('click', () => this.onToggle());
}

+ 3
- 3
src/webviews/webviewBase.ts Dosyayı Görüntüle

@ -201,15 +201,15 @@ export abstract class WebviewBase implements Disposable {
.replace(/#{cspSource}/g, webview.cspSource)
.replace(/#{root}/g, webview.asWebviewUri(Container.context.extensionUri).toString());
if (this.renderHead) {
if (this.renderHead != null) {
html = html.replace(/#{head}/i, await this.renderHead());
}
if (this.renderBody) {
if (this.renderBody != null) {
html = html.replace(/#{body}/i, await this.renderBody());
}
if (this.renderEndOfBody) {
if (this.renderEndOfBody != null) {
html = html.replace(/#{endOfBody}/i, await this.renderEndOfBody());
}

Yükleniyor…
İptal
Kaydet