Skip to content

Commit e7d7fdc

Browse files
authored
Fix autofixable ESLint warnings (#13613)
* Autofixed changes * Fix that one require that was confusing ESLint * Change max-len rule to warning + ignore strings * Add a return value to make compile step pass * Fix linting step * Re-enable comma-dangle + address comments * ESLint pass after main merge
1 parent be36d7a commit e7d7fdc

File tree

57 files changed

+828
-779
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

57 files changed

+828
-779
lines changed

.eslintignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -301,6 +301,7 @@ src/test/common/utils/regexp.unit.test.ts
301301
src/test/common/utils/cacheUtils.unit.test.ts
302302
src/test/common/utils/decorators.unit.test.ts
303303
src/test/common/utils/localize.functional.test.ts
304+
src/test/common/utils/workerPool.functional.test.ts
304305
src/test/common/configSettings/configSettings.pythonPath.unit.test.ts
305306
src/test/common/configSettings/configSettings.unit.test.ts
306307
src/test/common/featureDeprecationManager.unit.test.ts
@@ -1053,6 +1054,7 @@ src/client/common/utils/version.ts
10531054
src/client/common/utils/misc.ts
10541055
src/client/common/utils/logging.ts
10551056
src/client/common/utils/cacheUtils.ts
1057+
src/client/common/utils/workerPool.ts
10561058
src/client/common/crypto.ts
10571059
src/client/common/extensions.ts
10581060
src/client/common/dotnet/compatibilityService.ts

.eslintrc

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,6 @@
4545
"@typescript-eslint/no-useless-constructor": "error",
4646
"@typescript-eslint/no-var-requires": "off",
4747
// Other rules
48-
"comma-dangle": "off",
4948
"func-names": "off",
5049
"import/extensions": "off",
5150
"import/namespace": "off",
@@ -68,10 +67,12 @@
6867
}
6968
],
7069
"max-len": [
71-
"error",
70+
"warn",
7271
{
7372
"code": 120,
7473
"ignorePattern": "^import\\s.+\\sfrom\\s.+;$",
74+
"ignoreStrings": true,
75+
"ignoreTemplateLiterals": true,
7576
"ignoreUrls": true
7677
}
7778
],

