Skip to content

Commit

Permalink
Merge pull request #122918 from microsoft/tyriar/lint
Browse files Browse the repository at this point in the history
Add some eslint rules to terminal
  • Loading branch information
Tyriar authored May 4, 2021
2 parents 7a92985 + 2498273 commit 48010db
Show file tree
Hide file tree
Showing 47 changed files with 801 additions and 781 deletions.
2 changes: 1 addition & 1 deletion src/vs/platform/quickinput/browser/commandsQuickAccess.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ export abstract class AbstractCommandsQuickAccessProvider extends PickerQuickAcc
this.options = options;
}

protected async getPicks(filter: string, disposables: DisposableStore, token: CancellationToken): Promise<Array<ICommandQuickPick | IQuickPickSeparator>> {
protected async _getPicks(filter: string, disposables: DisposableStore, token: CancellationToken): Promise<Array<ICommandQuickPick | IQuickPickSeparator>> {

// Ask subclass for all command picks
const allCommandPicks = await this.getCommandPicks(disposables, token);
Expand Down
4 changes: 2 additions & 2 deletions src/vs/platform/quickinput/browser/pickerQuickAccess.ts
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ export abstract class PickerQuickAccessProvider<T extends IPickerQuickAccessItem
// Collect picks and support both long running and short or combined
const picksToken = picksCts.token;
const picksFilter = picker.value.substr(this.prefix.length).trim();
const providedPicks = this.getPicks(picksFilter, picksDisposables, picksToken);
const providedPicks = this._getPicks(picksFilter, picksDisposables, picksToken);

const applyPicks = (picks: Picks<T>, skipEmpty?: boolean): boolean => {
let items: readonly Pick<T>[];
Expand Down Expand Up @@ -330,5 +330,5 @@ export abstract class PickerQuickAccessProvider<T extends IPickerQuickAccessItem
* @returns the picks either directly, as promise or combined fast and slow results.
* Pickers can return `null` to signal that no change in picks is needed.
*/
protected abstract getPicks(filter: string, disposables: DisposableStore, token: CancellationToken): Picks<T> | Promise<Picks<T>> | FastAndSlowPicks<T> | null;
protected abstract _getPicks(filter: string, disposables: DisposableStore, token: CancellationToken): Picks<T> | Promise<Picks<T>> | FastAndSlowPicks<T> | null;
}
4 changes: 2 additions & 2 deletions src/vs/workbench/api/node/extHostTerminalService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import { ExtHostDocumentsAndEditors, IExtHostDocumentsAndEditors } from 'vs/work
import { IExtHostRpcService } from 'vs/workbench/api/common/extHostRpcService';
import { BaseExtHostTerminalService, ExtHostTerminal } from 'vs/workbench/api/common/extHostTerminalService';
import { ExtHostWorkspace, IExtHostWorkspace } from 'vs/workbench/api/common/extHostWorkspace';
import { ITerminalProfile, TERMINAL_SETTING_ID } from 'vs/workbench/contrib/terminal/common/terminal';
import { ITerminalProfile, TerminalSettingId } from 'vs/workbench/contrib/terminal/common/terminal';
import * as terminalEnvironment from 'vs/workbench/contrib/terminal/common/terminalEnvironment';
import { detectAvailableProfiles } from 'vs/workbench/contrib/terminal/node/terminalProfiles';
import type * as vscode from 'vscode';
Expand Down Expand Up @@ -134,7 +134,7 @@ export class ExtHostTerminalService extends BaseExtHostTerminalService {
private _buildSafeConfigProvider(configProvider: ExtHostConfigProvider): SafeConfigProvider {
const config = configProvider.getConfiguration();
return (key: string) => {
const isWorkspaceConfigAllowed = config.get(TERMINAL_SETTING_ID.AllowWorkspaceConfiguration);
const isWorkspaceConfigAllowed = config.get(TerminalSettingId.AllowWorkspaceConfiguration);
if (isWorkspaceConfigAllowed) {
return config.get(key) as any;
}
Expand Down
2 changes: 1 addition & 1 deletion src/vs/workbench/browser/parts/editor/editorQuickAccess.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ export abstract class BaseEditorQuickAccessProvider extends PickerQuickAccessPro
return super.provide(picker, token);
}

protected getPicks(filter: string): Array<IEditorQuickPickItem | IQuickPickSeparator> {
protected _getPicks(filter: string): Array<IEditorQuickPickItem | IQuickPickSeparator> {
const query = prepareQuery(filter);

// Filtering
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ export abstract class SimpleFindWidget extends Widget {
this._updateHistoryDelayer = new Delayer<void>(500);

this.oninput(this._findInput.domNode, (e) => {
this.foundMatch = this.onInputChanged();
this.foundMatch = this._onInputChanged();
this.updateButtons(this.foundMatch);
this._delayedUpdateHistory();
});
Expand Down Expand Up @@ -138,25 +138,25 @@ export abstract class SimpleFindWidget extends Widget {
});

this._focusTracker = this._register(dom.trackFocus(this._innerDomNode));
this._register(this._focusTracker.onDidFocus(this.onFocusTrackerFocus.bind(this)));
this._register(this._focusTracker.onDidBlur(this.onFocusTrackerBlur.bind(this)));
this._register(this._focusTracker.onDidFocus(this._onFocusTrackerFocus.bind(this)));
this._register(this._focusTracker.onDidBlur(this._onFocusTrackerBlur.bind(this)));

this._findInputFocusTracker = this._register(dom.trackFocus(this._findInput.domNode));
this._register(this._findInputFocusTracker.onDidFocus(this.onFindInputFocusTrackerFocus.bind(this)));
this._register(this._findInputFocusTracker.onDidBlur(this.onFindInputFocusTrackerBlur.bind(this)));
this._register(this._findInputFocusTracker.onDidFocus(this._onFindInputFocusTrackerFocus.bind(this)));
this._register(this._findInputFocusTracker.onDidBlur(this._onFindInputFocusTrackerBlur.bind(this)));

this._register(dom.addDisposableListener(this._innerDomNode, 'click', (event) => {
event.stopPropagation();
}));
}

protected abstract onInputChanged(): boolean;
protected abstract _onInputChanged(): boolean;
protected abstract find(previous: boolean): void;
protected abstract findFirst(): void;
protected abstract onFocusTrackerFocus(): void;
protected abstract onFocusTrackerBlur(): void;
protected abstract onFindInputFocusTrackerFocus(): void;
protected abstract onFindInputFocusTrackerBlur(): void;
protected abstract _onFocusTrackerFocus(): void;
protected abstract _onFocusTrackerBlur(): void;
protected abstract _onFindInputFocusTrackerFocus(): void;
protected abstract _onFindInputFocusTrackerBlur(): void;

protected get inputValue() {
return this._findInput.getValue();
Expand Down
2 changes: 1 addition & 1 deletion src/vs/workbench/contrib/debug/browser/debugQuickAccess.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ export class StartDebugQuickAccessProvider extends PickerQuickAccessProvider<IPi
});
}

protected async getPicks(filter: string): Promise<(IQuickPickSeparator | IPickerQuickAccessItem)[]> {
protected async _getPicks(filter: string): Promise<(IQuickPickSeparator | IPickerQuickAccessItem)[]> {
const picks: Array<IPickerQuickAccessItem | IQuickPickSeparator> = [];
picks.push({ type: 'separator', label: 'launch.json' });

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ export class InstallExtensionQuickAccessProvider extends PickerQuickAccessProvid
super(InstallExtensionQuickAccessProvider.PREFIX);
}

protected getPicks(filter: string, disposables: DisposableStore, token: CancellationToken): Array<IPickerQuickAccessItem | IQuickPickSeparator> | Promise<Array<IPickerQuickAccessItem | IQuickPickSeparator>> {
protected _getPicks(filter: string, disposables: DisposableStore, token: CancellationToken): Array<IPickerQuickAccessItem | IQuickPickSeparator> | Promise<Array<IPickerQuickAccessItem | IQuickPickSeparator>> {

// Nothing typed
if (!filter) {
Expand Down Expand Up @@ -100,7 +100,7 @@ export class ManageExtensionsQuickAccessProvider extends PickerQuickAccessProvid
super(ManageExtensionsQuickAccessProvider.PREFIX);
}

protected getPicks(): Array<IPickerQuickAccessItem | IQuickPickSeparator> {
protected _getPicks(): Array<IPickerQuickAccessItem | IQuickPickSeparator> {
return [{
label: localize('manage', "Press Enter to manage your extensions."),
accept: () => openExtensionsViewlet(this.viewletService)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ export class ViewQuickAccessProvider extends PickerQuickAccessProvider<IViewQuic
});
}

protected getPicks(filter: string): Array<IViewQuickPickItem | IQuickPickSeparator> {
protected _getPicks(filter: string): Array<IViewQuickPickItem | IQuickPickSeparator> {
const filteredViewEntries = this.doGetViewPickItems().filter(entry => {
if (!filter) {
return true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,7 @@ export class AnythingQuickAccessProvider extends PickerQuickAccessProvider<IAnyt
return toDisposable(() => this.clearDecorations(activeEditorControl));
}

protected getPicks(originalFilter: string, disposables: DisposableStore, token: CancellationToken): Picks<IAnythingQuickPickItem> | Promise<Picks<IAnythingQuickPickItem>> | FastAndSlowPicks<IAnythingQuickPickItem> | null {
protected _getPicks(originalFilter: string, disposables: DisposableStore, token: CancellationToken): Picks<IAnythingQuickPickItem> | Promise<Picks<IAnythingQuickPickItem>> | FastAndSlowPicks<IAnythingQuickPickItem> | null {

// Find a suitable range from the pattern looking for ":", "#" or ","
// unless we have the `@` editor symbol character inside the filter
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ export class SymbolsQuickAccessProvider extends PickerQuickAccessProvider<ISymbo
};
}

protected getPicks(filter: string, disposables: DisposableStore, token: CancellationToken): Promise<Array<ISymbolQuickPickItem>> {
protected _getPicks(filter: string, disposables: DisposableStore, token: CancellationToken): Promise<Array<ISymbolQuickPickItem>> {
return this.getSymbolPicks(filter, undefined, token);
}

Expand Down
2 changes: 1 addition & 1 deletion src/vs/workbench/contrib/tasks/browser/tasksQuickAccess.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ export class TasksQuickAccessProvider extends PickerQuickAccessProvider<IPickerQ
this.activationPromise = extensionService.activateByEvent('onCommand:workbench.action.tasks.runTask');
}

protected async getPicks(filter: string, disposables: DisposableStore, token: CancellationToken): Promise<Array<IPickerQuickAccessItem | IQuickPickSeparator>> {
protected async _getPicks(filter: string, disposables: DisposableStore, token: CancellationToken): Promise<Array<IPickerQuickAccessItem | IQuickPickSeparator>> {
// always await extensions
await this.activationPromise;

Expand Down
4 changes: 2 additions & 2 deletions src/vs/workbench/contrib/tasks/browser/terminalTaskSystem.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ import Constants from 'vs/workbench/contrib/markers/browser/constants';
import { ITelemetryService } from 'vs/platform/telemetry/common/telemetry';

import { IConfigurationResolverService } from 'vs/workbench/services/configurationResolver/common/configurationResolver';
import { ITerminalProfileResolverService, TERMINAL_SETTING_ID, TERMINAL_VIEW_ID } from 'vs/workbench/contrib/terminal/common/terminal';
import { ITerminalProfileResolverService, TerminalSettingId, TERMINAL_VIEW_ID } from 'vs/workbench/contrib/terminal/common/terminal';
import { ITerminalService, ITerminalInstance } from 'vs/workbench/contrib/terminal/browser/terminal';
import { IOutputService } from 'vs/workbench/contrib/output/common/output';
import { StartStopProblemCollector, WatchingProblemCollector, ProblemCollectorEventKind, ProblemHandlingStrategy } from 'vs/workbench/contrib/tasks/common/problemCollectors';
Expand Down Expand Up @@ -1074,7 +1074,7 @@ export class TerminalTaskSystem implements ITaskSystem {
// Under Mac remove -l to not start it as a login shell.
if (platform === Platform.Platform.Mac) {
// Background on -l on osx https://github.com/microsoft/vscode/issues/107563
const osxShellArgs = this.configurationService.inspect(TERMINAL_SETTING_ID.ShellArgsMacOs);
const osxShellArgs = this.configurationService.inspect(TerminalSettingId.ShellArgsMacOs);
if ((osxShellArgs.user === undefined) && (osxShellArgs.userLocal === undefined) && (osxShellArgs.userLocalValue === undefined)
&& (osxShellArgs.userRemote === undefined) && (osxShellArgs.userRemoteValue === undefined)
&& (osxShellArgs.userValue === undefined) && (osxShellArgs.workspace === undefined)
Expand Down
19 changes: 19 additions & 0 deletions src/vs/workbench/contrib/terminal/.eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{
"rules": {
"@typescript-eslint/naming-convention": [
"warn",
// variableLike
{ "selector": "variable", "format": ["camelCase", "UPPER_CASE", "PascalCase"] },
{ "selector": "variable", "filter": "^I.+Service$", "format": ["PascalCase"], "prefix": ["I"] },
// memberLike
{ "selector": "memberLike", "modifiers": ["private"], "format": ["camelCase"], "leadingUnderscore": "require" },
{ "selector": "memberLike", "modifiers": ["protected"], "format": ["camelCase"], "leadingUnderscore": "require" },
{ "selector": "enumMember", "format": ["PascalCase"] },
// memberLike - Allow enum-like objects to use UPPER_CASE
{ "selector": "method", "modifiers": ["public"], "format": ["camelCase", "UPPER_CASE"] },
// typeLike
{ "selector": "typeLike", "format": ["PascalCase"] },
{ "selector": "interface", "format": ["PascalCase"] }
]
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
*--------------------------------------------------------------------------------------------*/

import { EnvironmentVariableMutatorType, IEnvironmentVariableInfo, IMergedEnvironmentVariableCollection, IMergedEnvironmentVariableCollectionDiff } from 'vs/workbench/contrib/terminal/common/environmentVariable';
import { TERMINAL_COMMAND_ID } from 'vs/workbench/contrib/terminal/common/terminal';
import { TerminalCommandId } from 'vs/workbench/contrib/terminal/common/terminal';
import { ITerminalService } from 'vs/workbench/contrib/terminal/browser/terminal';
import { localize } from 'vs/nls';
import { ThemeIcon } from 'vs/platform/theme/common/themeService';
Expand Down Expand Up @@ -64,7 +64,7 @@ export class EnvironmentVariableInfoStale implements IEnvironmentVariableInfo {
return [{
label: localize('relaunchTerminalLabel', "Relaunch terminal"),
run: () => this._terminalService.getInstanceFromId(this._terminalId)?.relaunch(),
commandId: TERMINAL_COMMAND_ID.RELAUNCH
commandId: TerminalCommandId.Relaunch
}];
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ export class TerminalLinkManager extends DisposableStore {
if (uri.scheme === Schemas.file) {
// Just using fsPath here is unsafe: https://github.com/microsoft/vscode/issues/109076
const fsPath = uri.fsPath;
this._handleLocalLink(((this.osPath.sep === posix.sep) && isWindows) ? fsPath.replace(/\\/g, posix.sep) : fsPath);
this._handleLocalLink(((this._osPath.sep === posix.sep) && isWindows) ? fsPath.replace(/\\/g, posix.sep) : fsPath);
return;
}

Expand Down Expand Up @@ -263,7 +263,7 @@ export class TerminalLinkManager extends DisposableStore {
return markdown.appendMarkdown(`[${label}](${uri}) (${clickLabel})`);
}

private get osPath(): IPath {
private get _osPath(): IPath {
if (!this._processManager) {
throw new Error('Process manager is required');
}
Expand All @@ -282,7 +282,7 @@ export class TerminalLinkManager extends DisposableStore {
if (!this._processManager.userHome) {
return null;
}
link = this.osPath.join(this._processManager.userHome, link.substring(1));
link = this._osPath.join(this._processManager.userHome, link.substring(1));
} else if (link.charAt(0) !== '/' && link.charAt(0) !== '~') {
// Resolve workspace path . | .. | <relative_path> -> <path>/. | <path>/.. | <path>/<relative_path>
if (this._processManager.os === OperatingSystem.Windows) {
Expand All @@ -291,7 +291,7 @@ export class TerminalLinkManager extends DisposableStore {
// Abort if no workspace is open
return null;
}
link = this.osPath.join(this._processCwd, link);
link = this._osPath.join(this._processCwd, link);
} else {
// Remove \\?\ from paths so that they share the same underlying
// uri and don't open multiple tabs for the same file
Expand All @@ -302,10 +302,10 @@ export class TerminalLinkManager extends DisposableStore {
// Abort if no workspace is open
return null;
}
link = this.osPath.join(this._processCwd, link);
link = this._osPath.join(this._processCwd, link);
}
}
link = this.osPath.normalize(link);
link = this._osPath.normalize(link);

return link;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import { getQuickNavigateHandler } from 'vs/workbench/browser/quickaccess';
import { Extensions as ViewContainerExtensions, IViewContainersRegistry, ViewContainerLocation, IViewsRegistry } from 'vs/workbench/common/views';
import { registerTerminalActions, terminalSendSequenceCommand } from 'vs/workbench/contrib/terminal/browser/terminalActions';
import { TerminalViewPane } from 'vs/workbench/contrib/terminal/browser/terminalView';
import { KEYBINDING_CONTEXT_TERMINAL_SHELL_TYPE_KEY, KEYBINDING_CONTEXT_TERMINAL_FOCUS, TERMINAL_VIEW_ID, TERMINAL_COMMAND_ID } from 'vs/workbench/contrib/terminal/common/terminal';
import { KEYBINDING_CONTEXT_TERMINAL_SHELL_TYPE_KEY, KEYBINDING_CONTEXT_TERMINAL_FOCUS, TERMINAL_VIEW_ID, TerminalCommandId } from 'vs/workbench/contrib/terminal/common/terminal';
import { registerColors } from 'vs/workbench/contrib/terminal/common/terminalColorRegistry';
import { setupTerminalCommands } from 'vs/workbench/contrib/terminal/browser/terminalCommands';
import { IConfigurationRegistry, Extensions } from 'vs/platform/configuration/common/configurationRegistry';
Expand Down Expand Up @@ -82,7 +82,7 @@ Registry.as<IViewsRegistry>(ViewContainerExtensions.ViewsRegistry).registerViews
canMoveView: true,
ctorDescriptor: new SyncDescriptor(TerminalViewPane),
openCommandActionDescriptor: {
id: TERMINAL_COMMAND_ID.TOGGLE,
id: TerminalCommandId.Toggle,
mnemonicTitle: nls.localize({ key: 'miToggleIntegratedTerminal', comment: ['&& denotes a mnemonic'] }, "&&Terminal"),
keybindings: {
primary: KeyMod.CtrlCmd | KeyCode.US_BACKTICK,
Expand All @@ -97,7 +97,7 @@ registerTerminalActions();

function registerSendSequenceKeybinding(text: string, rule: { when?: ContextKeyExpression } & IKeybindings): void {
KeybindingsRegistry.registerCommandAndKeybindingRule({
id: TERMINAL_COMMAND_ID.SEND_SEQUENCE,
id: TerminalCommandId.SendSequence,
weight: KeybindingWeight.WorkbenchContrib,
when: rule.when || KEYBINDING_CONTEXT_TERMINAL_FOCUS,
primary: rule.primary,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

import { KeyCode, KeyMod } from 'vs/base/common/keyCodes';
import { KeybindingWeight, KeybindingsRegistry } from 'vs/platform/keybinding/common/keybindingsRegistry';
import { ITerminalProfileResolverService, TERMINAL_COMMAND_ID } from 'vs/workbench/contrib/terminal/common/terminal';
import { ITerminalProfileResolverService, TerminalCommandId } from 'vs/workbench/contrib/terminal/common/terminal';
import { registerSingleton } from 'vs/platform/instantiation/common/extensions';
import { BrowserTerminalProfileResolverService } from 'vs/workbench/contrib/terminal/browser/terminalProfileResolverService';

Expand All @@ -14,7 +14,7 @@ registerSingleton(ITerminalProfileResolverService, BrowserTerminalProfileResolve
// Register standard external terminal keybinding as integrated terminal when in web as the
// external terminal is not available
KeybindingsRegistry.registerKeybindingRule({
id: TERMINAL_COMMAND_ID.NEW,
id: TerminalCommandId.New,
weight: KeybindingWeight.WorkbenchContrib,
when: undefined,
primary: KeyMod.CtrlCmd | KeyMod.Shift | KeyCode.KEY_C
Expand Down
Loading

0 comments on commit 48010db

Please sign in to comment.