Skip to content

Commit 37ff6cb

Browse files
authored
Fix Eslint in legacyIOc (microsoft#13757)
1 parent 88c2708 commit 37ff6cb

File tree

3 files changed

+156
-135
lines changed

3 files changed

+156
-135
lines changed

.eslintrc

Lines changed: 101 additions & 109 deletions
Original file line numberDiff line numberDiff line change
@@ -1,111 +1,103 @@
11
{
2-
"env": {
3-
"node": true,
4-
"es6": true,
5-
"mocha": true
6-
},
7-
"parser": "@typescript-eslint/parser",
8-
"plugins": [
9-
"@typescript-eslint"
10-
],
11-
"extends": [
12-
"airbnb",
13-
"plugin:@typescript-eslint/recommended",
14-
"plugin:import/errors",
15-
"plugin:import/warnings",
16-
"plugin:import/typescript"
17-
],
18-
"rules": {
19-
// Overriding ESLint rules with Typescript-specific ones
20-
"@typescript-eslint/ban-ts-comment": [
21-
"error",
22-
{
23-
"ts-ignore": "allow-with-description"
24-
}
25-
],
26-
"no-bitwise": "off",
27-
"no-dupe-class-members": "off",
28-
"@typescript-eslint/no-dupe-class-members": "error",
29-
"no-empty-function": "off",
30-
"@typescript-eslint/no-empty-function": [
31-
"error"
32-
],
33-
"@typescript-eslint/no-empty-interface": "off",
34-
"@typescript-eslint/no-non-null-assertion": "off",
35-
"no-unused-vars": "off",
36-
"@typescript-eslint/no-unused-vars": "error",
37-
"no-use-before-define": "off",
38-
"@typescript-eslint/no-use-before-define": [
39-
"error",
40-
{
41-
"functions": false
42-
}
43-
],
44-
"no-useless-constructor": "off",
45-
"@typescript-eslint/no-useless-constructor": "error",
46-
"@typescript-eslint/no-var-requires": "off",
47-
// Other rules
48-
"func-names": "off",
49-
"import/extensions": "off",
50-
"import/namespace": "off",
51-
"import/no-extraneous-dependencies": "off",
52-
"import/no-unresolved": [
53-
"error",
54-
{
55-
"ignore": [
56-
"monaco-editor",
57-
"vscode"
58-
]
59-
}
60-
],
61-
"import/prefer-default-export": "off",
62-
"indent": [
63-
"error",
64-
4,
65-
{
66-
"SwitchCase": 1
67-
}
68-
],
69-
"max-len": [
70-
"warn",
71-
{
72-
"code": 120,
73-
"ignorePattern": "^import\\s.+\\sfrom\\s.+;$",
74-
"ignoreStrings": true,
75-
"ignoreTemplateLiterals": true,
76-
"ignoreUrls": true
77-
}
78-
],
79-
"no-confusing-arrow": [
80-
"error",
81-
{
82-
"allowParens": true
83-
}
84-
],
85-
"no-console": "off",
86-
"no-control-regex": "off",
87-
"no-extend-native": "off",
88-
"no-multi-str": "off",
89-
"no-param-reassign": "off",
90-
"no-prototype-builtins": "off",
91-
"no-template-curly-in-string": "off",
92-
"no-underscore-dangle": "off",
93-
"no-useless-escape": "off",
94-
"no-void": [
95-
"error",
96-
{
97-
"allowAsStatement": true
98-
}
99-
],
100-
"operator-assignment": "off",
101-
"react/jsx-filename-extension": [
102-
1,
103-
{
104-
"extensions": [
105-
".tsx"
106-
]
107-
}
108-
],
109-
"strict": "off"
110-
}
2+
"env": {
3+
"node": true,
4+
"es6": true,
5+
"mocha": true
6+
},
7+
"parser": "@typescript-eslint/parser",
8+
"plugins": ["@typescript-eslint"],
9+
"extends": [
10+
"airbnb",
11+
"plugin:@typescript-eslint/recommended",
12+
"plugin:import/errors",
13+
"plugin:import/warnings",
14+
"plugin:import/typescript"
15+
],
16+
"rules": {
17+
// Overriding ESLint rules with Typescript-specific ones
18+
"@typescript-eslint/ban-ts-comment": [
19+
"error",
20+
{
21+
"ts-ignore": "allow-with-description"
22+
}
23+
],
24+
"no-bitwise": "off",
25+
"no-dupe-class-members": "off",
26+
"@typescript-eslint/no-dupe-class-members": "error",
27+
"no-empty-function": "off",
28+
"@typescript-eslint/no-empty-function": ["error"],
29+
"@typescript-eslint/no-empty-interface": "off",
30+
"@typescript-eslint/no-non-null-assertion": "off",
31+
"no-unused-vars": "off",
32+
"@typescript-eslint/no-unused-vars": "error",
33+
"no-use-before-define": "off",
34+
"@typescript-eslint/no-use-before-define": [
35+
"error",
36+
{
37+
"functions": false
38+
}
39+
],
40+
"no-useless-constructor": "off",
41+
"@typescript-eslint/no-useless-constructor": "error",
42+
"@typescript-eslint/no-var-requires": "off",
43+
// Other rules
44+
"func-names": "off",
45+
"import/extensions": "off",
46+
"import/namespace": "off",
47+
"import/no-extraneous-dependencies": "off",
48+
"import/no-unresolved": [
49+
"error",
50+
{
51+
"ignore": ["monaco-editor", "vscode"]
52+
}
53+
],
54+
"import/prefer-default-export": "off",
55+
"indent": [
56+
"error",
57+
4,
58+
{
59+
"SwitchCase": 1
60+
}
61+
],
62+
"linebreak-style": "off",
63+
"max-len": [
64+
"warn",
65+
{
66+
"code": 120,
67+
"ignorePattern": "^import\\s.+\\sfrom\\s.+;$",
68+
"ignoreStrings": true,
69+
"ignoreTemplateLiterals": true,
70+
"ignoreUrls": true
71+
}
72+
],
73+
"no-confusing-arrow": [
74+
"error",
75+
{
76+
"allowParens": true
77+
}
78+
],
79+
"no-console": "off",
80+
"no-control-regex": "off",
81+
"no-extend-native": "off",
82+
"no-multi-str": "off",
83+
"no-param-reassign": "off",
84+
"no-prototype-builtins": "off",
85+
"no-template-curly-in-string": "off",
86+
"no-underscore-dangle": "off",
87+
"no-useless-escape": "off",
88+
"no-void": [
89+
"error",
90+
{
91+
"allowAsStatement": true
92+
}
93+
],
94+
"operator-assignment": "off",
95+
"react/jsx-filename-extension": [
96+
1,
97+
{
98+
"extensions": [".tsx"]
99+
}
100+
],
101+
"strict": "off"
102+
}
111103
}

src/client/pythonEnvironments/legacyIOC.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ import {
4949
import { WorkspaceVirtualEnvWatcherService } from './discovery/locators/services/workspaceVirtualEnvWatcherService';
5050
import { EnvironmentInfoService, IEnvironmentInfoService } from './info/environmentInfoService';
5151

52-
export function registerForIOC(serviceManager: IServiceManager, serviceContainer: IServiceContainer) {
52+
export function registerForIOC(serviceManager: IServiceManager, serviceContainer: IServiceContainer): void {
5353
serviceManager.addSingleton<IInterpreterLocatorHelper>(IInterpreterLocatorHelper, InterpreterLocatorHelper);
5454
serviceManager.addSingleton<IInterpreterLocatorService>(
5555
IInterpreterLocatorService,

src/test/pythonEnvironments/legacyIOC.unit.test.ts

Lines changed: 54 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -68,38 +68,67 @@ suite('Interpreters - Service Registry', () => {
6868
const serviceManager = mock(ServiceManager);
6969
const serviceContainer = mock(ServiceContainer);
7070
registerForIOC(instance(serviceManager), instance(serviceContainer));
71+
verify(serviceManager.addSingleton(IKnownSearchPathsForInterpreters, KnownSearchPathsForInterpreters)).once();
72+
verify(serviceManager.addSingleton(IVirtualEnvironmentsSearchPathProvider, GlobalVirtualEnvironmentsSearchPathProvider, 'global')).once();
73+
verify(serviceManager.addSingleton(IVirtualEnvironmentsSearchPathProvider, WorkspaceVirtualEnvironmentsSearchPathProvider, 'workspace')).once();
7174

72-
[
73-
[IKnownSearchPathsForInterpreters, KnownSearchPathsForInterpreters],
74-
[IVirtualEnvironmentsSearchPathProvider, GlobalVirtualEnvironmentsSearchPathProvider, 'global'],
75-
[IVirtualEnvironmentsSearchPathProvider, WorkspaceVirtualEnvironmentsSearchPathProvider, 'workspace'],
75+
verify(serviceManager.addSingleton(ICondaService, CondaService)).once();
76+
verify(serviceManager.addSingleton(IPipEnvServiceHelper, PipEnvServiceHelper)).once();
77+
verify(serviceManager.addSingleton(IPythonInPathCommandProvider, PythonInPathCommandProvider)).once();
7678

77-
[ICondaService, CondaService],
78-
[IPipEnvServiceHelper, PipEnvServiceHelper],
79-
[IPythonInPathCommandProvider, PythonInPathCommandProvider],
79+
verify(serviceManager.addSingleton(IInterpreterWatcherBuilder, InterpreterWatcherBuilder)).once();
8080

81-
[IInterpreterWatcherBuilder, InterpreterWatcherBuilder],
81+
verify(
82+
serviceManager.addSingleton(
83+
IInterpreterLocatorService,
84+
PythonInterpreterLocatorService,
85+
INTERPRETER_LOCATOR_SERVICE,
86+
),
87+
).once();
88+
verify(
89+
serviceManager.addSingleton(IInterpreterLocatorService, CondaEnvFileService, CONDA_ENV_FILE_SERVICE),
90+
).once();
91+
verify(serviceManager.addSingleton(IInterpreterLocatorService, CondaEnvService, CONDA_ENV_SERVICE)).once();
92+
verify(
93+
serviceManager.addSingleton(IInterpreterLocatorService, CurrentPathService, CURRENT_PATH_SERVICE),
94+
).once();
95+
verify(
96+
serviceManager.addSingleton(
97+
IInterpreterLocatorService,
98+
GlobalVirtualEnvService,
99+
GLOBAL_VIRTUAL_ENV_SERVICE,
100+
),
101+
).once();
102+
verify(
103+
serviceManager.addSingleton(
104+
IInterpreterLocatorService,
105+
WorkspaceVirtualEnvService,
106+
WORKSPACE_VIRTUAL_ENV_SERVICE,
107+
),
108+
).once();
109+
verify(serviceManager.addSingleton(IInterpreterLocatorService, PipEnvService, PIPENV_SERVICE)).once();
82110

83-
[IInterpreterLocatorService, PythonInterpreterLocatorService, INTERPRETER_LOCATOR_SERVICE],
84-
[IInterpreterLocatorService, CondaEnvFileService, CONDA_ENV_FILE_SERVICE],
85-
[IInterpreterLocatorService, CondaEnvService, CONDA_ENV_SERVICE],
86-
[IInterpreterLocatorService, CurrentPathService, CURRENT_PATH_SERVICE],
87-
[IInterpreterLocatorService, GlobalVirtualEnvService, GLOBAL_VIRTUAL_ENV_SERVICE],
88-
[IInterpreterLocatorService, WorkspaceVirtualEnvService, WORKSPACE_VIRTUAL_ENV_SERVICE],
89-
[IInterpreterLocatorService, PipEnvService, PIPENV_SERVICE],
111+
verify(
112+
serviceManager.addSingleton(
113+
IInterpreterLocatorService,
114+
WindowsRegistryService,
115+
WINDOWS_REGISTRY_SERVICE,
116+
),
117+
).once();
118+
verify(serviceManager.addSingleton(IInterpreterLocatorService, KnownPathsService, KNOWN_PATH_SERVICE)).once();
90119

91-
[IInterpreterLocatorService, WindowsRegistryService, WINDOWS_REGISTRY_SERVICE],
92-
[IInterpreterLocatorService, KnownPathsService, KNOWN_PATH_SERVICE],
120+
verify(serviceManager.addSingleton(IInterpreterLocatorHelper, InterpreterLocatorHelper)).once();
121+
verify(
122+
serviceManager.addSingleton(
123+
IInterpreterLocatorProgressService,
124+
InterpreterLocatorProgressService,
125+
),
126+
).once();
93127

94-
[IInterpreterLocatorHelper, InterpreterLocatorHelper],
95-
[IInterpreterLocatorProgressService, InterpreterLocatorProgressService],
128+
verify(serviceManager.addSingleton(WindowsStoreInterpreter, WindowsStoreInterpreter)).once();
129+
verify(serviceManager.addSingleton(InterpreterHashProvider, InterpreterHashProvider)).once();
130+
verify(serviceManager.addSingleton(InterpeterHashProviderFactory, InterpeterHashProviderFactory)).once();
96131

97-
[WindowsStoreInterpreter, WindowsStoreInterpreter],
98-
[InterpreterHashProvider, InterpreterHashProvider],
99-
[InterpeterHashProviderFactory, InterpeterHashProviderFactory],
100-
].forEach((mapping) => {
101-
verify(serviceManager.addSingleton.apply(serviceManager, mapping as any)).once();
102-
});
103132
verify(
104133
serviceManager.add<IInterpreterWatcher>(
105134
IInterpreterWatcher,

0 commit comments

Comments
 (0)