Skip to content

Commit 58e8c21

Browse files
Address various eslint errors (#14945)
Co-authored-by: Kim-Adeline Miguel <[email protected]>
1 parent 7f0b0d4 commit 58e8c21

22 files changed

+103
-40
lines changed

src/client/activation/common/cancellationUtils.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,7 @@ export class FileBasedCancellationStrategy implements CancellationStrategy, Disp
8080
this._sender = new FileCancellationSenderStrategy(folderName);
8181
}
8282

83+
// eslint-disable-next-line class-methods-use-this
8384
get receiver(): CancellationReceiverStrategy {
8485
return CancellationReceiverStrategy.Message;
8586
}

src/client/activation/jedi/activator.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ import { ILanguageServerManager } from '../types';
1919
*/
2020
@injectable()
2121
export class JediLanguageServerActivator extends LanguageServerActivatorBase {
22+
// eslint-disable-next-line @typescript-eslint/no-useless-constructor
2223
constructor(
2324
@inject(ILanguageServerManager) manager: ILanguageServerManager,
2425
@inject(IWorkspaceService) workspace: IWorkspaceService,
@@ -28,6 +29,7 @@ export class JediLanguageServerActivator extends LanguageServerActivatorBase {
2829
super(manager, workspace, fs, configurationService);
2930
}
3031

32+
// eslint-disable-next-line class-methods-use-this, @typescript-eslint/no-unused-vars
3133
public async ensureLanguageServerIsAvailable(_resource: Resource): Promise<void> {
3234
// Nothing to do here. Jedi language server is shipped with the extension
3335
}

src/client/activation/jedi/analysisOptions.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import { ILanguageServerOutputChannel } from '../types';
88

99
@injectable()
1010
export class JediLanguageServerAnalysisOptions extends LanguageServerAnalysisOptionsBase {
11+
// eslint-disable-next-line @typescript-eslint/no-useless-constructor
1112
constructor(
1213
@inject(IEnvironmentVariablesProvider) envVarsProvider: IEnvironmentVariablesProvider,
1314
@inject(ILanguageServerOutputChannel) lsOutputChannel: ILanguageServerOutputChannel

src/client/common/utils/resourceLifecycle.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,12 +44,13 @@ export class Disposables implements IDisposables {
4444
this.disposables.push(...disposables);
4545
}
4646

47-
public push(...disposables: IDisposable[]) {
47+
public push(...disposables: IDisposable[]): void {
4848
this.disposables.push(...disposables);
4949
}
5050

5151
public async dispose(): Promise<void> {
52-
const disposables = this.disposables;
52+
// tslint:disable-next-line: no-this-assignment
53+
const { disposables } = this;
5354
this.disposables = [];
5455
await disposeAll(disposables);
5556
}

src/client/pythonEnvironments/common/windowsRegistry.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,8 @@ import {
66
} from 'winreg';
77
import { createDeferred } from '../../common/utils/async';
88

9-
109
export { HKCU, HKLM, REG_SZ, Options };
1110

12-
1311
export interface IRegistryKey {
1412
hive: string;
1513
arch: string;

src/client/pythonEnvironments/discovery/locators/services/KnownPathsService.ts

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
import { inject, injectable } from 'inversify';
66
import * as path from 'path';
7+
import { Uri } from 'vscode';
78
import { IFileSystem, IPlatformService } from '../../../../common/platform/types';
89
import { ICurrentProcess, IPathUtils } from '../../../../common/types';
910
import { IInterpreterHelper, IKnownSearchPathsForInterpreters } from '../../../../interpreter/contracts';
@@ -34,16 +35,18 @@ export class KnownPathsService extends CacheableLocatorService {
3435
* Called by VS Code to indicate it is done with the resource.
3536
*/
3637
// tslint:disable:no-empty
37-
// eslint-disable-next-line @typescript-eslint/no-empty-function,class-methods-use-this
38-
public dispose(): void {}
39-
// tslint:enable:no-empty
38+
// eslint-disable-next-line
39+
public dispose(): void {
40+
// No body
41+
}
4042

4143
/**
4244
* Return the located interpreters.
4345
*
4446
* This is used by CacheableLocatorService.getInterpreters().
4547
*/
46-
protected getInterpretersImplementation(): Promise<PythonEnvironment[]> {
48+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
49+
protected getInterpretersImplementation(_resource?: Uri): Promise<PythonEnvironment[]> {
4750
return this.suggestionsFromKnownPaths();
4851
}
4952

src/client/pythonEnvironments/discovery/locators/services/condaEnvFileService.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,13 +39,16 @@ export class CondaEnvFileService extends CacheableLocatorService {
3939
* Called by VS Code to indicate it is done with the resource.
4040
*/
4141
// tslint:disable-next-line:no-empty
42-
public dispose() {}
42+
public dispose(): void {
43+
// No body
44+
}
4345

4446
/**
4547
* Return the located interpreters.
4648
*
4749
* This is used by CacheableLocatorService.getInterpreters().
4850
*/
51+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
4952
protected getInterpretersImplementation(_resource?: Uri): Promise<PythonEnvironment[]> {
5053
return this.getSuggestionsFromConda();
5154
}
@@ -108,12 +111,12 @@ export class CondaEnvFileService extends CacheableLocatorService {
108111
private async getInterpreterDetails(environmentPath: string): Promise<PythonEnvironment | undefined> {
109112
const interpreter = this.condaService.getInterpreterPath(environmentPath);
110113
if (!interpreter || !(await this.fileSystem.fileExists(interpreter))) {
111-
return;
114+
return undefined;
112115
}
113116

114117
const details = await this.helperService.getInterpreterInformation(interpreter);
115118
if (!details) {
116-
return;
119+
return undefined;
117120
}
118121
const envName = details.envName ? details.envName : path.basename(environmentPath);
119122
this._hasInterpreters.resolve(true);

src/client/pythonEnvironments/discovery/locators/services/condaEnvService.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,13 +31,16 @@ export class CondaEnvService extends CacheableLocatorService {
3131
* Called by VS Code to indicate it is done with the resource.
3232
*/
3333
// tslint:disable-next-line:no-empty
34-
public dispose() {}
34+
public dispose(): void {
35+
// No body
36+
}
3537

3638
/**
3739
* Return the located interpreters.
3840
*
3941
* This is used by CacheableLocatorService.getInterpreters().
4042
*/
43+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
4144
protected getInterpretersImplementation(_resource?: Uri): Promise<PythonEnvironment[]> {
4245
return this.getSuggestionsFromConda();
4346
}

src/client/pythonEnvironments/discovery/locators/services/currentPathService.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,9 @@ export class CurrentPathService extends CacheableLocatorService {
3939
* Called by VS Code to indicate it is done with the resource.
4040
*/
4141
// tslint:disable-next-line:no-empty
42-
public dispose() {}
42+
public dispose(): void {
43+
// No body
44+
}
4345

4446
/**
4547
* Return the located interpreters.
@@ -77,7 +79,7 @@ export class CurrentPathService extends CacheableLocatorService {
7779
private async getInterpreterDetails(pythonPath: string): Promise<PythonEnvironment | undefined> {
7880
return this.helper.getInterpreterInformation(pythonPath).then((details) => {
7981
if (!details) {
80-
return;
82+
return undefined;
8183
}
8284
this._hasInterpreters.resolve(true);
8385
return {
@@ -110,7 +112,7 @@ export class CurrentPathService extends CacheableLocatorService {
110112
);
111113
return '';
112114
})
113-
.catch((_ex) => {
115+
.catch(() => {
114116
traceInfo(
115117
`Detection of Python Interpreter for Command ${options.command} and args ${pyArgs.join(
116118
' ',

src/client/pythonEnvironments/discovery/locators/services/pipEnvService.ts

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,9 @@ export class PipEnvService extends CacheableLocatorService implements IPipEnvSer
4646
}
4747

4848
// tslint:disable-next-line:no-empty
49-
public dispose() {}
49+
public dispose(): void {
50+
// No body
51+
}
5052

5153
public async isRelatedPipEnvironment(dir: string, pythonPath: string): Promise<boolean> {
5254
if (!this.didTriggerInterpreterSuggestions) {
@@ -99,12 +101,12 @@ export class PipEnvService extends CacheableLocatorService implements IPipEnvSer
99101
private async getInterpreterFromPipenv(pipenvCwd: string): Promise<PythonEnvironment | undefined> {
100102
const interpreterPath = await this.getInterpreterPathFromPipenv(pipenvCwd);
101103
if (!interpreterPath) {
102-
return;
104+
return undefined;
103105
}
104106

105107
const details = await this.helper.getInterpreterInformation(interpreterPath);
106108
if (!details) {
107-
return;
109+
return undefined;
108110
}
109111
this._hasInterpreters.resolve(true);
110112
await this.pipEnvServiceHelper.trackWorkspaceFolder(interpreterPath, Uri.file(pipenvCwd));
@@ -129,7 +131,7 @@ export class PipEnvService extends CacheableLocatorService implements IPipEnvSer
129131
private async getInterpreterPathFromPipenv(cwd: string, ignoreErrors = false): Promise<string | undefined> {
130132
// Quick check before actually running pipenv
131133
if (!(await this.checkIfPipFileExists(cwd))) {
132-
return;
134+
return undefined;
133135
}
134136
try {
135137
// call pipenv --version just to see if pipenv is in the PATH
@@ -139,7 +141,7 @@ export class PipEnvService extends CacheableLocatorService implements IPipEnvSer
139141
appShell.showWarningMessage(
140142
`Workspace contains Pipfile but '${this.executable}' was not found. Make sure '${this.executable}' is on the PATH.`,
141143
);
142-
return;
144+
return undefined;
143145
}
144146
// The --py command will fail if the virtual environment has not been setup yet.
145147
// so call pipenv --venv to check for the virtual environment first.
@@ -149,7 +151,7 @@ export class PipEnvService extends CacheableLocatorService implements IPipEnvSer
149151
appShell.showWarningMessage(
150152
'Workspace contains Pipfile but the associated virtual environment has not been setup. Setup the virtual environment manually if needed.',
151153
);
152-
return;
154+
return undefined;
153155
}
154156
const pythonPath = await this.invokePipenv('--py', cwd);
155157
return pythonPath && (await this.fs.fileExists(pythonPath)) ? pythonPath : undefined;
@@ -160,6 +162,8 @@ export class PipEnvService extends CacheableLocatorService implements IPipEnvSer
160162
return undefined;
161163
}
162164
}
165+
166+
return undefined;
163167
}
164168

165169
private async checkIfPipFileExists(cwd: string): Promise<boolean> {
@@ -200,5 +204,7 @@ export class PipEnvService extends CacheableLocatorService implements IPipEnvSer
200204
traceWarning('Error in invoking PipEnv', error);
201205
traceWarning(`Relevant Environment Variables ${JSON.stringify(enviromentVariableValues, undefined, 4)}`);
202206
}
207+
208+
return undefined;
203209
}
204210
}

0 commit comments

Comments
 (0)