src/client/pythonEnvironments/discovery/globalenv.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ export function getPyenvTypeFinder(
2525
pathJoin: (...parts: string[]) => string,
2626
// </path>
2727
getEnvVar: (name: string) => string | undefined,
28-
exec: ExecFunc
28+
exec: ExecFunc,
2929
): TypeFinderFunc {
3030
const find = getPyenvRootFinder(homedir, pathJoin, getEnvVar, exec);
3131
return async (python) => {
@@ -49,7 +49,7 @@ export function getPyenvRootFinder(
4949
homedir: string,
5050
pathJoin: (...parts: string[]) => string,
5151
getEnvVar: (name: string) => string | undefined,
52-
exec: ExecFunc
52+
exec: ExecFunc,
5353
): RootFinderFunc {
5454
return async () => {
5555
const root = getEnvVar('PYENV_ROOT');

src/client/pythonEnvironments/discovery/locators/helpers.ts

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -30,13 +30,12 @@ export async function lookForInterpretersInDirectory(pathToCheck: string, _: IFi
3030
export class InterpreterLocatorHelper implements IInterpreterLocatorHelper {
3131
constructor(
3232
@inject(IFileSystem) private readonly fs: IFileSystem,
33-
@inject(IPipEnvServiceHelper) private readonly pipEnvServiceHelper: IPipEnvServiceHelper
33+
@inject(IPipEnvServiceHelper) private readonly pipEnvServiceHelper: IPipEnvServiceHelper,
3434
) {}
35+
3536
public async mergeInterpreters(interpreters: PythonEnvironment[]): Promise<PythonEnvironment[]> {
3637
const items = interpreters
37-
.map((item) => {
38-
return { ...item };
39-
})
38+
.map((item) => ({ ...item }))
4039
.map((item) => {
4140
item.path = path.normalize(item.path);
4241
return item;
@@ -47,11 +46,11 @@ export class InterpreterLocatorHelper implements IInterpreterLocatorHelper {
4746
// If same version and same base path, then ignore.
4847
// Could be Python 3.6 with path = python.exe, and Python 3.6 and path = python3.exe.
4948
if (
50-
item.version &&
51-
item.version.raw === currentVersion &&
52-
item.path &&
53-
current.path &&
54-
this.fs.arePathsSame(path.dirname(item.path), path.dirname(current.path))
49+
item.version
50+
&& item.version.raw === currentVersion
51+
&& item.path
52+
&& current.path
53+
&& this.fs.arePathsSame(path.dirname(item.path), path.dirname(current.path))
5554
) {
5655
return true;
5756
}
@@ -63,8 +62,8 @@ export class InterpreterLocatorHelper implements IInterpreterLocatorHelper {
6362
// Preserve type information.
6463
// Possible we identified environment as unknown, but a later provider has identified env type.
6564
if (
66-
existingItem.envType === EnvironmentType.Unknown &&
67-
current.envType !== EnvironmentType.Unknown
65+
existingItem.envType === EnvironmentType.Unknown
66+
&& current.envType !== EnvironmentType.Unknown
6867
) {
6968
existingItem.envType = current.envType;
7069
}
@@ -75,7 +74,7 @@ export class InterpreterLocatorHelper implements IInterpreterLocatorHelper {
7574
'sysPrefix',
7675
'architecture',
7776
'sysVersion',
78-
'version'
77+
'version',
7978
];
8079
for (const prop of props) {
8180
if (!existingItem[prop] && current[prop]) {
@@ -95,7 +94,7 @@ export class InterpreterLocatorHelper implements IInterpreterLocatorHelper {
9594
item.pipEnvWorkspaceFolder = info.workspaceFolder.fsPath;
9695
item.envName = info.envName || item.envName;
9796
}
98-
})
97+
}),
9998
);
10099
return items;
101100
}

src/client/pythonEnvironments/discovery/locators/index.ts

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
import { inject, injectable } from 'inversify';
2-
import { Disposable, Event, EventEmitter, Uri } from 'vscode';
2+
import {
3+
Disposable, Event, EventEmitter, Uri,
4+
} from 'vscode';
35
import { traceDecorators } from '../../../common/logger';
46
import { IPlatformService } from '../../../common/platform/types';
57
import { IDisposableRegistry } from '../../../common/types';
@@ -15,7 +17,7 @@ import {
1517
KNOWN_PATH_SERVICE,
1618
PIPENV_SERVICE,
1719
WINDOWS_REGISTRY_SERVICE,
18-
WORKSPACE_VIRTUAL_ENV_SERVICE
20+
WORKSPACE_VIRTUAL_ENV_SERVICE,
1921
} from '../../../interpreter/contracts';
2022
import { IServiceContainer } from '../../../ioc/types';
2123
import { PythonEnvironment } from '../../info';
@@ -33,8 +35,11 @@ export class PythonInterpreterLocatorService implements IInterpreterLocatorServi
3335
public didTriggerInterpreterSuggestions: boolean;
3436

3537
private readonly disposables: Disposable[] = [];
38+
3639
private readonly platform: IPlatformService;
40+
3741
private readonly interpreterLocatorHelper: IInterpreterLocatorHelper;
42+
3843
private readonly _hasInterpreters: Deferred<boolean>;
3944

4045
constructor(@inject(IServiceContainer) private serviceContainer: IServiceContainer) {
@@ -44,6 +49,7 @@ export class PythonInterpreterLocatorService implements IInterpreterLocatorServi
4449
this.interpreterLocatorHelper = serviceContainer.get<IInterpreterLocatorHelper>(IInterpreterLocatorHelper);
4550
this.didTriggerInterpreterSuggestions = false;
4651
}
52+
4753
/**
4854
* This class should never emit events when we're locating.
4955
* The events will be fired by the indivitual locators retrieved in `getLocators`.
@@ -55,6 +61,7 @@ export class PythonInterpreterLocatorService implements IInterpreterLocatorServi
5561
public get onLocating(): Event<Promise<PythonEnvironment[]>> {
5662
return new EventEmitter<Promise<PythonEnvironment[]>>().event;
5763
}
64+
5865
public get hasInterpreters(): Promise<boolean> {
5966
return this._hasInterpreters.completed ? this._hasInterpreters.promise : Promise.resolve(false);
6067
}
@@ -115,7 +122,7 @@ export class PythonInterpreterLocatorService implements IInterpreterLocatorServi
115122
[GLOBAL_VIRTUAL_ENV_SERVICE, undefined],
116123
[WORKSPACE_VIRTUAL_ENV_SERVICE, undefined],
117124
[KNOWN_PATH_SERVICE, undefined],
118-
[CURRENT_PATH_SERVICE, undefined]
125+
[CURRENT_PATH_SERVICE, undefined],
119126
];
120127

121128
const locators = keys

src/client/pythonEnvironments/discovery/locators/progressService.ts

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,41 +16,51 @@ import { PythonEnvironment } from '../../info';
1616
@injectable()
1717
export class InterpreterLocatorProgressService implements IInterpreterLocatorProgressService {
1818
private deferreds: Deferred<PythonEnvironment[]>[] = [];
19+
1920
private readonly refreshing = new EventEmitter<void>();
21+
2022
private readonly refreshed = new EventEmitter<void>();
23+
2124
private readonly locators: IInterpreterLocatorService[] = [];
25+
2226
constructor(
2327
@inject(IServiceContainer) serviceContainer: IServiceContainer,
24-
@inject(IDisposableRegistry) private readonly disposables: Disposable[]
28+
@inject(IDisposableRegistry) private readonly disposables: Disposable[],
2529
) {
2630
this.locators = serviceContainer.getAll<IInterpreterLocatorService>(IInterpreterLocatorService);
2731
}
2832

2933
public get onRefreshing(): Event<void> {
3034
return this.refreshing.event;
3135
}
36+
3237
public get onRefreshed(): Event<void> {
3338
return this.refreshed.event;
3439
}
40+
3541
public register(): void {
3642
this.locators.forEach((locator) => {
3743
locator.onLocating(this.handleProgress, this, this.disposables);
3844
});
3945
}
46+
4047
@traceDecorators.verbose('Detected refreshing of Interpreters')
4148
private handleProgress(promise: Promise<PythonEnvironment[]>) {
4249
this.deferreds.push(createDeferredFrom(promise));
4350
this.notifyRefreshing();
4451
this.checkProgress();
4552
}
53+
4654
@traceDecorators.verbose('All locators have completed locating')
4755
private notifyCompleted() {
4856
this.refreshed.fire();
4957
}
58+
5059
@traceDecorators.verbose('Notify locators are locating')
5160
private notifyRefreshing() {
5261
this.refreshing.fire();
5362
}
63+
5464
private checkProgress() {
5565
if (this.deferreds.length === 0) {
5666
return;
@@ -63,6 +73,7 @@ export class InterpreterLocatorProgressService implements IInterpreterLocatorPro
6373
.then(() => this.checkProgress())
6474
.ignoreErrors();
6575
}
76+
6677
@traceDecorators.verbose('Checking whether locactors have completed locating')
6778
private areAllItemsComplete() {
6879
this.deferreds = this.deferreds.filter((item) => !item.completed);

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

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import { IServiceContainer } from '../../../../ioc/types';
99
import { EnvironmentType, PythonEnvironment } from '../../../info';
1010
import { lookForInterpretersInDirectory } from '../helpers';
1111
import { CacheableLocatorService } from './cacheableLocatorService';
12+
1213
const flatten = require('lodash/flatten') as typeof import('lodash/flatten');
1314

1415
/**
@@ -19,7 +20,7 @@ export class KnownPathsService extends CacheableLocatorService {
1920
public constructor(
2021
@inject(IKnownSearchPathsForInterpreters) private knownSearchPaths: IKnownSearchPathsForInterpreters,
2122
@inject(IInterpreterHelper) private helper: IInterpreterHelper,
22-
@inject(IServiceContainer) serviceContainer: IServiceContainer
23+
@inject(IServiceContainer) serviceContainer: IServiceContainer,
2324
) {
2425
super('KnownPathsService', serviceContainer);
2526
}
@@ -48,13 +49,15 @@ export class KnownPathsService extends CacheableLocatorService {
4849
const promises = this.knownSearchPaths.getSearchPaths().map((dir) => this.getInterpretersInDirectory(dir));
4950
return Promise.all<string[]>(promises)
5051
.then((listOfInterpreters) => flatten(listOfInterpreters))
51-
.then((interpreters) => interpreters.filter((item) => item.length > 0))
52-
.then((interpreters) =>
53-
Promise.all(interpreters.map((interpreter) => this.getInterpreterDetails(interpreter)))
54-
)
55-
.then((interpreters) =>
56-
interpreters.filter((interpreter) => !!interpreter).map((interpreter) => interpreter!)
57-
);
52+
.then((interpreters) => interpreters.filter(
53+
(item) => item.length > 0,
54+
))
55+
.then((interpreters) => Promise.all(
56+
interpreters.map((interpreter) => this.getInterpreterDetails(interpreter)),
57+
))
58+
.then((interpreters) => interpreters.filter(
59+
(interpreter) => !!interpreter,
60+
).map((interpreter) => interpreter!));
5861
}
5962

6063
/**
@@ -69,7 +72,7 @@ export class KnownPathsService extends CacheableLocatorService {
6972
return {
7073
...(details as PythonEnvironment),
7174
path: interpreter,
72-
envType: EnvironmentType.Unknown
75+
envType: EnvironmentType.Unknown,
7376
};
7477
}
7578

@@ -87,6 +90,7 @@ export class KnownPathsService extends CacheableLocatorService {
8790
@injectable()
8891
export class KnownSearchPathsForInterpreters implements IKnownSearchPathsForInterpreters {
8992
constructor(@inject(IServiceContainer) private readonly serviceContainer: IServiceContainer) {}
93+
9094
/**
9195
* Return the paths where Python interpreters might be found.
9296
*/

0 commit comments

Comments
 (0)