Skip to content

Commit

Permalink
Correct prettier errors
Browse files Browse the repository at this point in the history
  • Loading branch information
Kartik Raj committed Apr 7, 2020
1 parent 810191f commit d5f1677
Show file tree
Hide file tree
Showing 30 changed files with 742 additions and 718 deletions.
10 changes: 5 additions & 5 deletions src/client/activation/activationManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ export class ExtensionActivationManager implements IExtensionActivationManager {
await this.initialize();
// Activate all activation services together.
await Promise.all([
Promise.all(this.singleActivationServices.map(item => item.activate())),
Promise.all(this.singleActivationServices.map((item) => item.activate())),
this.activateWorkspace(this.activeResourceService.getActiveResource())
]);
await this.autoSelection.autoSelectInterpreter(undefined);
Expand All @@ -73,7 +73,7 @@ export class ExtensionActivationManager implements IExtensionActivationManager {

await this.autoSelection.autoSelectInterpreter(resource);
await this.evaluateAutoSelectedInterpreterSafety(resource);
await Promise.all(this.activationServices.map(item => item.activate(resource)));
await Promise.all(this.activationServices.map((item) => item.activate(resource)));
await this.appDiagnostics.performPreStartupHealthCheck(resource);
}
public async initialize() {
Expand Down Expand Up @@ -125,7 +125,7 @@ export class ExtensionActivationManager implements IExtensionActivationManager {
protected addHandlers() {
this.disposables.push(this.workspaceService.onDidChangeWorkspaceFolders(this.onWorkspaceFoldersChanged, this));
this.disposables.push(
this.interpreterPathService.onDidChange(i => this.evaluateAutoSelectedInterpreterSafety(i.uri))
this.interpreterPathService.onDidChange((i) => this.evaluateAutoSelectedInterpreterSafety(i.uri))
);
}
protected addRemoveDocOpenedHandlers() {
Expand All @@ -142,11 +142,11 @@ export class ExtensionActivationManager implements IExtensionActivationManager {
}
protected onWorkspaceFoldersChanged() {
//If an activated workspace folder was removed, delete its key
const workspaceKeys = this.workspaceService.workspaceFolders!.map(workspaceFolder =>
const workspaceKeys = this.workspaceService.workspaceFolders!.map((workspaceFolder) =>
this.getWorkspaceKey(workspaceFolder.uri)
);
const activatedWkspcKeys = Array.from(this.activatedWorkspaces.keys());
const activatedWkspcFoldersRemoved = activatedWkspcKeys.filter(item => workspaceKeys.indexOf(item) < 0);
const activatedWkspcFoldersRemoved = activatedWkspcKeys.filter((item) => workspaceKeys.indexOf(item) < 0);
if (activatedWkspcFoldersRemoved.length > 0) {
for (const folder of activatedWkspcFoldersRemoved) {
this.activatedWorkspaces.delete(folder);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ export class InvalidMacPythonInterpreterService extends BaseDiagnosticsService {
}

const interpreters = await this.interpreterService.getInterpreters(resource);
if (interpreters.filter(i => !this.helper.isMacDefaultPythonPath(i.path)).length === 0) {
if (interpreters.filter((i) => !this.helper.isMacDefaultPythonPath(i.path)).length === 0) {
return [
new InvalidMacPythonInterpreterDiagnostic(
DiagnosticCodes.MacInterpreterSelectedAndNoOtherInterpretersDiagnostic,
Expand All @@ -127,7 +127,7 @@ export class InvalidMacPythonInterpreterService extends BaseDiagnosticsService {
DiagnosticCommandPromptHandlerServiceId
);
await Promise.all(
diagnostics.map(async diagnostic => {
diagnostics.map(async (diagnostic) => {
const canHandle = await this.canHandle(diagnostic);
const shouldIgnore = await this.filterService.shouldIgnoreDiagnostic(diagnostic.code);
if (!canHandle || shouldIgnore) {
Expand All @@ -144,7 +144,7 @@ export class InvalidMacPythonInterpreterService extends BaseDiagnosticsService {
const interpreterPathService = this.serviceContainer.get<IInterpreterPathService>(IInterpreterPathService);
const experiments = this.serviceContainer.get<IExperimentsManager>(IExperimentsManager);
if (experiments.inExperiment(DeprecatePythonPath.experiment)) {
disposables.push(interpreterPathService.onDidChange(i => this.onDidChangeConfiguration(undefined, i)));
disposables.push(interpreterPathService.onDidChange((i) => this.onDidChangeConfiguration(undefined, i)));
}
experiments.sendTelemetryIfInExperiment(DeprecatePythonPath.control);
disposables.push(workspaceService.onDidChangeConfiguration(this.onDidChangeConfiguration.bind(this)));
Expand All @@ -157,9 +157,9 @@ export class InvalidMacPythonInterpreterService extends BaseDiagnosticsService {
if (event) {
const workspaceService = this.serviceContainer.get<IWorkspaceService>(IWorkspaceService);
const workspacesUris: (Uri | undefined)[] = workspaceService.hasWorkspaceFolders
? workspaceService.workspaceFolders!.map(workspace => workspace.uri)
? workspaceService.workspaceFolders!.map((workspace) => workspace.uri)
: [undefined];
const workspaceUriIndex = workspacesUris.findIndex(uri =>
const workspaceUriIndex = workspacesUris.findIndex((uri) =>
event.affectsConfiguration('python.pythonPath', uri)
);
if (workspaceUriIndex === -1) {
Expand All @@ -182,7 +182,7 @@ export class InvalidMacPythonInterpreterService extends BaseDiagnosticsService {
this.timeOut = setTimeout(() => {
this.timeOut = undefined;
this.diagnose(workspaceUri)
.then(diagnostics => this.handle(diagnostics))
.then((diagnostics) => this.handle(diagnostics))
.ignoreErrors();
}, this.changeThrottleTimeout);
}
Expand Down
14 changes: 7 additions & 7 deletions src/client/common/configSettings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -189,12 +189,12 @@ export class PythonSettings implements IPythonSettings {
throw new Error('Dispose can only be called from unit tests');
}
// tslint:disable-next-line:no-void-expression
PythonSettings.pythonSettings.forEach(item => item && item.dispose());
PythonSettings.pythonSettings.forEach((item) => item && item.dispose());
PythonSettings.pythonSettings.clear();
}
public dispose() {
// tslint:disable-next-line:no-unsafe-any
this.disposables.forEach(disposable => disposable && disposable.dispose());
this.disposables.forEach((disposable) => disposable && disposable.dispose());
this.disposables = [];
}
// tslint:disable-next-line:cyclomatic-complexity max-func-body-length
Expand Down Expand Up @@ -479,9 +479,9 @@ export class PythonSettings implements IPythonSettings {
}

// Resolve any variables found in the test arguments.
this.testing.nosetestArgs = this.testing.nosetestArgs.map(arg => systemVariables.resolveAny(arg));
this.testing.pytestArgs = this.testing.pytestArgs.map(arg => systemVariables.resolveAny(arg));
this.testing.unittestArgs = this.testing.unittestArgs.map(arg => systemVariables.resolveAny(arg));
this.testing.nosetestArgs = this.testing.nosetestArgs.map((arg) => systemVariables.resolveAny(arg));
this.testing.pytestArgs = this.testing.pytestArgs.map((arg) => systemVariables.resolveAny(arg));
this.testing.unittestArgs = this.testing.unittestArgs.map((arg) => systemVariables.resolveAny(arg));

// tslint:disable-next-line:no-backbone-get-set-outside-model no-non-null-assertion
const terminalSettings = systemVariables.resolveAny(pythonSettings.get<ITerminalSettings>('terminal'))!;
Expand Down Expand Up @@ -536,9 +536,9 @@ export class PythonSettings implements IPythonSettings {
}
protected onWorkspaceFoldersChanged() {
//If an activated workspace folder was removed, delete its key
const workspaceKeys = this.workspace.workspaceFolders!.map(workspaceFolder => workspaceFolder.uri.fsPath);
const workspaceKeys = this.workspace.workspaceFolders!.map((workspaceFolder) => workspaceFolder.uri.fsPath);
const activatedWkspcKeys = Array.from(PythonSettings.pythonSettings.keys());
const activatedWkspcFoldersRemoved = activatedWkspcKeys.filter(item => workspaceKeys.indexOf(item) < 0);
const activatedWkspcFoldersRemoved = activatedWkspcKeys.filter((item) => workspaceKeys.indexOf(item) < 0);
if (activatedWkspcFoldersRemoved.length > 0) {
for (const folder of activatedWkspcFoldersRemoved) {
PythonSettings.pythonSettings.delete(folder);
Expand Down
10 changes: 5 additions & 5 deletions src/client/common/experiments.ts
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ export class ExperimentsManager implements IExperimentsManager {
return false;
}
this.sendTelemetryIfInExperiment(experimentName);
return this.userExperiments.find(exp => exp.name === experimentName) ? true : false;
return this.userExperiments.find((exp) => exp.name === experimentName) ? true : false;
}

/**
Expand Down Expand Up @@ -180,7 +180,7 @@ export class ExperimentsManager implements IExperimentsManager {

@traceDecorators.error('Failed to send telemetry when user is in experiment')
public sendTelemetryIfInExperiment(experimentName: string): void {
if (this.userExperiments.find(exp => exp.name === experimentName)) {
if (this.userExperiments.find((exp) => exp.name === experimentName)) {
sendTelemetryEvent(EventName.PYTHON_EXPERIMENTS, undefined, { expName: experimentName });
}
}
Expand Down Expand Up @@ -223,7 +223,7 @@ export class ExperimentsManager implements IExperimentsManager {
throw new Error('Machine ID should be a string');
}
let hash: number;
if (oldExperimentSalts.find(oldSalt => oldSalt === salt)) {
if (oldExperimentSalts.find((oldSalt) => oldSalt === salt)) {
hash = this.crypto.createHash(`${this.appEnvironment.machineId}+${salt}`, 'number', 'SHA512');
} else {
hash = this.crypto.createHash(`${this.appEnvironment.machineId}+${salt}`, 'number', 'FNV');
Expand Down Expand Up @@ -337,7 +337,7 @@ export class ExperimentsManager implements IExperimentsManager {
this._experimentsOptedOutFrom[i] = '';
}
}
this._experimentsOptedInto = this._experimentsOptedInto.filter(exp => exp !== '');
this._experimentsOptedOutFrom = this._experimentsOptedOutFrom.filter(exp => exp !== '');
this._experimentsOptedInto = this._experimentsOptedInto.filter((exp) => exp !== '');
this._experimentsOptedOutFrom = this._experimentsOptedOutFrom.filter((exp) => exp !== '');
}
}
30 changes: 16 additions & 14 deletions src/client/common/utils/decorators.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ export function debounceAsync(wait?: number) {

export function makeDebounceDecorator(wait?: number) {
// tslint:disable-next-line:no-any no-function-expression
return function(_target: any, _propertyName: string, descriptor: TypedPropertyDescriptor<VoidFunction>) {
return function (_target: any, _propertyName: string, descriptor: TypedPropertyDescriptor<VoidFunction>) {
// We could also make use of _debounce() options. For instance,
// the following causes the original method to be called
// immediately:
Expand All @@ -72,7 +72,7 @@ export function makeDebounceDecorator(wait?: number) {
const options = {};
const originalMethod = descriptor.value!;
const debounced = _debounce(
function(this: any) {
function (this: any) {
return originalMethod.apply(this, arguments as any);
},
wait,
Expand All @@ -84,7 +84,7 @@ export function makeDebounceDecorator(wait?: number) {

export function makeDebounceAsyncDecorator(wait?: number) {
// tslint:disable-next-line:no-any no-function-expression
return function(_target: any, _propertyName: string, descriptor: TypedPropertyDescriptor<AsyncVoidFunction>) {
return function (_target: any, _propertyName: string, descriptor: TypedPropertyDescriptor<AsyncVoidFunction>) {
type StateInformation = {
started: boolean;
deferred: Deferred<any> | undefined;
Expand All @@ -94,7 +94,7 @@ export function makeDebounceAsyncDecorator(wait?: number) {
const state: StateInformation = { started: false, deferred: undefined, timer: undefined };

// Lets defer execution using a setTimeout for the given time.
(descriptor as any).value = function(this: any) {
(descriptor as any).value = function (this: any) {
const existingDeferred: Deferred<any> | undefined = state.deferred;
if (existingDeferred && state.started) {
return existingDeferred.promise;
Expand All @@ -112,11 +112,11 @@ export function makeDebounceAsyncDecorator(wait?: number) {
state.started = true;
originalMethod
.apply(this)
.then(r => {
.then((r) => {
state.started = false;
deferred.resolve(r);
})
.catch(ex => {
.catch((ex) => {
state.started = false;
deferred.reject(ex);
});
Expand All @@ -141,15 +141,15 @@ export function clearCachedResourceSpecificIngterpreterData(
type PromiseFunctionWithAnyArgs = (...any: any) => Promise<any>;
const cacheStoreForMethods = getGlobalCacheStore();
export function cache(expiryDurationMs: number) {
return function(
return function (
target: Object,
propertyName: string,
descriptor: TypedPropertyDescriptor<PromiseFunctionWithAnyArgs>
) {
const originalMethod = descriptor.value!;
const className = 'constructor' in target && target.constructor.name ? target.constructor.name : '';
const keyPrefix = `Cache_Method_Output_${className}.${propertyName}`;
descriptor.value = async function(...args: any) {
descriptor.value = async function (...args: any) {
if (isTestExecution()) {
return originalMethod.apply(this, args) as Promise<any>;
}
Expand All @@ -161,7 +161,9 @@ export function cache(expiryDurationMs: number) {
}
const promise = originalMethod.apply(this, args) as Promise<any>;
promise
.then(result => cacheStoreForMethods.set(key, { data: result, expiry: Date.now() + expiryDurationMs }))
.then((result) =>
cacheStoreForMethods.set(key, { data: result, expiry: Date.now() + expiryDurationMs })
)
.ignoreErrors();
return promise;
};
Expand All @@ -177,18 +179,18 @@ export function cache(expiryDurationMs: number) {
*/
export function swallowExceptions(scopeName: string) {
// tslint:disable-next-line:no-any no-function-expression
return function(_target: any, propertyName: string, descriptor: TypedPropertyDescriptor<any>) {
return function (_target: any, propertyName: string, descriptor: TypedPropertyDescriptor<any>) {
const originalMethod = descriptor.value!;
const errorMessage = `Python Extension (Error in ${scopeName}, method:${propertyName}):`;
// tslint:disable-next-line:no-any no-function-expression
descriptor.value = function(...args: any[]) {
descriptor.value = function (...args: any[]) {
try {
// tslint:disable-next-line:no-invalid-this no-use-before-declare no-unsafe-any
const result = originalMethod.apply(this, args);

// If method being wrapped returns a promise then wait and swallow errors.
if (result && typeof result.then === 'function' && typeof result.catch === 'function') {
return (result as Promise<void>).catch(error => {
return (result as Promise<void>).catch((error) => {
if (isTestExecution()) {
return;
}
Expand All @@ -209,10 +211,10 @@ export function swallowExceptions(scopeName: string) {
type PromiseFunction = (...any: any[]) => Promise<any>;

export function displayProgress(title: string, location = ProgressLocation.Window) {
return function(_target: Object, _propertyName: string, descriptor: TypedPropertyDescriptor<PromiseFunction>) {
return function (_target: Object, _propertyName: string, descriptor: TypedPropertyDescriptor<PromiseFunction>) {
const originalMethod = descriptor.value!;
// tslint:disable-next-line:no-any no-function-expression
descriptor.value = async function(...args: any[]) {
descriptor.value = async function (...args: any[]) {
const progressOptions: ProgressOptions = { location, title };
// tslint:disable-next-line:no-invalid-this
const promise = originalMethod.apply(this, args);
Expand Down
6 changes: 3 additions & 3 deletions src/client/common/variables/environmentVariablesProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ export class EnvironmentVariablesProvider implements IEnvironmentVariablesProvid

public dispose() {
this.changeEventEmitter.dispose();
this.fileWatchers.forEach(watcher => {
this.fileWatchers.forEach((watcher) => {
if (watcher) {
watcher.dispose();
}
Expand All @@ -62,7 +62,7 @@ export class EnvironmentVariablesProvider implements IEnvironmentVariablesProvid
return Promise.resolve(cacheStore.data) as Promise<EnvironmentVariables>;
}
const promise = this._getEnvironmentVariables(resource);
promise.then(result => (cacheStore.data = result)).ignoreErrors();
promise.then((result) => (cacheStore.data = result)).ignoreErrors();
return promise;
}
public async _getEnvironmentVariables(resource?: Uri): Promise<EnvironmentVariables> {
Expand All @@ -89,7 +89,7 @@ export class EnvironmentVariablesProvider implements IEnvironmentVariablesProvid
return this.envVarsService.parseFile(settings.envFile, this.process.env);
}
public configurationChanged(e: ConfigurationChangeEvent) {
this.trackedWorkspaceFolders.forEach(item => {
this.trackedWorkspaceFolders.forEach((item) => {
const uri = item && item.length > 0 ? Uri.file(item) : undefined;
if (e.affectsConfiguration('python.envFile', uri)) {
this.onEnvironmentFileChanged(uri);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ export class InterpreterSecurityStorage implements IInterpreterSecurityStorage {
}

public async resetInterpreterSecurityStorage(): Promise<void> {
this.flaggedWorkspacesKeysStorage.value.forEach(async key => {
this.flaggedWorkspacesKeysStorage.value.forEach(async (key) => {
const areInterpretersInWorkspaceSafe = this.persistentStateFactory.createGlobalPersistentState<
boolean | undefined
>(key, undefined);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ export class InterpreterSelector implements IInterpreterSelector {

type WorkspaceSelectionQuickPickItem = QuickPickItem & { uri: Uri };
const quickPickItems: WorkspaceSelectionQuickPickItem[] = [
...this.workspaceService.workspaceFolders.map(w => ({
...this.workspaceService.workspaceFolders.map((w) => ({
label: w.name,
description: path.dirname(w.uri.fsPath),
uri: w.uri
Expand Down
Loading

0 comments on commit d5f1677

Please sign in to comment.