Skip to content

Commit 78f8697

Browse files
committed
WIP - eliminate more tslint warnings
1 parent 549db98 commit 78f8697

11 files changed

+603
-653
lines changed

examples/.vscode/settings.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,4 @@
33
// Relative paths for this setting are always relative to the workspace root dir.
44
"powershell.scriptAnalysis.settingsPath": "./PSScriptAnalyzerSettings.psd1",
55
"files.defaultLanguage": "powershell"
6-
}
6+
}

src/controls/animatedStatusBar.ts

+5-5
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,14 @@
33
*--------------------------------------------------------*/
44

55
import {
6-
StatusBarItem,
6+
Disposable,
77
StatusBarAlignment,
8+
StatusBarItem,
89
ThemeColor,
9-
Disposable,
1010
window} from "vscode";
1111

1212
export function showAnimatedStatusBarMessage(text: string, hideWhenDone: Thenable<any>): Disposable {
13-
let animatedStatusBarItem: AnimatedStatusBarItem = new AnimatedStatusBarItem(text);
13+
const animatedStatusBarItem: AnimatedStatusBarItem = new AnimatedStatusBarItem(text);
1414
animatedStatusBarItem.show(hideWhenDone);
1515
return animatedStatusBarItem;
1616
}
@@ -73,7 +73,7 @@ class AnimatedStatusBarItem implements StatusBarItem {
7373
this.counter = 0;
7474
this.suffixStates = [" ", ". ", ".. ", "..."];
7575
this.maxCount = this.suffixStates.length;
76-
this.timerInterval = ((1/this.maxCount) * 1000) / this.animationRate;
76+
this.timerInterval = ((1 / this.maxCount) * 1000) / this.animationRate;
7777
this.elapsedTime = 0;
7878
}
7979

@@ -121,4 +121,4 @@ class AnimatedStatusBarItem implements StatusBarItem {
121121
private stop(): void {
122122
clearInterval(this.intervalId);
123123
}
124-
}
124+
}

src/controls/checkboxQuickPick.ts

+28-29
Original file line numberDiff line numberDiff line change
@@ -4,96 +4,95 @@
44

55
import vscode = require("vscode");
66

7-
var confirmItemLabel: string = "$(checklist) Confirm";
8-
var checkedPrefix: string = "[ $(check) ]";
9-
var uncheckedPrefix: string = "[ ]";
10-
var defaultPlaceHolder: string = "Select 'Confirm' to confirm or press 'Esc' key to cancel";
7+
const confirmItemLabel: string = "$(checklist) Confirm";
8+
const checkedPrefix: string = "[ $(check) ]";
9+
const uncheckedPrefix: string = "[ ]";
10+
const defaultPlaceHolder: string = "Select 'Confirm' to confirm or press 'Esc' key to cancel";
1111

12-
export interface CheckboxQuickPickItem {
12+
export interface ICheckboxQuickPickItem {
1313
label: string;
1414
description?: string;
1515
isSelected: boolean;
1616
}
1717

18-
export interface CheckboxQuickPickOptions {
18+
export interface ICheckboxQuickPickOptions {
1919
confirmPlaceHolder: string;
2020
}
2121

22-
var defaultOptions:CheckboxQuickPickOptions = { confirmPlaceHolder: defaultPlaceHolder};
22+
const defaultOptions: ICheckboxQuickPickOptions = { confirmPlaceHolder: defaultPlaceHolder};
2323

2424
export function showCheckboxQuickPick(
25-
items: CheckboxQuickPickItem[],
26-
options: CheckboxQuickPickOptions = defaultOptions): Thenable<CheckboxQuickPickItem[]> {
25+
items: ICheckboxQuickPickItem[],
26+
options: ICheckboxQuickPickOptions = defaultOptions): Thenable<ICheckboxQuickPickItem[]> {
2727

2828
return showInner(items, options).then(
2929
(selectedItem) => {
3030
// We're mutating the original item list so just return it for now.
3131
// If 'selectedItem' is undefined it means the user cancelled the
3232
// inner showQuickPick UI so pass the undefined along.
33-
return selectedItem != undefined ? items : undefined;
34-
})
33+
return selectedItem !== undefined ? items : undefined;
34+
});
3535
}
3636

