Skip to content

Commit

Permalink
Enable noUnusedLocals tsconfig flag (#515)
Browse files Browse the repository at this point in the history
  • Loading branch information
TwitchBronBron committed Nov 3, 2023
1 parent 316000b commit a36dcf8
Show file tree
Hide file tree
Showing 31 changed files with 32 additions and 122 deletions.
3 changes: 1 addition & 2 deletions src/BrightScriptDeclaration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@ import type {
} from 'vscode';
import {
Location,
SymbolKind,
TextDocument
SymbolKind
} from 'vscode';
import * as vscode from 'vscode';

Expand Down
1 change: 0 additions & 1 deletion src/BrightScriptReferenceProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@ export class BrightScriptReferenceProvider implements vscode.ReferenceProvider {
let locations = [];
let searchTerm = word;
let regex = new RegExp(searchTerm, 'ig');
let wordLength = word.length;
for (const [line, text] of iterlines(input)) {
let result;
while ((result = regex.exec(text))) {
Expand Down
4 changes: 0 additions & 4 deletions src/BrightScriptXmlDefinitionProvider.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,9 @@
import * as vscode from 'vscode';

import type {
CancellationToken,
Definition,
DefinitionProvider, Position, TextDocument
} from 'vscode';
import {
Range
} from 'vscode';

import { BrightScriptDeclaration } from './BrightScriptDeclaration';
import BrightScriptFileUtils from './BrightScriptFileUtils';
Expand Down
2 changes: 0 additions & 2 deletions src/DebugConfigurationProvider.spec.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
/* eslint-disable no-template-curly-in-string */
import * as brighterscript from 'brighterscript';
import { assert, expect } from 'chai';
import * as path from 'path';
import { createSandbox } from 'sinon';
Expand Down
11 changes: 0 additions & 11 deletions src/DebugConfigurationProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ import { fileUtils } from 'roku-debug';
import { util } from './util';
import type { TelemetryManager } from './managers/TelemetryManager';
import type { ActiveDeviceManager, RokuDeviceDetails } from './ActiveDeviceManager';
import { debounce } from 'debounce';

/**
* An id to represent the "Enter manually" option in the host picker
Expand Down Expand Up @@ -68,22 +67,13 @@ export class BrightScriptDebugConfigurationProvider implements DebugConfiguratio
deactivateOnSessionEnd: false
}
};

let config: any = vscode.workspace.getConfiguration('brightscript') || {};
this.showDeviceInfoMessages = config.deviceDiscovery?.showInfoMessages;

vscode.workspace.onDidChangeConfiguration((e) => {
let config: any = vscode.workspace.getConfiguration('brightscript') || {};
this.showDeviceInfoMessages = config.deviceDiscovery?.showInfoMessages;
});
}

//make unit testing easier by adding these imports properties
public fsExtra = fsExtra;
public util = util;

private configDefaults: any;
private showDeviceInfoMessages: boolean;

/**
* Massage a debug configuration just before a debug session is being launched,
Expand Down Expand Up @@ -390,7 +380,6 @@ export class BrightScriptDebugConfigurationProvider implements DebugConfiguratio
//replace all environment variable placeholders with their values
while ((match = regexp.exec(configValue))) {
let environmentVariableName = match[1];
let environmentVariableValue = envConfig[environmentVariableName];
configValue = configDefaults[key];
console.log(`The configuration value for ${key} was not found in the env file under the name ${environmentVariableName}. Defaulting the value to: ${configValue}`);
}
Expand Down
1 change: 0 additions & 1 deletion src/DeclarationProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,6 @@ export class DeclarationProvider implements Disposable {
}

private onDidChangeFile(uri: Uri) {
const excludes = getExcludeGlob();
this.dirty.set(uri.fsPath, uri);
}

Expand Down
1 change: 0 additions & 1 deletion src/DefinitionRepository.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import type {
Position,
TextDocument
} from 'vscode';
import { Uri } from 'vscode';
import { BrightScriptDeclaration } from './BrightScriptDeclaration';
import type { DeclarationProvider } from './DeclarationProvider';
import { getExcludeGlob } from './DeclarationProvider';
Expand Down
1 change: 0 additions & 1 deletion src/LanguageServerManager.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ Module.prototype.require = function hijacked(file) {
const tempDir = s`${process.cwd()}/.tmp`;

describe('extension', () => {
let context: any;
let languageServerManager: LanguageServerManager;

beforeEach(() => {
Expand Down
2 changes: 1 addition & 1 deletion src/LanguageServerManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,7 @@ export class LanguageServerManager {
this.simpleSubscriptions.push(
vscode.languages.registerDefinitionProvider(selector, definitionProvider),
vscode.languages.registerDocumentSymbolProvider(selector, new BrightScriptDocumentSymbolProvider(this.declarationProvider)),
vscode.languages.registerWorkspaceSymbolProvider(new BrightScriptWorkspaceSymbolProvider(this.declarationProvider, symbolInformationRepository)),
vscode.languages.registerWorkspaceSymbolProvider(new BrightScriptWorkspaceSymbolProvider(symbolInformationRepository)),
vscode.languages.registerReferenceProvider(selector, new BrightScriptReferenceProvider()),
vscode.languages.registerSignatureHelpProvider(selector, new BrightScriptSignatureHelpProvider(this.definitionRepository), '(', ',')
);
Expand Down
2 changes: 1 addition & 1 deletion src/LogDocumentLinkProvider.spec.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { assert, expect } from 'chai';
import { expect } from 'chai';
import * as path from 'path';
import * as sinonImport from 'sinon';

Expand Down
4 changes: 0 additions & 4 deletions src/LogDocumentLinkProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import * as path from 'path';
import * as rokuDeploy from 'roku-deploy';
import { DocumentLink, Position, Range } from 'vscode';
import * as vscode from 'vscode';
import { util } from './util';
import BrightscriptFileUtils from './BrightScriptFileUtils';
import type { BrightScriptLaunchConfiguration } from './DebugConfigurationProvider';

Expand Down Expand Up @@ -38,7 +37,6 @@ export class LogDocumentLinkProvider implements vscode.DocumentLinkProvider {
public fileUtils: BrightscriptFileUtils;

public async setLaunchConfig(launchConfig: BrightScriptLaunchConfiguration) {
this.launchConfig = launchConfig;
this.fileMaps = {};

let sourceRootDir = launchConfig.sourceDirs ? launchConfig.sourceDirs : [launchConfig.rootDir];
Expand Down Expand Up @@ -70,8 +68,6 @@ export class LogDocumentLinkProvider implements vscode.DocumentLinkProvider {
public fileMaps: Record<string, { src: string; dest: string; pkgPath: string }>;
public customLinks: DocumentLink[];

private launchConfig: BrightScriptLaunchConfiguration;

public provideDocumentLinks(doc: vscode.TextDocument, token: vscode.CancellationToken) {
return this.customLinks;
}
Expand Down
4 changes: 1 addition & 3 deletions src/LogOutputManager.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,7 @@ Module.prototype.require = function hijacked(file) {
import { DeclarationProvider } from './DeclarationProvider';
import { LogDocumentLinkProvider } from './LogDocumentLinkProvider';
import { LogLine, LogOutputManager } from './LogOutputManager';
import type { BSDebugDiagnostic } from 'roku-debug';
import { DiagnosticsEvent, LaunchStartEvent, LogOutputEvent } from 'roku-debug';
import { util } from 'brighterscript';
import { LaunchStartEvent, LogOutputEvent } from 'roku-debug';

describe('LogOutputManager ', () => {
let logOutputManagerMock: Sinon.SinonMock;
Expand Down
29 changes: 1 addition & 28 deletions src/LogOutputManager.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import * as vscode from 'vscode';
import type { BSDebugDiagnostic } from 'roku-debug';
import { isChanperfEvent, isDiagnosticsEvent, isLaunchStartEvent, isLogOutputEvent, isPopupMessageEvent, isRendezvousEvent } from 'roku-debug';
import { isChanperfEvent, isLaunchStartEvent, isLogOutputEvent, isPopupMessageEvent, isRendezvousEvent } from 'roku-debug';
import type { DeclarationProvider } from './DeclarationProvider';
import type { LogDocumentLinkProvider } from './LogDocumentLinkProvider';
import { CustomDocumentLink } from './LogDocumentLinkProvider';
Expand Down Expand Up @@ -31,7 +30,6 @@ export class LogOutputManager {
this.loadConfigSettings();
});

this.context = context;
let subscriptions = context.subscriptions;
this.includeRegex = null;
this.logLevelRegex = null;
Expand Down Expand Up @@ -85,7 +83,6 @@ export class LogOutputManager {
this.clearOutput();

}
private context: any;
private displayedLogLines: LogLine[];
private allLogLines: LogLine[];
private markCount: number;
Expand Down Expand Up @@ -247,30 +244,6 @@ export class LogOutputManager {
}
}

private getMatches(str, regex) {
const matches = [];
let match;

if (regex.global) {
regex.lastIndex = 0;
} else {
regex = new RegExp(regex.source, 'g' +
(regex.ignoreCase ? 'i' : '') +
(regex.multiline ? 'm' : '') +
(regex.sticky ? 'y' : ''));
}

while (match === regex.exec(str)) {
matches.push(match);

if (regex.lastIndex === match.index) {
regex.lastIndex++;
}
}

return matches;
}

private showMessage(message: string, severity: string) {
const methods = {
error: vscode.window.showErrorMessage,
Expand Down
4 changes: 1 addition & 3 deletions src/SymbolInformationRepository.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,10 @@ import type { DeclarationProvider } from './DeclarationProvider';

export class BrightScriptWorkspaceSymbolProvider implements WorkspaceSymbolProvider {

constructor(provider: DeclarationProvider, symbolInformationRepository: SymbolInformationRepository) {
this.declarationProvider = provider;
constructor(symbolInformationRepository: SymbolInformationRepository) {
this.repo = symbolInformationRepository;
}

private declarationProvider: DeclarationProvider;
private repo: SymbolInformationRepository;

public provideWorkspaceSymbols(query: string, token: CancellationToken): Promise<SymbolInformation[]> {
Expand Down
1 change: 0 additions & 1 deletion src/autoIndent.spec.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { readFileSync } from 'fs-extra';
import * as glob from 'glob';
import { expect } from 'chai';
import undent from 'undent';
interface IndentationRulesJSON {
Expand Down
5 changes: 2 additions & 3 deletions src/commands/BrighterScriptPreviewCommand.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { Uri, Position, Range } from 'vscode';
import { Uri, Range } from 'vscode';
import * as vscode from 'vscode';
import { extension } from '../extension';
import { util } from '../util';
import * as path from 'path';
import * as querystring from 'querystring';
Expand Down Expand Up @@ -129,7 +128,7 @@ export class BrighterScriptPreviewCommand {
/**
* Sync a source editor to the selection in the preview editor
*/
private async syncSourceLocation(uri: vscode.Uri) {
public async syncSourceLocation(uri: vscode.Uri) {
let sourceFsPath = this.getSourcePathFromPreviewUri(uri);
let activePreview = this.activePreviews[sourceFsPath];

Expand Down
1 change: 0 additions & 1 deletion src/commands/CaptureScreenshotCommand.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import * as vscode from 'vscode';
import * as fsExtra from 'fs-extra';
import * as rokuDeploy from 'roku-deploy';
import type { BrightScriptCommands } from '../BrightScriptCommands';

Expand Down
3 changes: 0 additions & 3 deletions src/commands/LanguageServerInfoCommand.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,7 @@ import * as path from 'path';
export class LanguageServerInfoCommand {
public static commandName = 'extension.brightscript.languageServer.info';

private context: vscode.ExtensionContext;
public register(context: vscode.ExtensionContext) {
this.context = context;

context.subscriptions.push(vscode.commands.registerCommand(LanguageServerInfoCommand.commandName, async () => {
const commands = [{
label: `Change Selected BrighterScript Version`,
Expand Down
3 changes: 0 additions & 3 deletions src/extension-web.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
import type * as vscode from 'vscode';

//TODO move this to a common file since it's duplicated in extension.ts
const EXTENSION_ID = 'RokuCommunity.brightscript';

export class Extension {

public async activate(context: vscode.ExtensionContext) {
Expand Down
1 change: 0 additions & 1 deletion src/extension.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ Module.prototype.require = function hijacked(file) {
};

describe('extension', () => {
let context: any;
let originalWebviews;
const extensionInstance = extension.extension;

Expand Down
4 changes: 1 addition & 3 deletions src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -96,14 +96,12 @@ export class Extension {

const definitionRepo = new DefinitionRepository(declarationProvider);

let languageServerPromise = languageServerManager.init(context, definitionRepo);

//register a tree data provider for this extension's "RENDEZVOUS" view in the debug area
let rendezvousViewProvider = new RendezvousViewProvider(context);
vscode.window.registerTreeDataProvider(ViewProviderId.rendezvousView, rendezvousViewProvider);

//register a tree data provider for this extension's "Online Devices" view
let onlineDevicesViewProvider = new OnlineDevicesViewProvider(context, activeDeviceManager);
let onlineDevicesViewProvider = new OnlineDevicesViewProvider(activeDeviceManager);
vscode.window.registerTreeDataProvider(ViewProviderId.onlineDevicesView, onlineDevicesViewProvider);

context.subscriptions.push(vscode.commands.registerCommand('extension.brightscript.rendezvous.clearHistory', async () => {
Expand Down
2 changes: 0 additions & 2 deletions src/formatter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,9 @@ import type { FormattingOptions } from 'brighterscript-formatter';
import { Runner, Formatter as BrighterScriptFormatter } from 'brighterscript-formatter';
import type {
DocumentRangeFormattingEditProvider,
ProviderResult,
TextDocument
} from 'vscode';
import {
EndOfLine,
Position,
Range,
TextEdit,
Expand Down
4 changes: 2 additions & 2 deletions src/managers/WebviewViewProviderManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ import { RokuAutomationViewViewProvider } from '../viewProviders/RokuAutomationV

export class WebviewViewProviderManager {
constructor(
private context: vscode.ExtensionContext,
context: vscode.ExtensionContext,
private rtaManager: RtaManager,
private brightScriptCommands: BrightScriptCommands
brightScriptCommands: BrightScriptCommands
) {

for (const webview of this.webviewViews) {
Expand Down
3 changes: 0 additions & 3 deletions src/managers/WhatsNewManager.spec.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,9 @@
import { expect } from 'chai';
import * as semver from 'semver';
import { createSandbox } from 'sinon';
import { GlobalStateManager } from '../GlobalStateManager';
import { vscode } from '../mockVscode.spec';
import { WhatsNewManager } from './WhatsNewManager';

const sinon = createSandbox();

describe('WhatsNewManager', () => {
let whatsNewManager: WhatsNewManager;
let globalStateManager: GlobalStateManager;
Expand Down
Loading

0 comments on commit a36dcf8

Please sign in to comment.