37-
function getQuickPickItems(items: CheckboxQuickPickItem[]): vscode.QuickPickItem[] {
37+
function getQuickPickItems(items: ICheckboxQuickPickItem[]): vscode.QuickPickItem[] {
3838

39-
let quickPickItems: vscode.QuickPickItem[] = [];
39+
const quickPickItems: vscode.QuickPickItem[] = [];
4040
quickPickItems.push({ label: confirmItemLabel, description: "" });
4141

42-
items.forEach(item =>
42+
items.forEach((item) =>
4343
quickPickItems.push({
4444
label: convertToCheckBox(item),
45-
description: item.description
45+
description: item.description,
4646
}));
4747

4848
return quickPickItems;
4949
}
5050

5151
function showInner(
52-
items: CheckboxQuickPickItem[],
53-
options: CheckboxQuickPickOptions): Thenable<vscode.QuickPickItem> {
52+
items: ICheckboxQuickPickItem[],
53+
options: ICheckboxQuickPickOptions): Thenable<vscode.QuickPickItem> {
5454

55-
var quickPickThenable: Thenable<vscode.QuickPickItem> =
55+
const quickPickThenable: Thenable<vscode.QuickPickItem> =
5656
vscode.window.showQuickPick(
5757
getQuickPickItems(items),
5858
{
5959
ignoreFocusOut: true,
6060
matchOnDescription: true,
61-
placeHolder: options.confirmPlaceHolder
61+
placeHolder: options.confirmPlaceHolder,
6262
});
6363

6464
return quickPickThenable.then(
6565
(selection) => {
6666
if (!selection) {
67-
//return Promise.reject<vscode.QuickPickItem>("showCheckBoxQuickPick cancelled")
6867
return Promise.resolve<vscode.QuickPickItem>(undefined);
6968
}
7069

7170
if (selection.label === confirmItemLabel) {
7271
return selection;
7372
}
7473

75-
let index: number = getItemIndex(items, selection.label);
74+
const index: number = getItemIndex(items, selection.label);
7675

7776
if (index >= 0) {
7877
toggleSelection(items[index]);
79-
}
80-
else {
78+
} else {
79+
// tslint:disable-next-line:no-console
8180
console.log(`Couldn't find CheckboxQuickPickItem for label '${selection.label}'`);
8281
}
8382

8483
return showInner(items, options);
8584
});
8685
}
8786

88-
function getItemIndex(items: CheckboxQuickPickItem[], itemLabel: string): number {
89-
var trimmedLabel = itemLabel.substr(itemLabel.indexOf("]") + 2);
90-
return items.findIndex(item => item.label === trimmedLabel);
87+
function getItemIndex(items: ICheckboxQuickPickItem[], itemLabel: string): number {
88+
const trimmedLabel = itemLabel.substr(itemLabel.indexOf("]") + 2);
89+
return items.findIndex((item) => item.label === trimmedLabel);
9190
}
9291

93-
function toggleSelection(item: CheckboxQuickPickItem): void {
92+
function toggleSelection(item: ICheckboxQuickPickItem): void {
9493
item.isSelected = !item.isSelected;
9594
}
9695

97-
function convertToCheckBox(item: CheckboxQuickPickItem): string {
96+
function convertToCheckBox(item: ICheckboxQuickPickItem): string {
9897
return `${item.isSelected ? checkedPrefix : uncheckedPrefix} ${item.label}`;
99-
}
98+
}

src/features/CodeActions.ts

+9-9
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,17 @@
22
* Copyright (C) Microsoft Corporation. All rights reserved.
33
*--------------------------------------------------------*/
44

5-
import vscode = require('vscode');
6-
import { LanguageClient } from 'vscode-languageclient';
5+
import vscode = require("vscode");
6+
import { LanguageClient } from "vscode-languageclient";
77
import Window = vscode.window;
8-
import { IFeature } from '../feature';
8+
import { IFeature } from "../feature";
99

1010
export class CodeActionsFeature implements IFeature {
1111
private command: vscode.Disposable;
1212
private languageClient: LanguageClient;
1313

1414
constructor() {
15-
this.command = vscode.commands.registerCommand('PowerShell.ApplyCodeActionEdits', (edit: any) => {
15+
this.command = vscode.commands.registerCommand("PowerShell.ApplyCodeActionEdits", (edit: any) => {
1616
Window.activeTextEditor.edit((editBuilder) => {
1717
editBuilder.replace(
1818
new vscode.Range(
@@ -25,11 +25,11 @@ export class CodeActionsFeature implements IFeature {
2525
});
2626
}
2727

28-
public setLanguageClient(languageclient: LanguageClient) {
29-
this.languageClient = languageclient;
30-
}
31-
3228
public dispose() {
3329
this.command.dispose();
3430
}
35-
}
31+
32+
public setLanguageClient(languageclient: LanguageClient) {
33+
this.languageClient = languageclient;
34+
}
35+
}

0 commit comments

Comments
 (0)